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: How to read Unsigned integer from binary file? How to read "Unsigned 8/16/24/32/64-bit integer" from binary file ? ( big-endian byte order ) unpack ? any examples ? A: Use the struct module. That covers 8,16,32 and 64 bits. 24 bits you will need to do some extra fiddling yourself Examples are here
How to read Unsigned integer from binary file?
How to read "Unsigned 8/16/24/32/64-bit integer" from binary file ? ( big-endian byte order ) unpack ? any examples ?
[ "Use the struct module. That covers 8,16,32 and 64 bits. 24 bits you will need to do some extra fiddling yourself\nExamples are here\n" ]
[ 4 ]
[]
[]
[ "python" ]
stackoverflow_0006775023_python.txt
Q: Graphically represent lists Is there a quick way (without the overhead of using a GUI or graphics module) to visually render 2d and 3d lists. For example if I have a 2d array of zeros and ones, I would like to draw a black and white grid according to this array. I am looking for a module that allows me to do these...
Graphically represent lists
Is there a quick way (without the overhead of using a GUI or graphics module) to visually render 2d and 3d lists. For example if I have a 2d array of zeros and ones, I would like to draw a black and white grid according to this array. I am looking for a module that allows me to do these thing in simple ways. Similar to...
[ "The command matshow in matplotlib displays a matrix:\nimport pylab as p\np.matshow(p.array([[0,1],[1,1]]),cmap=\"Greys\") ; p.show()\n\nThis would work for 2d lists. As for 3d lists, I'm not sure I fully understand how you're planning on visualising them.\n", "Are you looking for something to run on command line...
[ 7, 3 ]
[]
[]
[ "python" ]
stackoverflow_0006774716_python.txt
Q: Python copy on PIL image object I'm trying to create a set of thumbnails, each one separately downscaled from the original image. image = Image.open(path) image = image.crop((left, upper, right, lower)) for size in sizes: temp = copy.copy(image) temp.thumbnail((size, height), Image.ANTIALIAS) temp.save('%s%s...
Python copy on PIL image object
I'm trying to create a set of thumbnails, each one separately downscaled from the original image. image = Image.open(path) image = image.crop((left, upper, right, lower)) for size in sizes: temp = copy.copy(image) temp.thumbnail((size, height), Image.ANTIALIAS) temp.save('%s%s%s.%s' % (path, name, size, format), ...
[ "I guess copy.copy() does not work for the PIL Image class. Try using Image.copy() instead, since it is there for a reason:\nimage = Image.open(path)\nimage = image.crop((left, upper, right, lower))\nfor size in sizes:\n temp = image.copy() # <-- Instead of copy.copy(image)\n temp.thumbnail((size, height), Imag...
[ 64 ]
[]
[]
[ "copy", "python", "python_imaging_library" ]
stackoverflow_0006775216_copy_python_python_imaging_library.txt
Q: Calling Excel macros/Excel Solver from Python over com I have a macro inside a 2007 xlsm file that, when called, creates a solver configuration (target, constraints, ...) and performs the solve without any user interaction. When run manually from Excel, this works fine. I now want to script this from Python over c...
Calling Excel macros/Excel Solver from Python over com
I have a macro inside a 2007 xlsm file that, when called, creates a solver configuration (target, constraints, ...) and performs the solve without any user interaction. When run manually from Excel, this works fine. I now want to script this from Python over com. However, when the Python code calls the solver macro: ap...
[ "I finally found a solution after posting on the MSDN Excel Developers forum. And the solution was maddingly trivial:\nInstead of running the solver like so:\napp.Run(\"runsolver()\")\n\nYou apparently have to drop the brackets and run it like so:\napp.Run(\"runsolver\")\n\nGo figure.\n" ]
[ 4 ]
[]
[]
[ "com", "excel", "python", "solver", "win32com" ]
stackoverflow_0006734458_com_excel_python_solver_win32com.txt
Q: Storing a List into Python Sqlite3 I am trying to scrape form field IDs using Beautiful Soup like this for link in BeautifulSoup(content, parseOnlyThese=SoupStrainer('input')): if link.has_key('id'): print link['id'] Lets us assume that it returns something like username email password passwordagain ...
Storing a List into Python Sqlite3
I am trying to scrape form field IDs using Beautiful Soup like this for link in BeautifulSoup(content, parseOnlyThese=SoupStrainer('input')): if link.has_key('id'): print link['id'] Lets us assume that it returns something like username email password passwordagain terms button_register I would like to w...
[ "There is a normalization problem in your table.\nUsing 2 tables with \nTABLE domains\nint id primary key\ntext name\n\nTABLE field_ids\nint id primary key\nint domain_id foreign key ref domains\ntext value\n\nis a better solution.\n", "Proper database design would suggest you have a table of URLs, and a table of...
[ 1, 1, 0 ]
[]
[]
[ "database", "python", "sql", "sqlite" ]
stackoverflow_0006775428_database_python_sql_sqlite.txt
Q: Is there a way to add multiple conditions in a for loop? n=int(raw_input('enter the number of mcnuggets you want to buy : ')) #total number of mcnuggets you want yo buy for a in range(1,n) and b in range(1,n) and c in range(1,n) : if (6*a+9*b+20*c==n): print 'number of pac...
Is there a way to add multiple conditions in a for loop?
n=int(raw_input('enter the number of mcnuggets you want to buy : ')) #total number of mcnuggets you want yo buy for a in range(1,n) and b in range(1,n) and c in range(1,n) : if (6*a+9*b+20*c==n): print 'number of packs of 6 are ',a print 'number of packs of 9 are ',...
[ "You should use nested loops:\nfor a in range(1, n):\n for b in range(1, n):\n for c in range(1, n):\n if ...\n\nOr even better:\nimport itertools\n\nfor a, b, c in itertools.product(range(1, n + 1), repeat=3):\n if ...\n\n", "I think you should start the ranges from 0, otherwise you will ...
[ 5, 3, 1 ]
[]
[]
[ "conditional", "for_loop", "python" ]
stackoverflow_0006774980_conditional_for_loop_python.txt
Q: Why don't I see the hebrew characters, when I print text from an utf-8 file in Python? I'm trying to read hebrew from a text file: def task1(): f = open('C:\\Users\\royi\\Desktop\\final project\\corpus-haaretz.txt', 'r',"utf-8") print 'success' return f a = task1() When i read it it shows me this: '[...
Why don't I see the hebrew characters, when I print text from an utf-8 file in Python?
I'm trying to read hebrew from a text file: def task1(): f = open('C:\\Users\\royi\\Desktop\\final project\\corpus-haaretz.txt', 'r',"utf-8") print 'success' return f a = task1() When i read it it shows me this: '[\xee\xe0\xee\xf8 \xee\xf2\xf8\xeb\xfa \xf9\xec \xe4\xf0\xe9\xe5-\xe9\xe5\xf8\xf7 \xe8\xe9\xe...
[ "You print it like this:\nprint task1().encode('your terminal encoding here')\n\nYou must be sure that your terminal is able to display hebrew characters. For exemple, under an full utf-8 Linux distrib with hebrew locales installed:\nprint task1().encode('utf-8')\n\nCareful with open:\n\nwith python 2.7, you have n...
[ 5, 1, 1, 0 ]
[]
[]
[ "encoding", "printing", "python" ]
stackoverflow_0006774373_encoding_printing_python.txt
Q: parsing .xsd in python I need to parse a file .xsd in Python as i would parse an XML. I am using libxml2. I have to parse an xsd that look as follow: <xs:complexType name="ClassType"> <xs:sequence> <xs:element name="IeplcHeader"> <xs:complexType> <xs:sequence> <xs:element n...
parsing .xsd in python
I need to parse a file .xsd in Python as i would parse an XML. I am using libxml2. I have to parse an xsd that look as follow: <xs:complexType name="ClassType"> <xs:sequence> <xs:element name="IeplcHeader"> <xs:complexType> <xs:sequence> <xs:element name="device-number" type="xs...
[ "If you have to deal with xsd files, maybe also using them to validate xml files I suggest you to pass to lxml that has a good support for XMLSchema files.\nexample code:\nfrom lxml import etree\nfrom cStringIO import StringIO\n\nf = StringIO()\n\nf = StringIO('''\\\n <xsd:schema xmlns:xsd=\"http://www.w3.org/2001/...
[ 9 ]
[]
[]
[ "parsing", "python", "xml", "xsd" ]
stackoverflow_0006775521_parsing_python_xml_xsd.txt
Q: psycopg - Get formatted sql instead of executing I have a piece of Python code, that interacts with a PostgreSQL database via psycopg. All literature warns against doing sql formatting by oneself, and recommends letting the driver do it. E.g.: cur.execute('select name, age from people where name = %s;', ('ann',) ...
psycopg - Get formatted sql instead of executing
I have a piece of Python code, that interacts with a PostgreSQL database via psycopg. All literature warns against doing sql formatting by oneself, and recommends letting the driver do it. E.g.: cur.execute('select name, age from people where name = %s;', ('ann',) ) The driver then formats the sql string. Let's say I...
[ "you wold use function curs.mogrify():\nSQLstring = curs.mogrify('select name, age from people where name = %s;', ('ann',) )\n\n", "edit: it looks like the following is not quite correct, psycopg doesn't use PQexecParams, but is planning to (See my comment below). Leaving answer because it's a useful abstraction,...
[ 22, 1 ]
[]
[]
[ "postgresql", "psycopg", "python" ]
stackoverflow_0006775497_postgresql_psycopg_python.txt
Q: Add timestamps in python How to add The following timestamps month wise in python 2.4 i.e, all the timestamps occurring in month 3 should be added together. For example: the result should be like on 2011-03 total timestamp is 1:00:45 and so on for other months.. 2011-03-07 0:27:41 2011-03-06 0:13:41 2011-03-08 ...
Add timestamps in python
How to add The following timestamps month wise in python 2.4 i.e, all the timestamps occurring in month 3 should be added together. For example: the result should be like on 2011-03 total timestamp is 1:00:45 and so on for other months.. 2011-03-07 0:27:41 2011-03-06 0:13:41 2011-03-08 0:17:40 2011-03-04 0:55:40 20...
[ "How about this:\nimport datetime\nimport re\nfrom collections import defaultdict\nmonths = defaultdict(int)\n# months = {} # for Python 2.4\nwith open(\"test.txt\") as timestamps:\n for line in timestamps:\n month = line[:7]\n time = re.search(r\"(\\d+):(\\d+):(\\d+)\", line)\n if time:\n ...
[ 2, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0006775811_python.txt
Q: What are the Uses of Python? I'm new here, so forgive me if I wrote something wrong here... For which-all fields can Python be used for and to which extent? Can Python be used to make softwares(with GUI, for different platforms ) and web apps? UPDATE*- I want to make simple software ( for my works and enjoyment ...
What are the Uses of Python?
I'm new here, so forgive me if I wrote something wrong here... For which-all fields can Python be used for and to which extent? Can Python be used to make softwares(with GUI, for different platforms ) and web apps? UPDATE*- I want to make simple software ( for my works and enjoyment and a little of web dev. ) I'm ask...
[ "This type of question is a bit of a hornets nest since your mileage may vary and it is largely dependent on opinion. But I'll show a few usecases.\nYou can use Python for near all. The tutorial of Python is a good start.\nYou could start out by learning Python 3.x but be advised that near all real-world stuff is s...
[ 2 ]
[]
[]
[ "programming_languages", "python", "python_3.x", "software_design" ]
stackoverflow_0006776169_programming_languages_python_python_3.x_software_design.txt
Q: Problems accessing Tkinter widgets in a list I'm trying to write a small program where I have a list of Labels and Entry-fields using Python and Tkinter (see code below). Adding the widgets is no problem. However, when I want to use a method of one of the instances (like Insert() on one of the Entry-fields) I can'...
Problems accessing Tkinter widgets in a list
I'm trying to write a small program where I have a list of Labels and Entry-fields using Python and Tkinter (see code below). Adding the widgets is no problem. However, when I want to use a method of one of the instances (like Insert() on one of the Entry-fields) I can't figure out a way to do it. My code looks like th...
[ "Entry(root).grid() returns a NoneType object, so all you are storing in your list is None. You can create the Entry widget first, call grid() and then append it to your list.\nfrom Tkinter import *\nimport random\nroot = Tk()\nattributes = {'Strength':10, 'Dexterity':10, 'Constitution':10, 'Intelligence':10, 'wis...
[ 6, 1 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0006776322_python_tkinter.txt
Q: Forcing a pass-by-reference in Python Boy am I not understanding the python pass-by-reference issues... I have created the extremely useful "unpacker" class which I pass around to various objects that need to unpack from it, yet given how extraordinarily slow it is, I can tell it's making a copy of binaryStr each...
Forcing a pass-by-reference in Python
Boy am I not understanding the python pass-by-reference issues... I have created the extremely useful "unpacker" class which I pass around to various objects that need to unpack from it, yet given how extraordinarily slow it is, I can tell it's making a copy of binaryStr each time I pass a BU object. I know this beca...
[ "The copies are made when you slice a string to get a substring. For example:\n[value, nBytes] = unpackVarInt(self.binaryStr[pos:])\n\nThis will create a copy of the string from index pos to the end, which can take time for a long string. It will be faster if you can determine the number of bytes you actually need ...
[ 4, 3, 0 ]
[]
[]
[ "python", "reference", "string" ]
stackoverflow_0006776503_python_reference_string.txt
Q: Websockets handshake problem I created a websockets server in Python (based in this gist) that works in localhost but not in production server. For example, in localhost I have the following Handshake's messages: //Message from webbrowser client GET / HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: 127.0.0...
Websockets handshake problem
I created a websockets server in Python (based in this gist) that works in localhost but not in production server. For example, in localhost I have the following Handshake's messages: //Message from webbrowser client GET / HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: 127.0.0.1:8080 Origin: null Sec-WebSocket...
[ "\nWhat is the crazy code at the end of the messages?\n\nThe 8 raw bytes at the end of the client handshake is essentially the third key value . The 16 raw bytes sent back by the server is the digest that was generated from the 3 key values in the client handshake. This is how the digest works in the current Hixie-...
[ 3 ]
[]
[]
[ "html", "python", "websocket" ]
stackoverflow_0006769342_html_python_websocket.txt
Q: Python equivalent of Perl's 'w' packing format What format I should use in struct.unpack to decode data packed in perl using w format character (as doc says 'BER compressed integer')? A: I don't believe python's struct module has support for that format, it mainly supports only the encodings that are commonly fo...
Python equivalent of Perl's 'w' packing format
What format I should use in struct.unpack to decode data packed in perl using w format character (as doc says 'BER compressed integer')?
[ "I don't believe python's struct module has support for that format, it mainly supports only the encodings that are commonly found in C structs. BER & DER encodings are generally only encountered within ASN.1 encoded streams... one of the Python ASN.1 modules might be helpful in that case (I should note they are no...
[ 3 ]
[]
[]
[ "perl", "python", "struct" ]
stackoverflow_0006776553_perl_python_struct.txt
Q: Trying to get the Storm ORM to work with Pyramid but I'm having troubles with threads Here's the relevant code from my websites __init__.py from site.models import initialise_sql def main(global_config, **settings): """ This function returns a Pyramid WSGI application """ initialise_sql(settings['databas...
Trying to get the Storm ORM to work with Pyramid but I'm having troubles with threads
Here's the relevant code from my websites __init__.py from site.models import initialise_sql def main(global_config, **settings): """ This function returns a Pyramid WSGI application """ initialise_sql(settings['database.url']) return config.make_wsgi_app() Here's my models/__init__.py from storm.locals...
[ "The web server you're using is multithreaded, not Pyramid itself. It's safer to think about your application in terms of handling requests. Basically you'll have one request per thread at any given point in time, so each active request should be using a different connection to the database. This is handled trivial...
[ 1, 0 ]
[]
[]
[ "orm", "pylons", "pyramid", "python", "storm_orm" ]
stackoverflow_0006714970_orm_pylons_pyramid_python_storm_orm.txt
Q: Python: Modify a dict to make the key a value, and a value the key Say I have a dictionary dict, with the following values: dict1 = {'1': ['a','b', 'c', 'd'], '2': ['e','f', 'g', 'h']} How would I make one of the values the key in a new dictionary, dict1? dict2 = {'d': ['a','b', 'c', '1'], 'h': ['e','f', 'g', '2'...
Python: Modify a dict to make the key a value, and a value the key
Say I have a dictionary dict, with the following values: dict1 = {'1': ['a','b', 'c', 'd'], '2': ['e','f', 'g', 'h']} How would I make one of the values the key in a new dictionary, dict1? dict2 = {'d': ['a','b', 'c', '1'], 'h': ['e','f', 'g', '2']}
[ "In [12]: d = {'1': ['a','b', 'c', 'd'], '2': ['e','f', 'g', 'h']}\n\nIn [13]: dict((v[-1],v[:-1]+[k]) for k,v in d.iteritems())\nOut[13]: {'d': ['a', 'b', 'c', '1'], 'h': ['e', 'f', 'g', '2']}\n\nk is the original key, v is the original value (the list). In the result, v[-1] becomes the new key and v[:-1]+[k] beco...
[ 6, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0006776860_python.txt
Q: Django: Null field with managed=False When a model is not managed by Django, does it matter what the value of null on a field is? A: managed=False no database table creation or deletion operations will be performed for this model. So, Your field is null or not null does not reflect through your code written in m...
Django: Null field with managed=False
When a model is not managed by Django, does it matter what the value of null on a field is?
[ "managed=False no database table creation or deletion operations will be performed for this model. So, Your field is null or not null does not reflect through your code written in models.py\n", "In the model, if you have null=True, then the field can have null or be left blank in a form. If set to False, then the...
[ 2, 1 ]
[]
[]
[ "django", "django_models", "nullable", "python" ]
stackoverflow_0006768738_django_django_models_nullable_python.txt
Q: parallelly execute blocking calls in python I need to do a blocking xmlrpc call from my python script to several physical server simultaneously and perform actions based on response from each server independently. To explain in detail let us assume following pseudo code while True: response=call_to_server1() #...
parallelly execute blocking calls in python
I need to do a blocking xmlrpc call from my python script to several physical server simultaneously and perform actions based on response from each server independently. To explain in detail let us assume following pseudo code while True: response=call_to_server1() #blocking and takes very long time if response...
[ "Use the threading module.\n", "Boilerplate threading code (I can tailor this if you give me a little more detail on what you are trying to accomplish)\ndef run_me(func):\n while not stop_event.isSet():\n response= func() #blocking and takes very long time\n if response==this:\n do that\n\nd...
[ 1, 1, 0, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0006775822_python.txt
Q: Automatically create title from a given text I am trying to write a program that will give an apt title when an article is give ( usually an abstract). Is there any standard algorithm available? A: If you want to do it by hand, you'd have to start with something like word frequency counting, then analyzing phras...
Automatically create title from a given text
I am trying to write a program that will give an apt title when an article is give ( usually an abstract). Is there any standard algorithm available?
[ "If you want to do it by hand, you'd have to start with something like word frequency counting, then analyzing phrases that appear a lot or words that appear around each other. I have only briefly touched this topic in Java, but there seems to be a good book for Python that deals with text analysis:\nText Processin...
[ 3 ]
[]
[]
[ "python", "text_processing" ]
stackoverflow_0006776588_python_text_processing.txt
Q: SWIG C++ Python: wrapping int by reference or pointer I'm trying to wrap some C++ functions into a Python wrapper. For this, it seems SWIG is a nice and easy way. Wrapping works, but I get a problem when passing integers by reference or by pointer. Since Python cannot work with references, SWIG internally converts...
SWIG C++ Python: wrapping int by reference or pointer
I'm trying to wrap some C++ functions into a Python wrapper. For this, it seems SWIG is a nice and easy way. Wrapping works, but I get a problem when passing integers by reference or by pointer. Since Python cannot work with references, SWIG internally converts these to pointers. Some simple example code: Blaat.hpp : #...
[ "I don't think python has the concept of return by reference, but here is my solution:\nBlaat.i:\n%module Blaat\n%include typemaps.i\n%apply int &OUTPUT { int & fA };\n%{\n/* Includes the header in the wrapper code */\n#include \"Blaat.hpp\"\n%}\n\n/* Parse the header file to generate wrappers */\nclass Blaat\n{\np...
[ 7, 2 ]
[]
[]
[ "c++", "integer", "python", "reference", "swig" ]
stackoverflow_0006709608_c++_integer_python_reference_swig.txt
Q: How to set Text Background Color using PyUNO with OpenOffice I have a python script that successfully does a search and replace in an OpenOffice Writer document using PyUNO. I am able to set the CharColor of the replaced text ok but am unable to set the BackColor (background color). found.setPropertyValue( "CharCo...
How to set Text Background Color using PyUNO with OpenOffice
I have a python script that successfully does a search and replace in an OpenOffice Writer document using PyUNO. I am able to set the CharColor of the replaced text ok but am unable to set the BackColor (background color). found.setPropertyValue( "CharColor", 16776960 ) //OK found.setPropertyValue( "BackColor", 167769...
[ "I think property name is CharBackColor not BackColor.\nP.S. \nyou could directly use properties in Python instead of calling setPropertyValue method for example\nfound.CharColor = 16776960\nfound.CharBackColor = 16776960\n\n" ]
[ 1 ]
[]
[]
[ "openoffice_writer", "python", "pyuno" ]
stackoverflow_0006700449_openoffice_writer_python_pyuno.txt
Q: Not able to change a date of my Picasa Web Albums album via Python API I am not able to change a date of my Picasa Web Albums album via Python API. Spent many hours with that and I am hopeless now. Code: # set values remote_album.timestamp.text = str(get_published_as_timestamp()) remote_album.published.text = publ...
Not able to change a date of my Picasa Web Albums album via Python API
I am not able to change a date of my Picasa Web Albums album via Python API. Spent many hours with that and I am hopeless now. Code: # set values remote_album.timestamp.text = str(get_published_as_timestamp()) remote_album.published.text = published + 'T04:01:01.000Z' # test before print remote_album.published print r...
[ "I was able to change my album timestamp as follows:\nalbum.timestamp = gdata.photos.Timestamp(\n text=\"%d000\" % time.mktime((2010, 02, 03, 12, 00, 00, -1, -1, -1)))\nupdated_album = gd_client.Put(\n album, \n album.GetEditLink().href, \n converter=gdata.photos.AlbumEntryFromString)\n\nObviously my co...
[ 2 ]
[]
[]
[ "api", "gdata", "picasa", "python" ]
stackoverflow_0004559030_api_gdata_picasa_python.txt
Q: Defining appropriate number of processes I have a python code treating a lot of apache logs (decompress, parse, crunching numbers, regexping etc). One parent process which takes a list of files (up to few millions), and sends a list of files to parse to workers, using multiprocess pool. I wonder, if there is any ...
Defining appropriate number of processes
I have a python code treating a lot of apache logs (decompress, parse, crunching numbers, regexping etc). One parent process which takes a list of files (up to few millions), and sends a list of files to parse to workers, using multiprocess pool. I wonder, if there is any guidelines / benchmarks / advices which can he...
[ "\nI wonder, if there is any guidelines / benchmarks / advices which can help me to estimate ideal number of child process ? \n\nNo.\n\nhaving one process per core is better than launching few hundreds of them?\n\nYou can never know in advance.\nThere are too many degrees of freedom. \nYou can only discover it emp...
[ 1, 1, 0, 0 ]
[]
[]
[ "benchmarking", "multithreading", "performance", "python" ]
stackoverflow_0006774561_benchmarking_multithreading_performance_python.txt
Q: A loop within tkinter - HELP! this is my first time using this forum, hopefully, i can get a quick response with a detailed explanation. Running: Python 3.2 Tkinter 8.5 & Windows7 x64 My code: from tkinter import * import tkinter.messagebox class Application(Frame): def __init__(self, master): super(Ap...
A loop within tkinter - HELP!
this is my first time using this forum, hopefully, i can get a quick response with a detailed explanation. Running: Python 3.2 Tkinter 8.5 & Windows7 x64 My code: from tkinter import * import tkinter.messagebox class Application(Frame): def __init__(self, master): super(Application, self).__init__(master) ...
[ "You can put the original buttons into a list:\ndef level_one(self):\n ...\n self.game_buttons = []\n\n for btn_index in range(9):\n bg = \"red\" # change this to something based on the index\n next_button = Button(self, bg = bg, width = 20, height = 10)\n next_button['command'] = (lam...
[ 3 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0006770228_python_tkinter.txt
Q: Want to display an image I am having a slight problem. I want a django app that can upload and display an image. Currently, it can upload the image but I cannnot display that image. So for example, {{comment.photo}} will print out the path C:/Users/AQUIL/Desktop/myproject/images/P1000992.JPG. But I want to see th...
Want to display an image
I am having a slight problem. I want a django app that can upload and display an image. Currently, it can upload the image but I cannnot display that image. So for example, {{comment.photo}} will print out the path C:/Users/AQUIL/Desktop/myproject/images/P1000992.JPG. But I want to see that image on the screen. Not th...
[ "{% if comment.photo %} <img src=\"{{ comment.photo.url }}\" alt=\"Photo\" /> {% endif %}\n\nSee Geoffrey's comment for how to upload the image correctly.\n", "The upload parameter of ImageField must be a local path, so replace:\nphoto = models.ImageField(upload_to='C:/Users/AQUIL/Desktop/myproject/media/images',...
[ 4, 4, 0 ]
[]
[]
[ "database", "django", "mysql", "python", "sql" ]
stackoverflow_0006777732_database_django_mysql_python_sql.txt
Q: Python: deeply copy ast node tree I'm trying to use deepcopy (from the copy module) to deeply copy a node tree from the ast module. This doesn't seem to work. I'm getting strange errors like TypeError: required field "name" missing from FunctionDef when I use the copied result (and I checked it; it really is missi...
Python: deeply copy ast node tree
I'm trying to use deepcopy (from the copy module) to deeply copy a node tree from the ast module. This doesn't seem to work. I'm getting strange errors like TypeError: required field "name" missing from FunctionDef when I use the copied result (and I checked it; it really is missing in the copied node), so it didn't co...
[ "Sorry, I was wrong. copy.deepcopy seems to work correct. The reason I thought it wouldn't work is because of this very odd behavior:\nimport ast, copy\nn = ast.FunctionDef(\n name=None,\n args=ast.arguments(args=[], vararg=None, kwarg=None, defaults=[]),\n body=[], decorator_list=[])\nn.name =...
[ 11 ]
[]
[]
[ "abstract_syntax_tree", "copy", "deep_copy", "python" ]
stackoverflow_0006777794_abstract_syntax_tree_copy_deep_copy_python.txt
Q: how to read info from binary file I have a binary file and specifications: after 'abst' (0x61627374): var1 Unsigned 8-bit integer var2 Unsigned 24-bit integer var3 Sequence of Unicode 8-bit characters (UTF-8), terminated with 0x00 How to read var1,var2,var3 from file ? A: Quick and dirty and not tested: # as...
how to read info from binary file
I have a binary file and specifications: after 'abst' (0x61627374): var1 Unsigned 8-bit integer var2 Unsigned 24-bit integer var3 Sequence of Unicode 8-bit characters (UTF-8), terminated with 0x00 How to read var1,var2,var3 from file ?
[ "Quick and dirty and not tested:\n# assumption: the file is small enough to fit into the RAM\n# and also that 'abst' does not occur in the dataset\nfor hunk in input.split('abst')[1:]: # skip first hunk, since it is the stuff befor the first 'abst' occurence\n var1 = ord(hunk[0])\n var2 = ord(hunk[1]) + ord(h...
[ 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0006761461_python.txt
Q: easy_install virtualenv on python 2.4 I'm trying to install the latest version of virtualenv using easy_install on a RHEL5.6 with python 2.4 and I'm receiving the following error. File "/usr/lib/python2.4/site-packages/virtualenv-1.6.3-py2.4.egg/virtualenv.py", line 500 finally: ^ SyntaxError: invalid sy...
easy_install virtualenv on python 2.4
I'm trying to install the latest version of virtualenv using easy_install on a RHEL5.6 with python 2.4 and I'm receiving the following error. File "/usr/lib/python2.4/site-packages/virtualenv-1.6.3-py2.4.egg/virtualenv.py", line 500 finally: ^ SyntaxError: invalid syntax I've checked the virtualenv code http...
[ "\nChanged in version 2.5: In previous versions of Python,\n try...except...finally did not work. try...except had to be nested in\n try...finally.\n\nLooks like the latest virtualenv is not compatible with python <2.5\n" ]
[ 1 ]
[]
[]
[ "easy_install", "python", "virtualenv" ]
stackoverflow_0006778976_easy_install_python_virtualenv.txt
Q: Python: getting segmentation fault when using compile/eval Code: import ast globalsDict = {} fAst = ast.FunctionDef( name="foo", args=ast.arguments(args=[], vararg=None, kwarg=None, defaults=[]), body=[], decorator_list=[]) exprAst = ast.Interactive(body=[fAst]) ast.fix_missing_locations(exprAst) co...
Python: getting segmentation fault when using compile/eval
Code: import ast globalsDict = {} fAst = ast.FunctionDef( name="foo", args=ast.arguments(args=[], vararg=None, kwarg=None, defaults=[]), body=[], decorator_list=[]) exprAst = ast.Interactive(body=[fAst]) ast.fix_missing_locations(exprAst) compiled = compile(exprAst, "<foo>", "single") eval(compiled, glob...
[ "I guess that your function definition must not have an empty body. I tested your code by adding a no-op statement as the function body:\nfAst = ast.FunctionDef(\n # ...\n body=[ast.Pass()],\n # ...\n\nAnd the segmentation fault is gone; output is:\n<function foo at 0x022DB3F0>\nIf I am correct, this coul...
[ 5 ]
[]
[]
[ "compilation", "cpython", "pypy", "python", "segmentation_fault" ]
stackoverflow_0006778816_compilation_cpython_pypy_python_segmentation_fault.txt
Q: How to stop all threads on KeyboardInterupt with Python's workerpool This is my Job class: class QueryJob(workerpool.Job): "Job for downloading a given URL." def __init__(self, query): self.query = query # The query we'll need to download when the job runs def run(self): try: ...
How to stop all threads on KeyboardInterupt with Python's workerpool
This is my Job class: class QueryJob(workerpool.Job): "Job for downloading a given URL." def __init__(self, query): self.query = query # The query we'll need to download when the job runs def run(self): try: // Query something... except (Exception, KeyboardInterrupt, Sys...
[ "I found this:\nhttp://code.activestate.com/recipes/577187-python-thread-pool/\nIt seems to function just as workerpool does, but actually will listen to the KeyboardInterrupt and halt the script.\nThis works for me, so I'm answering my own question with it. I'm still up for finding a way to use workerpool, but fo...
[ 0 ]
[]
[]
[ "multithreading", "python", "threadpool" ]
stackoverflow_0006778249_multithreading_python_threadpool.txt
Q: XPath failing using lxml I have used xpaths to great effect with both HTML and XML before, but can't seem to get any results this time. The data is from http://www.ahrefs.com/api/, under "Example of an answer", saved to an .xml file My code: from lxml import etree doc = etree.XML(open('example.xml').read()) print ...
XPath failing using lxml
I have used xpaths to great effect with both HTML and XML before, but can't seem to get any results this time. The data is from http://www.ahrefs.com/api/, under "Example of an answer", saved to an .xml file My code: from lxml import etree doc = etree.XML(open('example.xml').read()) print doc.xpath('//result') which d...
[ "You need to take the namespace of the document into account:\nfrom lxml import etree\n\ndoc = etree.parse('example.xml')\nprint doc.xpath('//n:result',\n namespaces={'n': \"http://ahrefs.com/schemas/api/links/1\"})\n\n=>\n[<Element {http://ahrefs.com/schemas/api/links/1}result at 0xc8d670>, \n <Elem...
[ 1, 0 ]
[]
[]
[ "lxml", "python", "xml" ]
stackoverflow_0006778840_lxml_python_xml.txt
Q: Can I avoid permission_required decorator on Django testing? I am testing a set of Django applications which make extensive use of the 'permission_required' decorator. This derives in a 302 HTTP response in most of the views that I have. My question is: there is any way to avoid or deactivate the 'permission_requi...
Can I avoid permission_required decorator on Django testing?
I am testing a set of Django applications which make extensive use of the 'permission_required' decorator. This derives in a 302 HTTP response in most of the views that I have. My question is: there is any way to avoid or deactivate the 'permission_required' in testing, so I can get a 200 response when I call my views,...
[ "Just log in with a superuser in your test case setUp method\n\nfrom django.test import TestCase\nfrom django.contrib.auth.models import User\n\nclass TestThatNeedsLogin(TestCase):\n def setUp(self):\n User.objects.create_superuser(\n 'user1',\n 'user1@example.com',\n 'psw...
[ 5, 1, 0 ]
[]
[]
[ "django", "python", "testing" ]
stackoverflow_0006772676_django_python_testing.txt
Q: utf-16 file seeking in python. how? For some reason i can not seek my utf16 file. It produces 'UnicodeException: UTF-16 stream does not start with BOM'. My code: f = codecs.open(ai_file, 'r', 'utf-16') seek = self.ai_map[self._cbClass.Text] #seek is valid int f.seek(seek) while True: ln = f.readline().strip()...
utf-16 file seeking in python. how?
For some reason i can not seek my utf16 file. It produces 'UnicodeException: UTF-16 stream does not start with BOM'. My code: f = codecs.open(ai_file, 'r', 'utf-16') seek = self.ai_map[self._cbClass.Text] #seek is valid int f.seek(seek) while True: ln = f.readline().strip() I tried random stuff like first reading...
[ "Well, the error message is telling you why: it's not reading a byte order mark. The byte order mark is at the beginning of the file. Without having read the byte order mark, the UTF-16 decoder can't know what order the bytes are in. Apparently it does this lazily, the first time you read, instead of when you open ...
[ 26 ]
[]
[]
[ "python", "utf_16" ]
stackoverflow_0006779315_python_utf_16.txt
Q: Python File Creation Date & Rename - Request for Critique Scenario: When I photograph an object, I take multiple images, from several angles. Multiplied by the number of objects I "shoot", I can generate a large number of images. Problem: Camera generates images identified as, 'DSCN100001', 'DSCN100002", etc. Cry...
Python File Creation Date & Rename - Request for Critique
Scenario: When I photograph an object, I take multiple images, from several angles. Multiplied by the number of objects I "shoot", I can generate a large number of images. Problem: Camera generates images identified as, 'DSCN100001', 'DSCN100002", etc. Cryptic. I put together a script that will prompt for directory sp...
[ "The way you're doing it looks Pythonic. A few alternatives (not necessarily suggestions):\nYou could skip os.chdir(target) and do os.path.join(target, filename) in the loop.\nYou could do strftime('{0}-%Y-%m-%d-%H:%M:%S.jpg'.format(prefix)) to avoid string concatenation. This is the only one I'd reccomend.\nYou co...
[ 9, 3, 3 ]
[]
[]
[ "creation", "date", "file", "python", "rename" ]
stackoverflow_0006778923_creation_date_file_python_rename.txt
Q: ValueError when using strptime to get a datetime object Im trying to convert a date string to a datetime object as shown below : dt = datetime.datetime.strptime('2011-07-15 13:00:00+00:00', '%Y-%m-%d %H:%M:%S') But,im getting the error below : Traceback (most recent call last): File "", line 1, in File "...
ValueError when using strptime to get a datetime object
Im trying to convert a date string to a datetime object as shown below : dt = datetime.datetime.strptime('2011-07-15 13:00:00+00:00', '%Y-%m-%d %H:%M:%S') But,im getting the error below : Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/_strptime.py", line 328, in _strptime ...
[ "How about ...\n dt_string = '2011-07-15 13:00:00+00:00'\n new_dt = dt_string[:19]\n dt = datetime.datetime.strptime(new_dt, '%Y-%m-%d %H:%M:%S')\n\n", "dt = datetime.datetime.strptime('2011-07-15 13:00:00+00:00', '%Y-%m-%d %H:%M:%S+%z')\n\n" ]
[ 15, 4 ]
[ ">>> datetime.datetime.strptime('2011-07-15 13:00:00', '%Y-%m-%d %H:%M:%S'\ndatetime.datetime(2011, 7, 15, 13, 0)\n\n" ]
[ -7 ]
[ "datetime", "python" ]
stackoverflow_0006707398_datetime_python.txt
Q: How do I interleave strings in Python? How do I interleave strings in Python? Given s1 = 'abc' s2 = 'xyz' How do I get axbycz? A: Here is one way to do it >>> s1 = "abc" >>> s2 = "xyz" >>> "".join(i for j in zip(s1, s2) for i in j) 'axbycz' It also works for more than 2 strings >>> s3 = "123" >>> "".join(i for...
How do I interleave strings in Python?
How do I interleave strings in Python? Given s1 = 'abc' s2 = 'xyz' How do I get axbycz?
[ "Here is one way to do it\n>>> s1 = \"abc\"\n>>> s2 = \"xyz\"\n>>> \"\".join(i for j in zip(s1, s2) for i in j)\n'axbycz'\n\nIt also works for more than 2 strings\n>>> s3 = \"123\"\n>>> \"\".join(i for j in zip(s1, s2, s3) for i in j)\n'ax1by2cz3'\n\nHere is another way\n>>> \"\".join(\"\".join(i) for i in zip(s1,s...
[ 16, 2, 0 ]
[]
[]
[ "python" ]
stackoverflow_0003083829_python.txt
Q: PyQt4: Trigger click on a javascript link I am trying to scrape some web pages in Python were the information is generated by Javascript. I managed to retrieve the information generated on page load by using a headless browser with PyQt4 (example here: http://blog.motane.lu/2009/07/07/downloading-a-pages-content-w...
PyQt4: Trigger click on a javascript link
I am trying to scrape some web pages in Python were the information is generated by Javascript. I managed to retrieve the information generated on page load by using a headless browser with PyQt4 (example here: http://blog.motane.lu/2009/07/07/downloading-a-pages-content-with-python-and-webkit/) But now, I'm trying to ...
[ "I guess you need Form Extractor Example. The trick is that you can expose any python object to javascript and call its methods. Pytonic version of this example could be found in PyQt distribution.\n" ]
[ 0 ]
[]
[]
[ "javascript", "pyqt", "python", "qwebview", "webkit" ]
stackoverflow_0006724991_javascript_pyqt_python_qwebview_webkit.txt
Q: how do i process html form using pyqt? I am using QTextBrowser to display static html documents. I want to embed forms inside these documents but i can't seem to figure out how am going to process these forms using python or pyqt. The application am building is a desktop app so QWebView ain't much of an option. A...
how do i process html form using pyqt?
I am using QTextBrowser to display static html documents. I want to embed forms inside these documents but i can't seem to figure out how am going to process these forms using python or pyqt. The application am building is a desktop app so QWebView ain't much of an option.
[ "Consider whether you need to do it in HTML. If you don't, it will be much easier. If possible, use the standard Qt form components.\nIf for some reason you do need to do it in an actual HTML document with HTML forms, you will not be able to do it with a QTextBrowser. Be aware that QTextBrowser has limited function...
[ 0, 0 ]
[ "consider implementing a Python server in your desktop application (read e.g. about the SimpleHTTPServer module here).\nyou can 'serve' your static html or forms containing pages to the browser within your application (requesting pages from 'localhost/...' ) and receive get or post requests.\n" ]
[ -1 ]
[ "pyqt4", "python", "qt4" ]
stackoverflow_0006741528_pyqt4_python_qt4.txt
Q: get() excepts MultipleObjectsReturned on a field marked unique I have a field on a model that's marked unique: uid = models.CharField(max_length=255, blank=False, null=False, unique=True) I'm trying to use get() to get the one Profile that should match this uid: UserProfile.objects.get(uid=fr_uid) The problem is...
get() excepts MultipleObjectsReturned on a field marked unique
I have a field on a model that's marked unique: uid = models.CharField(max_length=255, blank=False, null=False, unique=True) I'm trying to use get() to get the one Profile that should match this uid: UserProfile.objects.get(uid=fr_uid) The problem is that this line raises a MultipleObjectsReturned exception for some ...
[ "Have you made any modifications to the manager? Or are you doing any sort of filtering on the queryset before calling get() on it? In particular, using Q objects for OR boolean searches can often result in the same object being returned multiple times. If that's the case, call distinct() on the queryset before get...
[ 1 ]
[]
[]
[ "django", "mysql", "python" ]
stackoverflow_0006780636_django_mysql_python.txt
Q: Is it possible to subclass Lock() objects in Python? If not, other ways to debug deadlock? So, I've got a multithreaded python program, which is currently suffering from deadlock. I was going to log lock acquiring by subclassing threading.Lock objects: import traceback class DebugLock(threading.Lock): def acqu...
Is it possible to subclass Lock() objects in Python? If not, other ways to debug deadlock?
So, I've got a multithreaded python program, which is currently suffering from deadlock. I was going to log lock acquiring by subclassing threading.Lock objects: import traceback class DebugLock(threading.Lock): def acquire(self): print >>sys.stderr, "acquired", self #traceback.print_tb thre...
[ "You could just use the \"has a lock\" versus \"is a lock\" approach, like so:\nimport threading, traceback, sys\nclass DebugLock(object):\n def __init__(self):\n self._lock = threading.Lock()\n def acquire(self):\n print(\"acquired\", self)\n #traceback.print_tb\n self._lock.acqui...
[ 18, 4, 3 ]
[]
[]
[ "deadlock", "multithreading", "oop", "python", "thread_safety" ]
stackoverflow_0006780613_deadlock_multithreading_oop_python_thread_safety.txt
Q: Python Wrap Class Method I'm trying to create an object with a run method that will be wrapped by a _wrap_run method. I'd like to be able to call the method and it's wrapper by simply typing instance.run() and I'd like to be able to subclass the object so I can override the run() method and have it still execute t...
Python Wrap Class Method
I'm trying to create an object with a run method that will be wrapped by a _wrap_run method. I'd like to be able to call the method and it's wrapper by simply typing instance.run() and I'd like to be able to subclass the object so I can override the run() method and have it still execute the wrapper. More simply put,...
[ "Use a Metaclass.\nclass MetaClass(type):\n @staticmethod\n def wrap(run):\n \"\"\"Return a wrapped instance method\"\"\"\n def outer(self):\n print \"PRE\",\n return_value = run(self)\n print \"POST\"\n return return_value\n return outer\n d...
[ 26, 5, 2, 0 ]
[]
[]
[ "class", "methods", "python", "wrapper" ]
stackoverflow_0006780907_class_methods_python_wrapper.txt
Q: Read Disconected Graph in igraph for python I'd like to know the best way to read a disconected undirected graph using igraph for python. For instance, if I have the simple graph in which 0 is linked to 1 and 2 is a node not connected to any other. I couldn't get igraph to read it from a edgelist format(Graph.Read...
Read Disconected Graph in igraph for python
I'd like to know the best way to read a disconected undirected graph using igraph for python. For instance, if I have the simple graph in which 0 is linked to 1 and 2 is a node not connected to any other. I couldn't get igraph to read it from a edgelist format(Graph.Read_Edgelist(...)), because every line must be an ed...
[ "There's the LGL format which allows isolated vertices (see Graph.Read_LGL). The format looks like this:\n# nodeID\nnodeID2\nnodeID3\n# nodeID2\nnodeID4\nnodeID5\nnodeID\n# isolatedNode\n# nodeID5\n\nI think you get the basic idea; lines starting with a hash mark indicate that a new node is being defined. After thi...
[ 1 ]
[]
[]
[ "graph", "igraph", "python" ]
stackoverflow_0006780500_graph_igraph_python.txt
Q: Storing and reloading large multidimensional data sets in Python I'm going to be running a large number of simulations producing a large amount of data that needs to be stored and accessed again later. Output data from my simulation program is written to text files (one per simulation). I plan on writing a Python ...
Storing and reloading large multidimensional data sets in Python
I'm going to be running a large number of simulations producing a large amount of data that needs to be stored and accessed again later. Output data from my simulation program is written to text files (one per simulation). I plan on writing a Python program that reads these text files and then stores the data in a form...
[ "Why not using a big table for keep all the 500 millions of entries? If you use on-the-flight compression (Blosc compressor recommended here), most of the duplicated entries will be deduped, so the overhead in storage is kept under a minimum. I'd recommend give this a try; sometimes the simple solution works best...
[ 2, 0, 0 ]
[]
[]
[ "data_warehouse", "multidimensional_array", "pytables", "python" ]
stackoverflow_0005060070_data_warehouse_multidimensional_array_pytables_python.txt
Q: Why is this code behaving differently across various distros/Unixes? The following (a small C program and a python script that calls it) behave differently across various Unixes. In some of them (e.g. Debian stable), the C app gets the signal, the message is printed fine from the signal handler and the script f...
Why is this code behaving differently across various distros/Unixes?
The following (a small C program and a python script that calls it) behave differently across various Unixes. In some of them (e.g. Debian stable), the C app gets the signal, the message is printed fine from the signal handler and the script finishes. In others (e.g. a two year-old Ubuntu and an OpenBSD) the signal...
[ "Just because Python uses /bin/sh doesn't mean it's the same shell on all systems. \n/bin/sh is almost always an alias in the form of a symbolic link: the real shell could be busybox, bash, ash, csh, ksh, dash, zsh, tcsh, or something crazy(er).\nConfirm that you're actually using the same shell on all the systems,...
[ 6, 0 ]
[]
[]
[ "python", "shell", "signals", "subprocess", "unix" ]
stackoverflow_0006773456_python_shell_signals_subprocess_unix.txt
Q: How do I enable external access to a python fcgi app? I have a simple web app which displays a simple hello world. I can access the app through the web browser (127.0.0.1:3000/test/hello), but cannot access it using the local ip the app is running on, or using my external ip (i have forwarded the port appropriatel...
How do I enable external access to a python fcgi app?
I have a simple web app which displays a simple hello world. I can access the app through the web browser (127.0.0.1:3000/test/hello), but cannot access it using the local ip the app is running on, or using my external ip (i have forwarded the port appropriately on my router). server.modules += ( "mod_fastcgi" ) serv...
[ "Set server.bind to the local network IP of the server rather than localhost 127.0.0.1. Also check that port 3000 is not blocked between hosts on your network.\nBy binding to localhost you are bound to the loopback interface of your machine, which means that lighttpd is not even listening on the network at all.\nAl...
[ 1, 1, 0 ]
[]
[]
[ "fastcgi", "lighttpd", "python" ]
stackoverflow_0006781469_fastcgi_lighttpd_python.txt
Q: How to do simple value check with error message in Deform/Colander I'm implementing a simple 'tick to agree to terms and conditions box' in Deform/Colander. So, I simply want to check that the box is checked and have an error message saying 'You must agree to T&C'. I understand that I can use: colander.OneOf([True...
How to do simple value check with error message in Deform/Colander
I'm implementing a simple 'tick to agree to terms and conditions box' in Deform/Colander. So, I simply want to check that the box is checked and have an error message saying 'You must agree to T&C'. I understand that I can use: colander.OneOf([True]) to ensure the box is ticked. However, OneOf does not allow for a cu...
[ "Use a custom validator:\ndef t_and_c_validator(node, value):\n if not value:\n raise Invalid(node, 'You must agree to the T&C')\n\nclass MySchema(colander.Schema):\n t_and_c = colander.SchemaNode(\n colander.Boolean(),\n description='Terms and Conditions',\n ...
[ 5 ]
[]
[]
[ "colander", "deform", "pyramid", "python" ]
stackoverflow_0006775005_colander_deform_pyramid_python.txt
Q: Why does Idle keep crashing? (Mac) I just installed python 2.6 on Mac OS X (Snow Leopard) and when I start IDLE it keeps quitting! I removed all the installations of python by: rm -rf /Library/Frameworks/Python.Framework and then re-installed it and I still get the same problem :( Any ideas what it might be? Th...
Why does Idle keep crashing? (Mac)
I just installed python 2.6 on Mac OS X (Snow Leopard) and when I start IDLE it keeps quitting! I removed all the installations of python by: rm -rf /Library/Frameworks/Python.Framework and then re-installed it and I still get the same problem :( Any ideas what it might be? Thanks
[ "You are undoubtedly using a version of Python that is dynamically linking to the Apple-supplied Tcl/Tk 8.5 in OS X 10.6. That version of Tcl/Tk is seriously flawed. There are several easy ways to avoid the problem, the simplest being to install a current Python 2.7 (or now out-of-date 2.6) installer from python....
[ 5 ]
[]
[]
[ "macos", "python", "python_2.6", "python_idle" ]
stackoverflow_0006781558_macos_python_python_2.6_python_idle.txt
Q: Dynamic per-request database connections in Django I'm building a centralised django application that will be interacting with a dynamic number of databases with basically identical schema. These dbs are also used by a couple legacy applications, some of which are in PHP. Our solution to avoid multiple silos of ...
Dynamic per-request database connections in Django
I'm building a centralised django application that will be interacting with a dynamic number of databases with basically identical schema. These dbs are also used by a couple legacy applications, some of which are in PHP. Our solution to avoid multiple silos of db credentials is to store this info in generic setting ...
[ "rereading the file is a heavy penalty to pay when it's unlikely that the file has changed.\nMy usual approach is to use INotify to watch for configuration file changes, rather than trying to read a file on every request. Additionally, I tend to keep a \"current\" configuration, parsed from the file, and only repl...
[ 2, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0006780827_django_python.txt
Q: SQLAlchemy One-to-Many relationship on single table inheritance - declarative Basically, I have this model, where I mapped in a single table a "BaseNode" class, and two subclasses. The point is that I need one of the subclasses, to have a one-to-many relationship with the other subclass. So in sort, it is a relati...
SQLAlchemy One-to-Many relationship on single table inheritance - declarative
Basically, I have this model, where I mapped in a single table a "BaseNode" class, and two subclasses. The point is that I need one of the subclasses, to have a one-to-many relationship with the other subclass. So in sort, it is a relationship with another row of different class (subclass), but in the same table. How d...
[ "I was struggling through this myself earlier. I was able to get this self-referential relationship working:\nclass Employee(Base):\n __tablename__ = 'employee'\n id = Column(Integer, primary_key=True)\n name = Column(String(64), nullable=False)\nEmployee.manager_id = Column(Integer, ForeignKey(Employee.id))\nE...
[ 18 ]
[]
[]
[ "orm", "python", "sqlalchemy" ]
stackoverflow_0006782133_orm_python_sqlalchemy.txt
Q: Can I use md5 authentication with psycopg2? After two hours of reading documentation, source code and help-threads, I'm giving up. I can't get psycopg2 to authenticate with a md5-string. According to this thread I don't have to anything besides enabling md5-auth in pg_hba.conf. This is my current pg_hba.conf: # TY...
Can I use md5 authentication with psycopg2?
After two hours of reading documentation, source code and help-threads, I'm giving up. I can't get psycopg2 to authenticate with a md5-string. According to this thread I don't have to anything besides enabling md5-auth in pg_hba.conf. This is my current pg_hba.conf: # TYPE DATABASE USER CIDR-ADDRESS ...
[ "Psycopg2 is a wrapper around libpq, that is, the Postgres client library, which implements this already. No need to hash you password. It will be hashed (by libpq) before being sent over the wire.\n\nIt's worth noting that libpq actually sends the MD5 sum of your password salted with your user name as well as the ...
[ 7 ]
[]
[]
[ "authentication", "md5", "psycopg2", "python" ]
stackoverflow_0006782026_authentication_md5_psycopg2_python.txt
Q: Is it possible to run doctests using unit2 I recently switched from nose to the new unittest2 package for my python unit testing needs. It does everything I want, except from the fact that I can't get its "discover" command to recognize the doctests in my code - I still have to use nose to run them. Is this not im...
Is it possible to run doctests using unit2
I recently switched from nose to the new unittest2 package for my python unit testing needs. It does everything I want, except from the fact that I can't get its "discover" command to recognize the doctests in my code - I still have to use nose to run them. Is this not implemented or is there something I'm missing here...
[ "Unit2 only discovers regular Python tests. In order to have it run your doctests, I'm afraid you would need to write some minimal boilerplate. Also: the upcoming plugin architecture will make it easy to automate some of these tasks.\nIn the meantime. you might want to take a look at tox (described here by unittes...
[ 3, 1 ]
[]
[]
[ "nose", "python", "testing", "unittest2" ]
stackoverflow_0003342193_nose_python_testing_unittest2.txt
Q: How to 'print' the result of a division in Ironpython (Python.net)? I need to print the result of 'x/y' but it always returns '0'. When I print 'x' it tells me that correctly, when I print 'y' it tells me that correctly but when I print 'x/y' it says 0. Here is my code: import random y = 0 x = 0 p = 1 while True...
How to 'print' the result of a division in Ironpython (Python.net)?
I need to print the result of 'x/y' but it always returns '0'. When I print 'x' it tells me that correctly, when I print 'y' it tells me that correctly but when I print 'x/y' it says 0. Here is my code: import random y = 0 x = 0 p = 1 while True: i = [random.randint(1,100), random.randint(1,100), random.rand...
[ "If x and y are both integers, Python always does integer division. So if the result is 0.something, Python will show 0.\nYou need to convert them to floats if you want to do float division:\nprint float(x) / float(y)\n\nor Decimal objects:\nfrom decimal import Decimal\nprint Decimal(x) / Decimal(y)\n\n", "Do thi...
[ 6, 5, 4, 1 ]
[]
[]
[ "division", "ironpython", "printing", "python", "random" ]
stackoverflow_0006781898_division_ironpython_printing_python_random.txt
Q: Who takes care of freeing MIB_TCPROW_OWNER_PID structure when calling GetExtendedTcpTable via ctypes in Python? I'm calling GetExtendedTcpTable via ctypes in Python. For this I'm declaring the following structures: class MIB_TCPROW_OWNER_PID(ctypes.Structure): _fields_ = [('dwState', DWORD), ...
Who takes care of freeing MIB_TCPROW_OWNER_PID structure when calling GetExtendedTcpTable via ctypes in Python?
I'm calling GetExtendedTcpTable via ctypes in Python. For this I'm declaring the following structures: class MIB_TCPROW_OWNER_PID(ctypes.Structure): _fields_ = [('dwState', DWORD), ('dwLocalAddr', DWORD), ('dwLocalPort', DWORD), ('dwRemoteAddr', DWORD), ...
[ "You have to allocate sufficient space in table before calling GetExtendedTcpTable. And then when that call returns you need to deallocate it, although ctypes will do that for you.\nIf you have obtained ANY_SIZE by calling GetExtendedTcpTable with pTcpTable as NULL then you have nothing special to do. You create a...
[ 1 ]
[]
[]
[ "ctypes", "memory", "python" ]
stackoverflow_0006782549_ctypes_memory_python.txt
Q: SQLAlchemy: Hybrid Value Object, Query Tuple Results I am trying to follow the examples from the documentation on building custom comparators using hybrid value objects, class CaseInsensitiveWord(Comparator): "Hybrid value representing a lower case representation of a word." def __init__(self, word): ...
SQLAlchemy: Hybrid Value Object, Query Tuple Results
I am trying to follow the examples from the documentation on building custom comparators using hybrid value objects, class CaseInsensitiveWord(Comparator): "Hybrid value representing a lower case representation of a word." def __init__(self, word): if isinstance(word, basestring): self.word...
[ "While it's not a fully baked Python feature, a convention is to comment attributes in the same way as functions and methods, i.e. by placing a string below the attribute. Comments like the above are picked up by tools like Sphinx. You can see examples of these docstrings getting generated in places like http...
[ 4 ]
[]
[]
[ "pylons", "python", "sqlalchemy" ]
stackoverflow_0006782381_pylons_python_sqlalchemy.txt
Q: In SciPy, fancy indexing for csr_matrices I am new to Python, so forgive me ahead of time if this is an elementary question, but I have searched around and have not found a satisfying answer. I am trying to do the following using NumPy and SciPy: I,J = x[:,0], x[:1] # x is a two column array of (r,c)...
In SciPy, fancy indexing for csr_matrices
I am new to Python, so forgive me ahead of time if this is an elementary question, but I have searched around and have not found a satisfying answer. I am trying to do the following using NumPy and SciPy: I,J = x[:,0], x[:1] # x is a two column array of (r,c) pairs V = ones(len(I)) G = sparse.coo_matrix((...
[ "In addition to doing something like G = G / G, you can operate on G.data.\nSo, in your case, doing either:\nG.data = np.ones(G.nnz)\n\nor \nG.data[G.data != 0] = 1\n\nWill do what you want. This is more flexible, as it allows you to preform other types of filters (e.g. G.data[G.data > 0.9] = 1 or G.data = np.ran...
[ 6 ]
[]
[]
[ "numpy", "python", "scipy" ]
stackoverflow_0006782556_numpy_python_scipy.txt
Q: Idiomatic way to port C bitfiddling to Python How would you port the following C code in a Pythonic way (especially the bit fiddling part in Get2, Get3, ...) switch(mem[pos-1]) { ... case 0x10: pos+=Get2(&mem[pos+0x02])+0x04; break; case 0x11: pos+=Get3(&mem[pos+0x0F])+0x12; break; case 0x16: pos+=Get4(&me...
Idiomatic way to port C bitfiddling to Python
How would you port the following C code in a Pythonic way (especially the bit fiddling part in Get2, Get3, ...) switch(mem[pos-1]) { ... case 0x10: pos+=Get2(&mem[pos+0x02])+0x04; break; case 0x11: pos+=Get3(&mem[pos+0x0F])+0x12; break; case 0x16: pos+=Get4(&mem[pos+0x00])+0x04; break; ... case 0x20: pos+=0...
[ "If you're just getting one unsigned byte, just do\nx = ord(mem[pos - 1])\n\non Python 2 or \nx = mem[pos - 1]\n\non Python 3.\nInstead of select / case, You want a dictionary.\npositions = {0x10: do_10, 0x11: do_12, 0x16: do_16}\n\nWhere do_10 etc. are functions:\ndef do_10(pos):\n # This actually would need an...
[ 2, 1, 1 ]
[]
[]
[ "bit_manipulation", "c", "python" ]
stackoverflow_0006779900_bit_manipulation_c_python.txt
Q: Removing image links from a list How would I go about removing image links (e.g. http://www.example.com/example.png) from a list of links? This includes .png, .jpg, and .gif file formats. A: list.remove('http://www.example.com/example.png') A: I assume you're after something like this: for idx in xrange(len(u...
Removing image links from a list
How would I go about removing image links (e.g. http://www.example.com/example.png) from a list of links? This includes .png, .jpg, and .gif file formats.
[ "list.remove('http://www.example.com/example.png')\n", "I assume you're after something like this:\nfor idx in xrange(len(url_list) - 1, -1, -1):\n url = url_list[idx]\n ext = url.rpartition('.')[-1]\n if ext in ('png', 'gif', 'jpg'):\n del url_list[idx]\n\n", "import re\nregex = re.compile('\\....
[ 1, 1, 1, 0, 0 ]
[]
[]
[ "image", "list", "python" ]
stackoverflow_0006782736_image_list_python.txt
Q: How to run " ps cax | grep something " in Python? How do I run a command with a pipe | in it? The subprocess module seems complex... Is there something like output,error = `ps cax | grep something` as in shell script? A: See Replacing shell pipeline: import subprocess proc1 = subprocess.Popen(['ps', 'cax'], st...
How to run " ps cax | grep something " in Python?
How do I run a command with a pipe | in it? The subprocess module seems complex... Is there something like output,error = `ps cax | grep something` as in shell script?
[ "See Replacing shell pipeline:\nimport subprocess\n\nproc1 = subprocess.Popen(['ps', 'cax'], stdout=subprocess.PIPE)\nproc2 = subprocess.Popen(['grep', 'python'], stdin=proc1.stdout,\n stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\nproc1.stdout.close() # Allow proc1 to receive a SIGPIPE ...
[ 70, 24, 12, 6, 4 ]
[]
[]
[ "command", "pipe", "python" ]
stackoverflow_0006780035_command_pipe_python.txt
Q: Adding a new column to a list of matrixs(arrays) I have a problem with lists/arrays/matrix at Python. I have a list of matrix (or arrays if it need to be) and i want to add to every single of of them a new column of ones (of the same number of lines). How can I do this?? I've a couple of things and didn't get any ...
Adding a new column to a list of matrixs(arrays)
I have a problem with lists/arrays/matrix at Python. I have a list of matrix (or arrays if it need to be) and i want to add to every single of of them a new column of ones (of the same number of lines). How can I do this?? I've a couple of things and didn't get any success. Thanks for the help. Here's an example: >>> A...
[ "Example for a 2D NumPy ndarray:\n>>> m = np.arange(12).reshape(3,4)\n>>> m = np.hstack((m, np.ones((m.shape[0], 1), dtype=m.dtype)))\n>>> m\narray([[ 0, 1, 2, 3, 1],\n [ 4, 5, 6, 7, 1],\n [ 8, 9, 10, 11, 1]])\n\nEdit: It works the same for a matrix. For a list of matrices, you can use a for l...
[ 3, 1 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0006783088_numpy_python.txt
Q: Using pygtk how can I make a simple fullscreen slide show Using pygtk how can I make a full screen slide show that rotates through all the images in a directory switching them every x seconds A: In the past I wrote exactly the same thing. Then I deleted it. This version uses a prepared code for exposing an imag...
Using pygtk how can I make a simple fullscreen slide show
Using pygtk how can I make a full screen slide show that rotates through all the images in a directory switching them every x seconds
[ "In the past I wrote exactly the same thing. Then I deleted it. This version uses a prepared code for exposing an image while scaling it. It was taken from Jack Valmadre’s Blog\n#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Taken and customed from Jack Valmadre's Blog:\n# http://jackvalmadre.wordpress.com/2008/0...
[ 3, 0 ]
[]
[]
[ "fullscreen", "pygtk", "python", "slideshow" ]
stackoverflow_0006450170_fullscreen_pygtk_python_slideshow.txt
Q: How to compare values within an array in Python - find out whether 2 values are the same I basically have an array of 50 integers, and I need to find out whether any of the 50 integers are equal, and if they are, I need to carry out an action. How would I go about doing this? As far as I know there isn't currentl...
How to compare values within an array in Python - find out whether 2 values are the same
I basically have an array of 50 integers, and I need to find out whether any of the 50 integers are equal, and if they are, I need to carry out an action. How would I go about doing this? As far as I know there isn't currently a function in Python that does this is there?
[ "If you mean you have a list and you want to know if there are any duplicate values, then make a set from the list and see if it's shorter than the list:\nif len(set(my_list)) < len(my_list):\n print \"There's a dupe!\"\n\nThis won't tell you what the duplicate value is, though.\n", "If you have Python 2.7+ yo...
[ 10, 5, 2, 1, 0 ]
[]
[]
[ "arrays", "list", "python" ]
stackoverflow_0006780048_arrays_list_python.txt
Q: Using python to run a C++ program and test it Suppose I have a simple C++ program that takes in inputs and outputs some string. Like this (actual program is much more complicated but still text based): $ ./game $ what kind of game? type r for regular, s for special. $ r $ choose a number from 1 - 10 $ 1 $ no try a...
Using python to run a C++ program and test it
Suppose I have a simple C++ program that takes in inputs and outputs some string. Like this (actual program is much more complicated but still text based): $ ./game $ what kind of game? type r for regular, s for special. $ r $ choose a number from 1 - 10 $ 1 $ no try again $ 2 $ no try again $ 5 $ yes you WIN! I haven...
[ "Use pexpect.\nNormal stdin/stdout piping usually doesn't work, because the standard library facilities in the parent and child processes tend to buffer I/O more aggressively when a file descriptor isn't a TTY (via the isatty call). Obviously, you can fix this in the parent, since you own that code; just call flush...
[ 4, 1, 0 ]
[]
[]
[ "c++", "python" ]
stackoverflow_0006783586_c++_python.txt
Q: Python function that accepts file object or path I want to write a function that accepts either a path as a string or a file object. So far I have: def awesome_parse(path_or_file): if isinstance(path_or_file, basestring): f = open(path_or_file, 'rb') else: f = path_or_file with f as f: ...
Python function that accepts file object or path
I want to write a function that accepts either a path as a string or a file object. So far I have: def awesome_parse(path_or_file): if isinstance(path_or_file, basestring): f = open(path_or_file, 'rb') else: f = path_or_file with f as f: return do_stuff(f) where do_stuff takes an op...
[ "The odd thing about your code is that if it is passed an open file, it will close it. This isn't good. Whatever code opened the file should be responsible for closing it. This makes the function a bit more complex though:\ndef awesome_parse(path_or_file):\n if isinstance(path_or_file, basestring):\n f...
[ 19, 6 ]
[]
[]
[ "file_io", "python" ]
stackoverflow_0006783472_file_io_python.txt
Q: Propagating Clips Error Messages in PyClips I'm finding it very difficult to develop with PyClips, because it appears to replace useful error messages thrown by Clips with a generic "syntax error" message. This makes debugging very laborious and practically impossible on large codebases when using PyClips. Conside...
Propagating Clips Error Messages in PyClips
I'm finding it very difficult to develop with PyClips, because it appears to replace useful error messages thrown by Clips with a generic "syntax error" message. This makes debugging very laborious and practically impossible on large codebases when using PyClips. Consider the following example. I wrote a very large exp...
[ "Catch the ClipsError, then read ErrorStream for the details. For example:\nengine = clips.Environment()\nengine.Reset()\nengine.Clear()\ntry:\n engine.Load(os.path.abspath(rule_file))\nexcept clips.ClipsError:\n logging.error(clips.ErrorStream.Read())\n\n" ]
[ 0 ]
[]
[]
[ "clips", "expert_system", "pyclips", "python" ]
stackoverflow_0003710690_clips_expert_system_pyclips_python.txt
Q: Is there a function for Converting IP address to decimal number in python? Is there any function or API or method that will convert a doted IP string to decimal number? A: I'm not sure what is the decimal number you really want, but take a look at socket.inet_aton. It will give you string with binary representat...
Is there a function for Converting IP address to decimal number in python?
Is there any function or API or method that will convert a doted IP string to decimal number?
[ "I'm not sure what is the decimal number you really want, but take a look at socket.inet_aton. It will give you string with binary representation of the IP address in network byte order. If you want to get a regular integer out of it, you could use struct.unpack with either \"!I\" or \"I\", depending on which byte ...
[ 16 ]
[]
[]
[ "decimal", "ip", "python" ]
stackoverflow_0006783926_decimal_ip_python.txt
Q: pip setup and setting PYTHONPATH I'm not experienced in Python, and I need the requests module. I've tried installing it using pip install requests The installation went successfully, but when I try to import the module, I get an error like "no module named requests". Should I add the install location to PYTHONPAT...
pip setup and setting PYTHONPATH
I'm not experienced in Python, and I need the requests module. I've tried installing it using pip install requests The installation went successfully, but when I try to import the module, I get an error like "no module named requests". Should I add the install location to PYTHONPATH? If yes, how can I find the location...
[ "You should install pip for python3 first \nHow to install pip with Python 3?\nthen with the pip-3.X install the required module.\n" ]
[ 2 ]
[]
[]
[ "installation", "pip", "python" ]
stackoverflow_0006783826_installation_pip_python.txt
Q: Affinity Matrix Calculation using Numpy I am trying to create an affinity matrix for an image. I am trying to use simple pixel value differences for now, my image is 84x84, flattened it is a vector of size 7056, which gives me affinity matrix A of size 7056x7056. To fill in the values of the affinity matrix, I st...
Affinity Matrix Calculation using Numpy
I am trying to create an affinity matrix for an image. I am trying to use simple pixel value differences for now, my image is 84x84, flattened it is a vector of size 7056, which gives me affinity matrix A of size 7056x7056. To fill in the values of the affinity matrix, I started with the obvious the method: import mat...
[ "It may seem a bit mystical, but \nA = np.subtract.outer(Img2, Img2)\nA = np.abs(A)\n\nshould do what you want.\nI'll post a bit more explanation when I get off work (remind me if I don't!).\n" ]
[ 6 ]
[]
[]
[ "image_processing", "numpy", "python" ]
stackoverflow_0006784281_image_processing_numpy_python.txt
Q: Python WINEVTLOG Open Backup Logs I am attempting to use the OpenBackupEventLog("",file) to open eventlogs which are saved on a CDrom. I am going through a loop to load each file under the subdirectory. I have two issues at the moment. 1. The script will pull the first file name and output events on screen, ho...
Python WINEVTLOG Open Backup Logs
I am attempting to use the OpenBackupEventLog("",file) to open eventlogs which are saved on a CDrom. I am going through a loop to load each file under the subdirectory. I have two issues at the moment. 1. The script will pull the first file name and output events on screen, however when they reach the end it does n...
[ "Few items which were causing my issue:\n\nCDrom or CD was erroring out; I have to copy the files to a temp directory and then process them.\nNo break at the end of the loop; if not event: break\n\n" ]
[ 0 ]
[]
[]
[ "event_log", "python" ]
stackoverflow_0006771385_event_log_python.txt
Q: Opening a file in pwdir's folder in Python through Applescript Opening a file available in present working directory's temp folder in python I tried pwdir=os.getcwd() tempdir=pwdir+"/temp/test.txt" f=open(tempdir,'r+') When I print the path of tempdir, it is showing up correctly and also the contents of file are...
Opening a file in pwdir's folder in Python through Applescript
Opening a file available in present working directory's temp folder in python I tried pwdir=os.getcwd() tempdir=pwdir+"/temp/test.txt" f=open(tempdir,'r+') When I print the path of tempdir, it is showing up correctly and also the contents of file are also read. When I try to combine this operation from an Applescript...
[ "I don't know Applescript -- or OS X in general. It looks like the script is being run from the root folder, and os.getcwd() returns '/'. The directory of the script itself is sys.path[0] or the dirname of the current module -- dirname(__file__) -- if it's a single script instead of a package. Try one of the follow...
[ 3, 1 ]
[]
[]
[ "applescript", "file_io", "macos", "python", "scripting" ]
stackoverflow_0006783360_applescript_file_io_macos_python_scripting.txt
Q: How to INTERACT between a program on the server and the user via a web page REAL-TIME Let me start with an example: There is a c++ program which can be run on my server, the program is named "Guess the Number" which means every time it runs, first it will generate an integer between 1 and 100 randomly. then i n...
How to INTERACT between a program on the server and the user via a web page REAL-TIME
Let me start with an example: There is a c++ program which can be run on my server, the program is named "Guess the Number" which means every time it runs, first it will generate an integer between 1 and 100 randomly. then i need the user to guess a number and pass it to me though a web page, form or something. now...
[ "This sounds a lot like a homework question, but even with this list, you have a lot of work ahead of you for a dubious reward, so here we go.\n\nYour C++ program should listen on a socket\nYour python program needs to listen on a web socket, and also have a connection open to the C++ program through the C++ socket...
[ 0, 0 ]
[]
[]
[ "ajax", "cgi", "pipe", "python", "subprocess" ]
stackoverflow_0006736152_ajax_cgi_pipe_python_subprocess.txt
Q: appending a list to a list to make a list of lists causes a problem when wanting to change a value by using the list of lists's index: python Basically there seems to be a problem when a list of lists is made by appending a list to another list using list.append(). The problem is that the entire column is changed ...
appending a list to a list to make a list of lists causes a problem when wanting to change a value by using the list of lists's index: python
Basically there seems to be a problem when a list of lists is made by appending a list to another list using list.append(). The problem is that the entire column is changed to the value you set it to for the index you give. for example the code here b = [1,1,1] c = [] c.append(b) c.append(b) c.append(b) c[0][0] = 4 an...
[ "What you've observed is normal and expected behavior in Python and any decent tutorial should cover it.\nc.append(b)\nc.append(b)\nc.append(b)\n\nThis appends to c three references to the list b. Since it's the same list, changing one reference changes it in all four places it's referenced, including b by the way....
[ 4, 1 ]
[]
[]
[ "append", "list", "multidimensional_array", "python" ]
stackoverflow_0006785198_append_list_multidimensional_array_python.txt
Q: Use openpyxl to edit a Excel2007 file (.xlsx) without changing its own styles? I have a .xlsx file to edit, I found openpyxl could manipulate Excel 2007 files. I only want to change the value in some cells and leave other settings unchanged. But after I went through the Documentation, I cannot find the examples to...
Use openpyxl to edit a Excel2007 file (.xlsx) without changing its own styles?
I have a .xlsx file to edit, I found openpyxl could manipulate Excel 2007 files. I only want to change the value in some cells and leave other settings unchanged. But after I went through the Documentation, I cannot find the examples to edit a existing file. It only demostrated reading a .xlsx file and writing to a new...
[ "Now openpyxl cannot handle styles good enough, so I tried using pywin32 COM and got the solution.\nHere is a good python-excel-mini-cookbook to use pywin32 COM for Excel\n", "Styles aren't fully supported yet in openpyxl. Make sure you're using the latest version (1.5.3 as of now), as it recently improved its s...
[ 18, 1 ]
[]
[]
[ "excel_2007", "openpyxl", "python" ]
stackoverflow_0006772438_excel_2007_openpyxl_python.txt
Q: How to use validation to make a clickable, pseudo-readonly FileField in the admin? I'm trying to have a FileField that is clickable in the admin but is also readonly. There's currently an open ticket for this issue, but I need a workaround now. I'm trying to write a validator for my admin class but I'm running int...
How to use validation to make a clickable, pseudo-readonly FileField in the admin?
I'm trying to have a FileField that is clickable in the admin but is also readonly. There's currently an open ticket for this issue, but I need a workaround now. I'm trying to write a validator for my admin class but I'm running into an exception when I run it. This is what I currently have: class ModelWithAttachment(m...
[ "I figured it out. My approach was correct, with clean_attachment being defined as: \ndef clean_attachment(self): \n if 'attachment' in self.changed_data: \n raise forms.ValidationError('no!') \n\n return self.cleaned_data['attachment'] \n\nThe problem was an old .pyc file getting reused incorrectly. O...
[ 0 ]
[]
[]
[ "django", "filefield", "python", "readonly" ]
stackoverflow_0006781520_django_filefield_python_readonly.txt
Q: Python expression to MathML I would like to be able to convert a python mathematical expression into content MathML using Python. The goal would be to turn an expression like (a*x^2 + b*x + c)/(2*a) into the content MathML example in the Wikipedia article on MathML. The asciimathml package will generate display M...
Python expression to MathML
I would like to be able to convert a python mathematical expression into content MathML using Python. The goal would be to turn an expression like (a*x^2 + b*x + c)/(2*a) into the content MathML example in the Wikipedia article on MathML. The asciimathml package will generate display MathML, but as far as I can tell, ...
[ "MathDOM: http://mathdom.sourceforge.net/\nDoes exactly what you want. Quoting the page:\n\nMathDOM is a set of Python 2.4 modules (using PyXML or lxml, and pyparsing) that import mathematical terms as a Content MathML DOM. It currently parses MathML and literal infix terms into a DOM or lxml document and writes ou...
[ 2, 0 ]
[]
[]
[ "expression", "math", "mathml", "parsing", "python" ]
stackoverflow_0006757521_expression_math_mathml_parsing_python.txt
Q: Efficient algorithm in Python and Django for choosing n JavaScript functions from file containing m I need an efficient algorithm in Python for the following requirement. Consider I am having N JavaScript functions in a file. I have to include any M JavaScript among N in any particular order. (For example, in one ...
Efficient algorithm in Python and Django for choosing n JavaScript functions from file containing m
I need an efficient algorithm in Python for the following requirement. Consider I am having N JavaScript functions in a file. I have to include any M JavaScript among N in any particular order. (For example, in one page I may include N1, N4, N5, N6 and another page N1, N5, N4, N3, but it should get included in the same...
[ "This is known as the maximum coverage problem, and is NP-Hard (non-deterministic polynomial-time hard)... There do, however, exist some approximation algorithms, the easiest to implement would be a greedy based algorithm.\nSay you need to include N_1 ... N_m JavaScript files. You would want to order your JavaScrip...
[ 1 ]
[]
[]
[ "algorithm", "django", "python" ]
stackoverflow_0006785357_algorithm_django_python.txt
Q: sqlobject: leak memory using selectby method I had discovered that using selectby method with sqlobject there are leak memory. For example, when I execute this code: connection = connectionForURI('postgresql://test:test@localhost/test_sql_object') tran = connection.transaction() sqlhub.threadConnection = tran cl...
sqlobject: leak memory using selectby method
I had discovered that using selectby method with sqlobject there are leak memory. For example, when I execute this code: connection = connectionForURI('postgresql://test:test@localhost/test_sql_object') tran = connection.transaction() sqlhub.threadConnection = tran class Person(SQLObject): firstName = StringCol...
[ "If you run the test with profile, for example \n python -m cProfile -s cumulative\nYou can check that the problem is in the cursor of psycopg2.\nThe solution is in \nhttps://sourceforge.net/tracker/?func=detail&atid=540673&aid=3366899&group_id=74338\n" ]
[ 0 ]
[]
[]
[ "memory_leaks", "python", "sqlobject" ]
stackoverflow_0006663001_memory_leaks_python_sqlobject.txt
Q: Recursive generators and send() Does anyone know how send() works with generators when used recursively? I expected the value to be passed to the current generator, which could then pass it down to the recursed-generator...but it seems that is not the case? Some example code: def Walk(obj): recurse = (yield ob...
Recursive generators and send()
Does anyone know how send() works with generators when used recursively? I expected the value to be passed to the current generator, which could then pass it down to the recursed-generator...but it seems that is not the case? Some example code: def Walk(obj): recurse = (yield obj) if not recurse: print 'stop ...
[ "The important thing to realize is that send() also consumes!\nFrom http://docs.python.org/reference/expressions.html#generator.send:\n\nResumes the execution and “sends” a value into the generator function.\n The value argument becomes the result of the current yield expression.\n The send() method returns the n...
[ 6 ]
[]
[]
[ "generator", "python", "recursion" ]
stackoverflow_0006785052_generator_python_recursion.txt
Q: Draw a frame or dialog inside another I have seen this question a lot of times but nothing about wxpython I am working on a project where I have to admin a remote application. I would need to access the look of the remote application. I there some simple way how I could show in my local application how the applica...
Draw a frame or dialog inside another
I have seen this question a lot of times but nothing about wxpython I am working on a project where I have to admin a remote application. I would need to access the look of the remote application. I there some simple way how I could show in my local application how the application looks. Is it possible to export the re...
[ "To answer you last question, yes it is possible.\nYou can take a screenshot of your remote window as described here\nI do not know how do you admin your remote application, but you can then send the screenshot via sockets or whatever you want.\n" ]
[ 0 ]
[]
[]
[ "python", "wxpython", "wxwidgets" ]
stackoverflow_0006760408_python_wxpython_wxwidgets.txt
Q: Aptana (eclipse) does not recognize modifications to PATH written in .bashrc I encountered and solved this problem earlier this day and now I run into something similar but in another context. When I fire up python (2.7) in my mac Terminal (Mac OS Lion) and do import oursql everything is fine. When I do the same ...
Aptana (eclipse) does not recognize modifications to PATH written in .bashrc
I encountered and solved this problem earlier this day and now I run into something similar but in another context. When I fire up python (2.7) in my mac Terminal (Mac OS Lion) and do import oursql everything is fine. When I do the same within a python script in the Aptana IDE I get the following error. Traceback ...
[ "It's been a while since I used Pydev, but the Pydev docs on configuring the interpreter are probably worth a look.\nPython IDEs usually let you configure the environment python is run in when you run from the IDE.\nAlso, having .bashrc change your $PATH will only change the environment variable for bash sessions. ...
[ 3, 1 ]
[]
[]
[ "aptana", "bash", "eclipse", "path", "python" ]
stackoverflow_0006782529_aptana_bash_eclipse_path_python.txt
Q: How to remove this special character? I was trying to unify the lines in my file when I observed the following: word1 word2 word1 word2 I did not understand why these lines were not combined so I opened the file in vim and used :set list to see if there are any special characters and I found this: word1 <feff>wor...
How to remove this special character?
I was trying to unify the lines in my file when I observed the following: word1 word2 word1 word2 I did not understand why these lines were not combined so I opened the file in vim and used :set list to see if there are any special characters and I found this: word1 <feff>word2 word1 word2 I am not sure how to clean...
[ "U+FEFF is the Byte Order Mark character, which should only occur at the start of a document. In documents, it should be treated as a ZERO WIDTH NON-BREAKING SPACE. If this causes issues, you can remove it like any other character:\n>>> s = u'word1 \\ufeffword2'\n>>> s = s.replace(u'\\ufeff', '')\n>>> s\nu'word1 wo...
[ 31, 1 ]
[]
[]
[ "python", "string" ]
stackoverflow_0006786609_python_string.txt
Q: Python unexpected EOF while parsing My code: def getAppHistory(self): path = self.APP_STORAGE + "\\history.dat" if os.path.exists(path): hist_file = open(path, "r") hist_data = hist_file.read() else: hist_file = open(path, "w") hist_data = "[200, \"Empty\", \"You have no...
Python unexpected EOF while parsing
My code: def getAppHistory(self): path = self.APP_STORAGE + "\\history.dat" if os.path.exists(path): hist_file = open(path, "r") hist_data = hist_file.read() else: hist_file = open(path, "w") hist_data = "[200, \"Empty\", \"You have no device history!\", \"self.Void\"]" ...
[ "This could happen if the hist_file exists but is empty\nYou should print hist_data before you try to eval it so you can see for sure\nAlso: Make sure you understand the dangers of using eval\n", "As gnibbler has explained, this can occur if a file (in this case \"history.dat\") already exists but is empty.\nTest...
[ 2, 0 ]
[]
[]
[ "eof", "python" ]
stackoverflow_0006786502_eof_python.txt
Q: Is Python on every GNU/Linux distribution? I would like to know if is Python on every G/L distribution preinstalled or not. And why is it so popular on GNU/Linux and not so much on Windows? A: Well python does not come on ALL GNU/Linux distros but is present on most of the popular Linux home user distributions (...
Is Python on every GNU/Linux distribution?
I would like to know if is Python on every G/L distribution preinstalled or not. And why is it so popular on GNU/Linux and not so much on Windows?
[ "Well python does not come on ALL GNU/Linux distros but is present on most of the popular Linux home user distributions (Ubuntu and Fedora Core for example), possibly because most of the application of Gnome desktop environment and KDE use python 2.5+ (not python 3 yet) interpreters. Since python is almost integrat...
[ 7, 0 ]
[]
[]
[ "desktop", "gnu", "linux", "python" ]
stackoverflow_0006786693_desktop_gnu_linux_python.txt
Q: Python doesn't load _fileio library I have a problem, Python doesn't loads the dynamic c library _fileio ~ $ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. Could not open PYTHONSTARTUP IOError: [Errno 2] No such...
Python doesn't load _fileio library
I have a problem, Python doesn't loads the dynamic c library _fileio ~ $ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. Could not open PYTHONSTARTUP IOError: [Errno 2] No such file or directory: '/home/sven/.pythonrc...
[ "Seems like an environment issue, stemming from this line:\nIOError: [Errno 2] No such file or directory: '/home/sven/.pythonrc'\n\nTo solve this, find .pythonrc and make sure the PYTHONSTARTUP environment variable in your .bashrc file points to this file location. If it is in fact correct, try using the hardcoded ...
[ 1, 0 ]
[]
[]
[ "environment_variables", "python" ]
stackoverflow_0006778176_environment_variables_python.txt
Q: console output of os.system()? When calling os.system() in the Interactive Interpreter, you can see what it output's in the console. But in my case, I needed to change sys.stderr and sys.stdout to an instance of another class and the os.system function is called within an exec statement. The problem is, I don't se...
console output of os.system()?
When calling os.system() in the Interactive Interpreter, you can see what it output's in the console. But in my case, I needed to change sys.stderr and sys.stdout to an instance of another class and the os.system function is called within an exec statement. The problem is, I don't see what it output's. It does not writ...
[ "It goes to either file descriptor 1 or 2, depending on whether it outputs to stdout or stderr. If you need finer control of the output then you should use subprocess.\n" ]
[ 3 ]
[]
[]
[ "os.system", "python" ]
stackoverflow_0006787269_os.system_python.txt
Q: Error when assigning date in utc format to a field in mongodb from python code In my python code i have the following line which stores the current date in UTC format in a field in a mongodb database: s['metadata']['some_date'] = datetime.utcnow() But on running the program, i get the following error : TypeErro...
Error when assigning date in utc format to a field in mongodb from python code
In my python code i have the following line which stores the current date in UTC format in a field in a mongodb database: s['metadata']['some_date'] = datetime.utcnow() But on running the program, i get the following error : TypeError: 'unicode' object does not support item assignment What is the wrong with my code...
[ "Either 's' or s['metadata'] is a string but not a dict....pdb is your friend.\n" ]
[ 2 ]
[]
[]
[ "mongodb", "pymongo", "python" ]
stackoverflow_0006787140_mongodb_pymongo_python.txt
Q: How can I write readable Python code when there are no curly brackets and semicolons? I love the semicolons and curly brackets from C and PHP. Now I am starting to program with Python and when the code gets bigger it seems to me very messy without them (the curly brackets and semicolons). The orientation in PHP ...
How can I write readable Python code when there are no curly brackets and semicolons?
I love the semicolons and curly brackets from C and PHP. Now I am starting to program with Python and when the code gets bigger it seems to me very messy without them (the curly brackets and semicolons). The orientation in PHP or C is much efficient and faster, at least for me. On the other hand I like many features ...
[ ">>> from __future__ import braces\n File \"<stdin>\", line 1\nSyntaxError: not a chance\n\n", "there is semicolon:\na=3; b=4\n\nI don't see how braces make the code any more readable.\n", "One thing that makes code less readable is cluttering up your code by saying things twice.\nIndentation to clarify block ...
[ 15, 3, 2 ]
[]
[]
[ "curly_braces", "php", "python" ]
stackoverflow_0006787161_curly_braces_php_python.txt
Q: Quiz Generator using NLTK/Python The goal of this application is produce a system that can generate quizzes automatically. The user should be able to supply any word or phrase they like (e.g. "Sachin Tendulkar"); the system will then look for suitable topics online, identify a range of interesting facts, and rephr...
Quiz Generator using NLTK/Python
The goal of this application is produce a system that can generate quizzes automatically. The user should be able to supply any word or phrase they like (e.g. "Sachin Tendulkar"); the system will then look for suitable topics online, identify a range of interesting facts, and rephrase them as quiz questions. If I have ...
[ "In the general case, this is a very hard open research question. However, you might be able to get away with a simple solution a long as your \"facts\" follow a pretty simple grammar. \nYou could write a fairly simple solution by creating a set of transformation rules that act on parse trees. So if you saw a st...
[ 4 ]
[]
[]
[ "nlp", "nltk", "python" ]
stackoverflow_0006787345_nlp_nltk_python.txt
Q: Need help regarding confusion with jython , django and java I have few doubts regarding Jython and will be happy if someone can clear those In Django-Jython , can i install normal Django app the same way like manage.py startproject testing. I mean no relation with java, only python django Can i install normal Ja...
Need help regarding confusion with jython , django and java
I have few doubts regarding Jython and will be happy if someone can clear those In Django-Jython , can i install normal Django app the same way like manage.py startproject testing. I mean no relation with java, only python django Can i install normal Java Spring Hibernate webiste in Jython. I mean no relation with py...
[ "\nIf you're going to use Jython then you should use Jython.\njython django-admin.py startproject testing\n\nSpring and Hibernate have nothing to do with Jython.\n\n\"Why Jython\"\n\n\n" ]
[ 2 ]
[]
[]
[ "django", "java", "jython", "python" ]
stackoverflow_0006787378_django_java_jython_python.txt
Q: Importing Python modules on Linux from an NTFS share My problem is a difference in how Python searches for modules on Windows/Linux. I have a directory foo on a Windows 7 machine (NTFS), which I mount in a Ubuntu 10.04 virtual guest running on the same machine (via VirtualBox' guest additions). Inside foo, there i...
Importing Python modules on Linux from an NTFS share
My problem is a difference in how Python searches for modules on Windows/Linux. I have a directory foo on a Windows 7 machine (NTFS), which I mount in a Ubuntu 10.04 virtual guest running on the same machine (via VirtualBox' guest additions). Inside foo, there is a file OS.py (note the upper case) with the following co...
[ "Your problem has nothing to do with Linux or NTFS, the behaviour is exactly the same in a pure Windows environment with any Windows file system NTFS or FAT: Windows regards filenames as case insensitive, but Python regards module names as case sensitive.\nAll that is happening here is that when Python searches for...
[ 2, 0 ]
[]
[]
[ "linux", "python", "windows" ]
stackoverflow_0006786644_linux_python_windows.txt
Q: Unable to run python google app engine project I am developing a tiny webapp on google app engine using python. I am using eclipse IDE for the development. When I tried to run the python webapp I am getting this error. Status: 404 Not Found Content-Type: text/html; charset=utf-8 Cache-Control: no-cache Expires: ...
Unable to run python google app engine project
I am developing a tiny webapp on google app engine using python. I am using eclipse IDE for the development. When I tried to run the python webapp I am getting this error. Status: 404 Not Found Content-Type: text/html; charset=utf-8 Cache-Control: no-cache Expires: Fri, 01 Jan 1990 00:00:00 GMT Content-Length: 0
[ "This is most probably an error on the Eclipse side. Try using the launcher to run the application.\n" ]
[ 1 ]
[]
[]
[ "eclipse", "google_app_engine", "python" ]
stackoverflow_0006743234_eclipse_google_app_engine_python.txt
Q: Python socket proxy example, keep getting errors calling bind().. why? I'm writing an ad-hoc proxy that takes commands from a fifo file, then hosts arbitary proxy connections using python socket and select.poll.. My problem is that very frequently, when calling socket.bind.. I get either a "Bad file descriptor" er...
Python socket proxy example, keep getting errors calling bind().. why?
I'm writing an ad-hoc proxy that takes commands from a fifo file, then hosts arbitary proxy connections using python socket and select.poll.. My problem is that very frequently, when calling socket.bind.. I get either a "Bad file descriptor" error, or a "Socket operation on non-socket", and I'm not sure why? Here is a ...
[ "Hmmm.... If I declare the push_sock varaible after the pull_sock.connect bits and just before the bind, it no longer happens?! It's almost like there is a bug in Python which is getting the two sockets confused?\nSeems to work a dream now though!\n" ]
[ 0 ]
[]
[]
[ "linux", "network_programming", "proxy", "python", "sockets" ]
stackoverflow_0006787866_linux_network_programming_proxy_python_sockets.txt
Q: Can I add timeout for ftpslib connection? Can I add timepout for ftps connection and each command on ftp server ? r = ftpslib.FTP_TLS() ... A: In python >= 2.6, the timeout option has been added to FTPconstructor. It will be used for each blocking operation (ie connection, receive, sending...). In python >= 2...
Can I add timeout for ftpslib connection?
Can I add timepout for ftps connection and each command on ftp server ? r = ftpslib.FTP_TLS() ...
[ "In python >= 2.6, the timeout option has been added to FTPconstructor. It will be used for each blocking operation (ie connection, receive, sending...).\nIn python >= 2.7, the FTP_TLS object has been added (with timeout).\nIn python < 2.7, you'll have to modify the default global timeout on socket module with soc...
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0006787926_python.txt
Q: Python, how to read bytes from file and save it? I want to read bytes from a file and then write those bytes to another file, and save that file. How do I do this? A: Here's how to do it with the basic file operations in Python. This opens one file, reads the data into memory, then opens the second file and writ...
Python, how to read bytes from file and save it?
I want to read bytes from a file and then write those bytes to another file, and save that file. How do I do this?
[ "Here's how to do it with the basic file operations in Python. This opens one file, reads the data into memory, then opens the second file and writes it out.\nin_file = open(\"in-file\", \"rb\") # opening for [r]eading as [b]inary\ndata = in_file.read() # if you only wanted to read 512 bytes, do .read(512)\nin_file...
[ 132, 19, 7, 5 ]
[]
[]
[ "python" ]
stackoverflow_0006787233_python.txt
Q: Returning different objects at instantiation When I am instantiating a particular class I have written, I give it a name and several properties as arguments to __init__. Given the name passed, my __init__ tries to find a file on disk that applies to that name and instead of processing the other arguments passed it...
Returning different objects at instantiation
When I am instantiating a particular class I have written, I give it a name and several properties as arguments to __init__. Given the name passed, my __init__ tries to find a file on disk that applies to that name and instead of processing the other arguments passed it reads all those from the file. And if the file is...
[ "Use a factory function instead of doing this in __init__. Example:\nclass Foo(object):\n # whatever\n\ndef get_foo(path, *args, **kwargs):\n try:\n obj = pickle.load(open(path))\n if not isinstance(obj, Foo):\n raise TypeError, \"%s does not contain a Foo\" % path\n return obj...
[ 4, 0 ]
[]
[]
[ "python" ]
stackoverflow_0006788382_python.txt
Q: How to plot an image with non-linear y-axis with Matplotlib using imshow? How can I plot an 2D array as an image with Matplotlib having the y scale relative to the power of two of the y value? For instance the first row of my array will have a height in the image of 1, the second row will have a height of 4, etc. ...
How to plot an image with non-linear y-axis with Matplotlib using imshow?
How can I plot an 2D array as an image with Matplotlib having the y scale relative to the power of two of the y value? For instance the first row of my array will have a height in the image of 1, the second row will have a height of 4, etc. (units are irrelevant) It's not simple to explain with words so look at this im...
[ "Have you tried to transform the axis? For example:\nax = subplot(111)\nax.yaxis.set_ticks([0, 2, 4, 8])\nimshow(data)\n\nThis means there must be gaps in the data for the non-existent coordinates, unless there is a way to provide a transform function instead of just lists (never tried).\nEdit:\nI admit it was just...
[ 8, 4, 3, 2 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0001679126_matplotlib_python.txt
Q: handling unicode strings in Windows For the first time, I was trying out one of my Python scripts, which deals with unicode characters, on Windows (Vista) and found that it's not working. The script works perfectly okay on Linux and OS X but no joy on Windows. Here is the little script that I tried: #!/usr/bin/py...
handling unicode strings in Windows
For the first time, I was trying out one of my Python scripts, which deals with unicode characters, on Windows (Vista) and found that it's not working. The script works perfectly okay on Linux and OS X but no joy on Windows. Here is the little script that I tried: #!/usr/bin/python # -*- coding: utf-8 -*- import os, ...
[ "The Windows console has a Unicode API, but not utf-8. Python is trying to encode Unicode characters to your console's 8-bit code page cp850, which obviously won't work. There's supposedly a code page (chcp 65001) in the Windows console that supports utf-8, but it's severely broken. Read issue 1602 and look at sys_...
[ 5, 1 ]
[]
[]
[ "python", "unicode", "window" ]
stackoverflow_0006788158_python_unicode_window.txt
Q: Django / MacOS revised efficient development workflow I've been now happily developing applications (Django in particular) on the Mac for a few years now. As part of this process I am always looking to gain efficiencies in my workflow and enjoy reading about other development expieriences. Now it's my turn to gi...
Django / MacOS revised efficient development workflow
I've been now happily developing applications (Django in particular) on the Mac for a few years now. As part of this process I am always looking to gain efficiencies in my workflow and enjoy reading about other development expieriences. Now it's my turn to give back. This is a revision to my previous post with time ...
[ "As Daniel pointed out this isn't a question per se. So there isn't an answer - other than sure..\n" ]
[ 1 ]
[]
[]
[ "django", "macos", "methodology", "python", "workflow" ]
stackoverflow_0006696246_django_macos_methodology_python_workflow.txt
Q: Add timestamps in python month wise Possible Duplicate: Add timestamps in python dates = {} dates.update({'2011-03-07':'16:03:01'}) dates.update({'2011-03-06':'16:03:01'}) dates.update({'2011-03-08':'16:03:01'}) dates.update({'2011-03-04':'16:03:01'}) dates.update({'2011-05-16':'16:03:01'}) dates.update({'2011-...
Add timestamps in python month wise
Possible Duplicate: Add timestamps in python dates = {} dates.update({'2011-03-07':'16:03:01'}) dates.update({'2011-03-06':'16:03:01'}) dates.update({'2011-03-08':'16:03:01'}) dates.update({'2011-03-04':'16:03:01'}) dates.update({'2011-05-16':'16:03:01'}) dates.update({'2011-05-18':'16:03:01'}) dates.update({'2011-...
[ "It may be solved without RegExps:\n# dates = { ... } \n\nfrom datetime import datetime\n\nstamps = []\nfor date, time in dates.iteritems():\n stamps.append(datetime.strptime('%s %s' % (date, time), '%Y-%m-%d %H:%M:%S'))\n\ndef month_stamps(stamps, month):\n return filter(lambda x: x.month == month, stamps)\n...
[ 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0006788807_python.txt
Q: Local automation tool for Python I am looking for good python tool to automate several recurring tasks on localhost (Fabric doesn't fit this requirement since it aims to automate deployment and tasks on remote machines). E.g. I have to make some preparations (create directories, check access rights and so on) and ...
Local automation tool for Python
I am looking for good python tool to automate several recurring tasks on localhost (Fabric doesn't fit this requirement since it aims to automate deployment and tasks on remote machines). E.g. I have to make some preparations (create directories, check access rights and so on) and after that I can run application serve...
[ "Why not just use the Python Standard Library.\n", "Try SCons.\n", "I've found great tool which fits my need. It is Paver\n" ]
[ 2, 1, 0 ]
[]
[]
[ "automation", "python" ]
stackoverflow_0006763047_automation_python.txt