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: Python: manipulating sub trees I'm a nooby. I'd like to acknowledge Allen Downey, Jeffrey Elkner and Chris Meyers and 'How to think like a computer scientist' for what I know. I'm building a genetics inspired program to generate equations that match some provided problem. The node class looks like this: class Node...
Python: manipulating sub trees
I'm a nooby. I'd like to acknowledge Allen Downey, Jeffrey Elkner and Chris Meyers and 'How to think like a computer scientist' for what I know. I'm building a genetics inspired program to generate equations that match some provided problem. The node class looks like this: class Node(object): ''' ''' def __...
[ "Unfortunately you don't provide us with the Tree class, but let's assume it's something like:\nclass Tree(object):\n def __init__(self):\n self.data = None\n self.nextkey = 0\n self.thedict = {}\n\nwith the various attributes being updated accurately when new nodes are inserted. Now, while you talk about...
[ 2, 0 ]
[]
[]
[ "data_structures", "python", "tree" ]
stackoverflow_0001386493_data_structures_python_tree.txt
Q: python Invalid literal for float I am running a code to select chunks from a big file. I am getting some strange error that is "Invalid literal for float(): E-135" Does anybody know how to fix this? Thanks in advance. Actually this is the statement that is giving me error float (line_temp[line(line_temp)-1]) Th...
python Invalid literal for float
I am running a code to select chunks from a big file. I am getting some strange error that is "Invalid literal for float(): E-135" Does anybody know how to fix this? Thanks in advance. Actually this is the statement that is giving me error float (line_temp[line(line_temp)-1]) This statement produces error line_temp ...
[ "You need a number in front of the E to make it a valid string representation of a float number\n>>> float('1E-135')\n1e-135\n>>> float('E-135')\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nValueError: invalid literal for float(): E-135\n\nIn fact, which number is E-135 supposed to ...
[ 6, 3, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0001386420_python.txt
Q: Where should one place the code to autoincrement a sharded counter on Google App Engine/Django when one creates a new model? I've a model MyModel (extending Google's db.Model), and I want to keep track of the number of Models that have been created. I think the code at from Google's I/O talk on Sharding Counters i...
Where should one place the code to autoincrement a sharded counter on Google App Engine/Django when one creates a new model?
I've a model MyModel (extending Google's db.Model), and I want to keep track of the number of Models that have been created. I think the code at from Google's I/O talk on Sharding Counters is quite good, so I'm using that. But I'm not sure where I ought to be calling the increment when creating a new code. (I'm using D...
[ "I suggest the approach (curiously close to \"aspect oriented programming\") suggested by \"App Engine Fan\" here (essentially \"setting the scene\") and especially here (showing the right solution: not \"monkey patching\" but rather the use of the well-architected built-in \"hooks\" facility of App Engine).\nThe t...
[ 2 ]
[]
[]
[ "auto_increment", "django", "google_app_engine", "python", "sharding" ]
stackoverflow_0001384932_auto_increment_django_google_app_engine_python_sharding.txt
Q: python/genshi newline to html paragraphs I'm trying to output the content of a comment with genshi, but I can't figure out how to transform the newlines into HTML paragraphs. Here's a test case of what it should look like: input: 'foo\n\n\n\n\nbar\nbaz' output: <p>foo</p><p>bar</p><p>baz</p> I've looked everywher...
python/genshi newline to html paragraphs
I'm trying to output the content of a comment with genshi, but I can't figure out how to transform the newlines into HTML paragraphs. Here's a test case of what it should look like: input: 'foo\n\n\n\n\nbar\nbaz' output: <p>foo</p><p>bar</p><p>baz</p> I've looked everywhere for this function. I couldn't find it in gens...
[ "def tohtml(manylinesstr):\n return ''.join(\"<p>%s</p>\" % line\n for line in manylinesstr.splitlines()\n if line)\n\nSo for example,\nprint repr(tohtml('foo\\n\\n\\n\\n\\nbar\\nbaz'))\n\nemits:\n'<p>foo</p><p>bar</p><p>baz</p>'\n\nas required.\n", "There may be a built-in function in Genshi...
[ 3, 2, 1 ]
[]
[]
[ "genshi", "python", "turbogears" ]
stackoverflow_0001257746_genshi_python_turbogears.txt
Q: Globbing the processing of an object's attributes in Python? Here is a Django model I'm using. class Person(models.Model): surname = models.CharField(max_length=255, null=True, blank=True) first_name = models.CharField(max_length=255, null=True, blank=True) middle_names = models.CharField(max_length=25...
Globbing the processing of an object's attributes in Python?
Here is a Django model I'm using. class Person(models.Model): surname = models.CharField(max_length=255, null=True, blank=True) first_name = models.CharField(max_length=255, null=True, blank=True) middle_names = models.CharField(max_length=255, null=True, blank=True) birth_year = WideYear(null=True, bla...
[ "for n in dir(self):\n if getattr(self, n) is None:\n setattr(self, n, '')\n\nI'm using the normal is None idiom, assuming there's no hypersubtle motivation for that weird alternative you're using, but that's a separate issue;-)\nEdit: if you're using a framework laden with VERY deep black-magic, like Django, p...
[ 5 ]
[]
[]
[ "django_models", "oop", "python" ]
stackoverflow_0001387315_django_models_oop_python.txt
Q: Multipart form post to google app engine not working I am trying to post a multi-part form using httplib, url is hosted on google app engine, on post it says Method not allowed, though the post using urllib2 works. Full working example is attached. My question is what is the difference between two, why one works b...
Multipart form post to google app engine not working
I am trying to post a multi-part form using httplib, url is hosted on google app engine, on post it says Method not allowed, though the post using urllib2 works. Full working example is attached. My question is what is the difference between two, why one works but not the other is there a problem in my mulipart form p...
[ "Nick Johnson's answer \nHave you tried sending the request with httplib using .request() instead of .putrequest() etc, supplying the headers as a dict?\nit works!\n" ]
[ 0 ]
[]
[]
[ "forms", "google_app_engine", "html_post", "python" ]
stackoverflow_0001254270_forms_google_app_engine_html_post_python.txt
Q: Applescript - pygame, application bundle I'm trying to learn pygame, And I found the best way to have the finished game (assuming python 2.6 and pygame installed) is to have an applescript that runs it, and saved as an app bundle (with python files etc. inside the bundle). Here is what I have: do shell script "cd ...
Applescript - pygame, application bundle
I'm trying to learn pygame, And I found the best way to have the finished game (assuming python 2.6 and pygame installed) is to have an applescript that runs it, and saved as an app bundle (with python files etc. inside the bundle). Here is what I have: do shell script "cd " & the quoted form of the POSIX path of (path...
[ "pyinstaller should let you bundle pygame (use the SVN version: the released one is WAY out of date). Also, I suggest you have your code find relative directories more nicely:\nimport os\nresourcesdir = os.path.join(os.path.dirname(__file__), 'Resources')\n\nor the like, to avoid that clunky cd;-).\n" ]
[ 1 ]
[]
[]
[ "applescript", "macos", "pygame", "python" ]
stackoverflow_0001387775_applescript_macos_pygame_python.txt
Q: IF statement causing internal server error with webpy I have this class: class View(object): def main_page(self, extra_placeholders = None): file = '/media/Shared/sites/www/subdomains/pypular/static/layout.tmpl' placeholders = { 'site_name' : 'pypular' } # If we passed placeholders v...
IF statement causing internal server error with webpy
I have this class: class View(object): def main_page(self, extra_placeholders = None): file = '/media/Shared/sites/www/subdomains/pypular/static/layout.tmpl' placeholders = { 'site_name' : 'pypular' } # If we passed placeholders vars, append them if extra_placeholders != None: ...
[ "should you be using instead\nif !( extra_placeholders is None) :\n\nEdit: To reflect comment:\nIt appears (thanks) that you can also use:\n if extra_placeholders is not None :\n\nUpdate: The orginal link is now dead so this SO answer is a good reference : https://stackoverflow.com/a/3289606/30225\n" ]
[ 1 ]
[]
[]
[ "mod_wsgi", "python", "web.py" ]
stackoverflow_0001387902_mod_wsgi_python_web.py.txt
Q: How can I tokenize this with a regex? Suppose I have strings like the following : OneTwo ThreeFour AnotherString DVDPlayer CDPlayer I know how to tokenize the camel-case ones, except the "DVDPlayer" and "CDPlayer". I know I could tokenize them manually, but maybe you can show me a regex that can handle all the ca...
How can I tokenize this with a regex?
Suppose I have strings like the following : OneTwo ThreeFour AnotherString DVDPlayer CDPlayer I know how to tokenize the camel-case ones, except the "DVDPlayer" and "CDPlayer". I know I could tokenize them manually, but maybe you can show me a regex that can handle all the cases? EDIT: the expected tokens are : OneTwo...
[ "Look at my answer on the question, .NET - How can you split a “caps” delimited string into an array?.\nThe regex looks like this:\n/([A-Z]+(?=$|[A-Z][a-z])|[A-Z]?[a-z]+)/g\n\nIt can be modified slightly to allow searching for camel-cased tokens, by replacing the $ with \\b:\n/([A-Z]+(?=\\b|[A-Z][a-z])|[A-Z]?[a-z]+...
[ 4, 4, 1, 1, 0 ]
[]
[]
[ "lexical_analysis", "python", "regex", "ruby", "tokenize" ]
stackoverflow_0001389062_lexical_analysis_python_regex_ruby_tokenize.txt
Q: how to add json library i am new to python, on my Mac, when i issue command User:ihasfriendz user$ python main.py Traceback (most recent call last): File "main.py", line 2, in <module> import json ImportError: No module named json I get error on json. how to add this library? i'm using 2.5 (the default cam...
how to add json library
i am new to python, on my Mac, when i issue command User:ihasfriendz user$ python main.py Traceback (most recent call last): File "main.py", line 2, in <module> import json ImportError: No module named json I get error on json. how to add this library? i'm using 2.5 (the default came with leopard)
[ "You can also install simplejson.\nIf you have pip (see https://pypi.python.org/pypi/pip) as your Python package manager you can install simplejson with:\n pip install simplejson\n\nThis is similar to the comment of installing with easy_install, but I prefer pip to easy_install as you can easily uninstall in pip wi...
[ 31, 5, 2 ]
[]
[]
[ "json", "macos", "python", "python_2.5" ]
stackoverflow_0001389141_json_macos_python_python_2.5.txt
Q: What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies? I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code ...
What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good o...
[ "Here's a good link to an article about different IDE's and how they work with IronPython:\nhttp://www.voidspace.org.uk/ironpython/tools-and-ides.shtml\n", "See Michael Foord's website for IDE and unittest also discover. And many IronPython articles and the book IronPython in Action\nand his tweets save you havin...
[ 2, 1, 0, 0, 0 ]
[]
[]
[ ".net", "ironpython", "python" ]
stackoverflow_0001377548_.net_ironpython_python.txt
Q: What's wrong with my simple HTTP socket based proxy script? I wrote a simple Python script for a proxy functionality. It works fine, however, if the requested webpage has many other HTTP requests, e.g. Google maps, the page is rendered quite slow. Any hints as to what might be the bottleneck in my code, and how I...
What's wrong with my simple HTTP socket based proxy script?
I wrote a simple Python script for a proxy functionality. It works fine, however, if the requested webpage has many other HTTP requests, e.g. Google maps, the page is rendered quite slow. Any hints as to what might be the bottleneck in my code, and how I can improve? #!/usr/bin/python import socket,select,re from thre...
[ "I'm not sure what your speed problems are, but here are some other nits I found to pick:\nresult['protocal'] = vl[2]\n\nshould be\nresult['protocol'] = vl[2]\n\nThis code is indented one level too deep:\nsk2.connect((host,int(port)))\n\nYou can use this decorator to profile your individual methods by line.\n" ]
[ 0 ]
[]
[]
[ "http_proxy", "python", "sockets" ]
stackoverflow_0001389278_http_proxy_python_sockets.txt
Q: Should properties do nontrivial initialization? I have an object that is basically a Python implementation of an Oracle sequence. For a variety of reasons, we have to get the nextval of an Oracle sequence, count up manually when determining primary keys, then update the sequence once the records have been inserte...
Should properties do nontrivial initialization?
I have an object that is basically a Python implementation of an Oracle sequence. For a variety of reasons, we have to get the nextval of an Oracle sequence, count up manually when determining primary keys, then update the sequence once the records have been inserted. So here's the steps my object does: Construct an ...
[ "I think your doubts come from PEP-8:\n\n Note 3: Avoid using properties for computationally expensive\n operations; the attribute notation makes the caller believe\n that access is (relatively) cheap.\n\n\nAdherence to a standard behavior is usually quite a good idea; and this would be a reason to scrap a...
[ 4, 2, 0 ]
[]
[]
[ "initialization", "properties", "python" ]
stackoverflow_0001386210_initialization_properties_python.txt
Q: AN error about "User.add_to_class" to extend my user?I do not know why In my models.py, I user these code to extent two fields: User.add_to_class('bio', models.TextField(blank=True)) User.add_to_class('about', models.TextField(blank=True)) But when I creat a User : user = User.objects.create_user(username=self.cl...
AN error about "User.add_to_class" to extend my user?I do not know why
In my models.py, I user these code to extent two fields: User.add_to_class('bio', models.TextField(blank=True)) User.add_to_class('about', models.TextField(blank=True)) But when I creat a User : user = User.objects.create_user(username=self.cleaned_data['username'], \ email=self.cleaned_data['email'],passw...
[ "This is not a good way to store additional user information, for a number of reasons, as James Bennett points out in the linked thread. It's no surprise that you're getting weird SQL output and struggling to debug it. Keep things easy for yourself by using a related profile model instead.\n" ]
[ 3 ]
[]
[]
[ "django", "mysql", "python" ]
stackoverflow_0001389627_django_mysql_python.txt
Q: how to convert base64 /radix64 public key to a pem format in python is there any python method for converting base64 encoded key to a pem format . how to convert ASCII-armored PGP public key to a MIME encoded form. thanks A: ASCII-armored and PEM are very similar. You just need to change the BEGIN/END markers, s...
how to convert base64 /radix64 public key to a pem format in python
is there any python method for converting base64 encoded key to a pem format . how to convert ASCII-armored PGP public key to a MIME encoded form. thanks
[ "ASCII-armored and PEM are very similar. You just need to change the BEGIN/END markers, strip the PGP headers and checksums. I've done this before in PHP. I just ported it to Python for you,\nimport re\nimport StringIO\n\ndef pgp_pubkey_to_pem(pgp_key):\n # Normalise newlines\n pgp_key = re.compile('(\\n|\\r\...
[ 4 ]
[]
[]
[ "encoding", "python" ]
stackoverflow_0001387867_encoding_python.txt
Q: Verify CSV against given format I am expecting users to upload a CSV file of max size 1MB to a web form that should fit a given format similar to: "<String>","<String>",<Int>,<Float> That will be processed later. I would like to verify the file fits a specified format so that the program that shall later use the ...
Verify CSV against given format
I am expecting users to upload a CSV file of max size 1MB to a web form that should fit a given format similar to: "<String>","<String>",<Int>,<Float> That will be processed later. I would like to verify the file fits a specified format so that the program that shall later use the file doesnt receive unexpected input ...
[ "Pyparsing will process this data, and will be tolerant of unexpected things like spaces before and after commas, commas within quotes, etc. (csv module is too, but regex solutions force you to add \"\\s*\" bits all over the place).\nfrom pyparsing import *\n\ninteger = Regex(r\"-?\\d+\").setName(\"integer\")\nint...
[ 4, 2, 1, 1, 1, 0 ]
[]
[]
[ "csv", "python", "regex" ]
stackoverflow_0001387644_csv_python_regex.txt
Q: PyGTK: IM Client Window I'm trying to write something very similar to an IM client (for learning purposes only). I don't know how to write the Chat window. I want to display Users picture, name and message as any other IM client. The problem is that I don't know which gtk widget is best suited for it. Currently I ...
PyGTK: IM Client Window
I'm trying to write something very similar to an IM client (for learning purposes only). I don't know how to write the Chat window. I want to display Users picture, name and message as any other IM client. The problem is that I don't know which gtk widget is best suited for it. Currently I use TextView and TextBuffers ...
[ "You can display images in a gtk.TextBuffer, here is how: http://pygtk.org/pygtk2tutorial/sec-TextBuffers.html#id2855808\n" ]
[ 2 ]
[]
[]
[ "gtk", "pygtk", "python" ]
stackoverflow_0001387729_gtk_pygtk_python.txt
Q: Writing Interpreters in Python. Is isinstance considered harmful? I'm porting over the interpreter for a domain specific language I created from Scala to Python. In the process I tried to find a way that way pythonic to emulate the case class feature of Scala that I used extensively. In the end I resorted to using...
Writing Interpreters in Python. Is isinstance considered harmful?
I'm porting over the interpreter for a domain specific language I created from Scala to Python. In the process I tried to find a way that way pythonic to emulate the case class feature of Scala that I used extensively. In the end I resorted to using isinstance, but was left feeling that I was perhaps missing something....
[ "Yes.\nInstead of instance, just use Polymorphism. It's simpler.\nclass Node( object ):\n def eval( self, context ):\n raise NotImplementedError\n\nclass Add( object ):\n def eval( self, context ):\n return self.arg1.eval( context ) + self.arg2.eval( context )\n\nThis kind of this is very simple...
[ 2, 2, 2, 1, 0, 0 ]
[ "If you need Polymorphism on arguments (in addition to the receiver), for example to handle type conversions with binary operators as suggested by your example, you can use the following trick:\nclass EValue(object):\n\n def __init__(self, v):\n self.value = v\n\n def __str__(self):\n return str...
[ -1 ]
[ "interpreter", "language_design", "python", "scala" ]
stackoverflow_0001381845_interpreter_language_design_python_scala.txt
Q: Match database output (balanced parentheses, table & rows structure) and output as a list? How would I parse the following input (either going line by line or via regex... or combination of both): Table[ Row[ C_ID[Data:12345.0][Sec:12345.0][Type:Double] F_ID[Data:17660][Sec:17660][Type:Long] ...
Match database output (balanced parentheses, table & rows structure) and output as a list?
How would I parse the following input (either going line by line or via regex... or combination of both): Table[ Row[ C_ID[Data:12345.0][Sec:12345.0][Type:Double] F_ID[Data:17660][Sec:17660][Type:Long] NAME[Data:Mike Jones][Sec:Mike Jones][Type:String] ] Row[ C_ID[Data:2560....
[ "Parsing recursive structures with regex is a pain because you have to keep state.\nInstead, use pyparsing or some other real parser.\nSome folks like PLY because it follows the traditional Lex/Yacc architecture.\n", "There really isn't a lot of unpredictable nesting going on here, so you could do this with regex...
[ 3, 1, 0 ]
[ "This regex:\nRow\\[[\\s]*C_ID\\[[\\W]*Data:([0-9.]*)[\\S\\W]*F_ID\\[[\\S\\W]*Data:([0-9.]*)[\\S\\W]*NAME\\[[\\S\\W]*Data:([\\w ]*)[\\S ]*\n\nfor the first row will match:\n$1=12345.0\n$2=17660\n$3=Mike Jones\nThen you can use something like this:\n{'C_ID': $1, 'F_ID': $2, 'NAME': '$3'}\n\nto produce:\n{'C_ID': 123...
[ -1 ]
[ "parsing", "python", "regex" ]
stackoverflow_0001324949_parsing_python_regex.txt
Q: OpenGL in Python with Snow Leopard? I'm interested in playing around with OpenGL in Python. I've used OpenGL in C++ and Objective-C, but I don't have much experience in Python. I'm wondering if there's a good tutorial that works in Snow Leopard. I'd prefer to stay in 64-bit mode if possible, since I've heard 32-bi...
OpenGL in Python with Snow Leopard?
I'm interested in playing around with OpenGL in Python. I've used OpenGL in C++ and Objective-C, but I don't have much experience in Python. I'm wondering if there's a good tutorial that works in Snow Leopard. I'd prefer to stay in 64-bit mode if possible, since I've heard 32-bit programs require loading a lot of extra...
[ "I've used PyOpenGL 3.0.0 quite successfully on Snow Leopard. It uses ctypes, so it should be making 64-bit calls if those libraries are available (and Snow Leopard's Python includes a 64-bit version). I haven't used the wxPython stuff with PyOpenGL so that's where you might be running into problems, but PyOpenGL...
[ 4, 2, 0, 0 ]
[]
[]
[ "opengl", "osx_snow_leopard", "python" ]
stackoverflow_0001389928_opengl_osx_snow_leopard_python.txt
Q: What are the different options for processing uploaded PDF files in a Django application? Our Django application needs to do a few things with uploaded PDF files: Verify that the file is a PDF and isn't corrupted Check that the file isn't encrypted Count the number of pages We run into problems with one unfortun...
What are the different options for processing uploaded PDF files in a Django application?
Our Django application needs to do a few things with uploaded PDF files: Verify that the file is a PDF and isn't corrupted Check that the file isn't encrypted Count the number of pages We run into problems with one unfortunately popular application that's idea of an unencrypted PDF export is actually an encrypted PDF...
[ "PDFlib is excellent, but costs money. You didn't say it had to be free, though implicitly somehow I assume you want it to be! :)\n" ]
[ 1 ]
[]
[]
[ "django", "pdf", "python" ]
stackoverflow_0001390371_django_pdf_python.txt
Q: Removing redundant symbols from string Let's say I have a string like that: '12,423,343.93'. How to convert it to float in simple, effective and yet elegant way? It seems I need to remove redundant commas from the string and then call float(), but I have no good solution for that. Thanks A: s = "12,423,343.93" f...
Removing redundant symbols from string
Let's say I have a string like that: '12,423,343.93'. How to convert it to float in simple, effective and yet elegant way? It seems I need to remove redundant commas from the string and then call float(), but I have no good solution for that. Thanks
[ "s = \"12,423,343.93\"\nf = float(s.replace(\",\", \"\"))\n\n", "Note that the seperator symbols used vary from country to country. In some cultures, \".\" is used to seperate groups, and \",\" indicates a decimal point for instance. If you're parsing user-entered strings like this, it may be better to use the ...
[ 9, 6 ]
[]
[]
[ "floating_point", "python" ]
stackoverflow_0001390657_floating_point_python.txt
Q: Application Structure for GUI & Functions I'm starting a basic application using Python and PyQt and could use some experienced insight. Here's the structure I was thinking. This is understandably subjective, but is there a better way? myApp/GUI/__init__.py mainWindow.py subWindow1.py ...
Application Structure for GUI & Functions
I'm starting a basic application using Python and PyQt and could use some experienced insight. Here's the structure I was thinking. This is understandably subjective, but is there a better way? myApp/GUI/__init__.py mainWindow.py subWindow1.py subWindow2.py myApp/Logic/__init__.py ...
[ "MVC\nIt looks like you have been reading about model-view-controller.\nSeparating the UI from the back end is a good idea. It will make runnings tests and debugging just the logic side easier, and the internal structure will be more modular.\nI'm not certain it makes as much sense to split the UI into the current...
[ 1 ]
[]
[]
[ "python", "structure", "user_interface" ]
stackoverflow_0001391190_python_structure_user_interface.txt
Q: Upgrade python in linux I have a linux VPS that uses an older version of python (2.4.3). This version doesn't include the UUID module, but I need it for a project. My options are to upgrade to python2.6 or find a way to make uuid work with the older version. I am a complete linux newbie. I don't know how to upgrad...
Upgrade python in linux
I have a linux VPS that uses an older version of python (2.4.3). This version doesn't include the UUID module, but I need it for a project. My options are to upgrade to python2.6 or find a way to make uuid work with the older version. I am a complete linux newbie. I don't know how to upgrade python safely or how I coul...
[ "The safest way to upgrading Python is to install it to a different location (away from the default system path).\nTo do this, download the source of python and do a \n./configure --prefix=/opt\n(Assuming you want to install it to /opt which is where most install non system dependant stuff to)\nThe reason why I say...
[ 6, 2, 0 ]
[]
[]
[ "linux", "python" ]
stackoverflow_0001388464_linux_python.txt
Q: function decorators in c# Is there a C# analog for Python's function decorators? It feels like it's doable with attributes and the reflection framework, but I don't see a way to replace functions at runtime. Python decorators generally work this way: class decorator(obj): def __init__(self, f): self.f ...
function decorators in c#
Is there a C# analog for Python's function decorators? It feels like it's doable with attributes and the reflection framework, but I don't see a way to replace functions at runtime. Python decorators generally work this way: class decorator(obj): def __init__(self, f): self.f = f def __call__(self, *arg...
[ "The way I achieve this is through AOP frameworks like Castle Dynamic Proxy, Spring.NET or even the Policy Injection Application Block.\n", "You can do that using Post Sharp. Check out the demo video for instructions.\n", "you can sort of achieve that by \"ContextBoundObject\" in the .NET framework.\nbut it's a...
[ 12, 9, 4 ]
[]
[]
[ "c#", "decorator", "python", "reflection" ]
stackoverflow_0001391157_c#_decorator_python_reflection.txt
Q: Python: how do I implement 'pop' in this class? I'd like this class to act like a list. It's data resides in the attribute self.data. If I have an instance, pp = population, does defining __getitem__ mean I can refer to pp instead of pp.data? Or is it the defining of __repr__ that does that? Would deriving thi...
Python: how do I implement 'pop' in this class?
I'd like this class to act like a list. It's data resides in the attribute self.data. If I have an instance, pp = population, does defining __getitem__ mean I can refer to pp instead of pp.data? Or is it the defining of __repr__ that does that? Would deriving this class from list instead of object provide me with '...
[ "Why not just extend the list class? Then you have all of that functionality built in.\nclass population(list):\n # custom methods here\n\nJust remember, instead of referencing self.data for the list, just reference self.\n", "def pop(self, index=-1) :\n return self.data.pop(index)\n\nThis will implement th...
[ 8, 3, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0001390966_python.txt
Q: Should I use Mako for Templating? I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako. I've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient ...
Should I use Mako for Templating?
I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako. I've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe? Wouldn't templatin...
[ "As the mako homepage points out, Mako's advantages are pretty clear: insanely fast, instantly familiar to anyone who's handy with Python in terms of both syntax and features.\nGenshi chooses \"interpretation\" instead of ahead-of-time Python code generation (according to their FAQ, that's for clarity of error mess...
[ 19, 16, 2, 2, 0 ]
[]
[]
[ "genshi", "mako", "python", "template_engine" ]
stackoverflow_0001384634_genshi_mako_python_template_engine.txt
Q: easy way of installing python apps without using PYTHON path or muli symlink in site-package I didn't want to install python modules using easy install, symlinks in site-packages or PYTHONPATH. So, I am trying something that I do wants system wide, then any application installation is done locally. Note, the root ...
easy way of installing python apps without using PYTHON path or muli symlink in site-package
I didn't want to install python modules using easy install, symlinks in site-packages or PYTHONPATH. So, I am trying something that I do wants system wide, then any application installation is done locally. Note, the root password is required only once here. First create a symblink of.../pythonX.Y/site-packages/mymodul...
[ "Have a look at virtualenv.\nIt may do what you are after.\n" ]
[ 4 ]
[]
[]
[ "django", "module", "python", "pythonpath" ]
stackoverflow_0001391584_django_module_python_pythonpath.txt
Q: What python data structure and parser should I use with Apple's system_profiler? My problem is one like a simulated problem from http://my.safaribooksonline.com/0596007973/pythoncook2-CHP-10-SECT-17 which eventually made its way into Python Cookbook, 2nd Edition using an outdated xpath method from 2005 that I hav...
What python data structure and parser should I use with Apple's system_profiler?
My problem is one like a simulated problem from http://my.safaribooksonline.com/0596007973/pythoncook2-CHP-10-SECT-17 which eventually made its way into Python Cookbook, 2nd Edition using an outdated xpath method from 2005 that I haven't been able to get to work with 10.6's build-in python(nor installing older package...
[ "Use the -xml option to system_profiler to format the output in a standard OS X plist format, then use Python's built-in plistlib to parse into an appropriate data structure you can introspect. A simple example:\n>>> from subprocess import Popen, PIPE\n>>> from plistlib import readPlistFromString\n>>> from pprint ...
[ 7 ]
[]
[]
[ "macos", "parsing", "profiler", "python", "system_profiler" ]
stackoverflow_0001392604_macos_parsing_profiler_python_system_profiler.txt
Q: Django template, how to make a dropdown box with the predefined value selected? I am trying to create a drop down list box with the selected value equal to a value passed from the template values, but with no success. Can anyone take a look and show me what I am doing wrong. <select name="movie"> {% fo...
Django template, how to make a dropdown box with the predefined value selected?
I am trying to create a drop down list box with the selected value equal to a value passed from the template values, but with no success. Can anyone take a look and show me what I am doing wrong. <select name="movie"> {% for movie in movies %} {% ifequal movie.id selected_movie.id %} <option value=...
[ "Your code works for me with django 1.0.2 and firefox 3.5.\nYou can use {% else %} instead of {% ifnotequal %} and set selected=\"selected\". Hope it helps.\n<select name=\"movie\">\n {% for movie in movies %}\n {% ifequal movie.id selected_movie.id %}\n <option value=\"{{movie.key}}\" selected...
[ 14 ]
[]
[]
[ "django", "django_templates", "python" ]
stackoverflow_0001392706_django_django_templates_python.txt
Q: Is it possible to deploy one GAE application from another GAE application? In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that do...
Is it possible to deploy one GAE application from another GAE application?
In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed on...
[ "Is it possible? Yes. The protocol appcfg uses to update apps is entirely HTTP-based, so there's absolutely no reason you couldn't write an app that's capable of deploying other apps (or redeploying itself - self-modifying code)! You may even be able to reuse large parts of appcfg.py to do it.\nIs it easy? Probably...
[ 5, 2, 0 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0001391608_google_app_engine_python.txt
Q: Python: Why does ("hello" is "hello") evaluate as True? Why does "hello" is "hello" produce True in Python? I read the following here: If two string literals are equal, they have been put to same memory location. A string is an immutable entity. No harm can be done. So there is one and only one place in me...
Python: Why does ("hello" is "hello") evaluate as True?
Why does "hello" is "hello" produce True in Python? I read the following here: If two string literals are equal, they have been put to same memory location. A string is an immutable entity. No harm can be done. So there is one and only one place in memory for every Python string? Sounds pretty strange. What's g...
[ "Python (like Java, C, C++, .NET) uses string pooling / interning. The interpreter realises that \"hello\" is the same as \"hello\", so it optimizes and uses the same location in memory.\nAnother goodie: \"hell\" + \"o\" is \"hello\" ==> True\n", "\nSo there is one and only one place in memory for every Python st...
[ 93, 65, 13, 6, 2, 1, 0 ]
[]
[]
[ "identity", "object_comparison", "python", "string_comparison" ]
stackoverflow_0001392433_identity_object_comparison_python_string_comparison.txt
Q: 'Snippit' based django semi-CMS I remember reading somewhere on the internets about a half-assed tiny django CMS app, which was basically built on 'snippets' of text. The idea was, that in the admin, you make a snippet (say a description of a product), give it a name (such as 'google_desc') and call it in a templa...
'Snippit' based django semi-CMS
I remember reading somewhere on the internets about a half-assed tiny django CMS app, which was basically built on 'snippets' of text. The idea was, that in the admin, you make a snippet (say a description of a product), give it a name (such as 'google_desc') and call it in a template with something like {% snippet goo...
[ "Sounds like django-chunks to me.\n", "Are you talking about Django Simplepages? Official site here.\nAnother project that sounds similar to what you're after is django-page-cms.\n", "If you need some more features just checkout django-blocks (http://code.google.com/p/django-blocks/). Has multi-language Menu, ...
[ 2, 1, 1 ]
[]
[]
[ "content_management_system", "django", "python" ]
stackoverflow_0000257655_content_management_system_django_python.txt
Q: Problem with Python interpreter in Eclipse When trying to set the interpreter for python in Eclipse by choosing the executable, clicking OK displays "An error has occured." Does the interpreter name matter? A: I had a similar problems with this on Mac OS X. My problem was that I had a space in Eclipse's applicat...
Problem with Python interpreter in Eclipse
When trying to set the interpreter for python in Eclipse by choosing the executable, clicking OK displays "An error has occured." Does the interpreter name matter?
[ "I had a similar problems with this on Mac OS X. My problem was that I had a space in Eclipse's application path, e.g. \"/Applications/eclipse 3.3/Eclipse\".\nI changed the folder name to \"/Applications/eclipse3.3\" and it fixed it.\n", "Testing/running your apps on the command line is the safest bet, especially...
[ 1, 0 ]
[]
[]
[ "eclipse", "interpreter", "python", "ubuntu" ]
stackoverflow_0000976506_eclipse_interpreter_python_ubuntu.txt
Q: Call a function from a running process my programm starts a subprocess, which has to send some kind of signal to the parent after initialization. It would be perfekt if i could set up a handler in parent, which is called when this signal is sent. Is there any way to do it? Alendit A: If you are using Python 2.6,...
Call a function from a running process
my programm starts a subprocess, which has to send some kind of signal to the parent after initialization. It would be perfekt if i could set up a handler in parent, which is called when this signal is sent. Is there any way to do it? Alendit
[ "If you are using Python 2.6, you can use the multiprocessing module from the standard library, in particular pipes and queues. Simple example from the docs:\nfrom multiprocessing import Process, Pipe\n\ndef f(conn): #This code will be spawned as a new child process\n conn.send([42, None, 'hello']) #The child pr...
[ 4, 2, 1 ]
[]
[]
[ "ipc", "python", "subprocess" ]
stackoverflow_0001393242_ipc_python_subprocess.txt
Q: using RSPython in MacOSX I am trying to install the R/SPlus - Python Interface (RSPython) on my Mac OS X 10.4.11 with R version 2.7.2 (2008-08-25) and python 2.6.2 from fink. The routine: sudo R CMD INSTALL -c RSPython_0.7-1.tar.gz produced this error message: * Installing to library '/Library/Frameworks/R.framew...
using RSPython in MacOSX
I am trying to install the R/SPlus - Python Interface (RSPython) on my Mac OS X 10.4.11 with R version 2.7.2 (2008-08-25) and python 2.6.2 from fink. The routine: sudo R CMD INSTALL -c RSPython_0.7-1.tar.gz produced this error message: * Installing to library '/Library/Frameworks/R.framework/Resources/library' * Insta...
[ "Try running R CMD CHECK RSPython_0.7-1.tar.gz\nThat should produce at least produce bunch of logs in a RSPython.Rcheck folder\nYou might get some clues in there. \nUpdate --- \nIf you can get one of the other packages to work I'd recommend it. On my system (R 2.9.1 using system python (2.6) in /usr/bin/python), i...
[ 1, 1, 0 ]
[]
[]
[ "installation", "python", "r" ]
stackoverflow_0001392868_installation_python_r.txt
Q: using soaplib to connect to remote SOAP server lacking definition I am looking at the soaplib python module (it comes with standard ubuntu 9.04). I have used xmlrpclib extensively in the last years but now I am curious about soap. writing servers with soaplib is acceptably easy, I assume writing clients should b...
using soaplib to connect to remote SOAP server lacking definition
I am looking at the soaplib python module (it comes with standard ubuntu 9.04). I have used xmlrpclib extensively in the last years but now I am curious about soap. writing servers with soaplib is acceptably easy, I assume writing clients should be even easier. in my impatience I can't find a way to make use of intro...
[ "If I understand your question correctly, you would like to generate client code for a given webservice without defining what methods etc are availible on that service in your own code directly? IE: you would like to introspect the service and generate client automatically.\nIf this is the case then the answer is ...
[ 1 ]
[]
[]
[ "introspection", "python", "soap" ]
stackoverflow_0001373738_introspection_python_soap.txt
Q: Change Vim command to work in MS-Windows? Use make to check python syntax :make provides a list of errors which can be navigated through in order to fix. The problem is that this script only works in Unix based OSes. autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py...
Change Vim command to work in MS-Windows? Use make to check python syntax
:make provides a list of errors which can be navigated through in order to fix. The problem is that this script only works in Unix based OSes. autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\" autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f...
[ "For the first part to work, you must first add python to your PATH variable.\nhttp://vlaurie.com/computers2/Articles/environment.htm\npython.exe should be placed in:\nc:\\PythonXX\\bin\n\nBut I'm not that sure, check it out before adding that one.\n" ]
[ 1 ]
[]
[]
[ "python", "vim", "windows", "windows_xp" ]
stackoverflow_0001394058_python_vim_windows_windows_xp.txt
Q: In Python, what is the best way to execute a local Linux command stored in a string? In Python, what is the simplest way to execute a local Linux command stored in a string while catching any potential exceptions that are thrown and logging the output of the Linux command and any caught errors to a common log file...
In Python, what is the best way to execute a local Linux command stored in a string?
In Python, what is the simplest way to execute a local Linux command stored in a string while catching any potential exceptions that are thrown and logging the output of the Linux command and any caught errors to a common log file? String logfile = “/dev/log” String cmd = “ls” #try #execute cmd sending output to >> ...
[ "Using the subprocess module is the correct way to do it:\nimport subprocess\nlogfile = open(\"/dev/log\", \"w\")\noutput, error = subprocess.Popen(\n [\"ls\"], stdout=subprocess.PIPE,\n stderr=subprocess.PIPE).communicate()\nlogfile.write(output)\nlogfile.close()\n\nEDIT\nsubp...
[ 16, 0 ]
[ "Check out commands module.\n import commands\n f = open('logfile.log', 'w')\n try:\n exe = 'ls'\n content = commands.getoutput(exe)\n f.write(content)\n except Exception, text:\n f.write(text)\n f.close()\n\nSpecifying Exception as an exception class after except will tel...
[ -3 ]
[ "python" ]
stackoverflow_0001394198_python.txt
Q: Converting vb.net code to python for educational purposes. Output of a numeric value not occuring My day job is mainly coding in vb.net, so I am very familiar with it. While doing my first few dozen project euler problems, I used vb.net just to get the hang of the problem styles. Now I'd like to use project eule...
Converting vb.net code to python for educational purposes. Output of a numeric value not occuring
My day job is mainly coding in vb.net, so I am very familiar with it. While doing my first few dozen project euler problems, I used vb.net just to get the hang of the problem styles. Now I'd like to use project euler to help me learn a new language and have been running a couple in python. However. I've hit a snag. ...
[ "Previous solutions generate wrong answer.\n\nVB.net code operates on integers, and your Python code operates on floats, and this apparently fails somewhere.\nAs mentioned before, keyword capitalization (True/False).\nYou can use foo % bar == 0 with no problem.\nYou missed one level of indentation in \"factor = 0\"...
[ 2 ]
[]
[]
[ "python", "vb.net" ]
stackoverflow_0001394737_python_vb.net.txt
Q: configuration filename convention Is there a general naming conventions for configuration files for a simple python program? Thanks, Udi A: A convention? Mine would be, if my program was called "Bob", simply "bob.cfg". I have to admit, I didn't really suffer any angst in coming up with that convention. Maybe I'v...
configuration filename convention
Is there a general naming conventions for configuration files for a simple python program? Thanks, Udi
[ "A convention? Mine would be, if my program was called \"Bob\", simply \"bob.cfg\".\nI have to admit, I didn't really suffer any angst in coming up with that convention. Maybe I've been here too long :-)\nOf course, if your configuration information is of a specific format (e.g., XML), you could consider \"bob.xml\...
[ 4, 4, 4, 1, 0 ]
[]
[]
[ "configuration", "naming_conventions", "python" ]
stackoverflow_0001393731_configuration_naming_conventions_python.txt
Q: Django: How to create a leaderboard Lets say I have around 1,000,000 users. I want to find out what position any given user is in, and which users are around him. A user can get a new achievement at any time, and if he could see his standing update, that would be wonderful. Honestly, every way I think of doing thi...
Django: How to create a leaderboard
Lets say I have around 1,000,000 users. I want to find out what position any given user is in, and which users are around him. A user can get a new achievement at any time, and if he could see his standing update, that would be wonderful. Honestly, every way I think of doing this would be horrendously expensive in time...
[ "I think Counterstrike solves this by requiring users to meet a minimum threshold to become ranked--you only need to accurately sort the top 10% or whatever.\nIf you want to sort everyone, consider that you don't need to sort them perfectly: sort them to 2 significant figures. With 1M users you could update the le...
[ 4, 0 ]
[]
[]
[ "django", "leaderboard", "python", "sql" ]
stackoverflow_0001391601_django_leaderboard_python_sql.txt
Q: Trouble with simple Python Code I'm learning Python, and I'm having trouble with this simple piece of code: a = raw_input('Enter a number: ') if a > 0: print 'Positive' elif a == 0: print 'Null' elif a < 0: print 'Negative' It works great, apart from the fact that it always prints 'Positive', no matt...
Trouble with simple Python Code
I'm learning Python, and I'm having trouble with this simple piece of code: a = raw_input('Enter a number: ') if a > 0: print 'Positive' elif a == 0: print 'Null' elif a < 0: print 'Negative' It works great, apart from the fact that it always prints 'Positive', no matter if i enter a positive or negative ...
[ "That's because a is a string as inputted. Use int() to convert it to an integer before doing numeric comparisons.\na = int(raw_input('Enter a number: '))\nif a > 0:\n print 'Positive'\nelif a == 0:\n print 'Null'\nelif a < 0:\n print 'Negative'\n\nAlternatively, input() will do type conversion for you.\na...
[ 7, 7, 7, 5, 2, 1 ]
[]
[]
[ "python" ]
stackoverflow_0001395603_python.txt
Q: OpenGL Picking with Pyglet I'm trying to implement picking using Pyglet's OpenGL wrapper, but I'm having trouble converting a C tutorial to Python. Specifically the part below. #define BUFSIZE 512 GLuint selectBuf[BUFSIZE] void startPicking(int cursorX, int cursorY) { GLint viewport[4]; glSelectBuffer(B...
OpenGL Picking with Pyglet
I'm trying to implement picking using Pyglet's OpenGL wrapper, but I'm having trouble converting a C tutorial to Python. Specifically the part below. #define BUFSIZE 512 GLuint selectBuf[BUFSIZE] void startPicking(int cursorX, int cursorY) { GLint viewport[4]; glSelectBuffer(BUFSIZE,selectBuf); glRenderM...
[ "I haven't tried your particular example, but the normal way to declare arrays is in the ctypes documentation. Essentially you would create an array type like this:\nFourGLints = GLint * 4\nviewport = FourGLints(0, 1, 2, 3)\n\n", "I've had good luck with PyOpenGL. \nhttp://pyopengl.sourceforge.net/\nIt's pretty s...
[ 5, 1, 1 ]
[]
[]
[ "opengl", "picking", "pyglet", "python" ]
stackoverflow_0001290270_opengl_picking_pyglet_python.txt
Q: Efficient Python Data Storage (Abstract Data Types?) Pardon the ambiguity in the title- I wasn't quite sure how to phrase my question. Given a string: blah = "There are three cats in the hat" and the (I'm not quite sure which data structure to use for this) "userInfo": cats -> ("tim", "1 infinite loop") three ->...
Efficient Python Data Storage (Abstract Data Types?)
Pardon the ambiguity in the title- I wasn't quite sure how to phrase my question. Given a string: blah = "There are three cats in the hat" and the (I'm not quite sure which data structure to use for this) "userInfo": cats -> ("tim", "1 infinite loop") three -> ("sally", "123 fake st") three -> ("tim", "1 infinite loo...
[ "Something like this?\nclass Content( object ):\n def __init__( self, content, maps_to ):\n self.content= content.split()\n self.maps_to = maps_to\n def matches( self, words ):\n return all( c in words for c in self.content )\n def __str__( self ):\n return \"%s -> %r\" % ( \" \...
[ 6, 1, 0 ]
[]
[]
[ "data_structures", "python" ]
stackoverflow_0001396241_data_structures_python.txt
Q: Using CSV as a mutable database? Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database. While I can use MySQL with PHP, I can't use it with the Python backend of my program because of instal...
Using CSV as a mutable database?
Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database. While I can use MySQL with PHP, I can't use it with the Python backend of my program because of install issues with the host. I can't use S...
[ "Don't walk, run to get a new host immediately. If your host won't even get you the most basic of free databases, it's time for a change. There are many fish in the sea.\nAt the very least I'd recommend an xml data store rather than a csv. My blog uses an xml data provider and I haven't had any issues with perfo...
[ 15, 3, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 ]
[]
[]
[ "csv", "python" ]
stackoverflow_0000712510_csv_python.txt
Q: ctypes pointer question I was reading the ctypes tutorial, and I came across this: s = "Hello, World" c_s = c_char_p(s) print c_s c_s.value = "Hi, there" But I had been using pointers like this: s = "Hello, World!" c_s = c_char_p() c_s = s print c_s c_s.value Traceback (most recent call last): File "<pyshell#1...
ctypes pointer question
I was reading the ctypes tutorial, and I came across this: s = "Hello, World" c_s = c_char_p(s) print c_s c_s.value = "Hi, there" But I had been using pointers like this: s = "Hello, World!" c_s = c_char_p() c_s = s print c_s c_s.value Traceback (most recent call last): File "<pyshell#17>", line 1, in <module> ...
[ "In your second example, you've got the statements:\nc_s = c_char_p()\nc_s = s\n\nThe ctypes module can't break the rules of Python assignments, and in the above case the second assignment rebinds the c_s name from the just-created c_char_p object to the s object. In effect, this throws away the newly created c_cha...
[ 3 ]
[]
[]
[ "ctypes", "declaration", "object", "pointers", "python" ]
stackoverflow_0001396533_ctypes_declaration_object_pointers_python.txt
Q: Unexpected results feeding Django File upload object to Python CSV module I have no problems getting the file to upload and if I save it to disk, all formatting is intact. I wrote a function to read in the the file within Django using: data = csv.reader(f.read()) where f is the Django file object that I get from ...
Unexpected results feeding Django File upload object to Python CSV module
I have no problems getting the file to upload and if I save it to disk, all formatting is intact. I wrote a function to read in the the file within Django using: data = csv.reader(f.read()) where f is the Django file object that I get from 'form.cleaned_data['file']' and yes the file is already bound to the form. When...
[ "You're actually passing the wrong iterable to csv.reader(). Try changing that line to:\ndata = csv.reader(f)\n\nWhat you're doing is passing the whole contents of the file to the csv.reader() function, which will cause it to iterate over every individual character, treating each of them as a separate line. If yo...
[ 1, 0 ]
[]
[]
[ "csv", "django", "iterator", "python" ]
stackoverflow_0001396126_csv_django_iterator_python.txt
Q: Working with foreign symbols in python I'm parsing a JSON feed in Python and it contains this character, causing it not to validate. Is there a way to handle these symbols? Can they be converted or is they're a tidy way to remove them? I don't even know what this symbol is called or what causes them, otherwise ...
Working with foreign symbols in python
I'm parsing a JSON feed in Python and it contains this character, causing it not to validate. Is there a way to handle these symbols? Can they be converted or is they're a tidy way to remove them? I don't even know what this symbol is called or what causes them, otherwise I would research it myself. EDIT: Stackover ...
[ "That probably means the text you have is in some sort of encoding, and you need to figure out what encoding, and convert it to Unicode with a thetext.decode('encoding') call.\nI not sure, but it could possibly be the [?] character, meaning that the display you have there also doesn't know how to display it. That w...
[ 1, 0 ]
[]
[]
[ "ascii", "parsing", "python", "symbols", "utf_8" ]
stackoverflow_0001075866_ascii_parsing_python_symbols_utf_8.txt
Q: python and mechanize.open() I have some code that is using mechanize and a password protected site. I can login just fine and get the results I expect. However, once I log in I don't want to "click" links I want to iterate through a list of URLs. Unfortunately each .open() call simply gets a re-direct to the login...
python and mechanize.open()
I have some code that is using mechanize and a password protected site. I can login just fine and get the results I expect. However, once I log in I don't want to "click" links I want to iterate through a list of URLs. Unfortunately each .open() call simply gets a re-direct to the login page, which is the behaviour I w...
[ "Instead of using for each link:\nbrowser.open('www.google.com')\n\nTry using the following after doing the initial login:\nbrowser.follow_link(text = 'a href text')\n\nMy guess is that calling open is what is resetting your cookies.\n", "Will,\nYour suggestion pointed me in exactly the right direction.\nEvery we...
[ 2, 2, 1 ]
[]
[]
[ "mechanize", "python" ]
stackoverflow_0001396646_mechanize_python.txt
Q: How Do I Select all Objects via a Relationship Model Given the Model: class Profile(models.Model): user = models.ForeignKey(User, unique=True) class Thingie(models.Model): children = models.ManyToManyField('self', blank=True, symmetrical=False) class Relation(models.Model): profile = models.ForeignK...
How Do I Select all Objects via a Relationship Model
Given the Model: class Profile(models.Model): user = models.ForeignKey(User, unique=True) class Thingie(models.Model): children = models.ManyToManyField('self', blank=True, symmetrical=False) class Relation(models.Model): profile = models.ForeignKey(Profile) thingie = models.ForeignKey(Thingie) How ...
[ "Do you definitely need it to be a queryset? If you only need it to be an iterable, a simple expression for your purposes is:\nprofiles = [r.profile for r in thingie.relation_set.all()]\n\nI'm not sure if a list comprehension counts as irritating iterating, but to me this is a perfectly intuitive, pythonic approach...
[ 2, 0, 0 ]
[]
[]
[ "django", "django_queryset", "python" ]
stackoverflow_0001396985_django_django_queryset_python.txt
Q: Customizing how Python's `copy` module treats my objects From the copy documentation: Classes can use the same interfaces to control copying that they use to control pickling. [...] In order for a class to define its own copy implementation, it can define special methods __copy__() and __deepcopy__() So which on...
Customizing how Python's `copy` module treats my objects
From the copy documentation: Classes can use the same interfaces to control copying that they use to control pickling. [...] In order for a class to define its own copy implementation, it can define special methods __copy__() and __deepcopy__() So which one is it? __setstate__() and __getstate__() that are used when ...
[ "It works as follows: if a class defines __copy__, that takes precedence for copy.copy purposes (and similarly __deepcopy__ takes precedence for copy.deepcopy purposes). If these very specific special methods are not defined, then the same mechanisms as for pickling and unpickling are tested (this includes, but is ...
[ 7, 1 ]
[]
[]
[ "copy", "pickle", "python" ]
stackoverflow_0001396547_copy_pickle_python.txt
Q: how to recover the binary stream(original form) from radix 64 encoding how to get the actual public key i.e its binary form i.e without radix 64 conversion .i need to extract the public key from radix64 encoding .the pgp server gives me the key in radix 64 format now i have to extract the public key from it. A: ...
how to recover the binary stream(original form) from radix 64 encoding
how to get the actual public key i.e its binary form i.e without radix 64 conversion .i need to extract the public key from radix64 encoding .the pgp server gives me the key in radix 64 format now i have to extract the public key from it.
[ "import base64\n\ndecoded_bytes = base64.b64decode(ascii_chars)\n\n", "base64_encoded_data.decode('base64')\n\n" ]
[ 2, 0 ]
[]
[]
[ "encoding", "python" ]
stackoverflow_0001397799_encoding_python.txt
Q: Django: show list of many to many items in the admin interface This might be a simple question, but i can't seem to grasp it. I have two simple models in models.py: Service and Host. Host.services has a m2m relationship with Service. In other words, a host has several services and one service can reside on multipl...
Django: show list of many to many items in the admin interface
This might be a simple question, but i can't seem to grasp it. I have two simple models in models.py: Service and Host. Host.services has a m2m relationship with Service. In other words, a host has several services and one service can reside on multiple hosts; a basic m2m. models.py class Service(models.Model): ser...
[ "You should change get_services to something like:\ndef get_services(self):\n return \"\\n\".join([s.servicename for s in self.services.all()])\n\nUpdate: Try using \\n as the separator rather than <br/>, as the output of get_services is being escaped.\n" ]
[ 19 ]
[]
[]
[ "django", "python" ]
stackoverflow_0001398606_django_python.txt
Q: Handling big numbers in code I'm working on a programming problem where I need to handle a number involving 100000 digits. Can python handle numbers like this? A: As other answers indicated, Python does support integer numbers bounded only by the amount of memory available. If you want even faster support for th...
Handling big numbers in code
I'm working on a programming problem where I need to handle a number involving 100000 digits. Can python handle numbers like this?
[ "As other answers indicated, Python does support integer numbers bounded only by the amount of memory available. If you want even faster support for them, try gmpy (as gmpy's author and current co-maintainer I'm of course a little biased here;-):\n$ python -mtimeit -s'import gmpy; x=10**100000; y=gmpy.mpz(x)' 'x+1'...
[ 24, 7, 4, 3, 3 ]
[]
[]
[ "algorithm", "python" ]
stackoverflow_0001386604_algorithm_python.txt
Q: What is the simplest way to implement a remote FIFO queue as a Python GAE application? What is the simplest way to implement a remote FIFO queue as a Python GAE application and then push/pull name-value pair dictionaries to and from it? For example, when an http get is made to the GAE application, the GAE app wou...
What is the simplest way to implement a remote FIFO queue as a Python GAE application?
What is the simplest way to implement a remote FIFO queue as a Python GAE application and then push/pull name-value pair dictionaries to and from it? For example, when an http get is made to the GAE application, the GAE app would return the oldest collection of name-value pairs that were posted to the app which have n...
[ "Something along these lines:\nfrom google.appengine.ext import db\nfrom google.appengine.ext import webapp\nfrom google.appengine.ext.webapp import run_wsgi_app\n\nclass QueueItem(db.Model):\n created = db.DateTimeProperty(required=True, auto_now_add=True)\n data = db.BlobProperty(required=True)\n\n @staticmeth...
[ 3, 0 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0001397864_google_app_engine_python.txt
Q: Django : import problem with python-twitter module When I try to import python-twitter module in my app, django tries to import django.templatetags.twitter instead of python-twitter module (in /usr/lib/python2.5/site-packages/twitter.py), but I don't know why. :s For example: myproject/ myapp/ template...
Django : import problem with python-twitter module
When I try to import python-twitter module in my app, django tries to import django.templatetags.twitter instead of python-twitter module (in /usr/lib/python2.5/site-packages/twitter.py), but I don't know why. :s For example: myproject/ myapp/ templatetags/ file.py In file.py: import twitter # ...
[ "\nThe submodules often need to refer to each other. For example, the surround module might use the echo module. In fact, such references are so common that the import statement first looks in the containing package before looking in the standard module search path. source\n\nTherefore, you will need to use an abso...
[ 1 ]
[]
[]
[ "django", "import", "python", "twitter" ]
stackoverflow_0001399478_django_import_python_twitter.txt
Q: Eclipse (pydev): Is it possible to assign a shortcut to send selection to the python console? Question so easy that fitted in the title :) Eclipse (pydev): Is it possible to assign a shortcut to send selection to the python console? A: You can only assign shortcuts to "actions". Actions bound to buttons (for exa...
Eclipse (pydev): Is it possible to assign a shortcut to send selection to the python console?
Question so easy that fitted in the title :) Eclipse (pydev): Is it possible to assign a shortcut to send selection to the python console?
[ "You can only assign shortcuts to \"actions\". Actions bound to buttons (for example, the toolbar) and menus. If you have a menu for this, you can bind a key to it. If not, then you will have to open an enhancement request in the pydev project.\n", "If you mean to the interactive console, use ctrl+alt+enter in th...
[ 1, 1 ]
[]
[]
[ "ide", "python" ]
stackoverflow_0000323581_ide_python.txt
Q: Django and monkey patching issue I have recently started experimenting with Django for some web applications in my spare time. While designing the data model for one, I came across the dilemma of using inheritance to define a user of the website or using a technique known as monkey patching with the User class alr...
Django and monkey patching issue
I have recently started experimenting with Django for some web applications in my spare time. While designing the data model for one, I came across the dilemma of using inheritance to define a user of the website or using a technique known as monkey patching with the User class already supplied by the framework. I trie...
[ "There's an alternative to both approaches, which is to simply use a related profile model. This also happens to be a well-documented, highly recommended approach. Perhaps the reason that the add_to_class approach is not well-documented, as you noted, is because it's explicitly discouraged (for good reason).\n", ...
[ 13, 7, 2, 0, 0 ]
[]
[]
[ "django", "monkeypatching", "python" ]
stackoverflow_0001399746_django_monkeypatching_python.txt
Q: Python: convert free text to date Assuming the text is typed at the same time in the same (Israeli) timezone, The following free text lines are equivalent: Wed Sep 9 16:26:57 IDT 2009 2009-09-09 16:26:57 16:26:57 September 9th, 16:26:57 Is there a python module that would convert all these text-dates to an (iden...
Python: convert free text to date
Assuming the text is typed at the same time in the same (Israeli) timezone, The following free text lines are equivalent: Wed Sep 9 16:26:57 IDT 2009 2009-09-09 16:26:57 16:26:57 September 9th, 16:26:57 Is there a python module that would convert all these text-dates to an (identical) datetime.datetime instance? I wo...
[ "The python-dateutil package sounds like it would be helpful. Your examples only use simple HH:MM timestamps with a (magically shortened) city identifier, but it seems able to handle more complicated formats like those earlier in the question, too.\n", "parsedatetime seems to be a very capable module for this spe...
[ 6, 3, 0 ]
[]
[]
[ "freetext", "parsing", "python", "time" ]
stackoverflow_0001399727_freetext_parsing_python_time.txt
Q: Multi-line Pattern and tag search I'm trying to make a pattern for tags, but the sub method just replaces the first char and 3 at the end of the line, im trying to replace all tags on the line and with multiline p=re.compile('<img=([^}]*)>([^}]*)</img>', re.S) p.sub(r'[img=\1]\2[/img]','<img="test">dsad</img> <img...
Multi-line Pattern and tag search
I'm trying to make a pattern for tags, but the sub method just replaces the first char and 3 at the end of the line, im trying to replace all tags on the line and with multiline p=re.compile('<img=([^}]*)>([^}]*)</img>', re.S) p.sub(r'[img=\1]\2[/img]','<img="test">dsad</img> <img="test2">dsad2</img>') output: '**[**im...
[ "You're using towards the start of your re's pattern:\n<img=([^}]*)>\n\nthis will gobble up (as group 1) all characters after the leading <img=, including other tags!!!, up to the last > it can possibly gobble; * is GREEDY -- it gobbles up as much as it possibly can. Not sure why you're specifically excluding close...
[ 1 ]
[]
[]
[ "multiline", "python", "regex" ]
stackoverflow_0001400136_multiline_python_regex.txt
Q: Python datatype suitable for my cache I'm searching for the a datatype for a cache, basically I need the functionality of a dict, i.e. random access based on a key, which has a limited number of entries so that when the limit is reached the oldest item gets automatically removed. Furthermore I need to be able to s...
Python datatype suitable for my cache
I'm searching for the a datatype for a cache, basically I need the functionality of a dict, i.e. random access based on a key, which has a limited number of entries so that when the limit is reached the oldest item gets automatically removed. Furthermore I need to be able to store it via shelve or pickle and rely on Py...
[ "I think you answered the question yourself. You need to subclass a dict. And you also of course needs to have a list of the keys, so when the list gets too long you can purge the oldest one.\nI would however possibly look into memcached or similar.\n", "You probably want an LRU cache (one where \"oldest\" is mea...
[ 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0001399717_python.txt
Q: how can I get the uuid module for python 2.4.3 I have an older version of python on the server i'm using and cannot upgrade it. is there a way to get the uuid module? A: Get it from pypi -- just download and install, it will work with Python 2.3 or better. Edit: to install, first unpack the .tar.gz you just down...
how can I get the uuid module for python 2.4.3
I have an older version of python on the server i'm using and cannot upgrade it. is there a way to get the uuid module?
[ "Get it from pypi -- just download and install, it will work with Python 2.3 or better.\nEdit: to install, first unpack the .tar.gz you just downloaded, i.e., from a terminal, cd to the directory you downloaded it to, then tar xzvf uuid-1.30.tar.gz, then cd uuid-1.30, and sudo python setup.py install (the sudo may ...
[ 5, 1 ]
[]
[]
[ "python" ]
stackoverflow_0001213328_python.txt
Q: Are Python extensions produced by Cython/Pyrex threadsafe? If not, is there a way I can guarantee thread safety by programming a certain way? To clarify, when talking about "threadsafe,' I mean Python threads, not OS-level threads. A: It all depends on the interaction between your Cython code and Python's GIL, a...
Are Python extensions produced by Cython/Pyrex threadsafe?
If not, is there a way I can guarantee thread safety by programming a certain way? To clarify, when talking about "threadsafe,' I mean Python threads, not OS-level threads.
[ "It all depends on the interaction between your Cython code and Python's GIL, as documented in detail here. If you don't do anything special, Cython-generated code will respect the GIL (as will a C-coded extension that doesn't use the GIL-releasing macros); that makes such code \"as threadsafe as Python code\" -- ...
[ 5, 2 ]
[]
[]
[ "cython", "pyrex", "python", "thread_safety" ]
stackoverflow_0001397977_cython_pyrex_python_thread_safety.txt
Q: Difference between returning modified class and using type() I guess it's more of a python question than a django one, but I couldn't replicate this behavior anywhere else, so I'll use exact code that doesn't work as expected. I was working on some dynamic forms in django, when I found this factory function snippe...
Difference between returning modified class and using type()
I guess it's more of a python question than a django one, but I couldn't replicate this behavior anywhere else, so I'll use exact code that doesn't work as expected. I was working on some dynamic forms in django, when I found this factory function snippet: def get_employee_form(employee): """Return the form for a s...
[ "Lennart's hypothesis is correct: a metaclass is indeed the culprit. No need to guess, just look at the sources: the metaclass is DeclarativeFieldsMetaclass currently at line 53 of that file, and adds attributes base_fields and possibly media based on what attributes the class has at creation time. At line 329 ff y...
[ 5, 3, 1 ]
[]
[]
[ "class", "django", "python", "types" ]
stackoverflow_0001251294_class_django_python_types.txt
Q: Dictionary of tags in declarative SQLAlchemy? I am working on a quite large code base that has been implemented using sqlalchemy.ext.declarative, and I need to add a dict-like property to one of the classes. What I need is the same as in this question, but in a declarative fashion. Can anyone with more knowledge i...
Dictionary of tags in declarative SQLAlchemy?
I am working on a quite large code base that has been implemented using sqlalchemy.ext.declarative, and I need to add a dict-like property to one of the classes. What I need is the same as in this question, but in a declarative fashion. Can anyone with more knowledge in SQLAlchemy give me an example? Thanks in advance....
[ "Declarative is just another way of defining things. Virtually you end up with the exact same environment than if you used separated mapping.\nSince I answered the other question, I'll try this one as well. Hope it gives more upvotes ;)\nWell, first we define the classes\nfrom sqlalchemy import Column, Integer, Str...
[ 14 ]
[]
[]
[ "declarative", "python", "sqlalchemy" ]
stackoverflow_0001400537_declarative_python_sqlalchemy.txt
Q: CRC32 to make short URL for web I am trying to understand crc32 to generate the unique url for web page. If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates? What could be the approximative string length to keep the checksum to be 2^32? When I tried UUID for an url a...
CRC32 to make short URL for web
I am trying to understand crc32 to generate the unique url for web page. If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates? What could be the approximative string length to keep the checksum to be 2^32? When I tried UUID for an url and convert the uuid bytes to base 64,...
[ "There is no such number as the \"maximum number of urls can be used so that we can avoid duplicates\" for CRC32.\nThe problem is that CRC32 can produce duplicates, and it's not a function of how many values you throw at it, it's a function of what those values look like.\nSo you might have a collision on the secon...
[ 7, 4, 2, 1, 0 ]
[ "The quickest (and perhaps best!) way to solve things may be to simply use a hash of the local path and query of a given URI, as follows:\nusing System;\n\nnamespace HashSample\n{\n class Program\n {\n static void Main(string[] args)\n {\n Uri uri = new Uri(\n \"http://...
[ -1 ]
[ "c#", "crc32", "python", "short_url", "url" ]
stackoverflow_0001401218_c#_crc32_python_short_url_url.txt
Q: Return the number of affected rows from a MERGE with cx_oracle How can you get the number of affected rows from executing a "MERGE INTO..." sql command within CX_Oracle? When ever I execute the MERGE SQL on cx_oracle, I get a cursor.rowcount of -1. Is there a way to get the number of rows affected by the merge? ...
Return the number of affected rows from a MERGE with cx_oracle
How can you get the number of affected rows from executing a "MERGE INTO..." sql command within CX_Oracle? When ever I execute the MERGE SQL on cx_oracle, I get a cursor.rowcount of -1. Is there a way to get the number of rows affected by the merge?
[ "Since cx_oracle follows the python DBAPI specification (I presume), this is expected 'behaviour'. The exact same problem was discussed here on stackoverflow before.\nSome more links with possible solutions:\n\nhttp://www.oracle-developer.net/display.php?id=220\nhttp://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P...
[ 1 ]
[]
[]
[ "cx_oracle", "oracle", "python" ]
stackoverflow_0001401328_cx_oracle_oracle_python.txt
Q: How to using widget PlainTextEdit or TextEdit for output and input text? How to using widget PlainTextEdit or TextEdit for output and input text? I'm interested PyQt4. A: PlainTextEdit TextEdit A: You need to be more specific, but anyways, the following code will create a dialog with a TextEdit that will show ...
How to using widget PlainTextEdit or TextEdit for output and input text?
How to using widget PlainTextEdit or TextEdit for output and input text? I'm interested PyQt4.
[ "PlainTextEdit\nTextEdit\n", "You need to be more specific, but anyways, the following code will create a dialog with a TextEdit that will show the input file:\n\nfrom PyQt4 import QtCore, QtGui\ndef read_file(file):\n \"\"\"\n Returns all contents of file\n \"\"\"\n result = \"\"\n with open(file)...
[ 3, 0 ]
[]
[]
[ "python", "qt", "user_interface" ]
stackoverflow_0001396339_python_qt_user_interface.txt
Q: Performance lost when open a db multiple times in BerkeleyDB I'm using BerkeleyDB to develop a small app. And I have a question about opening a database multiple time in BDB. I have a large set of text ( corpus ), and I want to load a part of it to do the calculation. I have two pseudo-code (mix with python) here ...
Performance lost when open a db multiple times in BerkeleyDB
I'm using BerkeleyDB to develop a small app. And I have a question about opening a database multiple time in BDB. I have a large set of text ( corpus ), and I want to load a part of it to do the calculation. I have two pseudo-code (mix with python) here @1 def getCorpus(token): DB.open() DB.get(token) DB.cl...
[ "If you aren't caching the opened file you will always get performance lost because:\n\nyou call open() and close() multiple times which are quite expensive,\nyou lose all potential buffers (both system buffers and bdb internal buffers).\n\nBut I wouldn't care too much about the performance before the code is writt...
[ 3 ]
[]
[]
[ "berkeley_db", "database", "performance", "python" ]
stackoverflow_0001401497_berkeley_db_database_performance_python.txt
Q: Python vs Groovy vs Ruby? (based on criteria listed in question) Considering the criteria listed below, which of Python, Groovy or Ruby would you use? Criteria (Importance out of 10, 10 being most important) Richness of API/libraries available (eg. maths, plotting, networking) (9) Ability to embed in desktop (jav...
Python vs Groovy vs Ruby? (based on criteria listed in question)
Considering the criteria listed below, which of Python, Groovy or Ruby would you use? Criteria (Importance out of 10, 10 being most important) Richness of API/libraries available (eg. maths, plotting, networking) (9) Ability to embed in desktop (java/c++) applications (8) Ease of deployment (8) Ability to interface wi...
[ "I think it's going to be difficult to get an objective comparison. I personally prefer Python. To address one of your criteria, Python was designed from the start to be an embeddable language. It has a very rich C API, and the interpreter is modularized to make it easy to call from C. If Java is your host envi...
[ 34, 29, 24, 10, 8, 7, 6, 3, 2, 0 ]
[]
[]
[ "groovy", "python", "ruby", "scripting" ]
stackoverflow_0000257730_groovy_python_ruby_scripting.txt
Q: Pythonic way to "flatten" object hierarchy to nested dicts? I need to "flatten" objects into nested dicts of the object's properties. The objects I want to do this with are generally just containers for basic types or other objects which act in a similar way. For example: class foo(object): bar = None baz ...
Pythonic way to "flatten" object hierarchy to nested dicts?
I need to "flatten" objects into nested dicts of the object's properties. The objects I want to do this with are generally just containers for basic types or other objects which act in a similar way. For example: class foo(object): bar = None baz = None class spam(object): eggs = [] x = spam() y = foo() y...
[ "Code: You may need to handle other iterable types though:\ndef flatten(obj):\n if obj is None:\n return None\n elif hasattr(obj, '__dict__') and obj.__dict__:\n return dict([(k, flatten(v)) for (k, v) in obj.__dict__.items()])\n elif isinstance(obj, (dict,)):\n return dict([(k, flatte...
[ 3, 0, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0001393010_python.txt
Q: how to generate a many-to-many-relationship FORM in web2py? Do I need a custom validator? Do I need a custom widget? If this helps to clear the problem, the relationship is between member and language where a member can have multiple languages and a language is spoken by multiple members. I would like to add a mul...
how to generate a many-to-many-relationship FORM in web2py?
Do I need a custom validator? Do I need a custom widget? If this helps to clear the problem, the relationship is between member and language where a member can have multiple languages and a language is spoken by multiple members. I would like to add a multi-select box in the "add member" form (that I generate using SQL...
[ "It depends and I suggest you take this on the web2py mailin list. One way to do it is\ndb.table.field.requires=IS_IN_DB(db,'othertable.id','%(otherfield)',multiple=True)\n\n", "Another way to do this:\ndb.define_table( 'make', Field( 'name' ) )\n\ndb.define_table( 'model', \n Field( 'name' ), \n Field( 'ma...
[ 1, 0 ]
[]
[]
[ "python", "web2py" ]
stackoverflow_0001012179_python_web2py.txt
Q: Problem with list of strings in python Why on Earth doesn't the interpreter raise SyntaxError everytime I do this: my_abc = ['a', 'b', 'c' 'd',] I just wanted to add 'c' to the list of strings, and forgot to append the comma. I would expect this to cause some kind of error, as it's c...
Problem with list of strings in python
Why on Earth doesn't the interpreter raise SyntaxError everytime I do this: my_abc = ['a', 'b', 'c' 'd',] I just wanted to add 'c' to the list of strings, and forgot to append the comma. I would expect this to cause some kind of error, as it's cleary incorrect. Instead, what I got: >>> m...
[ "Is called \"Implicit String Concatenation\" and a PEP that proposed its removal was rejected: http://www.python.org/dev/peps/pep-3126/\n", "It's by design. It allows, for example, writing long string literals in several lines without using +.\n", "As others said, it's by design.\nWhy is it so ? Mostly for hist...
[ 13, 6, 3, 2, 2 ]
[]
[]
[ "list", "python" ]
stackoverflow_0001401650_list_python.txt
Q: How to get Django admin.TabularInline to NOT require some items class LineItemInline(admin.TabularInline): model = LineItem extra = 10 class InvoiceAdmin(admin.ModelAdmin): model = Invoice inlines = (LineItemInline,) and class LineItem(models.Model): invoice = models.ForeignKey(Invoice) i...
How to get Django admin.TabularInline to NOT require some items
class LineItemInline(admin.TabularInline): model = LineItem extra = 10 class InvoiceAdmin(admin.ModelAdmin): model = Invoice inlines = (LineItemInline,) and class LineItem(models.Model): invoice = models.ForeignKey(Invoice) item_product_code = models.CharField(max_length=32) item_descripti...
[ "That's strange, it's supposed not to do that - it shouldn't require any data in a row if you haven't entered anything.\nI wonder if the default options are causing it to get confused. Again, Django should cope with this, but try removing those and see what happens.\nAlso note that this:\nitem_unit_of_measure = mod...
[ 1, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0001400981_django_python.txt
Q: Need advice how to represent a certain datastructure in Python I'm not sure how to represent a certain datastructure in Python. It consists of groups and users where each user must be a member of exactly one group and groups should be in turn contained in a container, groups and users will only be used within this...
Need advice how to represent a certain datastructure in Python
I'm not sure how to represent a certain datastructure in Python. It consists of groups and users where each user must be a member of exactly one group and groups should be in turn contained in a container, groups and users will only be used within this container. Furthermore I need random access to groups and users. A ...
[ "I think an abundance of behavior-less classes, in a multi-paradigm language (one like C++ or Python, that while supporting classes doesn't constrain you to use them when simpler structures will do), is a \"design smell\" -- the design equivalent of a \"code smell\", albeit a mild one.\nIf I was doing a code review...
[ 5, 2, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0001393849_python.txt
Q: Convert list of objects to a list of integers and a lookup table To illustrate what I mean by this, here is an example messages = [ ('Ricky', 'Steve', 'SMS'), ('Steve', 'Karl', 'SMS'), ('Karl', 'Nora', 'Email') ] I want to convert this list and a definition of groups to a list of integers and a loo...
Convert list of objects to a list of integers and a lookup table
To illustrate what I mean by this, here is an example messages = [ ('Ricky', 'Steve', 'SMS'), ('Steve', 'Karl', 'SMS'), ('Karl', 'Nora', 'Email') ] I want to convert this list and a definition of groups to a list of integers and a lookup dictionary so that each element in the group gets a unique id. Tha...
[ "defaultdict combined with the itertools.count().next method is a good way to assign identifiers to unique items. Here's an example of how to apply this in your case:\nfrom itertools import count\nfrom collections import defaultdict\n\ndef create_lookup_list(data, domains):\n domain_keys = defaultdict(lambda:def...
[ 3, 2, 2, 1, 1, 0, 0 ]
[]
[]
[ "lookup", "python" ]
stackoverflow_0001401721_lookup_python.txt
Q: "deprecated" status on Google App Engine Django I'm looking at Google App Engine Django on google code but the latest release (May 15/09) has been deprecated. I'd like to know why that is? Are they discouraging us from using it? What deprecated it? Is there a better way to get set up with django? A: None of t...
"deprecated" status on Google App Engine Django
I'm looking at Google App Engine Django on google code but the latest release (May 15/09) has been deprecated. I'd like to know why that is? Are they discouraging us from using it? What deprecated it? Is there a better way to get set up with django?
[ "None of the packaged downloads are recommended by the project's owners -- deprecated basically means the same thing as \"NOT recommended\". There have been several changes since the May 15 upload of the last (now-deprecated) downloads, and I imagine the project owners are working to get a new enhanced download rou...
[ 4 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0001403413_google_app_engine_python.txt
Q: Error using python doctest I try to use doctest from example from http://docs.python.org/library/doctest.html But when I run python example.py -v I get this Traceback (most recent call last): File "example.py", line 61, in <module> doctest.testmod() AttributeError: 'module' object has no attribute 'testmod'...
Error using python doctest
I try to use doctest from example from http://docs.python.org/library/doctest.html But when I run python example.py -v I get this Traceback (most recent call last): File "example.py", line 61, in <module> doctest.testmod() AttributeError: 'module' object has no attribute 'testmod' But I can import doctest in py...
[ "Clearly the doctest module object you have at hand at that point is NOT the normal, unadulterated one you get from an import doctest from the standard library. Printing doctest.__file__ (and sys.stdout.flush()ing after that, just to make sure you do get to see the results;-) before the line-61 exception will let ...
[ 5, 0 ]
[]
[]
[ "doctest", "python" ]
stackoverflow_0001403408_doctest_python.txt
Q: What are some small, fast and lightweight open source applications (µTorrent -esque)? Possible duplicate What is the best open source example of a lightweight Windows Application? µTorrent is a small bit-torrent client, a really small one. It doesn't come with an installer, just a exe, you drop in your PATH so...
What are some small, fast and lightweight open source applications (µTorrent -esque)?
Possible duplicate What is the best open source example of a lightweight Windows Application? µTorrent is a small bit-torrent client, a really small one. It doesn't come with an installer, just a exe, you drop in your PATH somewhere. It's super lightweight and yet feature rich. Plus it is the work of one man. I...
[ "I think you should take a look at Notepad++ if you want to see a feature-rich low-consumption of power software :)\n", "Netcat\nIt's the program that started all of the curiousity behind networks and how things WORK.\nEveryone's looked at this source code.\n", "rTorrent is a lightweight, feature-rich, console-...
[ 7, 2, 1, 1, 0 ]
[]
[]
[ "c++", "performance", "python" ]
stackoverflow_0001391756_c++_performance_python.txt
Q: Efficient way to determine whether a particular function is on the stack in Python For debugging, it is often useful to tell if a particular function is higher up on the call stack. For example, we often only want to run debugging code when a certain function called us. One solution is to examine all of the stack ...
Efficient way to determine whether a particular function is on the stack in Python
For debugging, it is often useful to tell if a particular function is higher up on the call stack. For example, we often only want to run debugging code when a certain function called us. One solution is to examine all of the stack entries higher up, but it this is in a function that is deep in the stack and repeatedly...
[ "Unless the function you're aiming for does something very special to mark \"one instance of me is active on the stack\" (IOW: if the function is pristine and untouchable and can't possibly be made aware of this peculiar need of yours), there is no conceivable alternative to walking frame by frame up the stack unti...
[ 14, 1 ]
[]
[]
[ "callstack", "python" ]
stackoverflow_0001403471_callstack_python.txt
Q: Pyqt GroupBox parenting In Python and Pyqt - I've got a simple class which instantiates a Label class and a GroupBox class. According to docs, passing the Groupbox to the Label upon creation should make the Groupbox the parent of Label. However, I must be missing something simple here. When I create the GroupBox ...
Pyqt GroupBox parenting
In Python and Pyqt - I've got a simple class which instantiates a Label class and a GroupBox class. According to docs, passing the Groupbox to the Label upon creation should make the Groupbox the parent of Label. However, I must be missing something simple here. When I create the GroupBox it's fine, when I create the ...
[ "The problem is that you are not using a layout. Because you are not using one, both widgets are being rendered one on top of the other one. It of course depends on what you are trying to do, but the following should be a good example:\nclass FileBrowser(QMainWindow):\n def __init__(self):\n QMainWindow._...
[ 2 ]
[]
[]
[ "oop", "pyqt", "python", "qt" ]
stackoverflow_0001391174_oop_pyqt_python_qt.txt
Q: Pythonic way to return list of every nth item in a larger list Say we have a list of numbers from 0 to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item, i.e. [0, 10, 20, 30, ... ]? Yes, I can do this using a for loop, but I'm wondering if there is a neater way t...
Pythonic way to return list of every nth item in a larger list
Say we have a list of numbers from 0 to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item, i.e. [0, 10, 20, 30, ... ]? Yes, I can do this using a for loop, but I'm wondering if there is a neater way to do this, perhaps even in one line?
[ ">>> lst = list(range(165))\n>>> lst[0::10]\n[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]\n\nNote that this is around 100 times faster than looping and checking a modulus for each element:\n$ python -m timeit -s \"lst = list(range(1000))\" \"lst1 = [x for x in lst if x % 10 == 0]\"\n10...
[ 365, 71, 31, 30, 13, 4, 3, 1 ]
[ "List comprehensions are exactly made for that:\nsmaller_list = [x for x in range(100001) if x % 10 == 0]\n\nYou can get more info about them in the python official documentation:\nhttp://docs.python.org/tutorial/datastructures.html#list-comprehensions\n" ]
[ -9 ]
[ "list", "python" ]
stackoverflow_0001403674_list_python.txt
Q: Setting up/Inserting into Many-to-Many Database with Python, SQLALchemy, Sqlite I am learning Python, and as a first project am taking Twitter RSS feeds, parsing the data, and inserting the data into a sqlite database. I have been able to successfully parse each feed entry into a content variable (e.g., "You shoul...
Setting up/Inserting into Many-to-Many Database with Python, SQLALchemy, Sqlite
I am learning Python, and as a first project am taking Twitter RSS feeds, parsing the data, and inserting the data into a sqlite database. I have been able to successfully parse each feed entry into a content variable (e.g., "You should buy low..."), a url variable (e.g., u'http://bit.ly/HbFwL'), and a hashtag list (e....
[ "First, you should use the SQLAlchemy SQL builder for the inserts to give SQLAlcehemy more insight into what you're doing.\n result = conn.execute(RSSEntries.insert(), {'feed_id': id, 'short_url': tinyurl,\n 'content': content, 'hashtags': hashtags, 'date': date})\n entry_id = result.last_insert_ids()[0]\n\n...
[ 4 ]
[]
[]
[ "insert", "many_to_many", "python", "sqlalchemy", "sqlite" ]
stackoverflow_0001403084_insert_many_to_many_python_sqlalchemy_sqlite.txt
Q: Combine tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet I need to combine several tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet, preferably using Python. There is not much cleverness needed in combining them - just copying each TSV file onto a separate sheet in Excel w...
Combine tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet
I need to combine several tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet, preferably using Python. There is not much cleverness needed in combining them - just copying each TSV file onto a separate sheet in Excel will do. Of course, the data needs to be split into columns and rows same as Excel d...
[ "Looks like xlwt may serve your needs -- you can read each TSV file with Python's standard library csv module (which DOES do tab-separated as well as comma-separated etc, don't worry!-) and use xlwt (maybe via this cheatsheet;-) to create an XLS file, make sheets in it, build each sheet from the data you read via c...
[ 2, 2, 1 ]
[]
[]
[ "excel", "excel_2007", "python" ]
stackoverflow_0001403468_excel_excel_2007_python.txt
Q: In bash, what is the simplest way to configure lighttpd to call a local python script based on a particular URL? In bash, what is the simplest way to configure lighttpd to call a local python script while passing any query string or name-value pairs included with the URL as a command line option for the local pyth...
In bash, what is the simplest way to configure lighttpd to call a local python script based on a particular URL?
In bash, what is the simplest way to configure lighttpd to call a local python script while passing any query string or name-value pairs included with the URL as a command line option for the local python app to parse? Example: www.myapp.com/sendtopython/app1.py?Foo=Bar results in the following occurring on the system...
[ "Mh, for one thing I wouldn't mess with the install script, but run it once and then edit the resulting lighttpd configuration file (webconsole.conf in your case).\nYou then need to register Python scripts for CGI, like is done for Perl in the install script. You could add a line\ncgi.assign = ( \".py\" => \"/usr/b...
[ 3 ]
[]
[]
[ "bash", "lighttpd", "python" ]
stackoverflow_0001403672_bash_lighttpd_python.txt
Q: Plotting two graphs that share an x-axis in matplotlib I have to plot 2 graphs in a single screen. The x-axis remains the same but the y-axis should be different. How can I do that in 'matplotlib'? A: twinx is the function you're looking for; here's an example of how to use it. A: subplot will let you plot mor...
Plotting two graphs that share an x-axis in matplotlib
I have to plot 2 graphs in a single screen. The x-axis remains the same but the y-axis should be different. How can I do that in 'matplotlib'?
[ "twinx is the function you're looking for; here's an example of how to use it.\n\n", "subplot will let you plot more than one figure on the same canvas. See the example on the linked documentation page.\nThere is an example of a shared axis plot in the examples directory, called shared_axis_demo.py:\nfrom pylab i...
[ 19, 7 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0001404502_matplotlib_python.txt
Q: Path separator char in python 2.4 Just out of curiosity - is there another way to obtain the platform's path separator char than os.path.normcase('/') in Python 2.4? I was expecting something like a os.path.separator constant... A: That would be os.sep.
Path separator char in python 2.4
Just out of curiosity - is there another way to obtain the platform's path separator char than os.path.normcase('/') in Python 2.4? I was expecting something like a os.path.separator constant...
[ "That would be os.sep.\n" ]
[ 41 ]
[]
[]
[ "path_separator", "python" ]
stackoverflow_0001404749_path_separator_python.txt
Q: Socket programming Please take a look at my code: from twisted.internet.protocol import ServerFactory from twisted.internet import reactor from twisted.protocols import basic class ThasherProtocol(basic.LineReceiver): def lineReceived(self, line): print line self.transport.write( 1 ) s...
Socket programming
Please take a look at my code: from twisted.internet.protocol import ServerFactory from twisted.internet import reactor from twisted.protocols import basic class ThasherProtocol(basic.LineReceiver): def lineReceived(self, line): print line self.transport.write( 1 ) self.transport.loseConne...
[ "you should send a line and not just hello in order to have lineReceived called\ne.g. s.sendall('hello\\r\\n')\n" ]
[ 2 ]
[]
[]
[ "python", "sockets" ]
stackoverflow_0001404724_python_sockets.txt
Q: Good way to write a lightweight client function to be imported Twisted Python I have the following server running: class ThasherProtocol(basic.LineReceiver): def lineReceived(self, line): dic = simplejson.loads( line) ret = self.factory.d[ dic['method'] ]( dic['args'] ) self.transport.w...
Good way to write a lightweight client function to be imported Twisted Python
I have the following server running: class ThasherProtocol(basic.LineReceiver): def lineReceived(self, line): dic = simplejson.loads( line) ret = self.factory.d[ dic['method'] ]( dic['args'] ) self.transport.write( simplejson.dumps( ret) ) self.transport.loseConnection() class Tha...
[ "You want getHash to return a Deferred, not a synchronous value.\nThe way to do this is to create a Deferred and associate it with the connection that performs a particular request.\nThe following is untested and probably won't work, but it should give you a rough idea:\nimport simplejson\nfrom twisted.python.proto...
[ 2 ]
[ "I managed to solve my own problem.\nUse sockets (Unix sockets in particular) it speed up my app 4x and it's not difficult to use at all.\nso now my solution is simplejson + socket\n" ]
[ -1 ]
[ "python", "twisted" ]
stackoverflow_0001404066_python_twisted.txt
Q: Is it possible to intercept attribute getting/setting in ActionScript 3? When developing in ActionScript 3, I often find myself looking for a way to achieve something similar to what is offered by python's __getattr__ / __setattr__ magic methods i.e. to be able to intercept attribute lookup on an instance, and do ...
Is it possible to intercept attribute getting/setting in ActionScript 3?
When developing in ActionScript 3, I often find myself looking for a way to achieve something similar to what is offered by python's __getattr__ / __setattr__ magic methods i.e. to be able to intercept attribute lookup on an instance, and do something custom. Is there some acceptable way to achieve this in ActionScrip...
[ "Look a the flash.utils.Proxy object.\n\nThe Proxy class lets you override the\n default behavior of ActionScript\n operations (such as retrieving and\n modifying properties) on an object.\n\n", "In AS3 you can code explicit variables accessors.\nExample Class1:\nprivate var __myvar:String;\n\npublic function ...
[ 0, 0 ]
[]
[]
[ "actionscript_3", "python" ]
stackoverflow_0001398890_actionscript_3_python.txt
Q: How to get colored emails from crontab? I call a Python script from crontab. The script does generates colored output using ANSI escapes but when crontab is sending the mail with the output I see the escapes instead of colors. What is happening is logic but I would like to know if it would be possible to generate...
How to get colored emails from crontab?
I call a Python script from crontab. The script does generates colored output using ANSI escapes but when crontab is sending the mail with the output I see the escapes instead of colors. What is happening is logic but I would like to know if it would be possible to generate a html message instead. I would like a solu...
[ "Maybe you can try with some txt to html converter, for example, http://txt2html.sourceforge.net/, you can also use pygments with some modifications.\n" ]
[ 0 ]
[]
[]
[ "ansi_escape", "colors", "console", "crontab", "python" ]
stackoverflow_0001405108_ansi_escape_colors_console_crontab_python.txt
Q: gVim and multiple programming languages My day job involves coding with Perl. At home I play around with Python and Erlang. For Perl I want to indent my code with two spaces. Whereas for Python the standard is 4. Also I have some key bindings to open function declarations which I would like to use with all program...
gVim and multiple programming languages
My day job involves coding with Perl. At home I play around with Python and Erlang. For Perl I want to indent my code with two spaces. Whereas for Python the standard is 4. Also I have some key bindings to open function declarations which I would like to use with all programming languages. How can this be achieved in g...
[ "In your $HOME, make .vim/ directory (or vimfiles/ on Windows), in it make ftplugin/ directory, and in it keep files named \"perl.vim\" or \"python.vim\" or \"html.vim\" or ...\nThese should be loaded automatically when you open/create new file of given filetype as long as you don't forget to add :filetype plugin o...
[ 25, 23, 7, 3 ]
[]
[]
[ "editor", "perl", "python", "vim" ]
stackoverflow_0001404515_editor_perl_python_vim.txt
Q: Special considerations for using Python in init.d script? Are there any special considerations for using Python in an 'init.d' script being run through init? (i.e. booting Ubuntu) From what I understand through googling/testing on Ubuntu, the environment variables provided to an 'init.d' script are scarce and so u...
Special considerations for using Python in init.d script?
Are there any special considerations for using Python in an 'init.d' script being run through init? (i.e. booting Ubuntu) From what I understand through googling/testing on Ubuntu, the environment variables provided to an 'init.d' script are scarce and so using "#!/usr/bin/env python" might not work. Anything else?
[ "That just highlights the biggest problem with python in an init.d script -- added complexity. \nPython has no specification, and the env doesn't even have to point to cpython. If you upgrade and python breaks, you'll have to bite your tongue. And there is a much greater chance that python will break than sh (the s...
[ 4, 1 ]
[]
[]
[ "init.d", "linux", "python", "ubuntu" ]
stackoverflow_0001405555_init.d_linux_python_ubuntu.txt
Q: How to catch error in Django project on apache: 10048 "Address already in use" Python 2.5.2, Apache 2.2, Django 1.0.2 final My Django app tries to connect to a certain port. When that port is busy, I get the error 10048 "Address already in use" from apache. I know where the error is coming from. How do I catch thi...
How to catch error in Django project on apache: 10048 "Address already in use"
Python 2.5.2, Apache 2.2, Django 1.0.2 final My Django app tries to connect to a certain port. When that port is busy, I get the error 10048 "Address already in use" from apache. I know where the error is coming from. How do I catch this apache error? More info: error at /report/5/2009/08/01/ (10048, 'Address already ...
[ "If you're calling httplib.connect directly from your code, then the try/except should be around that direct call. Or is the call happening indirectly...? Unfortunately Apache is not giving you a stack trace, so if you're having problems locating exactly what call sequence is involved you could put a broad try/exc...
[ 1 ]
[]
[]
[ "apache", "django", "python" ]
stackoverflow_0001404259_apache_django_python.txt
Q: Python sched.scheduler exceeds max recursion depth I have recently started learning Python and part of the simple app I am making includes a timer with a hh:mm:ss display running in its own thread. Looking around the web I found two ways of implementing this: Using sched.scheduler Using threading.Timer The way I...
Python sched.scheduler exceeds max recursion depth
I have recently started learning Python and part of the simple app I am making includes a timer with a hh:mm:ss display running in its own thread. Looking around the web I found two ways of implementing this: Using sched.scheduler Using threading.Timer The way I did it looks similar for both implementations: sched: d...
[ "Here's how to make a one-shot into a periodic event, e.g. with sched: if the function must make its own scheduler and be the only thing running on its thread:\ndef tick(self, display, alarm_time, scheduler=None):\n # make a new scheduler only once & schedule this function immediately\n if scheduler is None:\n ...
[ 6, 3 ]
[]
[]
[ "clock", "python", "scheduler", "timer" ]
stackoverflow_0001404580_clock_python_scheduler_timer.txt
Q: Why do I have this TypeError when using tkinter? so I upgraded to python 3.1.1 from 2.6 and i ran an old program of mine which uses tkinter. I get the following error message which I don't recall getting in the 2.6 version. Exception in Tkinter callback Traceback (most recent call last): File "C:\Python31\lib\tk...
Why do I have this TypeError when using tkinter?
so I upgraded to python 3.1.1 from 2.6 and i ran an old program of mine which uses tkinter. I get the following error message which I don't recall getting in the 2.6 version. Exception in Tkinter callback Traceback (most recent call last): File "C:\Python31\lib\tkinter\__init__.py", line 1399, in __call__ return ...
[ "There were several breaking changes from Python 2.X to Python 3.X -- among them, map's functionality.\nHave you run your script through 2to3 yet?\n", "self.canvas.coords(name)\n\nreturn a map object, and as the error states map object is unsubscriptable in python 3. you need to change coords to be a tuple or a l...
[ 3, 2 ]
[]
[]
[ "python", "python_3.x", "tkinter", "typeerror" ]
stackoverflow_0001406371_python_python_3.x_tkinter_typeerror.txt
Q: Splitting a string with no line breaks into a list of lines with a maximum column count I have a long string (multiple paragraphs) which I need to split into a list of line strings. The determination of what makes a "line" is based on: The number of characters in the line is less than or equal to X (where X is a...
Splitting a string with no line breaks into a list of lines with a maximum column count
I have a long string (multiple paragraphs) which I need to split into a list of line strings. The determination of what makes a "line" is based on: The number of characters in the line is less than or equal to X (where X is a fixed number of columns per line_) OR, there is a newline in the original string (that will ...
[ "EDIT\nWhat you are looking for is textwrap, but that's only part of the solution not the complete one. To take newline into account you need to do this:\nfrom textwrap import wrap\n'\\n'.join(['\\n'.join(wrap(block, width=50)) for block in text.splitlines()])\n\n>>> print '\\n'.join(['\\n'.join(wrap(block, width=5...
[ 14, 4 ]
[]
[]
[ "python", "text_manipulation" ]
stackoverflow_0001406493_python_text_manipulation.txt
Q: Deploying a Web.py application with WSGI, several servers I've created a web.py application, and now that it is ready to be deployed, I want to run in not on web.py's built-in webserver. I want to be able to run it on different webservers, Apache or IIS, without having to change my application code. This is where ...
Deploying a Web.py application with WSGI, several servers
I've created a web.py application, and now that it is ready to be deployed, I want to run in not on web.py's built-in webserver. I want to be able to run it on different webservers, Apache or IIS, without having to change my application code. This is where WSGI is supposed to come in, if I understand it correctly. Howe...
[ "Exactly what you need to do to host it with a specific WSGI hosting mechanism varies with the server.\nFor the case of Apache/mod_wsgi and Phusion Passenger, you just need to provide a WSGI script file which contains an object called 'application'. For web.py 0.2, this is the result of calling web.wsgifunc() with ...
[ 6, 0, 0 ]
[]
[]
[ "python", "web.py", "wsgi" ]
stackoverflow_0001078599_python_web.py_wsgi.txt
Q: How do I keep state between requests in AppEngine (Python)? I'm writing a simple app with AppEngine, using Python. After a successful insert by a user and redirect, I'd like to display a flash confirmation message on the next page. What's the best way to keep state between one request and the next? Or is this not...
How do I keep state between requests in AppEngine (Python)?
I'm writing a simple app with AppEngine, using Python. After a successful insert by a user and redirect, I'd like to display a flash confirmation message on the next page. What's the best way to keep state between one request and the next? Or is this not possible because AppEngine is distributed? I guess, the underlyi...
[ "No session support is included in App Engine itself, but you can add your own session support.\nGAE Utilities is one library made specifically for this; a more heavyweight alternative is to use django sessions through App Engine Patch.\n", "The ways to reliable keep state between requests are memcache, the datas...
[ 3, 3 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0001406636_google_app_engine_python.txt