content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
Keeping an Audit Trail of any/all Python Database objects in GAE
I'm new to Python. I'm trying to figure out how to emulate an existing application I've coded using PHP and MS-SQL, and re-create the basic back-end functionality on the Google Apps Engine.
One of the things I'm trying to do is emulate the current a... | Keeping an Audit Trail of any/all Python Database objects in GAE | I'm new to Python. I'm trying to figure out how to emulate an existing application I've coded using PHP and MS-SQL, and re-create the basic back-end functionality on the Google Apps Engine.
One of the things I'm trying to do is emulate the current activity on certain tables I have in MS-SQL, which is an Insert/Delete/... | [
"This is certainly possible, albeit somewhat tricky. Here's a few tips to get you started:\n\nOverriding the class's put() method isn't sufficient, since entities can also be stored by calling db.put(), which won't call any methods on the class being written.\nYou can get around this by monkeypatching the SDK to ca... | [
1,
0
] | [] | [] | [
"audit",
"google_app_engine",
"object",
"python"
] | stackoverflow_0006350576_audit_google_app_engine_object_python.txt |
Q:
Python equivalent for curl -b (--cookie)
I wish to convert a bash script that's currently using "curl -b 'cookie'" into a Python script. I've looked at Pycurl, but I couldnt' find a -b equivalent. There are also urllib and urllib2, but I couldn't see an easy way to replicate the line.
Any help would be great.
A:
... | Python equivalent for curl -b (--cookie) | I wish to convert a bash script that's currently using "curl -b 'cookie'" into a Python script. I've looked at Pycurl, but I couldnt' find a -b equivalent. There are also urllib and urllib2, but I couldn't see an easy way to replicate the line.
Any help would be great.
| [
"This should get you started.\nhttp://docs.python.org/library/cookielib.html#cookielib.CookieJar\n",
"You can use CookieJar.add_cookie_header to add your cookie to a http request header.\n"
] | [
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0006352644_python.txt |
Q:
Accessing Parent Class' Property From Derived Class
I'm new to python and GAE and I thought python will act as any other OO language, but apparently not. How does __init__(self): function gives me different results in the following code?
class BaseHandler(webapp.RequestHandler):
@property
def current_user... | Accessing Parent Class' Property From Derived Class | I'm new to python and GAE and I thought python will act as any other OO language, but apparently not. How does __init__(self): function gives me different results in the following code?
class BaseHandler(webapp.RequestHandler):
@property
def current_user(self):
if not hasattr(self, "_current_user"):
... | [
"If you look at your SubmitHandler class you'll notice that it indeed does not have a request attribute -- at least, none you set, and none you give the parent class a chance to set. Perhaps what you need to do is call the parentclass __init__ method before you try to access self.current_user.\nAs a side note, you ... | [
3,
0,
0
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0006343044_google_app_engine_python.txt |
Q:
trying to understand lambda
When I do
dict = {'Alice': '7898', 'Beth': '9102', 'Cecil': '3258'}
print filter(lambda x: x, dict['Alice'])
it shows: 7898
When I do the next
dict = {'Alice': '2341', 'Beth': '9102', 'Cecil': '3258'}
print filter(lambda x: x=="2341", dict['Alice'])
it shows:
Why it doesn't show True... | trying to understand lambda | When I do
dict = {'Alice': '7898', 'Beth': '9102', 'Cecil': '3258'}
print filter(lambda x: x, dict['Alice'])
it shows: 7898
When I do the next
dict = {'Alice': '2341', 'Beth': '9102', 'Cecil': '3258'}
print filter(lambda x: x=="2341", dict['Alice'])
it shows:
Why it doesn't show True. How to get True ?
| [
"filter() does the following: given a function and an iterable (like a list, tuple, etc), passes each item in the list to a function. For each item, the function returns a boolean true or false. If the function returns true on an item, the item is added to a new list.\nWhen filter is finished, it returns the new li... | [
5,
4,
3,
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0006353135_python.txt |
Q:
psycopg2 E' on table, field and schema
I am having the same problem as:
python adds "E" to string
All the answers given are relevant, but I am breaking my neck on this one.
The problem is that psycopg2 not only escapes values, but also schema, table and column names like this:
CREATE TABLE E'Tablename' (E'identifi... | psycopg2 E' on table, field and schema | I am having the same problem as:
python adds "E" to string
All the answers given are relevant, but I am breaking my neck on this one.
The problem is that psycopg2 not only escapes values, but also schema, table and column names like this:
CREATE TABLE E'Tablename' (E'identificatie' VARCHAR(16))
Which it simply shouldn'... | [
"It is, for better or worse, generally not supported by the Python interfaces and Psycopg in particular to substitute user-supplied identifiers into SQL commands. You will have to roll your own. It can be done with a few lines of code.\n",
"Ok, thanks Peter, at least I know not to look any further. I decided to... | [
1,
0
] | [] | [] | [
"postgresql",
"psycopg2",
"python"
] | stackoverflow_0006294001_postgresql_psycopg2_python.txt |
Q:
Python Database Cursor Exception Timing
I'm creating a class that will manage a connection to a Firebird database. The Firebird Service will be installed to facilitate multiple connections to the database. Unfortunately, the environments where my software will deploy can be volatile, and I can't always guarantee... | Python Database Cursor Exception Timing | I'm creating a class that will manage a connection to a Firebird database. The Firebird Service will be installed to facilitate multiple connections to the database. Unfortunately, the environments where my software will deploy can be volatile, and I can't always guarantee that the Firebird Service will be running wh... | [
"I am testing the following modifications to my class which I believe will achieve the centralized handling that I want with minimal code duplication. They also simplify the query and dml methods slightly, and it eliminates the extra queries (heartbeat) that I wanted to avoid.\nclass DBConnection(object):\n # sel... | [
1,
0
] | [] | [] | [
"cursor",
"database",
"exception",
"firebird",
"python"
] | stackoverflow_0006217796_cursor_database_exception_firebird_python.txt |
Q:
App Engine: Restrict application to an authorized set of users
Some time ago, reading the App Engine Cookbook, I found this recipe based on the Users API (Python): http://goo.gl/aQl45 But my question is: How do I create the Users Database? Where do I locate the "allowed users" list? I don't understand...
Can some... | App Engine: Restrict application to an authorized set of users | Some time ago, reading the App Engine Cookbook, I found this recipe based on the Users API (Python): http://goo.gl/aQl45 But my question is: How do I create the Users Database? Where do I locate the "allowed users" list? I don't understand...
Can somebody explain me how to get that recipe working in an actual app?
| [
"In the middle of the page you link to, right below \"Attached Files\", are links to the three files that make up the sample app. The AuthorizedUser table is defined at the top of auth.py. You don't need to create that table manually in the same way you would with a relational database. You create AuthorizedUser en... | [
4
] | [] | [] | [
"authentication",
"database",
"google_app_engine",
"python"
] | stackoverflow_0006353482_authentication_database_google_app_engine_python.txt |
Q:
GqlQuery OrderBy a property in a ReferenceProperty
I don't know how to make a GqlQuery that order by a property of the ReferenceProperty.
In this case, I want to get all the Seat but order by the id of the Room
The GqlQuery reference does not allow a join, so how do you approach in this case?
class Room(db.Model):... | GqlQuery OrderBy a property in a ReferenceProperty | I don't know how to make a GqlQuery that order by a property of the ReferenceProperty.
In this case, I want to get all the Seat but order by the id of the Room
The GqlQuery reference does not allow a join, so how do you approach in this case?
class Room(db.Model):
id = db.IntegerProperty()
dimension = db.String... | [
"In general, to work around non-relational DBs lack of JOIN functionality, you denormalize; specifically, you redundantly put data pieces in more than one place, so they can be effectively accessed in your queries (this does make it more cumbersome to update your store, but then, non-relational DBs in general are h... | [
0,
0
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0001514450_django_google_app_engine_python.txt |
Q:
Handling keyboard events in python
How can I handle keyboard events in python? More exactly I need to manage keyboard arrows and some other keys for my command-line application.
Is there a module for this or I need to handle key by key using for example "if get(key)==(mykey): do something" (it's pseudo-code)?
I'm ... | Handling keyboard events in python | How can I handle keyboard events in python? More exactly I need to manage keyboard arrows and some other keys for my command-line application.
Is there a module for this or I need to handle key by key using for example "if get(key)==(mykey): do something" (it's pseudo-code)?
I'm on Gnu/Linux OS.
| [
"Would the cmd module suit your needs? It handles command-line history through the arrow keys, for instance, as well as completion.\nIf you need to catch a single key, there is a cross-platform recipe for this (see also Python read a single character from the user on StackOverflow).\n",
"You're probably looking ... | [
3,
2,
1,
0
] | [] | [] | [
"keyboard_events",
"python"
] | stackoverflow_0006348952_keyboard_events_python.txt |
Q:
mod-wsgi & apache & pyramid (pylonsproject)
i have a problem with running pyramid site under apache+mod-wsgi. the problem is that i can't tell apache which python interpretor is the right one for the site it serve. i have several virtual environments and i would like to take those python interpretors.
i added this... | mod-wsgi & apache & pyramid (pylonsproject) | i have a problem with running pyramid site under apache+mod-wsgi. the problem is that i can't tell apache which python interpretor is the right one for the site it serve. i have several virtual environments and i would like to take those python interpretors.
i added this code to my apache config:
WSGIApplicationGroup %... | [
"Documentation explaining how to use virtual environments with mod_wsgi can be found at:\nhttp://code.google.com/p/modwsgi/wiki/VirtualEnvironments\n"
] | [
1
] | [] | [] | [
"apache",
"apache2",
"mod_wsgi",
"pyramid",
"python"
] | stackoverflow_0006354012_apache_apache2_mod_wsgi_pyramid_python.txt |
Q:
Dynamic (JS/Ajax) field updates w/ Django admin interface
This might be a complicated explanation. Here it goes.
There are two models in the scope of this problem, Asset and AssetGroup. AssetGroup contains information about a 'group' of assets (e.g. brand, model, specifications) and Asset contains individual ass... | Dynamic (JS/Ajax) field updates w/ Django admin interface | This might be a complicated explanation. Here it goes.
There are two models in the scope of this problem, Asset and AssetGroup. AssetGroup contains information about a 'group' of assets (e.g. brand, model, specifications) and Asset contains individual asset information (e.g. cost, date of purchase, reason for purchas... | [
"You can customize the template that Django admin uses for your particular model. You don't have to write the whole template, instead, you can juste add the bunch of javascript that you need inside a {% block extrahead %} template tags. And use jQuery to set your event handling. Django use jQuery in the admin inter... | [
2
] | [] | [] | [
"database_design",
"django",
"models",
"python"
] | stackoverflow_0006352499_database_design_django_models_python.txt |
Q:
Break up several actions into multiple view functions
I have one large view function where a user can Add, Edit, Delete, and Update his education. I am currently doing this all in one view because I haven't yet learned how to split up views by function. Here is what I currently have --
I have a single URL pointin... | Break up several actions into multiple view functions | I have one large view function where a user can Add, Edit, Delete, and Update his education. I am currently doing this all in one view because I haven't yet learned how to split up views by function. Here is what I currently have --
I have a single URL pointing to the view --
url(r'^profile/edit/education/$', 'views.... | [
"There's a couple of ways you could do this.\nThis could be a part of your view:\nif request.method == 'POST':\n\n if 'Add School' in request.POST.values():\n return HttpResponseRedirect('/add_school/')\n\nThen this could be part of another view, corresponding with the /add_school/ url:\ndef add_school(re... | [
1,
1
] | [] | [] | [
"django",
"django_forms",
"django_models",
"django_views",
"python"
] | stackoverflow_0006353190_django_django_forms_django_models_django_views_python.txt |
Q:
Do all browsers support excel respond?
I'm developing web application on python.
But the client wants a tool that exports current page to excel.
So I had to write an extra code in every pages (views) that converts the table to excel using xlwt (python module).
But I have a better solution. It sends a current page'... | Do all browsers support excel respond? | I'm developing web application on python.
But the client wants a tool that exports current page to excel.
So I had to write an extra code in every pages (views) that converts the table to excel using xlwt (python module).
But I have a better solution. It sends a current page's content html to the server and the server ... | [
"Setting the content type like this is notification to the client that the document has a specific type -- in a sense, you're lying to the browser by telling it you're sending it an Excel spreadsheet when you're actually sending it an HTML document. The effect of this is that the browser will try to open it as if ... | [
2,
1
] | [] | [] | [
"browser",
"html",
"python",
"web_applications"
] | stackoverflow_0006355169_browser_html_python_web_applications.txt |
Q:
Instantiating SQLAlchemy Base object with session query methods
Here's the simplest description of my SQLAlchemy model:
A Host object (subclass of Base), and a Network object (also Base). Host has a 1:Many relationship with the Network, and the Network object to be associated with the Host can be directly identifi... | Instantiating SQLAlchemy Base object with session query methods | Here's the simplest description of my SQLAlchemy model:
A Host object (subclass of Base), and a Network object (also Base). Host has a 1:Many relationship with the Network, and the Network object to be associated with the Host can be directly identified with the information given to the Host object as part of its initi... | [
"I would avoid passing Session object to the constructor of the class.\nIf it is so easy to find the Network from the Host, do you really need to keep the relation in the database? You could just have a properly with the SA lookup instead:\nclass Host(...):\n ...\n @property\n def Network(self):\n S... | [
4
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0006351277_python_sqlalchemy.txt |
Q:
python oop polymorphism
I can't understand why this code:
class A(object):
def __init__(self):
self.__value = 1
def get_value(self):
return self.__value
class B(A):
def __init__(self):
A.__init__( self )
self.__value = 2
b = B()
print b.get_value()
gives 1, but not 2... | python oop polymorphism | I can't understand why this code:
class A(object):
def __init__(self):
self.__value = 1
def get_value(self):
return self.__value
class B(A):
def __init__(self):
A.__init__( self )
self.__value = 2
b = B()
print b.get_value()
gives 1, but not 2. Thanks for your help.
| [
"Your problem is that double underscores are special in python, and create some modicum of privacy (not enforced, but it mangles the names, which is what is affecting you here). You should recreate this without the variable being named with double underscores. Also, you should use super instead of calling A.__ini... | [
7,
3
] | [] | [] | [
"oop",
"polymorphism",
"python"
] | stackoverflow_0006355337_oop_polymorphism_python.txt |
Q:
Formatting strings with python in django
I have a question list for a questionnaire which are stored in database but some questions has to be modified by certain parameters.
For example, if someone selects an employer name from previous page, some questions should have employer's name "Do you like to work for ....... | Formatting strings with python in django | I have a question list for a questionnaire which are stored in database but some questions has to be modified by certain parameters.
For example, if someone selects an employer name from previous page, some questions should have employer's name "Do you like to work for ........ company ?".
One solution might be savinf ... | [
"The most flexible way - is to create custom template filter. If string needs formatting, it will do that, if it doesn't - just output it.\n"
] | [
1
] | [] | [] | [
"django",
"python",
"string"
] | stackoverflow_0006355449_django_python_string.txt |
Q:
Interactive matplotlib under windows
When I am in an interactive python session (usually IPython), the following commands:
from matplotlib import pyplot as plt
plt.plot([1,2,3,4])
do not automatically raise a window, showing the plot. The only way I can make matplotlib actually raise the window is using show(), w... | Interactive matplotlib under windows | When I am in an interactive python session (usually IPython), the following commands:
from matplotlib import pyplot as plt
plt.plot([1,2,3,4])
do not automatically raise a window, showing the plot. The only way I can make matplotlib actually raise the window is using show(), which also captures all input until I close... | [
"If you use IPython pylab mode, this works:\nIn [1]: plot([1,2,3,4])\nOut[1]: [<matplotlib.lines.Line2D object at 0x020F75B0>]\n\nthere is not need for show() nor matplotlib import.\nIn IPython normal mode you can make your session interactive. This also works:\nIn [4]: from matplotlib import interactive\n\nIn [5]:... | [
3
] | [] | [] | [
"matplotlib",
"python",
"windows"
] | stackoverflow_0006355618_matplotlib_python_windows.txt |
Q:
Initialise matrix in python
Possible Duplicate:
Python list problem
I try to initialise a matrix in python.
First I did this:
>>> M=[[0]*4]*4
But here is my probleme, every line is changing when I change the first one:
>>> M
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
>>> M[1][1]=1
>>> M
[[0, 1, 0... | Initialise matrix in python |
Possible Duplicate:
Python list problem
I try to initialise a matrix in python.
First I did this:
>>> M=[[0]*4]*4
But here is my probleme, every line is changing when I change the first one:
>>> M
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
>>> M[1][1]=1
>>> M
[[0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0]... | [
"When you multiply those lists, Python is copying them by reference rather than creating entirely new objects.\nA simple example might help, showing what happens with copy by reference:\n>>> pie = ['apple', 'cherry', 'pecan']\n>>> pie_copy = pie\n>>> pie_copy[0] = 'banana'\n>>> pie\n['banana', 'cherry', 'pecan']\n>... | [
3,
2,
1
] | [] | [] | [
"list",
"python"
] | stackoverflow_0006356163_list_python.txt |
Q:
Confused about a simple regex with sub
I have following python code:
TRAC_REQUEST_LOCATION=""
TRAC_ENV=TRAC_ENV_PARENT+"/"+re.sub(r'^'+TRAC_REQUEST_LOCATION+'/([^/]+).*', r'\1', environ['REQUEST_URI'])
The content of environ['REQUEST_URI'] is something like that /abc/DEF and I want to get only abc, but it do... | Confused about a simple regex with sub | I have following python code:
TRAC_REQUEST_LOCATION=""
TRAC_ENV=TRAC_ENV_PARENT+"/"+re.sub(r'^'+TRAC_REQUEST_LOCATION+'/([^/]+).*', r'\1', environ['REQUEST_URI'])
The content of environ['REQUEST_URI'] is something like that /abc/DEF and I want to get only abc, but it doesn't work. Only sometimes it works, but why... | [
"Why do you need a regexp? Use urlparse (Python 2.x, there is a link for Python 3.x in there). \n",
"If you want to extract the first part of the request path this is the simplest solution:\nTRAC_ENV = ''\nif '/' in environ['REQUEST_URI']:\n TRAC_ENV = environ['REQUEST_URI'].split('/')[1]\nEDIT\nAn example usa... | [
2,
1,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0005104407_python_regex.txt |
Q:
How to get rid of non-ascii characters in Perl & Python [both]?
How to get rid of non-ascii characters like "^L,¢,â" in Perl & Python ? Actually while parsing PDF files in Python & Perl. I'm getting these special characters. Now i have text version of these PDF files, but with these special characters. Is there an... | How to get rid of non-ascii characters in Perl & Python [both]? | How to get rid of non-ascii characters like "^L,¢,â" in Perl & Python ? Actually while parsing PDF files in Python & Perl. I'm getting these special characters. Now i have text version of these PDF files, but with these special characters. Is there any function available which will make insures that a file or a variabl... | [
"The direct answer to your question, in Python, is to use .encode('ascii', 'ignore'), on the Unicode string in question. This will convert the Unicode string to an ASCII string and take out any non-ASCII characters:\n>>> u'abc\\x0c¢â'.encode('ascii', errors='ignore')\n'abc\\x0c'\n\nNote that it did not take out the... | [
6,
5,
2
] | [] | [] | [
"pdf",
"perl",
"python"
] | stackoverflow_0006354260_pdf_perl_python.txt |
Q:
Permission Denied error while sending mail using Python smtplib
I am trying to send mail using Python 3.2. My code is as follows:
#from email import Encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE, ... | Permission Denied error while sending mail using Python smtplib | I am trying to send mail using Python 3.2. My code is as follows:
#from email import Encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
import os
import smtplib
from base64 import encode
from em... | [
"As the error says: you need to call the connect method on the smtplib.SMTP_SSL instance before you try to use it. smtplib.SMTP_SSL does not automatically connect (and neither does smtplib.SMTP.)\n"
] | [
1
] | [] | [] | [
"python",
"sendmail",
"smtp",
"smtplib"
] | stackoverflow_0006356617_python_sendmail_smtp_smtplib.txt |
Q:
Python Popen writing to stdin not working when in a thread
I'm trying to write a program that simultaneously reads and writes to a process's std(out/in) respectively. However, it seems that writing to a program's stdin in a thread does not work. Here's the relevant bits of code:
import subprocess, threading, queue... | Python Popen writing to stdin not working when in a thread | I'm trying to write a program that simultaneously reads and writes to a process's std(out/in) respectively. However, it seems that writing to a program's stdin in a thread does not work. Here's the relevant bits of code:
import subprocess, threading, queue
def intoP(proc, que):
while True:
if proc.returnco... | [
"The answer is - buffering. If you add a\nproc.stdin.flush()\n\nafter the proc.stdin.write() call, you'll see \"Hello, world!\" printed to the console (by the subprocess), as you'd expect.\n",
"I changed proc.stdin.write(text) to proc.communicate(text), and that works in Python 3.1.\n"
] | [
8,
0
] | [] | [] | [
"multithreading",
"python",
"subprocess"
] | stackoverflow_0006351908_multithreading_python_subprocess.txt |
Q:
Tracking users and gathering analytics on a second party site
I've got a Python/Django powered site that offers a service to clients. All the clients who use my service simply need to include a "single" JS tag in their page. All works fine but I need to some tracking on the client side. Clients could be using thei... | Tracking users and gathering analytics on a second party site | I've got a Python/Django powered site that offers a service to clients. All the clients who use my service simply need to include a "single" JS tag in their page. All works fine but I need to some tracking on the client side. Clients could be using their own tracking system e.g. GA or something.
I need to gather the fo... | [
"You can even use your own GA if you want to.\nJust have the client make a _POST or a _GET request to your site via AJAX on every page view.\nEdit: \nUser is redirected from your site (mysite.com) to another site (externalsite.com) and you send the user to this particular page: http://externalsite.com/page/21.html#... | [
0
] | [] | [] | [
"analytics",
"django",
"javascript",
"python",
"tracking"
] | stackoverflow_0006356727_analytics_django_javascript_python_tracking.txt |
Q:
Decorate methods per instance in Python
Assume I have some simple class
class TestClass:
def doSomething(self):
print 'Did something'
I would like to decorate the doSomething method, for example to count the number of calls
class SimpleDecorator(object):
def __init__(self,func):
self.func=... | Decorate methods per instance in Python | Assume I have some simple class
class TestClass:
def doSomething(self):
print 'Did something'
I would like to decorate the doSomething method, for example to count the number of calls
class SimpleDecorator(object):
def __init__(self,func):
self.func=func
self.count=0
def __get__(sel... | [
"Utilize the fact that self (i.e. the object which the method is invoked on) is passed as a parameter to the method:\nimport functools\n\ndef counted(method):\n @functools.wraps(method)\n def wrapped(obj, *args, **kwargs):\n if hasattr(obj, 'count'): \n obj.count += 1\n else:\n ... | [
10,
1
] | [] | [] | [
"decorator",
"python"
] | stackoverflow_0006356858_decorator_python.txt |
Q:
Sqlite version for Python 3.x
I want to use sqlite3 with Python 3.1.3 and I need to set enable_load_extension to true. To do this I believe I need sqlite version 3.x. From reading posts here it looks like a suitable version of sqlite ought to be bundled with python version 2.6 and up. However, when I do:
import... | Sqlite version for Python 3.x | I want to use sqlite3 with Python 3.1.3 and I need to set enable_load_extension to true. To do this I believe I need sqlite version 3.x. From reading posts here it looks like a suitable version of sqlite ought to be bundled with python version 2.6 and up. However, when I do:
import sqlite3
sqlite3.version_info
The ... | [
"Don't confuse the version of SQLite with the version of pysqlite, the Python binding for the SQLite API. The version and version_info attributes you used refer to the latter.\nEver wondered why the module is named sqlite3? It only supports version 3.x!\nTo check the SQLite version, use sqlite_version instead:\ni... | [
12,
3
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0006357074_python_sqlite.txt |
Q:
Difficulty in displaying kml file with extension as .pl in android
I am developing an android application using google maps. I have to display some text information and some pictures related to the text. For this purpose I have a .pl file where the information is written as kml.
I know how to extract information ... | Difficulty in displaying kml file with extension as .pl in android | I am developing an android application using google maps. I have to display some text information and some pictures related to the text. For this purpose I have a .pl file where the information is written as kml.
I know how to extract information using sax parser from an xml, however I am not able to decide as how to ... | [
"KML is Keyhole Markup Language (KML) is an XML notation for expressing geographic annotation \nDownload sample project which can parse kml data from the following url. \nhttp://www.warriorpoint.com/blog/downloads/\nThanks\nDeepak\n"
] | [
0
] | [] | [] | [
"android",
"download",
"kml",
"python",
"xml"
] | stackoverflow_0006357035_android_download_kml_python_xml.txt |
Q:
Pyttsx not saying all text when using non default voice
I created a small module to speak the text that is sent to it.
It works fine if I don't use engine.setProperty to set the voice, but if I set the voice it will only play the first command.
import pyttsx
def speak( text ):
if text != "":
engine = ... | Pyttsx not saying all text when using non default voice | I created a small module to speak the text that is sent to it.
It works fine if I don't use engine.setProperty to set the voice, but if I set the voice it will only play the first command.
import pyttsx
def speak( text ):
if text != "":
engine = pyttsx.init()
engine.setProperty('voice', "HKEY_LOCAL... | [
"I think you should try the following code snippet :\nimport pyttsx\nengine = pyttsx.init()\nengine.say('Sally sells seashells by the seashore.')\nengine.say('The quick brown fox jumped over the lazy dog.')\nengine.runAndWait()\n\nwhich is originally from this page\n"
] | [
3
] | [] | [] | [
"python",
"text_to_speech"
] | stackoverflow_0003202851_python_text_to_speech.txt |
Q:
Help me pick a webservice platform to scale up an existing python webservice
I have a simple webservice that I need to scale up substantially.
I'm trying to decide where to go amongst the various web frameworks, load balancers, app servers (e.g Mongrel2, Tornado, and nginx, mod_proxy).
I have an existing Python a... | Help me pick a webservice platform to scale up an existing python webservice | I have a simple webservice that I need to scale up substantially.
I'm trying to decide where to go amongst the various web frameworks, load balancers, app servers (e.g Mongrel2, Tornado, and nginx, mod_proxy).
I have an existing Python app (currently exposed via BaseHTTPServer) that accepts some JSON data (about 900KB... | [
"First, you should decouple your webservice layer from number crunching. Use external job queue (for example http://celeryproject.org/), to offload web frontend. Then you can scale each part interdependently. \nYou should look for IaaS-type cloud providers (EC2, Rackspace, Linode, Softlayer etc), where you should b... | [
1
] | [] | [] | [
"performance",
"python",
"scalability",
"web_services"
] | stackoverflow_0006357606_performance_python_scalability_web_services.txt |
Q:
How do I run some python code in another process?
I want to start, from Python, some other Python code, preferably a function, but in another process.
It is mandatory to run this in another process, because I want to run some concurrency tests, like opening a file that was opened exclusively by the parent process... | How do I run some python code in another process? | I want to start, from Python, some other Python code, preferably a function, but in another process.
It is mandatory to run this in another process, because I want to run some concurrency tests, like opening a file that was opened exclusively by the parent process (this has to fail).
Requirements:
multiplatform: linu... | [
"I would seriously take a look at the documentation for multiprocessing library of Python. From the first sentence of the package's description:\n\nmultiprocessing is a package that supports spawning processes using an API similar to the threading module.\n\nIt then goes on to say that it side-steps the GIL, which... | [
22
] | [] | [] | [
"multiprocessing",
"python"
] | stackoverflow_0006357850_multiprocessing_python.txt |
Q:
using pipe with python
import re
import subprocess
sub = subprocess.Popen(['/home/karthik/Downloads/stanford-parser-2011-06- 08/lexparser.csh'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr = subprocess.PIPE)
sub.stdin.write("i am a fan of ac milan which is the best club in the world")
relns = []
wh... | using pipe with python | import re
import subprocess
sub = subprocess.Popen(['/home/karthik/Downloads/stanford-parser-2011-06- 08/lexparser.csh'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr = subprocess.PIPE)
sub.stdin.write("i am a fan of ac milan which is the best club in the world")
relns = []
while(True):
rel = sub.std... | [
"You may need to call flush() on sub.stdin after writing.\n"
] | [
1
] | [] | [] | [
"pipe",
"python",
"stanford_nlp"
] | stackoverflow_0006357810_pipe_python_stanford_nlp.txt |
Q:
Mixed content (float || unicode) for database column
For sake of simplicity let's say I have a questionare.
Each answer gains a score.
Some questions are qualitative so user must choose between one of the text answers.
Q: what's your fav pet?
cat [1 point]
dog [2 points]
caiman [3 points]
Answering dog I get 2 p... | Mixed content (float || unicode) for database column | For sake of simplicity let's say I have a questionare.
Each answer gains a score.
Some questions are qualitative so user must choose between one of the text answers.
Q: what's your fav pet?
cat [1 point]
dog [2 points]
caiman [3 points]
Answering dog I get 2 points.
Some questions are quantitative so user inputs a nu... | [
"What makes this needlessly complex is trying to optimize the quantitive answers. \nIt's multiple choice. Treat the quantitative answer as if it were qualitative. Carry the \"points\" as a separate attribute of each answer. \nAnd yes, there will be (\"3 liters\", 3) in the database. And yes, to a thinking perso... | [
3,
1
] | [] | [] | [
"database_design",
"python",
"sqlalchemy"
] | stackoverflow_0006154424_database_design_python_sqlalchemy.txt |
Q:
Naming dict keys for fast lookup in python
I'm going to have 1 small dictionary (between 5 and 20 keys) that will be referenced up to a hundred times or so for one page load in python 2.5.
I'm starting to name the keys which it will be looking up and I was wondering if there is a key naming convention I could foll... | Naming dict keys for fast lookup in python | I'm going to have 1 small dictionary (between 5 and 20 keys) that will be referenced up to a hundred times or so for one page load in python 2.5.
I'm starting to name the keys which it will be looking up and I was wondering if there is a key naming convention I could follow to help dict lookup times.
| [
"I had to test ;-)\nusing \n\nf1, integer key 1\nf2 short string, \"one\"\nf3 long string \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n\nas one of the keys into a dictionary of length 4. Iterating 10,000,000 times and measuring the times. I get this result:\n<function f1 at 0xb779187c>\nf1 3.64\n<function f2 ... | [
8,
6,
2,
1,
0
] | [] | [] | [
"dictionary",
"django",
"performance",
"python"
] | stackoverflow_0006358335_dictionary_django_performance_python.txt |
Q:
How do I install a DMG file from the command line?
I am looking for small bash or python script that will install a .dmg file.
We'll assume that the dmg contains one or more .app directories that have to be copied to /Applications, overriding any already existing directories.
Files or directories not matching the ... | How do I install a DMG file from the command line? | I am looking for small bash or python script that will install a .dmg file.
We'll assume that the dmg contains one or more .app directories that have to be copied to /Applications, overriding any already existing directories.
Files or directories not matching the *.app pattern are to be ignored.
| [
"You can mount the disk image using\nhdiutil attach -mountpoint <path-to-desired-mountpoint> <filename.dmg>\n\nThe disk image will be mounted at the selected path (the argument following -mountpoint). Then, search for an .app file and copy the file to /Applications.\nOnce you have finished installation unmount the ... | [
14
] | [] | [] | [
"bash",
"macos",
"python"
] | stackoverflow_0006357914_bash_macos_python.txt |
Q:
Python version recommendation
I have developed some internal tools at work using Python. I have been using version 2.5 (or 2.6/2.7) for that and my personal projects as they would work fine with Django and GAE. My question is - should I be switching to version 3 or shall I wait and continue to work with 2.5/2.6/2.... | Python version recommendation | I have developed some internal tools at work using Python. I have been using version 2.5 (or 2.6/2.7) for that and my personal projects as they would work fine with Django and GAE. My question is - should I be switching to version 3 or shall I wait and continue to work with 2.5/2.6/2.7. How stable is 3.0 as compared to... | [
"Python 3 isn't supported by Django and quite a few other notable projects. Although Python 3 (current version is 3.2.1 IIRC) is plenty stable, that's not the issues. The real issue is adoption and library support, and Python 3 does not have enough of either yet. I don't know of anyone using it in production.\nThe ... | [
11
] | [] | [] | [
"python"
] | stackoverflow_0006358624_python.txt |
Q:
How to split the list on the pairwise elements?
Possible Duplicate:
How do you split a list into evenly sized chunks in Python?
Let us have a list, there is always an even number of elements. We must break it down by pairing.
Example:
list['1','2','3','4']
need
1,2 and 3,4
A:
>>> L = [1, 2, 3, 4]
>>> pairs = z... | How to split the list on the pairwise elements? |
Possible Duplicate:
How do you split a list into evenly sized chunks in Python?
Let us have a list, there is always an even number of elements. We must break it down by pairing.
Example:
list['1','2','3','4']
need
1,2 and 3,4
| [
">>> L = [1, 2, 3, 4]\n>>> pairs = zip(L[::2], L[1::2])\n>>> print pairs\n[(1, 2), (3, 4)]\n\nHope this helps\n",
"If you want two halfs of a list. \nl = [1,2,3,4]\nprint l[:len(l)/2], l[len(l)/2:]\n>>> [1, 2] [3, 4]\n\nIf you want split a list by pairs then your question is exact duplicate.\n",
"You can use... | [
2,
1,
0,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0006358031_list_python.txt |
Q:
Python griddata meshgrid
in Python I want to interpolate some data using scipy.interpolate.griddata(x,y,z,xi,yi).
Since I want my unequal spaced original data on the X-Y grid map on an equal spaced XI-YI grid I have to use a meshgrid as:
X, Y = numpy.meshgrid([1,2,3], [2,5,6,8])
XI,YI = numpy.meshgrid([1,2,3],[4,5... | Python griddata meshgrid | in Python I want to interpolate some data using scipy.interpolate.griddata(x,y,z,xi,yi).
Since I want my unequal spaced original data on the X-Y grid map on an equal spaced XI-YI grid I have to use a meshgrid as:
X, Y = numpy.meshgrid([1,2,3], [2,5,6,8])
XI,YI = numpy.meshgrid([1,2,3],[4,5,6,7])
print scipy.interpolate... | [
"The correct call sequence in your case is\nprint scipy.interpolate.griddata((X.ravel(),Y.ravel()), (X**2+Y**2).ravel(), (XI, YI))\n\nI.e., you need to cast the input data points to 1-d. (This could be fixed to work without the .ravel()s in the next version of Scipy.)\n",
"I think you need to reshape your grids, ... | [
3,
0
] | [] | [] | [
"interpolation",
"matlab",
"mesh",
"python",
"scipy"
] | stackoverflow_0006358596_interpolation_matlab_mesh_python_scipy.txt |
Q:
Is it possible to increase the amount of RAM a python process is using
I am running a classification/feature extraction task on a windows server with 64GB of RAM, and somehow, python thinks i am running out of memory:
misiti@fff /cygdrive/c/NaiveBayes
$ python run_classify_comments.py > tenfoldcrossvalidation.txt
... | Is it possible to increase the amount of RAM a python process is using | I am running a classification/feature extraction task on a windows server with 64GB of RAM, and somehow, python thinks i am running out of memory:
misiti@fff /cygdrive/c/NaiveBayes
$ python run_classify_comments.py > tenfoldcrossvalidation.txt
Traceback (most recent call last):
File "run_classify_comments.py", line 7... | [
"Just rewrite your program to read your huge text file one line at a time. This is easily done by just changing get_all_words(path) to:\ndef get_all_words(path):\n return sum((words(line) for line in open(path))\n\nNote the use of a generator in the parenthesis, which is lazy and will evaluate on demand by the s... | [
4,
1
] | [] | [] | [
"nltk",
"python",
"regex"
] | stackoverflow_0006349560_nltk_python_regex.txt |
Q:
Gracefully Terminating Python Threads
I am trying to write a unix client program that is listening to a socket, stdin, and reading from file descriptors. I assign each of these tasks to an individual thread and have them successfully communicating with the "main" application using synchronized queues and a semapho... | Gracefully Terminating Python Threads | I am trying to write a unix client program that is listening to a socket, stdin, and reading from file descriptors. I assign each of these tasks to an individual thread and have them successfully communicating with the "main" application using synchronized queues and a semaphore. The problem is that when I want to shut... | [
"There is no good way to work around this, especially when the thread is blocking. \nI had a similar issue ( Python: How to terminate a blocking thread) and the only way I was able to stop my threads was to close the underlying connection. Which resulted in the thread that was blocking to raise and exception and ... | [
9,
0
] | [
"See these answers:\nPython SocketServer\nHow to exit a multithreaded program?\nBasically, don't block on recv() by using select() with a timeout to check for readability of the socket, and poll a quit flag when select() times out.\n"
] | [
-1
] | [
"multithreading",
"python"
] | stackoverflow_0006359597_multithreading_python.txt |
Q:
How to traverse a dict in python and make two separate dict out of it?
data = "GEOMETRYCOLLECTION (POINT (-8.9648437500000000 -4.1308593750000000), POINT (2.0214843750000000 -2.6367187500000000), POINT (-1.4062500000000000 -11.1621093750000000), POINT (-11.9531250000000000,-10.8984375000000000), POLYGON ((-21.6210... | How to traverse a dict in python and make two separate dict out of it? | data = "GEOMETRYCOLLECTION (POINT (-8.9648437500000000 -4.1308593750000000), POINT (2.0214843750000000 -2.6367187500000000), POINT (-1.4062500000000000 -11.1621093750000000), POINT (-11.9531250000000000,-10.8984375000000000), POLYGON ((-21.6210937500000000 1.8457031250000000,2.4609375000000000 2.1972656250000000, -18.9... | [
"OK, if you can make sure to separate all the numbers by a ,, then it is possible to do what I think you want to do with some simple python classes and the eval function. Basically, define a class for each of POINT, POLYGON and so on. With this, you can turn your string into an expression that makes a GEOMETRYCOLLE... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0006358577_python.txt |
Q:
Python textctrl setstyle cannot read the insertionpoint correctly
I am using python textctrl in a GUI I wrote. After I read several files, I post the contents of the file in textctrl. Since they are all in similar format, I tried to color the first several charactors to mark out the start of each file output. What... | Python textctrl setstyle cannot read the insertionpoint correctly | I am using python textctrl in a GUI I wrote. After I read several files, I post the contents of the file in textctrl. Since they are all in similar format, I tried to color the first several charactors to mark out the start of each file output. What I did is the following:
for file in self.dir:
f = open(file, 'r')
... | [
"Fixed.\nName another variable before AppendText for the GetInsertionPoint(). Otherwise, it will get the end of the file.\n"
] | [
0
] | [] | [] | [
"python",
"textctrl"
] | stackoverflow_0006349917_python_textctrl.txt |
Q:
Why does foo.append(bar) affect all elements in a list of lists?
I create a list of lists and want to append items to the individual lists, but when I try to append to one of the lists (a[0].append(2)), the item gets added to all lists.
a = []
b = [1]
a.append(b)
a.append(b)
a[0].append(2)
a[1].append(3)
print(... | Why does foo.append(bar) affect all elements in a list of lists? | I create a list of lists and want to append items to the individual lists, but when I try to append to one of the lists (a[0].append(2)), the item gets added to all lists.
a = []
b = [1]
a.append(b)
a.append(b)
a[0].append(2)
a[1].append(3)
print(a)
Gives: [[1, 2, 3], [1, 2, 3]]
Whereas I would expect: [[1, 2], [1,... | [
"It is because the list contains references to objects. Your list doesn't contain [[1 2 3] [1 2 3]], it is [<reference to b> <reference to b>].\nWhen you change the object (by appending something to b), you are changing the object itself, not the list that contains the object.\nTo get the effect you desire, your l... | [
37,
2,
1
] | [] | [] | [
"append",
"list",
"python"
] | stackoverflow_0006360286_append_list_python.txt |
Q:
How do you select choices in a form using Python?
I'd like to know how to select options in a form that is formatted like
<td align="left">
<select name="FORM1" id="FORM1" multiple="multiple" size="5">
<option value="Value1">Value1</option>
<option va... | How do you select choices in a form using Python? | I'd like to know how to select options in a form that is formatted like
<td align="left">
<select name="FORM1" id="FORM1" multiple="multiple" size="5">
<option value="Value1">Value1</option>
<option value="Value2">Value2</option>
</select... | [
"Here are some basic usage examples to get you going:\n>>> import mechanize\n>>> br = mechanize.Browser()\n>>> br.open('http://www.w3schools.com/html/html_forms.asp')\n\nForms have a name attribute; sometimes it's empty though:\n>>> [f.name for f in br.forms()]\n['searchform', None, None, None, None, 'input0']\n\nF... | [
22,
3
] | [] | [] | [
"mechanize",
"python"
] | stackoverflow_0006359817_mechanize_python.txt |
Q:
Python Plone views call others
I have a Python function registered as a View in Plone. I need to be able to call another function from within this registered function. I'm not sure if it would be best to register this other function as a view as well and try to call that (don't know how to call other views), or ... | Python Plone views call others | I have a Python function registered as a View in Plone. I need to be able to call another function from within this registered function. I'm not sure if it would be best to register this other function as a view as well and try to call that (don't know how to call other views), or if there is a better way to handle t... | [
"Just import it and call it as any other function. You don't want to make it a view - that requires you to do a MultiAdapter lookup which is a real pain, and completely unnecessary.\n[Edit - strictly using a view is a MultiAdapter lookup, but you can shortcut it via traversal, but that still isn't worth the effort... | [
1
] | [] | [] | [
"plone",
"python",
"views"
] | stackoverflow_0006359581_plone_python_views.txt |
Q:
merge multiple lines into single line by value of column
I have a tab-delimited text file that is very large. Many lines in the file have the same value for one of the columns in the file. I want to put them into same line. For example:
a foo
a bar
a foo2
b bar
c bar2
After run the script it should become:
a foo;... | merge multiple lines into single line by value of column | I have a tab-delimited text file that is very large. Many lines in the file have the same value for one of the columns in the file. I want to put them into same line. For example:
a foo
a bar
a foo2
b bar
c bar2
After run the script it should become:
a foo;bar;foo2
b bar
c bar2
how can I do this in either a shell scr... | [
"With awk you can try this\n{ a[$1] = a[$1] \";\" $2 }\nEND { for (item in a ) print item, a[item] }\n\nSo if you save this awk script in a file called awkf.awk and if your input file is ifile.txt, run the script \nawk -f awkf.awk ifile.txt | sed 's/ ;/ /'\n\nThe sed script is to remove out the leading ; \nHope t... | [
3,
2,
1,
0,
0,
0
] | [] | [] | [
"perl",
"python",
"split"
] | stackoverflow_0006359734_perl_python_split.txt |
Q:
pyramid: get application absolute url
Is there any way to get pyramid absolute application url in main() function?
I want to add it into global settings, so it could be called every where(in templates and js files).
In pyramid documents there is some functions would help, but all of them need a request object and ... | pyramid: get application absolute url | Is there any way to get pyramid absolute application url in main() function?
I want to add it into global settings, so it could be called every where(in templates and js files).
In pyramid documents there is some functions would help, but all of them need a request object and must call in a view.
Thanks.
| [
"Pyramid (like most WSGI applications) can be mounted on any domain and url prefix. Thus the application itself doesn't actually know what urls it is responsible for unless you code that into your application specifically (an INI setting, for example).\nThis is why request.application_url exists... because the appl... | [
4,
3
] | [] | [] | [
"pylons",
"pyramid",
"python"
] | stackoverflow_0006348094_pylons_pyramid_python.txt |
Q:
Using Scrapy to parse sitemaps
I want to be able to use scrapy to crawl links on a sitemap. I don't know much about this application, so I would be interested in any links/info/documentation you could provide.
Thanks
A:
A new generic spider has just been added to Scrapy trunk, for this purpose. It will be avail... | Using Scrapy to parse sitemaps | I want to be able to use scrapy to crawl links on a sitemap. I don't know much about this application, so I would be interested in any links/info/documentation you could provide.
Thanks
| [
"A new generic spider has just been added to Scrapy trunk, for this purpose. It will be available on next release (Scrapy 0.14)\n\nCode here: http://snippets.scrapy.org/snippets/20/\nDocumentation here: http://readthedocs.org/docs/scrapy/en/latest/topics/spiders.html#sitemapspider\n\n",
"All of the documentation ... | [
12,
0
] | [] | [] | [
"python",
"scrapy",
"sitemap"
] | stackoverflow_0006335906_python_scrapy_sitemap.txt |
Q:
Python : subclass `type` to create specialized types (e.g. a "list of int")
I am trying to subclass type in order to create a class allowing to build specialized types. e.g. a ListType :
>>> ListOfInt = ListType(list, value_type=int)
>>> issubclass(ListOfInt, list)
True
>>> issubclass(list, ListOfInt)
False
>>> # ... | Python : subclass `type` to create specialized types (e.g. a "list of int") | I am trying to subclass type in order to create a class allowing to build specialized types. e.g. a ListType :
>>> ListOfInt = ListType(list, value_type=int)
>>> issubclass(ListOfInt, list)
True
>>> issubclass(list, ListOfInt)
False
>>> # And so on ...
However, this ListOfInt will never be used to create instances ! I... | [
"I'm not quite sure what you want to achieve. Maybe it is better to use collections module instead of using abc directly?\nThere is more info about generic collection classes in PEP 3119\n",
"The sort of thing you want to do could probably be done more easily using a class factory function like the following. At ... | [
1,
1,
1,
1
] | [] | [] | [
"abc",
"python"
] | stackoverflow_0006332342_abc_python.txt |
Q:
Python Multiprocessing - Just not getting it
I've been spending some time trying to understand multiprocessing, though its finer points evade my untrained mind. I've been able to get a pool to return a simple integer, but if the function doesn't just return a result like all of the examples I can find (even in the... | Python Multiprocessing - Just not getting it | I've been spending some time trying to understand multiprocessing, though its finer points evade my untrained mind. I've been able to get a pool to return a simple integer, but if the function doesn't just return a result like all of the examples I can find (even in the documentation, it's some obscure example I can't ... | [
"It took me a while to understand what you want to happen. The problem has to do with the way multiprocessing works. Basically, you need to write your program in a functional style, instead of relying on side-effects as you do now. \nRight now, you're sending out objects to your pool to be modified and returning no... | [
12
] | [] | [] | [
"multiprocessing",
"pool",
"python",
"python_2.7",
"python_3.x"
] | stackoverflow_0006360679_multiprocessing_pool_python_python_2.7_python_3.x.txt |
Q:
Using Python and TKinter, how do I redraw the main screen
I have a program where the main window is divided into two sections each section has a collection of forms (simple label/input columns). The default is 4 of these columns in the first section and 2 in the second section. I would like the user to be able t... | Using Python and TKinter, how do I redraw the main screen | I have a program where the main window is divided into two sections each section has a collection of forms (simple label/input columns). The default is 4 of these columns in the first section and 2 in the second section. I would like the user to be able to change this ratio. I think I have all of the programming in ... | [
"Since you are using the grid geometry manager, you just need to use the grid method to place them in their new rows and columns. You may need to also call rowconfigure and/or columnconfigure to attach appropriate weights to the new rows and columns.\nHere's a bit of a contrived example showing the general principl... | [
2
] | [
"You've probably already tried this, but can you call update() on your root widget?\nYou might also need to pack() again, first.\n"
] | [
-1
] | [
"python",
"tkinter"
] | stackoverflow_0006360202_python_tkinter.txt |
Q:
printing to the screen on the same line at different times
My code looks like this:
print "Doing Something...",
do_some_function_that_takes_a_long_time()
print "Done"
I want it to print that statement at the top to the screen first, then do the function, and then print the "Done" line. Currently it waits until th... | printing to the screen on the same line at different times | My code looks like this:
print "Doing Something...",
do_some_function_that_takes_a_long_time()
print "Done"
I want it to print that statement at the top to the screen first, then do the function, and then print the "Done" line. Currently it waits until the "Done" line is executed before it prints the top part with it.... | [
"You have to flush the output after your first print.\n",
"You can also do something like: http://www.mutaku.com/wp/index.php/2011/06/python-dynamically-printing-to-single-line-of-stdout/\n"
] | [
9,
0
] | [] | [] | [
"python"
] | stackoverflow_0002671004_python.txt |
Q:
adwords api: retrieve daily spend (costs)
Does anybody have some sample code that shows how to get the daily, total spend (across all campaigns) of an AdWords account?
I haven't been able to find sample code that does something like this in a straightforward manner, so any help, pointers,code would be appreciated... | adwords api: retrieve daily spend (costs) | Does anybody have some sample code that shows how to get the daily, total spend (across all campaigns) of an AdWords account?
I haven't been able to find sample code that does something like this in a straightforward manner, so any help, pointers,code would be appreciated. (I'll use the python lib but any other langua... | [
"I'm not familiar with Python but the process should be similar in any language so this PHP might be of some help:\n$user = new AdWordsUser();\n\n// Get the CampaignService.\n$campaignService = $user->GetCampaignService('v201101');\n\n// Create selector.\n$selector = new Selector();\n// Fields to retrieve\n$selecto... | [
0
] | [] | [] | [
"api",
"google_ads_api",
"google_api",
"python"
] | stackoverflow_0006359972_api_google_ads_api_google_api_python.txt |
Q:
Scripting changes to multiple excel workbooks
I've trying to make large changes to a number of excel workbooks(over 20). Each workbook contains about 16 separate sheets, and I want to write a script that will loop through each workbook and the sheets contains inside and write/modify the cells that I need. I need t... | Scripting changes to multiple excel workbooks | I've trying to make large changes to a number of excel workbooks(over 20). Each workbook contains about 16 separate sheets, and I want to write a script that will loop through each workbook and the sheets contains inside and write/modify the cells that I need. I need to keep all string validation, macros, and formattin... | [
"I avoid working with multiple workbooks like the plague it's a pain, if this is an ongoing requirement then I would suggest looking back to your workbook design and seeing if you can consolidate back to one workbook. I often see workbooks each saved month by month when they should have one workbook with one shee... | [
4,
1,
0
] | [] | [] | [
"excel",
"python",
"scripting",
"vba"
] | stackoverflow_0006348011_excel_python_scripting_vba.txt |
Q:
How to use a for loop inside a Django conditional?
Basically if there is a certain GET parameter in the url (in this case "latest") I want to slice the object list by a different number than the usual. But doing this:
{% if 'latest' in request.GET %}
{% for object in object_list|slice:"22" %}
{% el... | How to use a for loop inside a Django conditional? | Basically if there is a certain GET parameter in the url (in this case "latest") I want to slice the object list by a different number than the usual. But doing this:
{% if 'latest' in request.GET %}
{% for object in object_list|slice:"22" %}
{% else %}
{% for object in object_list|slice:"10" %}... | [
"You need to have a body in your for loop. \n{% if 'latest' in request.GET %}\n {% for object in object_list|slice:\"22\" %} {{ object }} {% endfor %}\n{% else %}\n {% for object in object_list|slice:\"10\" %} {{ object }} {% endfor %}\n{% endif %}\n\nWithout it, you're saying the equivalent of the following... | [
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006361879_django_python.txt |
Q:
Communication with usb device using pyusb
I am using a module called pyUSB version 1.6 and am trying to communicate with a sensor.
I have set up the connection and can read from the ROM on the sensor. The sensor, when connected, has a master/slave relationship so I need to send a message to the sensor to receive ... | Communication with usb device using pyusb | I am using a module called pyUSB version 1.6 and am trying to communicate with a sensor.
I have set up the connection and can read from the ROM on the sensor. The sensor, when connected, has a master/slave relationship so I need to send a message to the sensor to receive the data I need.
Now, the write function can o... | [
"byte_ints = [0xFE, 0x04, 0x00, 0x03, 0x00, 0x01, 0xD5, 0xC5] # Python recognises these as hex.\nbyte_str = \"\".join(chr(n) for n in byte_ints)\n\nAlternatively, you can just put \\x before each pair of hex digits in a string:\n'\\xfe\\x04\\x00\\x03\\x00\\x01\\xd5\\xc5'\n\nIn Python 3, that needs to be:\nb'\\xfe\\... | [
6
] | [] | [] | [
"communication",
"python",
"pyusb",
"usb"
] | stackoverflow_0006361261_communication_python_pyusb_usb.txt |
Q:
ropemacs USAGE tutorial
There are many sites with instructions on installing ropemacs, but so far I couldn't find any with instructions on how to use it after it's already installed. I have it installed, or at least it seems so, Emacs has "Rope" menu in it's top menu bar. Now what? So far I could use only "Show do... | ropemacs USAGE tutorial | There are many sites with instructions on installing ropemacs, but so far I couldn't find any with instructions on how to use it after it's already installed. I have it installed, or at least it seems so, Emacs has "Rope" menu in it's top menu bar. Now what? So far I could use only "Show documentation" (C-c d by defaul... | [
"Well, you first need to select your project root folder. Quite simply, this is the folder at the top level of your project, or the current folder if you're dealing with a single file. Once you've selected the root folder, then other options will work, such as code assist, showing documentation, jumping to other sy... | [
63,
13,
10,
3
] | [] | [] | [
"autocomplete",
"emacs",
"ide",
"python"
] | stackoverflow_0002855378_autocomplete_emacs_ide_python.txt |
Q:
cannot integrate little script inside django/python app... can you explain how urls.py works?
I'm not a programmer, but I've written few things in php/mysql. So I've grasp of programming, but I cannot understand logic of django apps... and python is so weirdly complicated! Please help me solve a little problem I'm... | cannot integrate little script inside django/python app... can you explain how urls.py works? | I'm not a programmer, but I've written few things in php/mysql. So I've grasp of programming, but I cannot understand logic of django apps... and python is so weirdly complicated! Please help me solve a little problem I'm having.
My script is simple, it displays random sentence. nothing fancy!
So I've:
random-quotes.py... | [
"The tutorial provides an excellent explanation of what is happening here.\nIn short, any URL that matches the regular expression in urls.py will be mapped to the specified function in views.py. views.py will execute any necessary logic, and will load a template (if specified).\n"
] | [
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006362048_django_python.txt |
Q:
PyQt4 filename dialog
I am a bit of a novice so be kind ;-)
I had a GUI that I made using PyQt4 and python 2.6 with a working file dialog, (ie you clicked a button and a window popped up and allowed you to pick a file to load/save). The code for the GUI is like 2000 lines, so i will include the bits i think are i... | PyQt4 filename dialog | I am a bit of a novice so be kind ;-)
I had a GUI that I made using PyQt4 and python 2.6 with a working file dialog, (ie you clicked a button and a window popped up and allowed you to pick a file to load/save). The code for the GUI is like 2000 lines, so i will include the bits i think are important:
from PyQt4 import... | [
"Your class should inherit (directly or indirectly) from QtCore.QObject to be able to handle signals. The first one inherits from QWidget, which does the job.\n"
] | [
2
] | [] | [] | [
"pyqt4",
"python",
"qfiledialog",
"qt_designer",
"qtgui"
] | stackoverflow_0006362215_pyqt4_python_qfiledialog_qt_designer_qtgui.txt |
Q:
Django 1.3, extending to User auth system, User Profiling or Subclassing?
Subclassing:
http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/
User Profiling:
https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
Which one is more efficient ... | Django 1.3, extending to User auth system, User Profiling or Subclassing? | Subclassing:
http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/
User Profiling:
https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
Which one is more efficient and less of a hassle?
And
Which way should I go if I plan to scale big?
| [
"Don't use subclassing unless you're prepared to 1) write your own auth backend, and 2) forgo ever using a different auth backend.\n",
"It seems to makes sense to have the simplest model possible for authentication and then all other connected data in the Profile. \nGenerally I would use the UserProfile class for... | [
3,
1
] | [] | [] | [
"django",
"profiling",
"python",
"subclass"
] | stackoverflow_0006351521_django_profiling_python_subclass.txt |
Q:
Adobe Flash and hosting the player with python and wxWidgets
Does Adobe Flash expose any Automation or hosting interfaces through COM or a DLL in %systemroot%\system32? I'm working with Python and wxWidgets to host a flash application to monitor lunar phases.
http://www.calculatorcat.com/moon_phases/moon_phases.ph... | Adobe Flash and hosting the player with python and wxWidgets | Does Adobe Flash expose any Automation or hosting interfaces through COM or a DLL in %systemroot%\system32? I'm working with Python and wxWidgets to host a flash application to monitor lunar phases.
http://www.calculatorcat.com/moon_phases/moon_phases.phtml is the application to be hosted.
| [
"Yes, Flash does expose COM interfaces necessary for hosting it. There is even an example\nshowing how to do it in C++ in wxWidgets svn.\n"
] | [
1
] | [] | [] | [
"com",
"dll",
"flash",
"python",
"wxpython"
] | stackoverflow_0006361241_com_dll_flash_python_wxpython.txt |
Q:
Python - Extra Excel chart series with win32com
I'm writing some code for an assignment, and I need to create a simple column chart in Excel. This afternoon I found win32com (amazing tool by the way), but I've been suffering from either the lack of documentation about it, or my lack of luck to find it ^^
I'm playi... | Python - Extra Excel chart series with win32com | I'm writing some code for an assignment, and I need to create a simple column chart in Excel. This afternoon I found win32com (amazing tool by the way), but I've been suffering from either the lack of documentation about it, or my lack of luck to find it ^^
I'm playing around with the charts, and I think I've managed t... | [
"By observing the behavior of recording a macro in Excel which performs the same actions as we are replication in Python we can see that there does not appear to be a need to create a new series such as\nseries = chart.SeriesCollection().NewSeries()\n\nI was able to simply reference an existing series \nseries = ch... | [
2
] | [] | [] | [
"charts",
"excel",
"python",
"series",
"win32com"
] | stackoverflow_0006339115_charts_excel_python_series_win32com.txt |
Q:
Read from the terminal in Python
How can I receive input from the terminal in Python?
I am using Python to interface with another program which generates output from user input.
I am using subprocess.Popen() to input to the program, but I can't set stdout to subprocess.PIPE because the program does not seem to flu... | Read from the terminal in Python | How can I receive input from the terminal in Python?
I am using Python to interface with another program which generates output from user input.
I am using subprocess.Popen() to input to the program, but I can't set stdout to subprocess.PIPE because the program does not seem to flush ever, so everything gets stuck in t... | [
"Buffering in child processes is a common problem. Here are four possible approaches.\nFirst, and easiest, you could read one byte at a time from your pipe. This is what I would call a \"dirty hack\" and it carries a performance penalty, but it's easy and it guarantees that your read() calls will only block until... | [
1,
0
] | [] | [] | [
"python",
"terminal"
] | stackoverflow_0006361763_python_terminal.txt |
Q:
UTF-16 to Ascii ignoring characters with decimal value greater than 127
I know there are quite a few solutions for this problem but mine was peculiar in the sense that, I might get truncated utf16 data and yet have to make the best effort of dealing with conversions where decode and encode will fail with UnicodeDe... | UTF-16 to Ascii ignoring characters with decimal value greater than 127 | I know there are quite a few solutions for this problem but mine was peculiar in the sense that, I might get truncated utf16 data and yet have to make the best effort of dealing with conversions where decode and encode will fail with UnicodeDecodeError. So came up with the following code in python.
Please let me know y... | [
"What about:\ndata = open(filename).read()\ntry:\n data = data.decode(\"utf-16\")\nexcept UnicodeDecodeError:\n data = data[:-1].decode(\"utf-16\")\n\nI.e. if it's truncated mid-way through a code unit, snip the last byte off, and do it again. That should get you back to a valid UTF-16 string, without having ... | [
3,
2
] | [
"This just jumped out at me as a \"best practice\" improvement. File accesses should really be wrapped in with blocks. This will handle opening and cleaning up for you.\n"
] | [
-1
] | [
"ascii",
"python",
"utf_16"
] | stackoverflow_0006361775_ascii_python_utf_16.txt |
Q:
How to determine the nearest, previous business day for an event given custom business hours?
For a given Business with custom BusinessHours and Events, I need to figure out how get the nearest, previous business day for each event (say a weeks worth of events). For example, let's say a Business has BusinessHours... | How to determine the nearest, previous business day for an event given custom business hours? | For a given Business with custom BusinessHours and Events, I need to figure out how get the nearest, previous business day for each event (say a weeks worth of events). For example, let's say a Business has BusinessHours on Sunday, Wednesday, Friday, and Saturday. Given an Event that starts on Wed, June 22nd, 2011 at... | [
"You will want to do a query to your database written in python. I would check out the django docs on how to make database queries and the appendix of fieldlookups.\nThe basic format will probably look something like :\n# Will return a list of dictionary objects for all rows with that foreign key\n# Ex: [{'business... | [
3
] | [] | [] | [
"database_design",
"datetime",
"django",
"python"
] | stackoverflow_0006362564_database_design_datetime_django_python.txt |
Q:
ANTLR parsing MismatchedTokenException
I'm trying to write a simple parser for an even simpler language that I'm writing. It's composed of postfix expressions. As of now, I'm having issues with the parser. When I run it on the input 2 2 * test >> I get a MismatchedTokenException.
Also, how would I go about impleme... | ANTLR parsing MismatchedTokenException | I'm trying to write a simple parser for an even simpler language that I'm writing. It's composed of postfix expressions. As of now, I'm having issues with the parser. When I run it on the input 2 2 * test >> I get a MismatchedTokenException.
Also, how would I go about implementing a recursive postfix parser?
Here's my ... | [
"A couple of things are not correct:\n1\nYou've put the WS token on the HIDDEN channel, which makes them unavailable to parser rules. So all WS tokens inside your body rule are incorrect.\n2\n_(your latest edit removed the left-recursion issue, but I'll still make a point of it sorry, your other question has a left... | [
4
] | [
"The problem is that your body rule never terminates, because it's allowed to match nothing. I didn't fire up ANTLR, I really don't like to mess with it, instead I rewrote your grammar in C++ (using AXE parser generator), added print statements to trace the matches and got the following result from parsing \"2 2 * ... | [
-1
] | [
"antlr",
"antlrworks",
"parser_generator",
"python"
] | stackoverflow_0006359881_antlr_antlrworks_parser_generator_python.txt |
Q:
Python script is not running under cron, despite working when run manually
I know there have been plenty of questions about this, but I've been trying things for a while with no luck. I have a simple python testscript that creates a folder with a timestamped name. It works perfectly when I run it manually, but not... | Python script is not running under cron, despite working when run manually | I know there have been plenty of questions about this, but I've been trying things for a while with no luck. I have a simple python testscript that creates a folder with a timestamped name. It works perfectly when I run it manually, but nothing happens when I try to put it into crontab. Any idea where I'm messing up he... | [
"Use fully qualified path for all commands in crontab.\n0 */2 * * * /full/path/to/python /home/ec2-user/cronscripts/testscript.py\n\nAlso, all fields are *? When do you expect this to be run? The above example would run every other hr.\n"
] | [
6
] | [] | [] | [
"cron",
"linux",
"python"
] | stackoverflow_0006363023_cron_linux_python.txt |
Q:
In selenium.py, How to deal with 404 status code
I'm writing a selenium script by python. Something that I found out, is that when selenium gets 404 status code. it crashes. What is the best way to deal with it?
A:
I had a similar problem. Sometimes a server we were using (i.e., not the main server we were testi... | In selenium.py, How to deal with 404 status code | I'm writing a selenium script by python. Something that I found out, is that when selenium gets 404 status code. it crashes. What is the best way to deal with it?
| [
"I had a similar problem. Sometimes a server we were using (i.e., not the main server we were testing, only a \"sub-server\") throughout our tests would crash. I added a minor sanity test to see if the server is up or not before the main tests ran. That is, I performed a simple GET request to the server, surrounded... | [
1
] | [] | [] | [
"python",
"selenium"
] | stackoverflow_0005799512_python_selenium.txt |
Q:
lambda calling @classmethod fails
Maybe I get this completely wrong but I ran into some odd issues with lambda calling @classmethod.
I have the following class:
class MyClass:
LAMBDA = lambda: MyClass.ClassMethod()
@classmethod
def ClassMethod(cls):
pass
But this fails whenever LAMBDA is called with:
T... | lambda calling @classmethod fails | Maybe I get this completely wrong but I ran into some odd issues with lambda calling @classmethod.
I have the following class:
class MyClass:
LAMBDA = lambda: MyClass.ClassMethod()
@classmethod
def ClassMethod(cls):
pass
But this fails whenever LAMBDA is called with:
TypeError: unbound method <lambda>() mus... | [
"You must understand, that your code is exactly equivalent to\nclass MyClass:\n\n def LAMBDA():\n return MyClass.ClassMethod()\n\n @classmethod\n def ClassMethod(cls):\n pass\n\nYou, then, apparently call it like MyClass.LAMBDA(). But look, LAMBDA is an instance method. And you are calling it without an ac... | [
2,
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0003197223_python.txt |
Q:
string suffix replacement in python
i know how to make string replacements in python but I need a way to replace only
if the sequence is located at the end of the word.
for example:
rule: at -> ate
so:
cat -> cate
but:
attorney -> attorney
thanks.
A:
There is no special method to do this, but it's quite simple ... | string suffix replacement in python | i know how to make string replacements in python but I need a way to replace only
if the sequence is located at the end of the word.
for example:
rule: at -> ate
so:
cat -> cate
but:
attorney -> attorney
thanks.
| [
"There is no special method to do this, but it's quite simple anyways:\nw = 'at'\nrepl = 'ate'\ns = 'cat'\n\nif s.endswith(w):\n # if s ends with w, take only the part before w and add the replacement\n s = s[:-len(w)] + repl\n\n",
"A regex can do that with easyness:\nimport re\n\nregx = re.compile('at\\\\b... | [
6,
5,
1,
0
] | [] | [] | [
"python",
"string"
] | stackoverflow_0006363286_python_string.txt |
Q:
Downloading images from multiple websites concurrently using Python
I'm trying to download multiple images concurrently using Python over the internet, and I've looked at several option but none of them seem satisfactory.
I've considered pyCurl, but don't really understand the example code, and it seems to be way ... | Downloading images from multiple websites concurrently using Python | I'm trying to download multiple images concurrently using Python over the internet, and I've looked at several option but none of them seem satisfactory.
I've considered pyCurl, but don't really understand the example code, and it seems to be way overkill for a task as simple as this.
urlgrabber seems to be a good choi... | [
"It's not fancy, but you can use urllib.urlretrieve, and a pool of threads or processes running it.\nBecause they're waiting on network IO, you can get multiple threads running concurrently - stick the URLs and destination filenames in a Queue.Queue, and have each thread suck them up.\nIf you use multiprocessing, i... | [
1
] | [] | [] | [
"concurrency",
"curl",
"download",
"python",
"urllib2"
] | stackoverflow_0006363111_concurrency_curl_download_python_urllib2.txt |
Q:
Getting a syntax error when converting a string into an int
I am trying to convert a string into an int using the typecast "(int)". Here is what I am doing:
num = (int) request.POST['num']
A:
Try using the int() function instead.
num = int(request.POST['num'])
| Getting a syntax error when converting a string into an int | I am trying to convert a string into an int using the typecast "(int)". Here is what I am doing:
num = (int) request.POST['num']
| [
"Try using the int() function instead.\nnum = int(request.POST['num'])\n\n"
] | [
9
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006363769_django_python.txt |
Q:
Psycopg2 using wildcard causes TypeError
Currently I am attempting to search a database to grab certain events. My query is as such
SELECT * FROM events WHERE summary ILIKE E'%test%' AND start_time > '2010-10-01'
Simply put I need the query to look through a database of calendar events and return anything with a ... | Psycopg2 using wildcard causes TypeError | Currently I am attempting to search a database to grab certain events. My query is as such
SELECT * FROM events WHERE summary ILIKE E'%test%' AND start_time > '2010-10-01'
Simply put I need the query to look through a database of calendar events and return anything with a summary with 'test' in it and after the beginn... | [
"Not sure if this is the full root of your problem, but I think you need to escape your wildcards or the parameterization logic will get confused.\nSELECT * FROM events WHERE summary ILIKE E'%%test%%' AND start_time > %(begin)s \n\nEDIT: 10+ years later, I'm looking at the psycopg2 issues for an unrelated bug and f... | [
24,
3
] | [] | [] | [
"psycopg2",
"python"
] | stackoverflow_0003944276_psycopg2_python.txt |
Q:
Linking google-appengine native model to Django model
I've ported my GAE project to django-nonrel, and now I would like to have link from my object to Django User object:
class Opinion(google.appengine.ext.db.Model):
...
author = db.ReferenceProperty(django.contrib.auth.User)
Unfortunately, that's not possibl... | Linking google-appengine native model to Django model | I've ported my GAE project to django-nonrel, and now I would like to have link from my object to Django User object:
class Opinion(google.appengine.ext.db.Model):
...
author = db.ReferenceProperty(django.contrib.auth.User)
Unfortunately, that's not possible, since you only can link GAE models this way.
Question - ... | [
"My initial googling and searching brought me nothing good:\nOn django-nonrel list I read:\n\nYou cannot use appengine model into django-nonrel. You need alter all \n your models to django proper. That is, use original \n django-registration app not the appengine-patch provided registration. \n\nAnother question,... | [
0
] | [] | [] | [
"django",
"django_nonrel",
"google_app_engine",
"python"
] | stackoverflow_0006354301_django_django_nonrel_google_app_engine_python.txt |
Q:
CherryPy BackgroundTask
I need a simple example of invoking the cherrypy.process.plugins.BackgroundTask.
I tried it out but can't seem to get it to work (no examples in the docs).
Here is my code:
def func():
print "blah blah blah"
wd = cherrypy.process.plugins.BackgroundTask(15000,func)
wd.run()
A:
The short... | CherryPy BackgroundTask | I need a simple example of invoking the cherrypy.process.plugins.BackgroundTask.
I tried it out but can't seem to get it to work (no examples in the docs).
Here is my code:
def func():
print "blah blah blah"
wd = cherrypy.process.plugins.BackgroundTask(15000,func)
wd.run()
| [
"The short answer is, you want to call wd.start(), not wd.run().\nAlso, because BackgroundTask is daemonic, unless you are doing something else to keep the interpreter alive, Python will exit while your thread floats in the background with no way to see the output.\nThat said, I've been futzing around with trying t... | [
3
] | [] | [] | [
"cherrypy",
"python"
] | stackoverflow_0006363889_cherrypy_python.txt |
Q:
Joomla website (and its db ) + Python(add,edit, upgrade in another db ) application Integration
How can one integrate a web application(built in joomla) to (communicate, update db, do cron jobs) to a application in python(or django) , Since my website has huge no of visitors, I feel should there be a seperate app... | Joomla website (and its db ) + Python(add,edit, upgrade in another db ) application Integration | How can one integrate a web application(built in joomla) to (communicate, update db, do cron jobs) to a application in python(or django) , Since my website has huge no of visitors, I feel should there be a seperate application to be an interpreter between these two(joomla,python) like some sort of Initialization engin... | [
"Thrift supports both PHP and Python:\n\nThrift is a software framework for\n scalable cross-language services\n development. It combines a software\n stack with a code generation engine to\n build services that work efficiently\n and seamlessly between C++, Java,\n Python, PHP, Ruby, Erlang, Perl,\n Haskell... | [
0
] | [] | [] | [
"integration",
"joomla",
"python"
] | stackoverflow_0006364597_integration_joomla_python.txt |
Q:
continue loop if arrow keys are not pressed in pygame
I'm trying create this function such that if any key besides any of the arrow keys are pressed, the loop continues until an arrow key is pressed. The program crashes every time and doesn't display the error. Any idea why?
def speed(self, key):
# Figure ou... | continue loop if arrow keys are not pressed in pygame | I'm trying create this function such that if any key besides any of the arrow keys are pressed, the loop continues until an arrow key is pressed. The program crashes every time and doesn't display the error. Any idea why?
def speed(self, key):
# Figure out if it was an arrow key. If so
# adjust speed
n =... | [
"I have never used pygame in my life, nor written a single word of python, but here's my guess:\ndef speed(self, key):\n # Figure out if it was an arrow key. If so\n # adjust speed\n if key == pygame.K_LEFT:\n x_speed=-5\n y_speed=0\n return x_speed, y_speed\n\n if key == pygame.K_R... | [
5,
2
] | [] | [] | [
"pygame",
"python"
] | stackoverflow_0006363721_pygame_python.txt |
Q:
convert string into int()
I have a dataset that looks like this:
0 _ _ 23.0186E-03
10 _ _51.283E-03
20 _ _125.573E-03
where the numbers are lined up line by line (the underscores represent spaces).
The numbers in the right hand column are currently part of the line's string. I am trying to convert the number... | convert string into int() | I have a dataset that looks like this:
0 _ _ 23.0186E-03
10 _ _51.283E-03
20 _ _125.573E-03
where the numbers are lined up line by line (the underscores represent spaces).
The numbers in the right hand column are currently part of the line's string. I am trying to convert the numbers on the right into numerical v... | [
"I would suggest the following for the conversion:\nfloat(x.split()[-1])\n\nstr.split() will split on white space when no arguments are provided, and float() will convert the string into a number, for example:\n>>> '20 125.573E-03'.split()\n['20', '125.573E-03']\n>>> float('20 125.573E-03'.split()[-1])\n0.1255729... | [
5,
4,
2,
1
] | [] | [] | [
"int",
"python",
"string"
] | stackoverflow_0006364444_int_python_string.txt |
Q:
SequenceMatcher for multiple inputs, not just two?
wondering about the best way to approach this particular problem and if any libraries (python preferably, but I can be flexible if need be).
I have a file with a string on each line. I would like to find the longest common patterns and their locations in each lin... | SequenceMatcher for multiple inputs, not just two? | wondering about the best way to approach this particular problem and if any libraries (python preferably, but I can be flexible if need be).
I have a file with a string on each line. I would like to find the longest common patterns and their locations in each line. I know that I can use SequenceMatcher to compare lin... | [
"If all you want is to find common substrings that are at the same offset in each line, all you need is something like this:\nmatches = []\nzipped_strings = zip(s1,s2,s3)\nstartpos = -1\nfor i in len(zipped_strings):\n c1,c2,c3 = zipped_strings[i]\n # if you're not inside a match, \n # look for matching charact... | [
2
] | [] | [] | [
"compression",
"python",
"sequencematcher"
] | stackoverflow_0002562893_compression_python_sequencematcher.txt |
Q:
How to remove a key from a 2 dimensional dictionary in Python?
I am trying to use pop to remove a key from a 2 dimensional dictionary. I keep thinking that forward_hash[first_key].pop(second_key) should work but it's not.
A:
It appears to work for me:
>>> forward_hash = {"first_key": {"second_key": "data"}}
>>> ... | How to remove a key from a 2 dimensional dictionary in Python? | I am trying to use pop to remove a key from a 2 dimensional dictionary. I keep thinking that forward_hash[first_key].pop(second_key) should work but it's not.
| [
"It appears to work for me:\n>>> forward_hash = {\"first_key\": {\"second_key\": \"data\"}}\n>>> forward_hash[\"first_key\"].pop(\"second_key\")\n'data'\n>>> forward_hash\n{'first_key': {}}\n\n",
"If you're looking to remove second_key from all of your dicts, you should do:\nforward_hash = dict( a=dict(...), b=di... | [
4,
2,
1,
0
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0006364569_dictionary_python.txt |
Q:
Python 2.5 version of array.array.tostring()?
I am using 2.5 on GAE using some of the Crypto modules from gdata python modules. I am able to use hashAndSign on a string, but the function returns an array.array of 'B' unsigned characters.
I'm still experimenting on getting it all together, but one thing I'm stumbl... | Python 2.5 version of array.array.tostring()? | I am using 2.5 on GAE using some of the Crypto modules from gdata python modules. I am able to use hashAndSign on a string, but the function returns an array.array of 'B' unsigned characters.
I'm still experimenting on getting it all together, but one thing I'm stumbling on now is getting an:
array('B', [120, 231, 49,... | [
"If for some reason the .tostring() method isn't available -- which makes me think that this array is different from the usual array.array, because .tostring() was around at least as far back as python 2.4 -- then\n>>> import array\n>>> q = array.array('B', [120, 231, 49, 2, 125, 143, 213, 14, 214, 66, 52, 11, 124,... | [
2,
0,
0
] | [] | [] | [
"arrays",
"bytearray",
"gdata",
"google_app_engine",
"python"
] | stackoverflow_0006362912_arrays_bytearray_gdata_google_app_engine_python.txt |
Q:
python version for C for loop
Can anyone show me the python forloop style for this kind of C forloop
for (end_timeout=1, i=0; i<TIME_OUT; i++)
{
bit = Inp32(status_register) & (1 << PtrClk);
if ( ( bit >> PtrClk ) == 1 )
{
end_timeout = 0;
break;
}
}... | python version for C for loop | Can anyone show me the python forloop style for this kind of C forloop
for (end_timeout=1, i=0; i<TIME_OUT; i++)
{
bit = Inp32(status_register) & (1 << PtrClk);
if ( ( bit >> PtrClk ) == 1 )
{
end_timeout = 0;
break;
}
}
Thanks.
| [
"end_timeout = 1\nfor i in range(TIME_OUT):\n pass\n\n",
"end_timeout = 1\nfor i in xrange(TIME_OUT):\n ...\n\nThis will start the loop with i == 0. Use xrange(n, TIME_OUT) if you want to start with i == n.\nSee the documentation forxrange.\n",
"end_timeout = 1\nfor i in range(TIME_OUT):\n # ...your co... | [
5,
3,
1
] | [] | [] | [
"loops",
"python"
] | stackoverflow_0006365112_loops_python.txt |
Q:
Is there a way to construct lazy sequences in Python?
There is a Django view that loads Member objects from the database with a certain filter.
Now I need to change this logic to present a specific Member first, and let the rest follow in their natural order.
The most straightforward way is to execute the query ri... | Is there a way to construct lazy sequences in Python? | There is a Django view that loads Member objects from the database with a certain filter.
Now I need to change this logic to present a specific Member first, and let the rest follow in their natural order.
The most straightforward way is to execute the query right away, get a list, remove and insert the item at the beg... | [
"Use itertools.chain. Something like:\nimport itertools\noriginal_members = .... # get an iterator of the data\nmembers = itertools.chain([specific_member], original_members)\n\nThe chain function returns an iterator. The iterator starts by returning the value from the sequence in the first parameter, which is a si... | [
6
] | [] | [] | [
"django",
"django_queryset",
"generator_expression",
"lazy_sequences",
"python"
] | stackoverflow_0006365128_django_django_queryset_generator_expression_lazy_sequences_python.txt |
Q:
Binding event handlers in a wx.TaskBarIcon derived class
I'm trying to attach the EVT_TASKBAR_RIGHT_UP event to a function in a custom class derived from wx.TaskBarIcon using self.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.OnTaskBarRight). This is in the init function of the class. However, when the interpreter encounters... | Binding event handlers in a wx.TaskBarIcon derived class | I'm trying to attach the EVT_TASKBAR_RIGHT_UP event to a function in a custom class derived from wx.TaskBarIcon using self.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.OnTaskBarRight). This is in the init function of the class. However, when the interpreter encounters it, it gives me this:
Traceback (most recent call last):
File... | [
"If you override the __init__ method of a widget, you need to call the __init__ method of the parent class. Add\nsuper(tbicon, self).__init__()\n\nto your __init__.\n"
] | [
2
] | [] | [] | [
"bind",
"python",
"wxpython"
] | stackoverflow_0006364961_bind_python_wxpython.txt |
Q:
Django: How do I count the number of objects related to another in the database?
I want to make an application that will allow people to form groups to buy items together. I need a way to see how many people are already buying. I have the following models.py:
from django.db import models
class Buyer(models.Model)... | Django: How do I count the number of objects related to another in the database? | I want to make an application that will allow people to form groups to buy items together. I need a way to see how many people are already buying. I have the following models.py:
from django.db import models
class Buyer(models.Model):
''' Buyer of the item '''
first_name = models.CharField(max_length=40)
... | [
"You can just get the results and then count them:\ndef remaining(self):\n return self.quantity - len( self.buyers.all() )\n\nActually, to update, the documentation says not do do that, though it would work, so:\ndef remaining(self):\n return self.quantity - self.buyers.all().count()\n\n"
] | [
1
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0006365210_django_django_models_python.txt |
Q:
Python (Enthought) Tuple / List Trait: how to access a specific element?
Let's say I have a HasTraits object with a Tuple or a List attribute. Is there a way to set up an editor that would display (or allow to edit, in the case of a List), for example, only the first element of the sequence?
Thanks.
A:
On the e... | Python (Enthought) Tuple / List Trait: how to access a specific element? | Let's say I have a HasTraits object with a Tuple or a List attribute. Is there a way to set up an editor that would display (or allow to edit, in the case of a List), for example, only the first element of the sequence?
Thanks.
| [
"On the epd-users mailing list, I got the following answer: define a new trait as a property that depends on the tuple, and create an editor for this new Property.\nSomething like:\ntuple = Tuple(blah)\nt0 = Property(depends_on=\"tuple\", fget=lambda self: self.tuple[0])\n\n(and likewise a setter if necessary).\n"
... | [
1
] | [] | [] | [
"python",
"traits"
] | stackoverflow_0006350517_python_traits.txt |
Q:
Converting an NFO to PNG with Python and PIL
I'm trying to convert an NFO file with some crazy high ASCII arts using a Python script and PIL. Everything is nice when the NFO contains just simple characters, but with the "full rectangles" arts all i get is a lot of "ùùùù".
nfoFont = ImageFont.truetype('cour.ttf', s... | Converting an NFO to PNG with Python and PIL | I'm trying to convert an NFO file with some crazy high ASCII arts using a Python script and PIL. Everything is nice when the NFO contains just simple characters, but with the "full rectangles" arts all i get is a lot of "ùùùù".
nfoFont = ImageFont.truetype('cour.ttf', size=12, encoding='unic')
#[...other code...]
nfo... | [
"How do you get the contents of the nfoText variable? Is it a unicode or byte string?\nWithout knowing how PIL handles encodings, I'm assuming it works correctly with Unicode strings, then just read the nfo file with:\nimport codecs\nnfoText = codecs.open('something.nfo', 'r', 'cp437').read()\n\nI can't check right... | [
1
] | [] | [] | [
"png",
"python",
"python_imaging_library"
] | stackoverflow_0006364226_png_python_python_imaging_library.txt |
Q:
What does Django return when it cannot find an object?
I am doing a query on the database, and I want to do something if the query returns nothing, but I get an error:
user = User.objects.get(name=Jack)
if (user == NULL):
# something
I get a User matching query does not exist.
A:
It throws an exception. Per... | What does Django return when it cannot find an object? | I am doing a query on the database, and I want to do something if the query returns nothing, but I get an error:
user = User.objects.get(name=Jack)
if (user == NULL):
# something
I get a User matching query does not exist.
| [
"It throws an exception. Perhaps you should try catching it.\n",
"Django doesn't 'return' anything, it throws an error instead, so you are not getting to your if test.\nInstead surround the code in a try catch, like this\n try: \n user = User.objects.get(name=\"Jack\")\n except User.DoesNotExist:\n ... | [
4,
4,
3
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006365416_django_python.txt |
Q:
Custom field error from try/except in Django view?
I have a form for geocoding an address in my app. If a non-address is entered, the geocoder raises a "GQueryError". Using try/except I'd like to catch this error and send a custom error back to the form that would show up in the "errorlist" like the other errors a... | Custom field error from try/except in Django view? | I have a form for geocoding an address in my app. If a non-address is entered, the geocoder raises a "GQueryError". Using try/except I'd like to catch this error and send a custom error back to the form that would show up in the "errorlist" like the other errors and be appropriately displayed and styled. Can this be do... | [
"You should write a clean_field_name method and in it capture the error and raise a ValidationError e.g\nclass MyForm(forms.Form):\n ...\n # rest of the form\n ...\n\n def clean_address(self):\n address = self.cleaned_data['address']\n try:\n address = geo_clean(address)\n ... | [
0
] | [] | [] | [
"django",
"django_forms",
"geopy",
"python"
] | stackoverflow_0006365318_django_django_forms_geopy_python.txt |
Q:
django tagging - filter by tag
I'm on a free-time project, and I have this model:
class Post(models.Model):
title = models.CharField(max_length=255)
<..>
tags = TagAutocompleteField()
TagAutocompleteField() is same as TagField() from django-tagging witch is simple CharField so print post.tags will giv... | django tagging - filter by tag | I'm on a free-time project, and I have this model:
class Post(models.Model):
title = models.CharField(max_length=255)
<..>
tags = TagAutocompleteField()
TagAutocompleteField() is same as TagField() from django-tagging witch is simple CharField so print post.tags will give 'one two three' instead of ['one',... | [
"Try using regex\n.filter(tags__iregex=r'\\b%s\\b' % tag)\n\n"
] | [
2
] | [] | [] | [
"django",
"filter",
"python",
"tags",
"view"
] | stackoverflow_0006364373_django_filter_python_tags_view.txt |
Q:
How to fix these IOErrors when creating a thumbnail from a filepath in PIL (Python Imaging Library)
I am trying to make a simple function in python that can take in a filepath and an outputfilepath, and then make a 64x64 thumbnail for the image found at filepath and save the thumbnail to outputfilepath. Here is my... | How to fix these IOErrors when creating a thumbnail from a filepath in PIL (Python Imaging Library) | I am trying to make a simple function in python that can take in a filepath and an outputfilepath, and then make a 64x64 thumbnail for the image found at filepath and save the thumbnail to outputfilepath. Here is my entire code:
def create_thumbnail2(filepath, outputpath):
if not os.path.exists(filepath):
p... | [
"My installation of PIL does the same. (PIL 1.1.7, Py 2.6, OSX 10.6)\nEDIT:\nAh - the installation on a different OSX machine works. I know there are issues building PIL with JPG support on OSX, but I can't recall what the source of each of the two installations was, so I can't tell you how to fix it.\nEDIT 2: \nMy... | [
1
] | [] | [] | [
"ioerror",
"python",
"python_imaging_library"
] | stackoverflow_0006363666_ioerror_python_python_imaging_library.txt |
Q:
python lxml adds unused namespaces
I'm having an issue when using lxml's find() method to select a node in an xml file. Essentially I am trying to move a node from one xml file to another.
File 1:
<somexml xmlns:a='...' xmlns:b='...' xmlns:c='...'>
<somenode id='foo'>
<something>bar</something>
</... | python lxml adds unused namespaces | I'm having an issue when using lxml's find() method to select a node in an xml file. Essentially I am trying to move a node from one xml file to another.
File 1:
<somexml xmlns:a='...' xmlns:b='...' xmlns:c='...'>
<somenode id='foo'>
<something>bar</something>
</somenode>
</somexml>
Once I parse File ... | [
"If the namespaces are in the document, then the document uses the namespaces. The namespaces are being used in those nodes, because those nodes are part of the subtree which declared the namespace. Follow the link given by Daenyth to remove them, or strip them off the XML string before you turn it into an lxml obj... | [
3
] | [] | [] | [
"lxml",
"python"
] | stackoverflow_0006365422_lxml_python.txt |
Q:
Add to locals() in Python 3.2+?
I'm trying to programmatically define several variables in the local namespace:
for build_step in 'prepare', 'configure', 'make', 'stage', 'package', 'all':
p = build_subparsers.add_parser(build_step)
p.set_defaults(build_step=build_step)
if build_step != 'package':
... | Add to locals() in Python 3.2+? | I'm trying to programmatically define several variables in the local namespace:
for build_step in 'prepare', 'configure', 'make', 'stage', 'package', 'all':
p = build_subparsers.add_parser(build_step)
p.set_defaults(build_step=build_step)
if build_step != 'package':
p.add_argument('specfile')
lo... | [
"The answer is: don't do that. \nIf you want to programmatically store values, use a container:\n>>> d = dict()\n>>> d['a'] = 5\n\nOr create a container class, if you really must.\n>>> class Container(object):\n... pass\n... \n>>> c = Container()\n>>> setattr(c, 'a', 5)\n>>> c.a\n5\n\n",
"Why not give build i... | [
7,
5
] | [
"According to the docs for locals():\n\nThe contents of this dictionary should\n not be modified; changes may not\n affect the values of local and free\n variables used by the interpreter.\n\nTry putting them in globals() (which is the symbol dictionary for the current module, not truly global.)\n"
] | [
-2
] | [
"python",
"python_3.x",
"variables"
] | stackoverflow_0006365845_python_python_3.x_variables.txt |
Q:
Django template question: how to output just the text if the variable has html in it?
I have a lot of variables that has html in them. For example the value of a variable called {{object.name}} is the following:
Play this <a href="#">hot</a> game and see how <b>fun</b> it is!
Is there a filter that can be applied... | Django template question: how to output just the text if the variable has html in it? | I have a lot of variables that has html in them. For example the value of a variable called {{object.name}} is the following:
Play this <a href="#">hot</a> game and see how <b>fun</b> it is!
Is there a filter that can be applied on the variable that will give me just the text:
Play this hot game and see how fun it is!... | [
"striptags filter removes all html\n{{object.name|striptags}}\n",
"You have 3 options to strip the html code:\nUsing \"safe\" filter in your template:\n{{ object.name|safe }}\n\nUsing \"autoescape\" tag in your template:\n{% autoescape off %}\n{{ object.name }}\n{% endautoescape %}\n\nor declaring it as \"safe\" ... | [
7,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006359773_django_python.txt |
Q:
How should i proceed with banking Application in Python
I know baisc Python and Django but not advanced. I want to make Banking Application for personal use.
it will have various type of accounts like saving account , Fixed deposits account. I need to calculate interests and put money automatically in accounts.
Is... | How should i proceed with banking Application in Python | I know baisc Python and Django but not advanced. I want to make Banking Application for personal use.
it will have various type of accounts like saving account , Fixed deposits account. I need to calculate interests and put money automatically in accounts.
Is there any example of that type of application so that i can ... | [
"Start with the tutorials on djangoproject.com and go from there. \nIf you want to look at something already done go to: http://code.google.com/p/django-budget/ that should give you a great start.\n"
] | [
1
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0006359991_django_django_models_python.txt |
Q:
How do I get a string representation of an image before uploading?
I'm trying to intercept an image from an HTML form's input control to convert it into a byte string before processing it on the server side.
How do I intercept the file?
upload_files = self.get_uploads('file')
# Intercept here to do something dif... | How do I get a string representation of an image before uploading? | I'm trying to intercept an image from an HTML form's input control to convert it into a byte string before processing it on the server side.
How do I intercept the file?
upload_files = self.get_uploads('file')
# Intercept here to do something different than just upload
blob_info = upload_files[0]
How do I convert i... | [
"Assume your upload control is in a form named \"image\" and you are using Werkzeug's FileStorage: \nimg_stream = self.form.image.data\nmimetype = img_stream.content_type\nimg_str = img_stream.read().encode('base64').replace('\\n', '')\n\ndata_uri = 'data:%s;%s,%s' % (mimetype, 'base64', img_str)\n\nYour data_uri n... | [
0
] | [] | [] | [
"blobstore",
"google_app_engine",
"image",
"python"
] | stackoverflow_0006222891_blobstore_google_app_engine_image_python.txt |
Q:
Limit Python Output File Size
I have a Python program running on Debian that outputs data using a File object. I would like to set a limit on how large my file can be but I don't want to stop writing the file--I just want to remove the oldest line (at the top of the file). My data is written randomly as packets ar... | Limit Python Output File Size | I have a Python program running on Debian that outputs data using a File object. I would like to set a limit on how large my file can be but I don't want to stop writing the file--I just want to remove the oldest line (at the top of the file). My data is written randomly as packets arrive from clients (think web loggin... | [
"There is a reason that no logging system uses this strategy. You can't remove the first line from a file without rewriting the whole file, so it's extremely slow on a large file. Also, you can't write new data to the file while you're rewriting it.\nThe normal strategy is to start writing to a new file when the cu... | [
3,
2,
2,
2,
0
] | [] | [] | [
"linux",
"python",
"sed"
] | stackoverflow_0006363763_linux_python_sed.txt |
Q:
Why does Django get_or_create cause this IntegrityError?
I have a model that has this field on it:
token = models.CharField(max_length=32, default="", unique=True, null=False, db_index=True)
In the save() method I set this field to a 32 character random string using this method:
def save(self, *args, **kwargs):
... | Why does Django get_or_create cause this IntegrityError? | I have a model that has this field on it:
token = models.CharField(max_length=32, default="", unique=True, null=False, db_index=True)
In the save() method I set this field to a 32 character random string using this method:
def save(self, *args, **kwargs):
if (self.token is None or len(self.token) == 0):
sel... | [
"Yes.\nhttps://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-create\nFrom the docs:\nThe new object will be created roughly according to this algorithm:\ndefaults = kwargs.pop('defaults', {})\nparams = dict([(k, v) for k, v in kwargs.items() if '__' not in k])\nparams.update(defaults)\nobj = self.model... | [
4,
1
] | [] | [] | [
"django",
"model",
"orm",
"python"
] | stackoverflow_0006366333_django_model_orm_python.txt |
Q:
get C2DM auth token without passing your password?
I'm working on a C2DM app using appengine on Python. After several hours of wondering why my "send message" was giving me an error 401 I discovered that my auth token was wrong. I've looked at several examples and noticed that most people retrieve the token by pas... | get C2DM auth token without passing your password? | I'm working on a C2DM app using appengine on Python. After several hours of wondering why my "send message" was giving me an error 401 I discovered that my auth token was wrong. I've looked at several examples and noticed that most people retrieve the token by passing the email address and password as request parameter... | [
"No.\nIt's recommended to use a separate account for C2DM instead of using the account used for email and other services.\n"
] | [
1
] | [] | [] | [
"android",
"android_c2dm",
"google_authentication",
"oauth",
"python"
] | stackoverflow_0006362990_android_android_c2dm_google_authentication_oauth_python.txt |
Q:
How to do C language calculation in Python
I want to do some simulation of C language calculation in Python.
For example, unsigned short, single precision float ...
ushort(0xffff) + 1 -> 0
0.1f * 0.1f -> ...
Are there some library to do this in Python?
I can use ctypes to create unsigned short, single float, but... | How to do C language calculation in Python | I want to do some simulation of C language calculation in Python.
For example, unsigned short, single precision float ...
ushort(0xffff) + 1 -> 0
0.1f * 0.1f -> ...
Are there some library to do this in Python?
I can use ctypes to create unsigned short, single float, but they
cann't do math operation:
a = c_uint16(0xf... | [
"When compiling 0xfffe+0x01, this will be folded into the constant 65535. You aren't timing how long the addition takes -- you are just measuring the time of loading the constant:\n>>> dis.dis(compile(\"0xfffe+0x01\", \"\", \"eval\"))\n 1 0 LOAD_CONST 2 (65535)\n 3 RETURN_VALU... | [
6,
1
] | [] | [] | [
"ctypes",
"numpy",
"python"
] | stackoverflow_0006366017_ctypes_numpy_python.txt |
Q:
Un-"jQuery $.param" in Server Side Python (GAE)
I'm using jQuery's $.post() method to post JSON data, specifically I'm posting an array.
$.post('/my/url/',{my_list:['foo','bar','foo baz']})
I've read in the docs that the post method will use the $.param method to serialize JSON objects given to it as data. The jQ... | Un-"jQuery $.param" in Server Side Python (GAE) | I'm using jQuery's $.post() method to post JSON data, specifically I'm posting an array.
$.post('/my/url/',{my_list:['foo','bar','foo baz']})
I've read in the docs that the post method will use the $.param method to serialize JSON objects given to it as data. The jQuery docs seem to imply that their method of serializ... | [
"Figured it out!\nIn Google App Engine in particular the get_all method of the Request object handles JSON arrays serialized with jQuery's .param method. \nThe slightly confusing part is that jQuery tacks [] on to the end of the parameter key. As such, the Python code which you use is...\nclass MyListHandler(webapp... | [
4,
3,
2
] | [] | [] | [
"google_app_engine",
"http_post",
"jquery",
"json",
"python"
] | stackoverflow_0005784400_google_app_engine_http_post_jquery_json_python.txt |
Q:
Query filter not working, but GQL is: bug in app engine?
Can not reproduce this error on local devserver (1.5.0) but when we deploy code to google, it starts popping up? Is it a bug in the current online version of GAE?
Here is the problem. If we first do this:
proj = Project(created_by=users.User(email='test@sa... | Query filter not working, but GQL is: bug in app engine? | Can not reproduce this error on local devserver (1.5.0) but when we deploy code to google, it starts popping up? Is it a bug in the current online version of GAE?
Here is the problem. If we first do this:
proj = Project(created_by=users.User(email='test@sample.com'))
proj.put()
user = users.get_current_user()
print u... | [
"As i could see you are creating a user object and persisting that into created_by.\ni.e\nusers.User(email='test@sample.com')\n\nhere you are creating a users.User object with email 'test@sample.com'. You are persisting the same into Projects' created_by. Where as you are comparing that with users.get_current_user(... | [
3,
3,
0
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0006354609_google_app_engine_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.