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: What is the best design for polling a modem for incoming data? I have a GSM modem connected to my computer, i want to receive text messages sent to it using a python program i have written, am just wondering what is the best technique to poll for data. Should i write a program that has a infinite loop that contin...
What is the best design for polling a modem for incoming data?
I have a GSM modem connected to my computer, i want to receive text messages sent to it using a python program i have written, am just wondering what is the best technique to poll for data. Should i write a program that has a infinite loop that continuously checks for incoming sms's i.e within the loop the program sen...
[ "I have written something similar before. There is a way using AT commands to tell the modem to signal you each time an SMS is received.\nFor reference, I was using a Maestro 100 GSM Modem in an embedded application.\nFirst you have to initialize the modem properly. I was using text mode for the SMS, but you might ...
[ 3, 0 ]
[]
[]
[ "at_command", "gsm", "modem", "python" ]
stackoverflow_0001423308_at_command_gsm_modem_python.txt
Q: Komodo Edit - code-completion for Django? I've been using Komodo Edit for a small project in Django. The code completion features seem to work pretty well for standard python modules, however, it doesn't know anything about Django modules. Is there any way to configure Komodo Edit to use Django modules for autoc...
Komodo Edit - code-completion for Django?
I've been using Komodo Edit for a small project in Django. The code completion features seem to work pretty well for standard python modules, however, it doesn't know anything about Django modules. Is there any way to configure Komodo Edit to use Django modules for autocomplete as well?
[ "\no to Edit > Preferences. Expand the\n \"Languages\" group by clicking the [+]\n symbol. Click \"Python\". Click the\n little \"Add...\" button under \n \"Additional Python Import\n Directories\". Add the directory ABOVE\n your project and you should have\n intellisense enabled.\n\nThis has always worked...
[ 8, 4, 2 ]
[]
[]
[ "code_completion", "django", "ide", "komodo", "python" ]
stackoverflow_0001424392_code_completion_django_ide_komodo_python.txt
Q: Easy, Robust IPC between Python and PHP I have a python program which starts up a PHP script using the subprocess.Popen() function. The PHP script needs to communicate back-and-forth with Python, and I am trying to find an easy but robust way to manage the message sending/receiving. I have already written a workin...
Easy, Robust IPC between Python and PHP
I have a python program which starts up a PHP script using the subprocess.Popen() function. The PHP script needs to communicate back-and-forth with Python, and I am trying to find an easy but robust way to manage the message sending/receiving. I have already written a working protocol using basic sockets, but it doesn'...
[ "It sounds like you want a generic RPC framework.\nYou should take a look at:\n\nThrift http://incubator.apache.org/thrift/\nXML RPC http://docs.python.org/library/xmlrpclib.html and http://phpxmlrpc.sourceforge.net/\nAMQP e.g. http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol\n\nThrift is probably mor...
[ 2, 0 ]
[]
[]
[ "ipc", "php", "python" ]
stackoverflow_0001424593_ipc_php_python.txt
Q: Resources for developing Python and Google App Engine I would like to ask about some sources for developing applications with Python and Google App Engine. For example, some controls to generate automatically pages with the insert/update/delete of a database table, or any other useful resources are welcome. Thank ...
Resources for developing Python and Google App Engine
I would like to ask about some sources for developing applications with Python and Google App Engine. For example, some controls to generate automatically pages with the insert/update/delete of a database table, or any other useful resources are welcome. Thank you!
[ "The Python community tends to look askance at code generation; so, @Hoang, if you think code generation is THE way to go, I suggest you try just about any other language BUT Python.\n@Dominic has already suggested some excellent resources, I could point you to more (App Engine Fan, App Engine Utilities, etc, etc) ...
[ 7, 3, 2 ]
[]
[]
[ "controls", "google_app_engine", "python", "user_controls" ]
stackoverflow_0001415208_controls_google_app_engine_python_user_controls.txt
Q: What python web frameworks work well with CGI (e.g. on nearlyfreespeech.net)? From nearlyfreespeech's website, they state that the following don't work well: mod_python Web application frameworks that depend on persistent processes, including: Ruby On Rails, Django, Zope, and others (some of these will run under...
What python web frameworks work well with CGI (e.g. on nearlyfreespeech.net)?
From nearlyfreespeech's website, they state that the following don't work well: mod_python Web application frameworks that depend on persistent processes, including: Ruby On Rails, Django, Zope, and others (some of these will run under CGI, but will run slowly and are suitable only for development purposes) Are ther...
[ "WSGI can run on top of CGI, and popular frameworks typically run on top of WSGI, but performance is quite another issue -- since a CGI service starts afresh on each hit, any framework you may be using will need to reload from scratch each and every time, and that (in addition to opening a new connection to a DB, e...
[ 5, 2, 0 ]
[ "Well, if what you really need is just free hosting for a Python web app, Google AppEngine is a nice alternative and you won't be as limited on choice of frameworks.\n" ]
[ -3 ]
[ "cgi", "frameworks", "nearlyfreespeech", "python" ]
stackoverflow_0001423041_cgi_frameworks_nearlyfreespeech_python.txt
Q: talking between python tcp server and a c++ client I am having an issue trying to communicate between a python TCP server and a c++ TCP client. After the first call, which works fine, the subsequent calls cause issues. As far as WinSock is concerned, the send() function worked properly, it returns the proper leng...
talking between python tcp server and a c++ client
I am having an issue trying to communicate between a python TCP server and a c++ TCP client. After the first call, which works fine, the subsequent calls cause issues. As far as WinSock is concerned, the send() function worked properly, it returns the proper length and WSAGetLastError() does not return anything of sig...
[ "\nclient sends a PSH,ACK and then the\n server sends a PSH,ACK and a\n FIN,PSH,ACK\n\nThere is a FIN, so could it be that the Python version of your server is closing the connection immediately after the initial read?\nIf you are not explicitly closing the server's socket, it's probable that the server's remote ...
[ 2, 1 ]
[]
[]
[ "c++", "networking", "python", "sockets", "winsock" ]
stackoverflow_0001423251_c++_networking_python_sockets_winsock.txt
Q: exposing or hiding objects of dependencies? Common scenario: I have a library that uses other libraries. For example, a math library (let's call it foo) that uses numpy. Functions of foo can either: return a numpy object (either pure or an inherited reimplementation) return a list return a foo-implemented object ...
exposing or hiding objects of dependencies?
Common scenario: I have a library that uses other libraries. For example, a math library (let's call it foo) that uses numpy. Functions of foo can either: return a numpy object (either pure or an inherited reimplementation) return a list return a foo-implemented object that behaves like numpy (performing delegation) ...
[ "Since you're talking about return values, that's not really about \"internal objects\" -- you should just document the interfaces your returned objects will support (it's OK if that's a subset of numpy.array or whatever;-). I recommend against returning a reference to your internal mutable attributes and documenti...
[ 3, 2 ]
[]
[]
[ "python" ]
stackoverflow_0001424534_python.txt
Q: How do you mix old-style and new-style Python classes? I've seen a few questions on this topic, but I haven't been able to find a definitive answer. I would like to know the proper way to use old-style classes in a new Python code base. Let's say for example that I have two fixed classes, A and B. If I want to su...
How do you mix old-style and new-style Python classes?
I've seen a few questions on this topic, but I haven't been able to find a definitive answer. I would like to know the proper way to use old-style classes in a new Python code base. Let's say for example that I have two fixed classes, A and B. If I want to subclass A and B, and convert to new-style classes (A2 and B2)...
[ "This is not a issue of mixing old and new style classes. super() does not call all base classes functions, it calls the first one it finds according the method resolution order. In this case A2, which in turn calls A.\nIf you want to call both, do so explicitly:\nclass C(A2, B2):\n def __init__(self):\n A2....
[ 7 ]
[]
[]
[ "class", "instantiation", "multiple_inheritance", "python" ]
stackoverflow_0001425714_class_instantiation_multiple_inheritance_python.txt
Q: Method assignment and objects i've got a problem with python: I want to assign a method to an object form another class, but in this method use its own attributes. Since i have many container with different use methods in my project (not in that example) i dont want to use inheritance, thad would force me to creat...
Method assignment and objects
i've got a problem with python: I want to assign a method to an object form another class, but in this method use its own attributes. Since i have many container with different use methods in my project (not in that example) i dont want to use inheritance, thad would force me to create a custom class for each instance....
[ "Here you go. You should know that self.test is already bound since by the time you are in __init__ the instance has already been created and its methods are bound. Therefore you must access the unbound member by using the im_func member, and binding it with MethodType.\nimport types\n\nclass container():\n def ...
[ 2, 1, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0001425414_python.txt
Q: Problem configparser in python Actually I am stuck in my work. I want to import a txt file into my python program which should have two lists of intergers. The following program is working fine but I need to import the list 'a' and 'b' with the help of configparser. It will be so nice if some one help me with it!...
Problem configparser in python
Actually I am stuck in my work. I want to import a txt file into my python program which should have two lists of intergers. The following program is working fine but I need to import the list 'a' and 'b' with the help of configparser. It will be so nice if some one help me with it! I am a begineer in python so please...
[ "Seems like ConfigParser is not the best tool for the job. You may implement the parsing logic youself something like:\na, b = [], []\nwith open('myfile', 'r') as f:\n for num, line in enumerate(f.readlines()):\n if num >= 10: \n b.push(line)\n else:\n a.push(line)\n\nor you c...
[ 0, 0, 0 ]
[]
[]
[ "configparser", "python" ]
stackoverflow_0001426241_configparser_python.txt
Q: How to save a configuration file / python file IO I have this python code for opening a .cfg file, writing to it and saving it: import ConfigParser def get_lock_file(): cf = ConfigParser.ConfigParser() cf.read("svn.lock") return cf def save_lock_file(configurationParser): ...
How to save a configuration file / python file IO
I have this python code for opening a .cfg file, writing to it and saving it: import ConfigParser def get_lock_file(): cf = ConfigParser.ConfigParser() cf.read("svn.lock") return cf def save_lock_file(configurationParser): cf = configurationParser config_file = open('sv...
[ "Just to note that configuration file handling is simpler with ConfigObj.\nTo read and then write a config file:\nfrom configobj import ConfigObj\nconfig = ConfigObj(filename)\n\nvalue = config['entry']\nconfig['entry'] = newvalue\nconfig.write()\n\n", "Looks good to me.\nIf both places call get_lock_file, then ...
[ 13, 1, 1 ]
[]
[]
[ "configuration_files", "file", "file_io", "python" ]
stackoverflow_0001423214_configuration_files_file_file_io_python.txt
Q: How do scripting languages use sockets? Python, Perl and PHP, all support TCP stream sockets. But exactly how do I use sockets in a script file that is run by a webserver (eg Apache), assuming I only have FTP access and not root access to the machine? When a client connects to a specific port, how does the script...
How do scripting languages use sockets?
Python, Perl and PHP, all support TCP stream sockets. But exactly how do I use sockets in a script file that is run by a webserver (eg Apache), assuming I only have FTP access and not root access to the machine? When a client connects to a specific port, how does the script file get invoked? Does the script stay "runn...
[ "Scripting languages utilize sockets exactly the same way as compiled languages.\n1) The script typically opens and uses the socket. It's not \"run\" or \"invoked\" by the socket, but directly controls it via libraries (typically calling into the native C API for the OS).\n2) Yes.\n3) Not necessarily. Most modern...
[ 6, 2, 1, 1 ]
[]
[]
[ "perl", "php", "python", "scripting", "sockets" ]
stackoverflow_0001424511_perl_php_python_scripting_sockets.txt
Q: Problem with import in Python [Closing NOTE] Thank you everyone that trying to help me. I've found the problem and it have nothing to do with python understanding of mine (which is little). :p The problem is that I edit the wrong branch of the same project, Main.py in one branch and XWinInfos.py in another branch....
Problem with import in Python
[Closing NOTE] Thank you everyone that trying to help me. I've found the problem and it have nothing to do with python understanding of mine (which is little). :p The problem is that I edit the wrong branch of the same project, Main.py in one branch and XWinInfos.py in another branch. Thanks anyway. [Original Question]...
[ "Hmm... there's several typos in your example, so I wonder if your actual code has some typos as well. Here's the complete source from a quick test that does work fine without import errors.\nSomeUtils.py:\ndef funct1():\n print('Function 1')\n\ndef funct2():\n print('Function 2')\n\nclass MyClass1(object):\...
[ 3, 2, 1, 1, 0 ]
[]
[]
[ "import", "python" ]
stackoverflow_0001427855_import_python.txt
Q: How do you make a PDF searchable with text in the sidebar? I'm looking to create some PDF's from Python. I've noticed that some pdf's have sidebar text that allows you to see the context of occurrences of search terms. e.g. search for "dictionary" View in Sidebar: Page 10 Assigning a value to an existing dictionar...
How do you make a PDF searchable with text in the sidebar?
I'm looking to create some PDF's from Python. I've noticed that some pdf's have sidebar text that allows you to see the context of occurrences of search terms. e.g. search for "dictionary" View in Sidebar: Page 10 Assigning a value to an existing dictionary key simply replaces the old value with a new one. How is that...
[ "If you use Reportlab to generate your pdfs, then there are facilities in the library to bookmark as you want. Checkout the bookmarkPage method on page 54 of the documentation.\n", "I believe what you're referring to are bookmarks. The first hit on Google indicates that you can put them in by hand with Acrobat Pr...
[ 1, 0, 0 ]
[]
[]
[ "pdf", "python" ]
stackoverflow_0001351510_pdf_python.txt
Q: python html integration this is a complete n00b question and i understand i may get voted down for asking this but i am totally confused over python's html integration. as i understand one way to integrate python with html code is by using mod_python. now, is there any other way or method that is more effective fo...
python html integration
this is a complete n00b question and i understand i may get voted down for asking this but i am totally confused over python's html integration. as i understand one way to integrate python with html code is by using mod_python. now, is there any other way or method that is more effective for using python with html? ple...
[ "I would suggest you to start with web.py\n", "You can read a tutorial on how to use Python in the web.\nhttp://docs.python.org/howto/webservers.html\nIn few words, mod_python keeps python interpreter in memory ready to execute python scripts, which is faster than launching it every time. It doesn't let you integ...
[ 3, 2, 1 ]
[]
[]
[ "html", "python" ]
stackoverflow_0001428260_html_python.txt
Q: Is it possible to make re find the smallest match while using greedy characters Disclaimer: I'm not a regex expert. I'm using Python re module to perform regex matching on many htm files. One of the patterns is something like this: <bla><blabla>87765.*</blabla><bla> The problem I've encountered is that instead of...
Is it possible to make re find the smallest match while using greedy characters
Disclaimer: I'm not a regex expert. I'm using Python re module to perform regex matching on many htm files. One of the patterns is something like this: <bla><blabla>87765.*</blabla><bla> The problem I've encountered is that instead of finding all (say) five occurrences of the pattern, it will find only one. Because it...
[ "You can use a reluctant qualifier in your pattern (for more details, reference the python documentation on the *?, +?, and ?? operators):\n<bla><blabla>87765.*?</blabla><bla>\n\nOr, exclude < from the possible matched characters:\n<bla><blabla>87765[^<]*</blabla><bla>\n\nonly if there are no children tags between ...
[ 19, 5, 1, 0 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0001428780_python_regex.txt
Q: Extending Jython Syntax I would like to add syntax to Jython to enable a nicer API for users. For instance, matrix libraries like NumPy would benefit from having both matrix and elementwise operations like Matlab's :* vs. * infix operators. You can create a matrix in Octave using: A = [ 1, 1, 2; 3, 5, 8; 13, 21, 3...
Extending Jython Syntax
I would like to add syntax to Jython to enable a nicer API for users. For instance, matrix libraries like NumPy would benefit from having both matrix and elementwise operations like Matlab's :* vs. * infix operators. You can create a matrix in Octave using: A = [ 1, 1, 2; 3, 5, 8; 13, 21, 34 ] which is considerably ni...
[ "To the best of my knowledge there is not a macro / syntax expanding facility similar to EasyExtend, although the developer of EasyExtend has been working on some jython projects recently (including some which are similar to EE). I suppose you could write a preprocessor of some kind, but I would tend to suggest th...
[ 1 ]
[]
[]
[ "dsl", "jython", "python" ]
stackoverflow_0001331784_dsl_jython_python.txt
Q: Python switch order of elements I am a newbie and seeking for the Zen of Python :) Today's koan was finding the most Pythonesq way to solve the following problem: Permute the letters of a string pairwise, e.g. input: 'abcdefgh' output: 'badcfehg' A: I'd go for: s="abcdefgh" print "".join(b+a for a,b in zip(s[...
Python switch order of elements
I am a newbie and seeking for the Zen of Python :) Today's koan was finding the most Pythonesq way to solve the following problem: Permute the letters of a string pairwise, e.g. input: 'abcdefgh' output: 'badcfehg'
[ "I'd go for:\ns=\"abcdefgh\"\nprint \"\".join(b+a for a,b in zip(s[::2],s[1::2]))\n\ns[start:end:step] takes every step'th letter, zip matches them up pairwise, the loop swaps them, and the join gives you back a string.\n", "my personal favorite to do stuff pairwise:\ndef pairwise( iterable ):\n it = iter(itera...
[ 13, 6, 5, 2, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0001428547_python.txt
Q: lxml equivalent to BeautifulSoup "OR" syntax? I'm converting some html parsing code from BeautifulSoup to lxml. I'm trying to figure out the lxml equivalent syntax for the following BeautifullSoup statement: soup.find('a', {'class': ['current zzt', 'zzt']}) Basically I want to find all of the "a" tags in the doc...
lxml equivalent to BeautifulSoup "OR" syntax?
I'm converting some html parsing code from BeautifulSoup to lxml. I'm trying to figure out the lxml equivalent syntax for the following BeautifullSoup statement: soup.find('a', {'class': ['current zzt', 'zzt']}) Basically I want to find all of the "a" tags in the document that have a class attribute of either "curren...
[ "No, lxml does not provide the \"find first or return None\" method you're looking for. Just use (select(soup) or [None])[0] if you need that, or write a function to do it for you.\n#!/usr/bin/python\nimport lxml.html\nimport lxml.cssselect\nsoup = lxml.html.fromstring(\"\"\"\n <html>\n <a href=\"foo\...
[ 3 ]
[]
[]
[ "beautifulsoup", "lxml", "python" ]
stackoverflow_0001384470_beautifulsoup_lxml_python.txt
Q: Managing object instances I want to be able to create and unknown number of objects. I'm not sure if there is a better way to manage and reference them. Lets use a standard OOP example... say every time a user enters a name for a pet in a text field and clicks a button a new pet object is created via the petFactor...
Managing object instances
I want to be able to create and unknown number of objects. I'm not sure if there is a better way to manage and reference them. Lets use a standard OOP example... say every time a user enters a name for a pet in a text field and clicks a button a new pet object is created via the petFactory function. function pet(name) ...
[ "\"I could use an associative array\" Correct.\n\"the array is the only method I know for doing this.\"\nLearn about \"Mappings\" or \"Dictionaries\" as soon as you can. You will find that it does exactly what you're asking for.\nWhat language are you using? If you provide a specific language, we can provide spec...
[ 3, 2, 0 ]
[]
[]
[ "actionscript_3", "javascript", "oop", "python" ]
stackoverflow_0001427479_actionscript_3_javascript_oop_python.txt
Q: Using GetExtendedTcpTable in Python I am trying to use GetExtendedTcpTable via a Python program. Basically I am trying to convert "ActiveState Code Recipe 392572: Using the Win32 IPHelper API" to "Getting the active TCP/UDP connections using the GetExtendedTcpTable function". My problem is that I cannot seem to...
Using GetExtendedTcpTable in Python
I am trying to use GetExtendedTcpTable via a Python program. Basically I am trying to convert "ActiveState Code Recipe 392572: Using the Win32 IPHelper API" to "Getting the active TCP/UDP connections using the GetExtendedTcpTable function". My problem is that I cannot seem to get the Python script to recognize TCP_T...
[ "The TCP_TABLE_CLASS is an enum\n\ntypedef enum {\n TCP_TABLE_BASIC_LISTENER,\n TCP_TABLE_BASIC_CONNECTIONS,\n TCP_TABLE_BASIC_ALL,\n TCP_TABLE_OWNER_PID_LISTENER,\n TCP_TABLE_OWNER_PID_CONNECTIONS,\n TCP_TABLE_OWNER_PID_ALL,\n TCP_TABLE_OWNER_MODULE_LISTENER,\n TCP_TABLE_OWNER_MODULE_CONNECTIONS,\n TCP_T...
[ 1, 0 ]
[]
[]
[ "python", "winapi" ]
stackoverflow_0001429403_python_winapi.txt
Q: Python - Windows Shutdown Events When using win32api.setConsoleCtrlHandler(), I'm able to receive shutdown/logoff/etc events from Windows, and cleanly shut down my app. However, this only works when running the app under python.exe (i.e., it has a console window), but not under pythonw.exe (no console window). Is ...
Python - Windows Shutdown Events
When using win32api.setConsoleCtrlHandler(), I'm able to receive shutdown/logoff/etc events from Windows, and cleanly shut down my app. However, this only works when running the app under python.exe (i.e., it has a console window), but not under pythonw.exe (no console window). Is there an equivalent way in Windows to ...
[ "The problem here was that the HWND_MESSAGE window type doesn't actually receive broadcast messages - like the WM_QUERYENDSESSION and WM_ENDSESSION.\nSo instead of specifying win32con.HWND_MESSAGE for the \"parent window\" parameter of CreateWindowEx(), I just specified 0.\nBasically, this creates an actual window,...
[ 15, 5 ]
[]
[]
[ "python", "windows" ]
stackoverflow_0001411186_python_windows.txt
Q: How to wait for a child that respawns itself with os.execv() on win32? I have some code that uses pip to bootstrap a Python envionment for out build process: this is a lovely way of ensuring we get proper isolation of the build requirements from the rest of the host system, and helping us get more consistent build...
How to wait for a child that respawns itself with os.execv() on win32?
I have some code that uses pip to bootstrap a Python envionment for out build process: this is a lovely way of ensuring we get proper isolation of the build requirements from the rest of the host system, and helping us get more consistent build results overall. Anyway, the code I have that drives pip.py appears to have...
[ "I can't think of any smooth way to handle this. This may sound dirty, but perhaps you could work with dropping flag files onto the filesystem while your script is running, and wait for those files to be cleaned up?\n" ]
[ 0 ]
[]
[]
[ "execv", "pip", "python", "windows" ]
stackoverflow_0001194078_execv_pip_python_windows.txt
Q: Pythonic way to split comma separated numbers into pairs I'd like to split a comma separated value into pairs: >>> s = '0,1,2,3,4,5,6,7,8,9' >>> pairs = # something pythonic >>> pairs [(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)] What would # something pythonic look like? How would you detect and handle a string with ...
Pythonic way to split comma separated numbers into pairs
I'd like to split a comma separated value into pairs: >>> s = '0,1,2,3,4,5,6,7,8,9' >>> pairs = # something pythonic >>> pairs [(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)] What would # something pythonic look like? How would you detect and handle a string with an odd set of numbers?
[ "Something like:\nzip(t[::2], t[1::2])\n\nFull example:\n>>> s = ','.join(str(i) for i in range(10))\n>>> s\n'0,1,2,3,4,5,6,7,8,9'\n>>> t = [int(i) for i in s.split(',')]\n>>> t\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n>>> p = zip(t[::2], t[1::2])\n>>> p\n[(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)]\n>>>\n\nIf the number of it...
[ 44, 8, 8, 4, 2 ]
[]
[]
[ "python", "tuples" ]
stackoverflow_0000870652_python_tuples.txt
Q: Benefit cost analysis libraries I was wondering if there are any opensource libraries that are geared towards transportation ben/cost analysis. I currently use microBENCOST and would like to build my own solution. I'm most comfortable with C/c++ and Python. cheers A: My girlfriend works for a transportation pl...
Benefit cost analysis libraries
I was wondering if there are any opensource libraries that are geared towards transportation ben/cost analysis. I currently use microBENCOST and would like to build my own solution. I'm most comfortable with C/c++ and Python. cheers
[ "My girlfriend works for a transportation planning firm, and they use a variety of models developed in SPSS, with a lot of data munging in Excel and visualization in ArcGIS. As far as turnkey solutions go, though, I think you're going to be more or less on your own.\nAssuming you want to move on to something a bit ...
[ 4, 2, 1 ]
[]
[]
[ "c++", "economics", "python", "transport" ]
stackoverflow_0001373902_c++_economics_python_transport.txt
Q: How to programmatically set a global (module) variable? I would like to define globals in a "programmatic" way. Something similar to what I want to do would be: definitions = {'a': 1, 'b': 2, 'c': 123.4} for definition in definitions.items(): exec("%s = %r" % definition) # a = 1, etc. Specifically, I want t...
How to programmatically set a global (module) variable?
I would like to define globals in a "programmatic" way. Something similar to what I want to do would be: definitions = {'a': 1, 'b': 2, 'c': 123.4} for definition in definitions.items(): exec("%s = %r" % definition) # a = 1, etc. Specifically, I want to create a module fundamentalconstants that contains variable...
[ "Here is a better way to do it:\nimport sys\ndefinitions = {'a': 1, 'b': 2, 'c': 123.4}\nmodule = sys.modules[__name__]\nfor name, value in definitions.iteritems():\n setattr(module, name, value)\n\n", "You can set globals in the dictionary returned by globals():\ndefinitions = {'a': 1, 'b': 2, 'c': 123.4}\nfo...
[ 68, 49, 4 ]
[]
[]
[ "global_variables", "module", "python" ]
stackoverflow_0001429814_global_variables_module_python.txt
Q: Symmetrically adressable matrix I'm looking to create a 2d matrix of integers with symmetric addressing ( i.e. matrix[2,3] and matrix[3,2] will return the same value ) in python. The integers will have addition and subtraction done on them, and be used for logical comparisons. My initial idea was to create the int...
Symmetrically adressable matrix
I'm looking to create a 2d matrix of integers with symmetric addressing ( i.e. matrix[2,3] and matrix[3,2] will return the same value ) in python. The integers will have addition and subtraction done on them, and be used for logical comparisons. My initial idea was to create the integer objects up front and try to fill...
[ "Golub and Van Loan's \"Matrix Computations\" book outlines a feasible addressing scheme:\nYou pack the data in to a vector and access as follows, assuming i >= j:\na_ij = A.vec((j-1)n - j(j-1)/2 + i) \n\n", "You're probably better off using a full square numpy matrix. Yes, it wastes half the memory storing re...
[ 3, 2, 1, 1 ]
[]
[]
[ "data_structures", "matrix", "python" ]
stackoverflow_0001425162_data_structures_matrix_python.txt
Q: Python 3 smtplib send with unicode characters I'm having a problem emailing unicode characters using smtplib in Python 3. This fails in 3.1.1, but works in 2.5.4: import smtplib from email.mime.text import MIMEText sender = to = 'ABC@DEF.com' server = 'smtp.DEF.com' msg = MIMEText('€10') msg['Subject...
Python 3 smtplib send with unicode characters
I'm having a problem emailing unicode characters using smtplib in Python 3. This fails in 3.1.1, but works in 2.5.4: import smtplib from email.mime.text import MIMEText sender = to = 'ABC@DEF.com' server = 'smtp.DEF.com' msg = MIMEText('€10') msg['Subject'] = 'Hello' msg['From'] = sender msg['To'] = t...
[ "The key is in the docs:\nclass email.mime.text.MIMEText(_text, _subtype='plain', _charset='us-ascii')\n\n\nA subclass of MIMENonMultipart, the\n MIMEText class is used to create MIME\n objects of major type text. _text is\n the string for the payload. _subtype\n is the minor type and defaults to\n plain. _cha...
[ 14, 2 ]
[]
[]
[ "email", "python", "python_3.x", "smtplib", "unicode" ]
stackoverflow_0001429147_email_python_python_3.x_smtplib_unicode.txt
Q: Application to generate installers for Linux, Windows and MacOSX from a single configuration Here's what I want: Given a set of definitions (preferably in Python) on what files to install where and what post-install script to run, etc.. I would like this program to generate installers for the three major platforms...
Application to generate installers for Linux, Windows and MacOSX from a single configuration
Here's what I want: Given a set of definitions (preferably in Python) on what files to install where and what post-install script to run, etc.. I would like this program to generate installers for the three major platforms: MSI on Windows dmg on MacOSX Tarball w/ install.sh (and rpm/deb, if possible) on Linux For exa...
[ "Look into CPack. It works very well with CMake, if you use that for your build system, but it also works without it. This uses CMake-type syntax, not Python, but it can generate NSIS installers, ZIP archives, binary executables on Linux, RPMs, DEBs, and Mac OS X bundles\n", "Your requirements are probably such t...
[ 3, 0, 0 ]
[]
[]
[ "cross_platform", "dmg", "installation", "python", "wix" ]
stackoverflow_0001430497_cross_platform_dmg_installation_python_wix.txt
Q: Rescale intensities of a PIL Image What is the simplest/cleanest way to rescale the intensities of a PIL Image? Suppose that I have a 16-bit image from a 12-bit camera, so only the values 0–4095 are in use. I would like to rescale the intensities so that the entire range 0–65535 is used. What is the simplest/cle...
Rescale intensities of a PIL Image
What is the simplest/cleanest way to rescale the intensities of a PIL Image? Suppose that I have a 16-bit image from a 12-bit camera, so only the values 0–4095 are in use. I would like to rescale the intensities so that the entire range 0–65535 is used. What is the simplest/cleanest way to do this when the image is r...
[ "Since you know that the pixel values are 0-4095, I can't find a faster way than this:\nnew_image= image.point(lambda value: value<<4 | value>>8)\n\nAccording to the documentation, the lambda function will be called at most 4096 times, whatever the size of your image.\nEDIT: Since the function given to point must b...
[ 3, 2, 2, 1, 0 ]
[]
[]
[ "image_processing", "python", "python_imaging_library" ]
stackoverflow_0001327954_image_processing_python_python_imaging_library.txt
Q: Kill sub-threads when Django restarts? I'm running Django, and I'm creating threads that run in parallel while Django runs. Those threads sometimes run external processes that block while waiting for external input. When I restart Django, those threads that are blocking while awaiting external input sometimes pers...
Kill sub-threads when Django restarts?
I'm running Django, and I'm creating threads that run in parallel while Django runs. Those threads sometimes run external processes that block while waiting for external input. When I restart Django, those threads that are blocking while awaiting external input sometimes persist through the restart, and further they ha...
[ "It's not easy for a Python process to kill its own threads -- even harder (nearly impossible) to kill the threads of another process, and I suspect the latter is the case you have... the \"restart\" is presumably happening on a different process, so those threads are more or less out of bounds for you!\nWhat I sug...
[ 2, 0 ]
[]
[]
[ "django", "multithreading", "python" ]
stackoverflow_0001430517_django_multithreading_python.txt
Q: Python: Traversing a string, checking its element, and inputting dictionary key-value pairs I have a function that returns an 8 digit long binary string for given parameter: def rule(x): rule = bin(x)[2:].zfill(8) return rule I want to traverse each index of this string and check if it is a zero or a one. I tried...
Python: Traversing a string, checking its element, and inputting dictionary key-value pairs
I have a function that returns an 8 digit long binary string for given parameter: def rule(x): rule = bin(x)[2:].zfill(8) return rule I want to traverse each index of this string and check if it is a zero or a one. I tried to write a code like this: def rule(x): rule = bin(x)[2:].zfill(8) while i < len(rule(x))...
[ "Is this what you want?\ndef rule(x) :\n rule = bin(x)[2:].zfill(8)\n return dict((index, 'ON' if int(i) else 'OFF') for index, i in enumerate(rule)) \n\n", "Here's a much more Pythonic version of the code you've written - hopefully the comments explain the code well enough to understand.\ndef rule(x):\n ...
[ 2, 0 ]
[]
[]
[ "python" ]
stackoverflow_0001430957_python.txt
Q: Configuring Roundup with Apache I think I just need a bit more guidance than what the documentation gives, and it's quite hard to find anything relating to Roundup and Apache specifically. All i'm trying to do currently is to have Apache display what the stand-alone server does when running roundup-server support=...
Configuring Roundup with Apache
I think I just need a bit more guidance than what the documentation gives, and it's quite hard to find anything relating to Roundup and Apache specifically. All i'm trying to do currently is to have Apache display what the stand-alone server does when running roundup-server support=C:/Roundup/ Running windows XP with a...
[ "First, requires the following modules enabled:\nLoadModule proxy_module modules/mod_proxy.so\nLoadModule proxy_ajp_module modules/mod_proxy_ajp.so\nLoadModule proxy_balancer_module modules/mod_proxy_balancer.so\nLoadModule proxy_connect_module modules/mod_proxy_connect.so\nLoadModule proxy_ftp_module modules/mod_p...
[ 3, 1 ]
[]
[]
[ "apache", "python", "roundup" ]
stackoverflow_0001430364_apache_python_roundup.txt
Q: What are the ways to run a server side script forever? I need to run a server side script like Python "forever" (or as long as possible without loosing state), so they can keep sockets open and asynchronously react to events like data received. For example if I use Twisted for socket communication. How would I ma...
What are the ways to run a server side script forever?
I need to run a server side script like Python "forever" (or as long as possible without loosing state), so they can keep sockets open and asynchronously react to events like data received. For example if I use Twisted for socket communication. How would I manage something like this? Am I confused? or are there are b...
[ "If you are using twisted then it has a whole infrastructure for starting and stopping daemons.\nhttp://twistedmatrix.com/projects/core/documentation/howto/application.html\n\nHow would I manage something like this?\n\nTwisted works well for this, read the link above\n\nAm I confused? or are there are better ways t...
[ 3, 1, 1, 0, 0 ]
[]
[]
[ "apache", "python", "sockets", "twisted", "webserver" ]
stackoverflow_0001427000_apache_python_sockets_twisted_webserver.txt
Q: Pylint, PyChecker or PyFlakes? I would like to get some feedback on these tools on: features; adaptability; ease of use and learning curve. A: Well, I am a bit curious, so I just tested the three myself right after asking the question ;-) Ok, this is not a very serious review, but here is what I can say: I trie...
Pylint, PyChecker or PyFlakes?
I would like to get some feedback on these tools on: features; adaptability; ease of use and learning curve.
[ "Well, I am a bit curious, so I just tested the three myself right after asking the question ;-)\nOk, this is not a very serious review, but here is what I can say:\nI tried the tools with the default settings (it's important because you can pretty much choose your check rules) on the following script:\n#!/usr/loca...
[ 292, 95 ]
[]
[]
[ "pep8", "pychecker", "pyflakes", "pylint", "python" ]
stackoverflow_0001428872_pep8_pychecker_pyflakes_pylint_python.txt
Q: Accessing Plist items in a dict I have a class in a module I that reads a plist (XML) file and returns a dict. This is extremely convenient because I can say something like: Data.ServerNow.Property().DefaultChart This returns a property dictionary, specifically the value for DefaultChart. Very elegant. However, a...
Accessing Plist items in a dict
I have a class in a module I that reads a plist (XML) file and returns a dict. This is extremely convenient because I can say something like: Data.ServerNow.Property().DefaultChart This returns a property dictionary, specifically the value for DefaultChart. Very elegant. However, assembling a dictionary this way fails...
[ "It doesn't work because the dot operator is not proper accessor syntax for python dictionaries. You;re trying to treat it as an object and access a property, rather than accessing a data member of the data structure.\n", "You can use getattr redefinition to treat dictionary keys as attributes, e.g.:\nclass xmld...
[ 2, 1 ]
[]
[]
[ "namespaces", "plist", "python", "xml" ]
stackoverflow_0001431424_namespaces_plist_python_xml.txt
Q: Casting regex arguments into a list Greetings, A script is working on one or more files. I want to pass the filenames (with regex in them) as arguments and put them in a list. What is the best way to do it? For example I would accept the following arguments: script.py file[1-3].nc #would create list [file1.nc, fil...
Casting regex arguments into a list
Greetings, A script is working on one or more files. I want to pass the filenames (with regex in them) as arguments and put them in a list. What is the best way to do it? For example I would accept the following arguments: script.py file[1-3].nc #would create list [file1.nc, file2.nc, file3.nc] that I can work on scrip...
[ "The glob module is exactly what you are looking for\nCheck the examples:\n>>> import glob\n>>> glob.glob('./[0-9].*')\n['./1.gif', './2.txt']\n>>> glob.glob('*.gif')\n['1.gif', 'card.gif']\n>>> glob.glob('?.gif')\n['1.gif']\n\nYou can use optparse or just sys.argv to get arguments. And pass them to glob.\n", "Up...
[ 4, 1 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0001431968_python_regex.txt
Q: In which module does the Timer class reside in python? Am reading the following online Timer manual for python 2.5, but am wondering where is the actual module where the class Timer resides? Gath A: The way to figure this out: on the page you linked to, there's an Up link. It goes to the threading module. A: ...
In which module does the Timer class reside in python?
Am reading the following online Timer manual for python 2.5, but am wondering where is the actual module where the class Timer resides? Gath
[ "The way to figure this out: on the page you linked to, there's an Up link. It goes to the threading module.\n", "It's in the threading module.\n" ]
[ 6, 1 ]
[]
[]
[ "python", "timer" ]
stackoverflow_0001432068_python_timer.txt
Q: deleting files with python scripts I want to delete some files with python scripts (while using Windows). I have tried the following code: >>>import os >>> os.remove ('D:\new.docx') but I am getting the following error: Traceback (most recent call last): File "<pyshell#1>", line 1, in -toplevel- os.remove...
deleting files with python scripts
I want to delete some files with python scripts (while using Windows). I have tried the following code: >>>import os >>> os.remove ('D:\new.docx') but I am getting the following error: Traceback (most recent call last): File "<pyshell#1>", line 1, in -toplevel- os.remove ('D:\new.docx') OSError: [Errno 22] Inv...
[ "\\ is the escape char for python. try replacing it with \\\\ .\nex:\nos.remove ('D:\\\\new.docx')\n\n", "A few options:\nEscape the backslash:\n>>> os.remove('D:\\\\new.docx')\n\nThe runtime library in Windows accepts a forward slash as a separator:\n>>> os.remove('D:/new.docx')\n\nRaw string:\n>>> os.remove(r'D...
[ 6, 6 ]
[]
[]
[ "file", "python" ]
stackoverflow_0001432122_file_python.txt
Q: Returning a list I have the following code: def foo(*args) print len(args) print args now I'd like to know how to return that same args list. I guess it should be simple? Thanks A: It is indeed simple: return args Here is the Python tutorial: There are also many resources on beginners python on the ne...
Returning a list
I have the following code: def foo(*args) print len(args) print args now I'd like to know how to return that same args list. I guess it should be simple? Thanks
[ "It is indeed simple:\nreturn args\n\nHere is the Python tutorial: \nThere are also many resources on beginners python on the net. Some are listed in this question.\n" ]
[ 6 ]
[]
[]
[ "python" ]
stackoverflow_0001432358_python.txt
Q: Is it possible to run pydev connected to a virtualbox instance? At the moment I'm developing using a simple editor, putty, and a VirtualBox instance of a linux server. I've heard good things about pydev and would like to try it, but I'd like to use the python install & terminal from my VirtualBox guest OS. I'm alr...
Is it possible to run pydev connected to a virtualbox instance?
At the moment I'm developing using a simple editor, putty, and a VirtualBox instance of a linux server. I've heard good things about pydev and would like to try it, but I'd like to use the python install & terminal from my VirtualBox guest OS. I'm already using a Shared Folder with VirtualBox so my Guest OS can see my ...
[ "I assume your host box is windows.\nI also assume that pydev will run under linux (since it's eclipse based). Are you ok installing the dev environment on your linux server?\nIn which case:\n\ninstall and run xming on your windows box\nInstall eclipse & pydev on your linux box\nConfigure x forwarding in putty\nRun...
[ 1, 0 ]
[]
[]
[ "linux", "pydev", "python", "virtualbox" ]
stackoverflow_0001431936_linux_pydev_python_virtualbox.txt
Q: Help with Admin forms validation error I am quite new to Django, I'm having few problems with validation forms in Admin module, more specifically with raising exceptions in the ModelForm. I can validate and manipulate data in clean methods but cannot seem to raise any errors. Whenever I include any raise statement...
Help with Admin forms validation error
I am quite new to Django, I'm having few problems with validation forms in Admin module, more specifically with raising exceptions in the ModelForm. I can validate and manipulate data in clean methods but cannot seem to raise any errors. Whenever I include any raise statement I get this error "'NoneType' object has no ...
[ "You problem might be in the * import.\nfrom proj.models import * \n\nif proj.models contains any variable named forms (including some module import like \"from django import forms), it could trounce your initial import of:\nfrom django import forms\n\nI would explicitly import from proj.models, e.g.\nfrom proj.mod...
[ 4 ]
[]
[]
[ "django", "django_admin", "django_models", "python" ]
stackoverflow_0001432530_django_django_admin_django_models_python.txt
Q: Load an existing many-to-many table relation with sqlalchemy I'm using SqlAlchemy to interact with an existing PostgreSQL database. I need to access data organized in a many-to-many relationship. The documentation describes how to create relationships, but I cannot find an example for neatly loading and query an ...
Load an existing many-to-many table relation with sqlalchemy
I'm using SqlAlchemy to interact with an existing PostgreSQL database. I need to access data organized in a many-to-many relationship. The documentation describes how to create relationships, but I cannot find an example for neatly loading and query an existing one.
[ "Querying an existing relation is not really different than creating a new one. You pretty much write the same code but specify the table and column names that are already there, and of course you won't need SQLAlchemy to issue the CREATE TABLE statements.\nSee http://www.sqlalchemy.org/docs/05/mappers.html#many-to...
[ 1 ]
[]
[]
[ "python", "sqlalchemy" ]
stackoverflow_0001430584_python_sqlalchemy.txt
Q: Generate and parse Python code from C# application I need to generate Python code to be more specific IronPyton. I also need to be able to parse the code and to load it into AST. I just started looking at some tools. I played with "Oslo" and made a decision that it's not the right tool for me. I just looked very b...
Generate and parse Python code from C# application
I need to generate Python code to be more specific IronPyton. I also need to be able to parse the code and to load it into AST. I just started looking at some tools. I played with "Oslo" and made a decision that it's not the right tool for me. I just looked very briefly at Coco/R and it looks promising. Does anyone use...
[ "The IronPython implementation itself includes a parser and an AST representation of Python programs which can be walked with a PythonWalker.\n", "Not really my area of expertise but you might want to try ANTLR 4. It has support for generating Python 2 and Python 3.\n", "I think you should look at the Dynamic L...
[ 11, 2, 0 ]
[]
[]
[ "c#", "cocor", "code_generation", "ironpython", "python" ]
stackoverflow_0001432998_c#_cocor_code_generation_ironpython_python.txt
Q: Getting text values from XML in Python from xml.dom.minidom import parseString dom = parseString(data) data = dom.getElementsByTagName('data') the 'data' variable returns as an element object but I cant for the life of me see in the documentation to grab the text value of the element. For example: <something><dat...
Getting text values from XML in Python
from xml.dom.minidom import parseString dom = parseString(data) data = dom.getElementsByTagName('data') the 'data' variable returns as an element object but I cant for the life of me see in the documentation to grab the text value of the element. For example: <something><data>I WANT THIS</data></something> Anyone hav...
[ "So the way to look at it is that \"I WANT THIS\" is actually another node. It's a text child of \"data\".\nfrom xml.dom.minidom import parseString\ndom = parseString(data)\nnodes = dom.getElementsByTagName('data')\n\nAt this point, \"nodes\" is a NodeList and in your example, it has one item in it which is the \"...
[ 4, 3 ]
[]
[]
[ "parsing", "python", "xml" ]
stackoverflow_0001433907_parsing_python_xml.txt
Q: python help needed import os import sys, urllib2, urllib import re import time from threading import Thread class testit(Thread): def __init__ (self): Thread.__init__(self) def run(self): url = 'http://games.espnstar.asia/the-greatest-odi/post_brackets.php' data = urllib.urlencode([('i...
python help needed
import os import sys, urllib2, urllib import re import time from threading import Thread class testit(Thread): def __init__ (self): Thread.__init__(self) def run(self): url = 'http://games.espnstar.asia/the-greatest-odi/post_brackets.php' data = urllib.urlencode([('id',"btn_13_9_13"), ('ma...
[ "I edited your post to replace all the tabs with <TAB>. You need to delete the indentation on those lines and line it back up with spaces. Some editors can do that for you, but I don't know which editor you are using.\nIf you get serious about Python, you should reconfigure your editor to always insert 4 spaces whe...
[ 5, 4 ]
[]
[]
[ "indentation", "python" ]
stackoverflow_0001434276_indentation_python.txt
Q: PyQt4 - Image Watermark I'm trying to open a PNG image and write some text to it (a watermark) via QImage and QPainter. The code works 100% on Linux but when I run it on Windows XP (haven't tested with any other versions of Windows) the text is never written to the image. I have the code in a try/except block, but...
PyQt4 - Image Watermark
I'm trying to open a PNG image and write some text to it (a watermark) via QImage and QPainter. The code works 100% on Linux but when I run it on Windows XP (haven't tested with any other versions of Windows) the text is never written to the image. I have the code in a try/except block, but no errors are returned. imag...
[ "First thing that comes to my mind is maybe it isn't finding the specified font on Windows.\n", "My guess would be that whatever png lib you are using on Windows doesn't do tranparency (properly)\n" ]
[ 0, 0 ]
[]
[]
[ "pyqt4", "python", "qimage", "qpainter" ]
stackoverflow_0001434582_pyqt4_python_qimage_qpainter.txt
Q: Invalid syntax error for "print expr"? import os import sys, urllib2, urllib import re import time from threading import Thread class testit(Thread): def _init_ (self): Thread.__init__(self) def run(self): url = 'http://games.espnstar.asia/the-greatest-odi/post_brackets.php' ...
Invalid syntax error for "print expr"?
import os import sys, urllib2, urllib import re import time from threading import Thread class testit(Thread): def _init_ (self): Thread.__init__(self) def run(self): url = 'http://games.espnstar.asia/the-greatest-odi/post_brackets.php' data = urllib.urlencode([('id',"btn_13_9_...
[ "This is because (in Python 3.0 onwards at least), print is a function.\nUse:\nprint (time.ctime())\n\nand it should be fine.\n" ]
[ 4 ]
[ "From this page:\n\nctime(...)\nctime(seconds) -> string\nConvert a time in seconds since the Epoch to a string in local time.\nThis is equivalent to asctime(localtime(seconds)).\n\nctime requires an argument and you aren't giving it one. If you're trying to get the current time, try time.time() instead. Or, if you...
[ -2 ]
[ "python", "syntax_error" ]
stackoverflow_0001434751_python_syntax_error.txt
Q: Python Multiprocessing exit error I am seeing this when I press Ctrl-C to exit my app Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/python2.6/multiprocessing/util.py", line 269, in _exi...
Python Multiprocessing exit error
I am seeing this when I press Ctrl-C to exit my app Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/python2.6/multiprocessing/util.py", line 269, in _exit_function p.join() File "/usr/li...
[ "This is related to interactions OS system calls, signals and how it's handled in the multiprocessing module. I'm not really sure if it's a bug or a feature, but it's in somewhat tricky territory as it's where python meets the os.\nThe problem is that multiprocessing is blocking on waitpid until the child it's wait...
[ 6, 0 ]
[]
[]
[ "exception", "multiprocessing", "python" ]
stackoverflow_0001238349_exception_multiprocessing_python.txt
Q: Using UTM with geodjango I'm looking into using the UTM coordinate system with geodjango. And I can't figure out how to get the data in properly. I've been browsing the documentation and it seems that the "GEOSGeometry(geo_input, srid=None)" or "OGRGeometry" could be used with an EWKT, but I can't figure out how t...
Using UTM with geodjango
I'm looking into using the UTM coordinate system with geodjango. And I can't figure out how to get the data in properly. I've been browsing the documentation and it seems that the "GEOSGeometry(geo_input, srid=None)" or "OGRGeometry" could be used with an EWKT, but I can't figure out how to format the data. It looks li...
[ "The UTM zone (17N) is already specified by the spatial reference system -- SRID 2029, so you don't need to include it in the WKT you pass to the GEOSGeometry constructor.\n>>> from django.contrib.gis.geos import *\n>>> pnt = GEOSGeometry('SRID=2029;POINT(630084 4833438)')\n>>> (pnt.x, pnt.y)\n(630084.0, 4833438.0...
[ 6 ]
[]
[]
[ "django", "gdal", "geodjango", "geos", "python" ]
stackoverflow_0001332376_django_gdal_geodjango_geos_python.txt
Q: Matplotlib Legend for Scatter with custom colours I'm a bit of newbie at this and am trying to create a scatter chart with custom bubble sizes and colours. The chart displays fine but how do I get a legend saying what the colours refer to. This is as far as I've got: inc = [] out = [] bal = [] col = [] fig=Figu...
Matplotlib Legend for Scatter with custom colours
I'm a bit of newbie at this and am trying to create a scatter chart with custom bubble sizes and colours. The chart displays fine but how do I get a legend saying what the colours refer to. This is as far as I've got: inc = [] out = [] bal = [] col = [] fig=Figure() ax=fig.add_subplot(111) inc = (30000,20000,70000)...
[ "Maybe this example is helpful.\nIn general, the items in the legend are related with some kind of plotted object. The scatter function/method treats all circles as a single object, see:\nprint type(ax.scatter(...))\n\nThus the solution is to create multiple objects. Hence, calling scatter multiple times.\nUnfortun...
[ 10 ]
[]
[]
[ "charts", "matplotlib", "python" ]
stackoverflow_0001435535_charts_matplotlib_python.txt
Q: Getting Started with Tornado After installing the necessary packages through apt (python 2.5, simplejson etc) I get an error when I try to run the demos. : Request instance has no attribute 'responseHeaders' /usr/lib/python2.5/site-packages/tornado/web.py, line 404 in flush 402 for k,v in self._generate_header...
Getting Started with Tornado
After installing the necessary packages through apt (python 2.5, simplejson etc) I get an error when I try to run the demos. : Request instance has no attribute 'responseHeaders' /usr/lib/python2.5/site-packages/tornado/web.py, line 404 in flush 402 for k,v in self._generate_headers(): 403 if isinstance(v, li...
[ "I was under the impression tornado didn't depend on twisted. Have you tried the \"official\" version? line 404 is completely different.\nhttp://github.com/facebook/tornado/blob/master/tornado/web.py\ndef flush(self, include_footers=False):\n \"\"\"Flushes the current output buffer to the nextwork.\"\"\"\n i...
[ 2 ]
[]
[]
[ "python", "tornado", "twisted" ]
stackoverflow_0001435896_python_tornado_twisted.txt
Q: manage.py syncdb doesn't add tables for some models My second not-so-adept question of the day: I have a django project with four installed apps. When I run manage.py syndb, it only creates tables for two of them. To my knowledge, there are no problems in any of my models files, and all the apps are specified in I...
manage.py syncdb doesn't add tables for some models
My second not-so-adept question of the day: I have a django project with four installed apps. When I run manage.py syndb, it only creates tables for two of them. To my knowledge, there are no problems in any of my models files, and all the apps are specified in INSTALLED_APPS in my settings file. Manage.py syndb just s...
[ "I think I ran across something similar.\nI had an issue where a model wasn't being reset.\nIn this case it turned out that there was an error in my models that wasn't being spit out.\nAlthough I think syncdb, when run, spit out some kind of error.\nIn any case try to import your models file from the shell and see ...
[ 8, 6 ]
[]
[]
[ "django", "django_models", "django_syncdb", "python" ]
stackoverflow_0001435523_django_django_models_django_syncdb_python.txt
Q: Socket in use error when reusing sockets I am writing an XMLRPC client in c++ that is intended to talk to a python XMLRPC server. Unfortunately, at this time, the python XMLRPC server is only capable of fielding one request on a connection, then it shuts down, I discovered this thanks to mhawke's response to m...
Socket in use error when reusing sockets
I am writing an XMLRPC client in c++ that is intended to talk to a python XMLRPC server. Unfortunately, at this time, the python XMLRPC server is only capable of fielding one request on a connection, then it shuts down, I discovered this thanks to mhawke's response to my previous query about a related subject Becau...
[ "The problem is being caused by sockets hanging around in the TIME_WAIT state which is entered once you close the client's socket. By default the socket will remain in this state for 4 minutes before it is available for reuse. Your client (possibly helped by other processes) is consuming them all within a 4 minute ...
[ 11, 1, 0 ]
[]
[]
[ "c++", "python", "sockets", "xml_rpc" ]
stackoverflow_0001434914_c++_python_sockets_xml_rpc.txt
Q: state of HTML after onload javascript many webpages use onload JavaScript to manipulate their DOM. Is there a way I can automate accessing the state of the HTML after these JavaScript operations? A took like wget is not useful here because it just downloads the original source. Is there perhaps a way to use a web...
state of HTML after onload javascript
many webpages use onload JavaScript to manipulate their DOM. Is there a way I can automate accessing the state of the HTML after these JavaScript operations? A took like wget is not useful here because it just downloads the original source. Is there perhaps a way to use a web browser rendering engine? Ideally I am aft...
[ "The only good way I know to do such things is to automate a browser, for example via Selenium RC. If you have no idea of how to deduce that the page has finished running the relevant javascript, then, just a real live user visiting that page, you'll just have to wait a while, grab a snapshot, wait some more, grab ...
[ 2, 1 ]
[]
[]
[ "html", "javascript", "python", "screen_scraping" ]
stackoverflow_0001436211_html_javascript_python_screen_scraping.txt
Q: Python: bind child class at run time Can anyone tell me how to bind to specific child class at run time in the following code? I want mCar instance in the following example redirect to class Truck or Compact according to command line options? class Car(object): pass class Truck(Car): pass class Compact(...
Python: bind child class at run time
Can anyone tell me how to bind to specific child class at run time in the following code? I want mCar instance in the following example redirect to class Truck or Compact according to command line options? class Car(object): pass class Truck(Car): pass class Compact(Car): pass and a instance of Car mCar...
[ "You mean like this?\ncar_classes = {\n'car' : Car,\n'truck' : Truck,\n'compact' : Compact\n}\n\nif __name__ == '__main__':\n option = sys.argv[1]\n mCar = car_classes[option]()\n print 'I am a', mCar.__class__.__name__\n\n", "As a side note, while not particularly recommended, it IS possible to as...
[ 4, 1 ]
[]
[]
[ "class", "python" ]
stackoverflow_0001434949_class_python.txt
Q: Thread error in Python & PyQt I noticed that when the function setModel is executed in parallel thread (I tried threading.Timer or threading.thread), I get this: QObject: Cannot create children for a parent that is in a different thread. (Parent is QHeaderView(0x1c93ed0), parent's thread is QThread(0xb179c0), curr...
Thread error in Python & PyQt
I noticed that when the function setModel is executed in parallel thread (I tried threading.Timer or threading.thread), I get this: QObject: Cannot create children for a parent that is in a different thread. (Parent is QHeaderView(0x1c93ed0), parent's thread is QThread(0xb179c0), current thread is QThread(0x23dce38) QO...
[ "It is indeed a fact of life that multithreaded use of Qt (and other rich frameworks) is a delicate and difficult job, requiring explicit attention and care -- see Qt's docs for an excellent coverage of the subject (for readers experienced in threading in general, with suggested readings for those who yet aren't).\...
[ 5, 0 ]
[]
[]
[ "multithreading", "pyqt", "python" ]
stackoverflow_0001434831_multithreading_pyqt_python.txt
Q: Python - Iterate over all classes How can I iterate over a list of all classes loaded in memory? I'm thinking of doing it for a backup, looking for all classes inheriting from db.Model (Google App Engine). Thanks, Neal Walters A: In "normal" Python, you can reach all objects via the gc.getobjects() function o...
Python - Iterate over all classes
How can I iterate over a list of all classes loaded in memory? I'm thinking of doing it for a backup, looking for all classes inheriting from db.Model (Google App Engine). Thanks, Neal Walters
[ "In \"normal\" Python, you can reach all objects via the gc.getobjects() function of the gc standard library module; it's then very easy to loop on them, checking which one are classes (rather than instances or anything else -- I do believe you mean instances of classes, but you can very easily get the classes them...
[ 9, 2, 0 ]
[]
[]
[ "google_app_engine", "loops", "python" ]
stackoverflow_0001436384_google_app_engine_loops_python.txt
Q: Python web development - with or without a framework I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basically a ve...
Python web development - with or without a framework
I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basically a very light weight reporting interface. I did not use a fra...
[ "The command-line Python, IMO, definitely comes first. Get that to work, since that's the core of what you're doing.\nThe issue is that using a web framework's ORM from a command line application isn't obvious. Django provides specific instructions for using their ORM from a command-line app. Those are annoying ...
[ 15, 11, 4, 3, 2, 2, 2, 0 ]
[]
[]
[ "frameworks", "python" ]
stackoverflow_0000136069_frameworks_python.txt
Q: Fixing broken urls Does anyone know of a library for fixing "broken" urls. When I try to open a url such as http://www.domain.com/../page.html http://www.domain.com//page.html http://www.domain.com/page.html#stuff urllib2.urlopen chokes and gives me an HTTPError traceback. Does anyone know of a library that ca...
Fixing broken urls
Does anyone know of a library for fixing "broken" urls. When I try to open a url such as http://www.domain.com/../page.html http://www.domain.com//page.html http://www.domain.com/page.html#stuff urllib2.urlopen chokes and gives me an HTTPError traceback. Does anyone know of a library that can fix these sorts of thi...
[ "What about something like...:\nimport re\nimport urlparse\n\nurls = '''\nhttp://www.domain.com/../page.html\nhttp://www.domain.com//page.html\nhttp://www.domain.com/page.html#stuff\n'''.split()\n\ndef main():\n for u in urls:\n pieces = list(urlparse.urlparse(u))\n pieces[2] = re.sub(r'^[./]*', '/', pieces[...
[ 1 ]
[]
[]
[ "python", "url", "urllib2" ]
stackoverflow_0001436382_python_url_urllib2.txt
Q: Python: Passing a class name as a parameter to a function? class TestSpeedRetrieval(webapp.RequestHandler): """ Test retrieval times of various important records in the BigTable database """ def get(self): commandValidated = True beginTime = time() itemList = Subscriber.all().fetch(1000...
Python: Passing a class name as a parameter to a function?
class TestSpeedRetrieval(webapp.RequestHandler): """ Test retrieval times of various important records in the BigTable database """ def get(self): commandValidated = True beginTime = time() itemList = Subscriber.all().fetch(1000) for item in itemList: pass endTime =...
[ "class TestSpeedRetrieval(webapp.RequestHandler):\n \"\"\"\n Test retrieval times of various important records in the BigTable database \n \"\"\"\n def __init__(self, cls):\n self.cls = cls\n\n def get(self):\n commandValidated = True \n beginTime = time()\n itemList = self.cls.all().fetch(...
[ 30, 12, 3 ]
[]
[]
[ "function", "python" ]
stackoverflow_0001436444_function_python.txt
Q: unique pin generator The task is to generate a given number of numeric pins of a given length. Here's the code I came up with for a particular case of numeric pins that don't start with 0: def generate_pins(length, count): return random.sample(range(int('1' + '0' * (length - 1)), int('9' * length)), count) Ho...
unique pin generator
The task is to generate a given number of numeric pins of a given length. Here's the code I came up with for a particular case of numeric pins that don't start with 0: def generate_pins(length, count): return random.sample(range(int('1' + '0' * (length - 1)), int('9' * length)), count) How would you implement it? ...
[ "random.sample guarantees no repetition (\"sampling without replacement\", per the docs); is this condition part of your specs?\nAs expressed (without any word \"distinct\" to indicate lack of repetition), I'd do:\nimport random\nimport string\n\ndef generate_pins(length, count):\n return [''.join(random.choice(st...
[ 7, 1 ]
[]
[]
[ "python" ]
stackoverflow_0001436552_python.txt
Q: Python sort() method on list vs builtin sorted() function I know that __builtin__ sorted() function works on any iterable. But can someone explain this huge (10x) performance difference between anylist.sort() vs sorted(anylist) ? Also, please point out if I am doing anything wrong with way this is measured. """ ...
Python sort() method on list vs builtin sorted() function
I know that __builtin__ sorted() function works on any iterable. But can someone explain this huge (10x) performance difference between anylist.sort() vs sorted(anylist) ? Also, please point out if I am doing anything wrong with way this is measured. """ Example Output: $ python list_sort_timeit.py Using sort method...
[ "Your error in measurement is as follows: after your first call of test_list1.sort(), that list object IS sorted -- and Python's sort, aka timsort, is wickedly fast on already sorted lists!!! That's the most frequent error in using timeit -- inadvertently getting side effects and not accounting for them.\nHere's a...
[ 60, 14, 11 ]
[]
[]
[ "python", "sorting" ]
stackoverflow_0001436962_python_sorting.txt
Q: Better to install MySQL 32bit or 64bit on my 64bit Intel-based Mac (Perl/Python user)? I have had numerous headaches trying to get the MySQL APIs for Perl and Python working on my 64 bit Macbook Pro (Leopard). I installed the 64 bit version of MySQL, but Googling around now I have the impression that this could b...
Better to install MySQL 32bit or 64bit on my 64bit Intel-based Mac (Perl/Python user)?
I have had numerous headaches trying to get the MySQL APIs for Perl and Python working on my 64 bit Macbook Pro (Leopard). I installed the 64 bit version of MySQL, but Googling around now I have the impression that this could be the source of my pain. None of the various blogs and SO answers quite seem to work (for e...
[ "32-bit and 64-bit libraries don't play nice together. So, it depends whether you're using 32-bit Perl/Python or not.\nIf you are, you'll need 32-bit MySQL. Chances are your Python, at least, is 32-bit, since both the Apple-shipped Python and the binaries from python.org are 32-bit only. You can build 64-bit Pytho...
[ 4, 2 ]
[]
[]
[ "mysql", "perl", "python" ]
stackoverflow_0001436422_mysql_perl_python.txt
Q: Lightweight pickle for basic types in python? All I want to do is serialize and unserialize tuples of strings or ints. I looked at pickle.dumps() but the byte overhead is significant. Basically it looks like it takes up about 4x as much space as it needs to. Besides, all I need is basic types and have no need to s...
Lightweight pickle for basic types in python?
All I want to do is serialize and unserialize tuples of strings or ints. I looked at pickle.dumps() but the byte overhead is significant. Basically it looks like it takes up about 4x as much space as it needs to. Besides, all I need is basic types and have no need to serialize objects. marshal is a little better in ter...
[ "Take a look at json, at least the generated dumps are readable with many other languages.\n\nJSON (JavaScript Object Notation) http://json.org is a subset of JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data interchange format.\n\n", "personally i would use yaml. it's on par with json for enco...
[ 13, 8, 8, 6, 1, 0 ]
[ "Luckily there is solution which uses COMPRESSION, and solves \nthe general problem involving any arbitrary Python object \nincluding new classes. Rather than micro-manage mere \ntuples sometimes it's better to use a DRY tool.\nYour code will be more crisp and readily refactored \nin similar future situations. \ny_...
[ -1 ]
[ "pickle", "python", "serialization" ]
stackoverflow_0000532934_pickle_python_serialization.txt
Q: What are the risks (if any) of mixing Psyco into my project? I work on a large financial pricing application in which some long running calculations. We have identified some functions which can be sped up by the selective application of psyco. My management have requested an assessment of the costs & benefits of a...
What are the risks (if any) of mixing Psyco into my project?
I work on a large financial pricing application in which some long running calculations. We have identified some functions which can be sped up by the selective application of psyco. My management have requested an assessment of the costs & benefits of adding psyco into our stack. Given the critical nature of my proj...
[ "Why not try profiling it? Psyco has a pretty detailed logging facility:\n\nmemory usage: x+ kb\nPsyco's current notion of how much memory is consumes for the emitted machine code and supporting data structures. This is a rouch estimation of the memory overhead (the + sign is supposed to remind you that this figure...
[ 3, 2 ]
[]
[]
[ "psyco", "python" ]
stackoverflow_0001437403_psyco_python.txt
Q: Sorting by a field of another table referenced by a foreign key in SQLObject Is it possible to sort results returned by SQLObject by a value of another table? I have two tables: class Foo(SQLObject): bar = ForeignKey('Bar') class Bar(SQLObject): name = StringCol() foos = MultipleJo...
Sorting by a field of another table referenced by a foreign key in SQLObject
Is it possible to sort results returned by SQLObject by a value of another table? I have two tables: class Foo(SQLObject): bar = ForeignKey('Bar') class Bar(SQLObject): name = StringCol() foos = MultipleJoin('Foo') I'd like to get foos sorted by the name of a bar they are related to. D...
[ "Below is the answer of a SQLObject maintainer (he has trouble posting it himself because captcha is not displayed):\nDo an explicit join:\nfoos = Foo.select(Foo.q.barID==Bar.q.id, orderBy=Bar.q.name)\n\nThis generates a query:\nSELECT foo.id, foo.bar_id FROM foo, bar WHERE ((foo.bar_id) = (bar.id)) ORDER BY bar.na...
[ 3 ]
[]
[]
[ "python", "sorting", "sqlobject" ]
stackoverflow_0001413101_python_sorting_sqlobject.txt
Q: Encoding problems in PyQt My program stores file index in file packed by cPickle. There are non-english filenames. When I just do this print f [0] where f [0] is "\xc2\xe8\xf1\xee\xea\xee\xf1\xed\xfb\xe9 \xe3\xee\xe4" ("Високосный год" in normal view), it prints the string in proper way — in russian. When the pro...
Encoding problems in PyQt
My program stores file index in file packed by cPickle. There are non-english filenames. When I just do this print f [0] where f [0] is "\xc2\xe8\xf1\xee\xea\xee\xf1\xed\xfb\xe9 \xe3\xee\xe4" ("Високосный год" in normal view), it prints the string in proper way — in russian. When the program manually adds the string u...
[ "Have you run decode on the unpickled string using the correct encoding (\"cp1251\" by the look of it)? If not, you need to do this to make sure you're passing a Unicode string to the GUI.\n" ]
[ 2 ]
[]
[]
[ "encoding", "pyqt", "python" ]
stackoverflow_0001437838_encoding_pyqt_python.txt
Q: Retrieving values from 2 different tables with Django's QuerySet For the following models: class Topping(models.Model): name = models.CharField(max_length=100) class Pizza(models.Model): name = models.CharField(max_length=100) toppings = models.ManyToManyField(Toppping) My data looks like the followi...
Retrieving values from 2 different tables with Django's QuerySet
For the following models: class Topping(models.Model): name = models.CharField(max_length=100) class Pizza(models.Model): name = models.CharField(max_length=100) toppings = models.ManyToManyField(Toppping) My data looks like the following: Pizza and Topping tables joined: ID NAME TOPPINGS -----...
[ "I don't think there is a clean solution to this, since you want data from two different models. Depending on your data structure you might want to use select_related to avoid hitting the database for all the toppings. Going for your desired result, I would do:\nresult = []\npizzas = Pizza.objects.select_related()....
[ 2, 0 ]
[]
[]
[ "django", "django_models", "python" ]
stackoverflow_0001435438_django_django_models_python.txt
Q: What's the right way to use Unicode metadata in setup.py? I was writing a setup.py for a Python package using setuptools and wanted to include a non-ASCII character in the long_description field: #!/usr/bin/env python from setuptools import setup setup(... long_description=u"...", # in real code this value i...
What's the right way to use Unicode metadata in setup.py?
I was writing a setup.py for a Python package using setuptools and wanted to include a non-ASCII character in the long_description field: #!/usr/bin/env python from setuptools import setup setup(... long_description=u"...", # in real code this value is read from a text file ...) Unfortunately, passing a un...
[ "It is apparently a distutils bug that has been fixed in python 2.6: http://mail.python.org/pipermail/distutils-sig/2009-September/013275.html\nTarek suggests to patch post_to_server. The patch should pre-process all values in the\n\"data\" argument and turn them into unicode and then call the original method. Se...
[ 6, 4, 1 ]
[]
[]
[ "python", "setuptools", "unicode" ]
stackoverflow_0001162338_python_setuptools_unicode.txt
Q: Error while using multiprocessing module in a python daemon I'm getting the following error when using the multiprocessing module within a python daemon process (using python-daemon): Traceback (most recent call last): File "/usr/local/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **karg...
Error while using multiprocessing module in a python daemon
I'm getting the following error when using the multiprocessing module within a python daemon process (using python-daemon): Traceback (most recent call last): File "/usr/local/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/local/lib/python2.6/multiprocessing/util.py", lin...
[ "Your problem is a conflict between the daemon and multiprocessing modules, in particular in its handling of the SIGCLD (child process terminated) signal. daemon sets SIGCLD to SIG_IGN when launching, which, at least on Linux, causes terminated children to immediately be reaped (rather than becoming a zombie until ...
[ 7, 5, 0, 0, 0, 0 ]
[]
[]
[ "daemon", "multiprocessing", "python" ]
stackoverflow_0001359795_daemon_multiprocessing_python.txt
Q: Finding closest match in collection of strings representing numbers I have a sorted list of datetimes in text format. The format of each entry is '2009-09-10T12:00:00'. I want to find the entry closest to a target. There are many more entries than the number of searches I would have to do. I could change each en...
Finding closest match in collection of strings representing numbers
I have a sorted list of datetimes in text format. The format of each entry is '2009-09-10T12:00:00'. I want to find the entry closest to a target. There are many more entries than the number of searches I would have to do. I could change each entry to a number, then search numerically (for example these approaches), ...
[ "You want the bisect module from the standard library. It will do a binary search and tell you the correct insertion point for a new value into an already sorted list. Here's an example that will print the place in the list where target would be inserted:\nfrom bisect import bisect\ndates = ['2009-09-10T12:00:00'...
[ 4, 4, 2, 1 ]
[]
[]
[ "python", "search" ]
stackoverflow_0001438924_python_search.txt
Q: have you seen? _mysql_exceptions.OperationalError "Lost connection to MySQL server during query" being ignored I am just starting out with the MySQLdb module for python, and upon running some SELECT and UPDATE queries, the following gets output: Exception _mysql_exceptions.OperationalError: (2013, 'Lost connect...
have you seen? _mysql_exceptions.OperationalError "Lost connection to MySQL server during query" being ignored
I am just starting out with the MySQLdb module for python, and upon running some SELECT and UPDATE queries, the following gets output: Exception _mysql_exceptions.OperationalError: (2013, 'Lost connection to MySQL server during query') in bound method Cursor.del of MySQLdb.cursors.Cursor object at 0x8c0188c igno...
[ "Ha! Just realized I was trying to use the cursor after having closed the connection! In any case, it was nice writing! : )\nl\n" ]
[ 0 ]
[]
[]
[ "mysql", "python" ]
stackoverflow_0001439616_mysql_python.txt
Q: How can I measure the overall memory requirements of a Python program I have a financial pricing application written in Python 2.4.4 which runs as an Excel plugin. Excel has a 1GB memory limit for all addins, so if any addin process tries to allocate more than 1Gb in total it will cause Excel to crash. I've recen...
How can I measure the overall memory requirements of a Python program
I have a financial pricing application written in Python 2.4.4 which runs as an Excel plugin. Excel has a 1GB memory limit for all addins, so if any addin process tries to allocate more than 1Gb in total it will cause Excel to crash. I've recently made a change to the program which may have changed the overall memory ...
[ "I don't believe XP keeps track of the peak memory requirements of a process (the way Linux does in /proc/pid/status for example). You can use third-party utilities such as this one and set it to \"poll\" the process very frequently to get a good chance of grabbing the correct peak.\nA better approach, though it do...
[ 2, 1 ]
[]
[]
[ "python" ]
stackoverflow_0001438773_python.txt
Q: How do i return a quoted string from a tuple? I have a tuple of strings that i would want to extract the contents as a quoted string, i.e. tup=('string1', 'string2', 'string3') when i do this main_str = ",".join(tup) #i get main_str = 'string1, string2, string3' #I want the main_str to have something like thi...
How do i return a quoted string from a tuple?
I have a tuple of strings that i would want to extract the contents as a quoted string, i.e. tup=('string1', 'string2', 'string3') when i do this main_str = ",".join(tup) #i get main_str = 'string1, string2, string3' #I want the main_str to have something like this main_str = '"string1", "string2", "string3"' Ga...
[ "\", \".join('\"{0}\"'.format(i) for i in tup)\n\nor\n\", \".join('\"%s\"' % i for i in tup)\n\n", "Well, one answer would be:\n', '.join([repr(x) for x in tup])\n\nor\nrepr(tup)[1:-1]\n\nBut that's not really nice. ;)\nUpdated:\nAlthough, noted, you will not be able to control if resulting string starts with '\"...
[ 10, 2, 0 ]
[]
[]
[ "python", "tuples" ]
stackoverflow_0001439862_python_tuples.txt
Q: What is the builtin name of the 'type' of functions, in Python? What Python builtin returns <type 'function'>? >>> type(lambda: None) <type 'function'> Is there way of avoiding creating this lambda function, in order to get the type of functions in general? See http://www.finalcog.com/python-memoise-memoize-funct...
What is the builtin name of the 'type' of functions, in Python?
What Python builtin returns <type 'function'>? >>> type(lambda: None) <type 'function'> Is there way of avoiding creating this lambda function, in order to get the type of functions in general? See http://www.finalcog.com/python-memoise-memoize-function-type for more details. Thanks, Chris.
[ "You should be able to use types.FunctionType to do what you want:\n\n Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51) \n [GCC 4.2.1 (Apple Inc. build 5646)] on darwin\n Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n >>> import types\n >>> help(types.FunctionType)\n...
[ 6, 3, 1, 0 ]
[]
[]
[ "python", "types" ]
stackoverflow_0001439815_python_types.txt
Q: Google App Engine urlfetch to POST files I am trying to send a file to torrage.com from an app in GAE. the file is stored in memory after being received from a user upload. I would like to be able to post this file using the API available here: http://torrage.com/automation.php but i am having some problems undest...
Google App Engine urlfetch to POST files
I am trying to send a file to torrage.com from an app in GAE. the file is stored in memory after being received from a user upload. I would like to be able to post this file using the API available here: http://torrage.com/automation.php but i am having some problems undestanding how the body of the post should be enco...
[ "I find torrage's API docs on the POST interface (as opposed to the SOAP one) pretty confusing and conflicting with the sample C code they also supply. It seems to me that in their online example of PHP post they are not sending the file's contents (just like @kender's answer above is not sending it) while they ARE...
[ 2, 0, 0 ]
[]
[]
[ "google_app_engine", "http", "python" ]
stackoverflow_0001438542_google_app_engine_http_python.txt
Q: How to create simplest p2p remote desktop OR any Robot(Java) equivalent in python I want to create a simplest remote desktop application using p2p communication. I did created one small p2p program in python. My Idea is- Transmit screenshots of remote computer periodically Transmit keyboard and mouse events wrap...
How to create simplest p2p remote desktop OR any Robot(Java) equivalent in python
I want to create a simplest remote desktop application using p2p communication. I did created one small p2p program in python. My Idea is- Transmit screenshots of remote computer periodically Transmit keyboard and mouse events wrapped in xml to remote desktop. Problem- I could transmit a information for keyboard and ...
[ "You can control the keyboard and the mouse with python on Windows by calling the win32 apis: keybd_event and mouse_event thanks to ctypes \n" ]
[ 1 ]
[]
[]
[ "operating_system", "p2p", "python", "remote_desktop" ]
stackoverflow_0001440323_operating_system_p2p_python_remote_desktop.txt
Q: Should my python web app use unicode for all strings? I see some frameworks like Django using unicode all over the place so it seems like it might be a good idea. On the other hand, it seems like a big pain to have all these extra 'u's floating around everywhere. What will be a problem if I don't do this? Are the...
Should my python web app use unicode for all strings?
I see some frameworks like Django using unicode all over the place so it seems like it might be a good idea. On the other hand, it seems like a big pain to have all these extra 'u's floating around everywhere. What will be a problem if I don't do this? Are there any issues that will come up if I do do this? I'm using ...
[ "You can avoid the u'' in python 2.6 by doing:\nfrom __future__ import unicode_literals\n\nThat will make 'string literals' to be unicode objects, just like it is in python 3;\n", "In Python 3, all strings are Unicode. So, you can prepare for this by using u'' strings everywhere you need to, and then when you eve...
[ 20, 10, 3, 1 ]
[]
[]
[ "django", "pylons", "python", "unicode", "web_applications" ]
stackoverflow_0000827415_django_pylons_python_unicode_web_applications.txt
Q: How do I return a CSV from a Pylons app? I'm trying to return a CSV from an action in my webapp, and give the user a prompt to download the file or open it from a spreadsheet app. I can get the CSV to spit out onto the screen, but how do I change the type of the file so that the browser recognizes that this isn't ...
How do I return a CSV from a Pylons app?
I'm trying to return a CSV from an action in my webapp, and give the user a prompt to download the file or open it from a spreadsheet app. I can get the CSV to spit out onto the screen, but how do I change the type of the file so that the browser recognizes that this isn't supposed to be displayed as HTML? Can I use th...
[ "To tell the browser the type of content you're giving it, you need to set the Content-type header to 'text/csv'. In your Pylons function, the following should do the job:\nresponse.headers['Content-type'] = 'text/csv'\n", "PAG is correct, but furthermore if you want to suggest a name for the downloaded file you ...
[ 12, 9, 8 ]
[]
[]
[ "csv", "pylons", "python" ]
stackoverflow_0000790019_csv_pylons_python.txt
Q: pycurl fails but curl (from bash) works in ubuntu I'm using curl and pycurl to connect to a secure 3rd party api and when I use pycurl I'm getting authentication errors back from the server, but when I use curl on the command line and do the same thing it works. I set both to verbose mode and am seeing some differ...
pycurl fails but curl (from bash) works in ubuntu
I'm using curl and pycurl to connect to a secure 3rd party api and when I use pycurl I'm getting authentication errors back from the server, but when I use curl on the command line and do the same thing it works. I set both to verbose mode and am seeing some differences in the request, but I can't seem to figure out wh...
[ "Ubuntu pycurl uses GnuTLS while ubuntu curl command line uses OpenSSL.\nThere are differences e.g. in supported certificate formats.\nI for one cannot comprehend this decision taken by ubuntu devs/packagers. I stumbled on this once and could not work around it, luckily there are other distributions than ubuntu :-)...
[ 3, 1 ]
[]
[]
[ "curl", "https", "pycurl", "python", "ssl" ]
stackoverflow_0000568247_curl_https_pycurl_python_ssl.txt
Q: Why do I get error, KeyError: 'wsgi.input'? I'm using WSGI and trying to access the get/post data, using this code: import os import cgi from traceback import format_exception from sys import exc_info def application(environ, start_response): try: f = cgi.FieldStorage(fp=os.environ['wsgi.input'], env...
Why do I get error, KeyError: 'wsgi.input'?
I'm using WSGI and trying to access the get/post data, using this code: import os import cgi from traceback import format_exception from sys import exc_info def application(environ, start_response): try: f = cgi.FieldStorage(fp=os.environ['wsgi.input'], environ=os.environ) output = 'Test: %s' % f[...
[ "You're misusing the WSGI API. \nPlease create a minimal (\"hello world\") function that shows this error so we can comment on your code. [Don't post your entire application, it may be too big and unwieldy for us to comment on.]\nThe os.environ is not what you should be using. WSGI replaces this with an enriched...
[ 7 ]
[]
[]
[ "mod_wsgi", "python" ]
stackoverflow_0001441038_mod_wsgi_python.txt
Q: Trailing slashes in Pylons Routes What is the best way to make trailing slashes not matter in the latest version of Routes (1.10)? I currently am using the clearly non-DRY: map.connect('/logs/', controller='logs', action='logs') map.connect('/logs', controller='logs', action='logs') I think that turning minimizat...
Trailing slashes in Pylons Routes
What is the best way to make trailing slashes not matter in the latest version of Routes (1.10)? I currently am using the clearly non-DRY: map.connect('/logs/', controller='logs', action='logs') map.connect('/logs', controller='logs', action='logs') I think that turning minimization on would do the trick, but am under...
[ "The following snippet added as the very last route worked for me:\nmap.redirect('/*(url)/', '/{url}',\n _redirect_code='301 Moved Permanently')\n\n", "There are two possible ways to solve this:\n\nDo it entirely in pylons.\nAdd an htaccess rule to rewrite the trailing slash.\n\nPersonally I don't lik...
[ 16, 7, 2 ]
[]
[]
[ "pylons", "python", "routes" ]
stackoverflow_0000235191_pylons_python_routes.txt
Q: Python accessing web service protected by PKI/SSL I need to use Python to access data from a RESTful web service that requires certificate-based client authentication (PKI) over SSL/HTTPS. What is the recommended way of doing this? A: The suggestion by stribika using httplib.HTTPSConnection should work for you p...
Python accessing web service protected by PKI/SSL
I need to use Python to access data from a RESTful web service that requires certificate-based client authentication (PKI) over SSL/HTTPS. What is the recommended way of doing this?
[ "The suggestion by stribika using httplib.HTTPSConnection should work for you provided that you do not need to verify the server's certificate. If you do want/need to verify the server, you'll need to look at a 3rd party module such as pyOpenSSL (which is a Python wrapper around a subset of the OpenSSL library).\n"...
[ 2, 1, 0 ]
[]
[]
[ "certificate", "pki", "python", "ssl", "web_services" ]
stackoverflow_0001134565_certificate_pki_python_ssl_web_services.txt
Q: java to python conversion: x509 / dsa / sha1withdsa crypto howto? I've got the following Java code that I'm trying to convert to python, and I'm not really sure how to do this: import java.security.spec.X509EncodedKeySpec; import java.security.KeyFactory; import java.security.PublicKey; import java.security.Signat...
java to python conversion: x509 / dsa / sha1withdsa crypto howto?
I've got the following Java code that I'm trying to convert to python, and I'm not really sure how to do this: import java.security.spec.X509EncodedKeySpec; import java.security.KeyFactory; import java.security.PublicKey; import java.security.Signature; byte[] key = KeyReader.read(filestream) //KeyReader.read(input...
[ "I don't exactly understand the Java code, but is this what you are trying to do?\nfrom M2Crypto import X509\n\nx509 = X509.load_cert(filename)\nassert x509.verify() == 1\n\n" ]
[ 1 ]
[]
[]
[ "cryptography", "java", "m2crypto", "python", "sha1" ]
stackoverflow_0001338546_cryptography_java_m2crypto_python_sha1.txt
Q: Is it possible to have a python app authentication with a remote linux server? The idea here is to have a python app, that when started, asks for a user/password combination. This user/password combination should be the same as the user/password of the remote linux server or in such case, and authentication system...
Is it possible to have a python app authentication with a remote linux server?
The idea here is to have a python app, that when started, asks for a user/password combination. This user/password combination should be the same as the user/password of the remote linux server or in such case, and authentication system. Is this possible? How? Which APIs can I use? Thanks a lot.
[ "I would recommend looking into LDAP and python-ldap\n" ]
[ 0 ]
[]
[]
[ "authentication", "python" ]
stackoverflow_0001441875_authentication_python.txt
Q: Subdomains and Logins If you multiple subdomains e.g.: sub1.domain_name.com sub2.domain_name.com Is there a way to have a user be able to log into both of these without issues and double login issue? The platform is Python, Django. A: Without information regarding what platform you are using, it is difficult t...
Subdomains and Logins
If you multiple subdomains e.g.: sub1.domain_name.com sub2.domain_name.com Is there a way to have a user be able to log into both of these without issues and double login issue? The platform is Python, Django.
[ "Without information regarding what platform you are using, it is difficult to say. If you use cookies to store authentication information, and you are using subdomains as you describe, then you can force the cookie to be issued for the highest level domain, e.g. domain_name.com.\nThis will be accessable by both su...
[ 12, 6 ]
[]
[]
[ "authentication", "django", "login_control", "python", "subdomain" ]
stackoverflow_0001442017_authentication_django_login_control_python_subdomain.txt
Q: transforming Jython's source / ast I've got a problem to solve in Jython. The function I've got looks like this: ok = whatever1(x, ...) self.assertTrue("whatever1 failed: "+x...(), ok) ok = whatever2(x, ...) self.assertTrue("whatever2 failed: "+x...(), ok) [ many many lines ] ... There are many tests that look ...
transforming Jython's source / ast
I've got a problem to solve in Jython. The function I've got looks like this: ok = whatever1(x, ...) self.assertTrue("whatever1 failed: "+x...(), ok) ok = whatever2(x, ...) self.assertTrue("whatever2 failed: "+x...(), ok) [ many many lines ] ... There are many tests that look like this, they contain mostly ok=... te...
[ "Are you sure you need an AST? If the only lines of interest are the ones starting with \"ok = \", then maybe simple string work on the source files would be enough?\n" ]
[ 2 ]
[]
[]
[ "abstract_syntax_tree", "jython", "python" ]
stackoverflow_0001442084_abstract_syntax_tree_jython_python.txt
Q: Whats the error in this python code? What do i do to solve it? Terminal output is: abhi@abhi-desktop:~/Desktop/sslstrip-0.1$ python sslstrip.py --listen=3130 Traceback (most recent call last): File "sslstrip.py", line 254, in main(sys.argv[1:]) File "sslstrip.py", line 246, in main server = Threadin...
Whats the error in this python code?
What do i do to solve it? Terminal output is: abhi@abhi-desktop:~/Desktop/sslstrip-0.1$ python sslstrip.py --listen=3130 Traceback (most recent call last): File "sslstrip.py", line 254, in main(sys.argv[1:]) File "sslstrip.py", line 246, in main server = ThreadingHTTPServer(('', listenPort), StripProxy) ...
[ "Does it fail when you don't specify a port?\nMy guess is that listenPort is coming out of the option parsing as a string and needs to be cast to an in sslstrip.py on line 77.\n", "The provided link is to sslstrip-0.5. You are using sslstrip-0.1. These are very different (sslstrip-0.5 uses twisted). This bug was ...
[ 2, 2 ]
[]
[]
[ "python", "session_hijacking" ]
stackoverflow_0001441979_python_session_hijacking.txt
Q: Python Web-Scrape Loop via CSV list of URLs? HI, I've got a list of 10 websites in CSV. All of the sites have the same general format, including a large table. I only want the the data in the 7th columns. I am able to extract the html and filter the 7th column data (via RegEx) on an individual basis but I can't fi...
Python Web-Scrape Loop via CSV list of URLs?
HI, I've got a list of 10 websites in CSV. All of the sites have the same general format, including a large table. I only want the the data in the 7th columns. I am able to extract the html and filter the 7th column data (via RegEx) on an individual basis but I can't figure out how to loop through the CSV. I think I'm ...
[ "When I copied your routine, I did get a white space / tab error error. Check your tabs. You were indexing into the URL string incorrectly using your loop counter. This would have also messed you up.\nAlso, you don't really need to control the loop with a counter. This will loop for each line entry in your CSV file...
[ 2 ]
[]
[]
[ "csv", "list", "loops", "python" ]
stackoverflow_0001442097_csv_list_loops_python.txt
Q: GAE - How Do i edit / update the datastore in python I have this datastore model class Project(db.Model) projectname = db.StringProperty() projecturl = db.StringProperty() class Task(db.Model) project = db.ReferenceProperty(Project) taskname= db.StringProperty() taskdesc = db.StringProperty() How do I edit the v...
GAE - How Do i edit / update the datastore in python
I have this datastore model class Project(db.Model) projectname = db.StringProperty() projecturl = db.StringProperty() class Task(db.Model) project = db.ReferenceProperty(Project) taskname= db.StringProperty() taskdesc = db.StringProperty() How do I edit the value of taskname ? say I have task1 and i want to change i...
[ "oops sorry, Here is the formatted code:\ntaskkey = self.request.get(\"taskkey\")\ntaskid = Task.get(taskkey)\nquery = db.GqlQuery(\"SELECt * FROM Task WHERE key =:taskid\", taskid=taskid)\n\nif query.count() > 0:\n task = Task()\n task.taskname = \"task1-project\"\n task.put()\n\nby the way, I get it now. I change...
[ 2, 1 ]
[ "Probably the easiest way is to use the admin console. Locally it's:\nhttp://localhost:8080/_ah/admin\n\nand if you've uploaded it, it's the dashboard:\nhttp://appengine.google.com/dashboard?&app_id=******\n\nHere's a link:\n" ]
[ -1 ]
[ "google_app_engine", "gql", "gqlquery", "python" ]
stackoverflow_0001436545_google_app_engine_gql_gqlquery_python.txt
Q: Hiding Vertical Scrollbar in wx.TextCtrl I have a wx.TextCtrl that I am using to represent a display with a fixed number of character rows and columns. I would like to hide the vertical scrollbar that is displayed to the right of the text pane since it is entirely unnecessary in my application. Is there a way to a...
Hiding Vertical Scrollbar in wx.TextCtrl
I have a wx.TextCtrl that I am using to represent a display with a fixed number of character rows and columns. I would like to hide the vertical scrollbar that is displayed to the right of the text pane since it is entirely unnecessary in my application. Is there a way to achieve this? Also...I would like to hide the b...
[ "How about setting the style wx.TE_NO_VSCROLL for the wx.TxtCtrl?\n" ]
[ 4 ]
[]
[]
[ "python", "wxpython", "wxtextctrl" ]
stackoverflow_0001441502_python_wxpython_wxtextctrl.txt
Q: Accessing a Python variable in a list I think this is probably something really simple, but I'd appreciate a hint: I am using a python list to hold some some database insert statements: list = [ "table_to_insert_to" ],["column1","column2"],[getValue.value1],["value2"]] The problem is one of the values isn't evalu...
Accessing a Python variable in a list
I think this is probably something really simple, but I'd appreciate a hint: I am using a python list to hold some some database insert statements: list = [ "table_to_insert_to" ],["column1","column2"],[getValue.value1],["value2"]] The problem is one of the values isn't evaluated until runtime-- so before the page eve...
[ "You've just pointed out one (out of a zillion) problems with global variables: not using global variables is the best solution to this problem and many others. If you still mistakenly believe you must use a global variable, put a placeholder (e.g. None) in the place where the value you don't yet know will go, and ...
[ 3, 2, 1 ]
[]
[]
[ "list", "python", "variables" ]
stackoverflow_0001442250_list_python_variables.txt
Q: Radix 64 and encryption Need to share my problem that is : A PGP public key server gives me the key in Radix64 format . And i searching for any method which can encrypt my message using this Radix64 format public key . any alternate suggestions or documents are welcome ......... A: exPyCrypto looks good. This pr...
Radix 64 and encryption
Need to share my problem that is : A PGP public key server gives me the key in Radix64 format . And i searching for any method which can encrypt my message using this Radix64 format public key . any alternate suggestions or documents are welcome .........
[ "exPyCrypto looks good.\nThis previous SO question addresses Radix64 format specifically for public keys.\nTo convert the actual base/radix64 encoded characters, see this question:\nimport base64\ndecoded_bytes = base64.b64decode(ascii_chars)\n\n", "You can decode the key by using the base64 module and then encry...
[ 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0001442896_python.txt
Q: Failing to insert a record in sqlite using python Am getting a error when i attempt to insert a record in sqlite using python. This is my code: import sqlite3 db = sqlite3.connect('mydb') ins_str = 'insert into filer_filer(number, ms_date, ms_time, mp_code, Amount, recipient_name,recipient_number, Tran_date, Tra...
Failing to insert a record in sqlite using python
Am getting a error when i attempt to insert a record in sqlite using python. This is my code: import sqlite3 db = sqlite3.connect('mydb') ins_str = 'insert into filer_filer(number, ms_date, ms_time, mp_code, Amount, recipient_name,recipient_number, Tran_date, Tran_time, balance, userid_id ) values ('752098','09/09/16...
[ "It may be an artifact of SO's code block display but you seem to be missing quotes around the SQL string values.\nIf that is the case, you may resolve the issue by simply using double quotes for the ins_str variable.\nEdit:\nMy explanation was confusing. I apologize if I misled you. Now in more detail:\nPython s...
[ 1, 1, 0, 0 ]
[]
[]
[ "python", "sqlite" ]
stackoverflow_0001442675_python_sqlite.txt
Q: Problem with building Boost Graph Library Python bindings under Leopard I've inherited some Python code which is importing boost.graph and I'm having an issue setting up the following under Mac OS X Leopard (I believe this is what I need to install to get it working): http://osl.iu.edu/~dgregor/bgl-python/ Accordi...
Problem with building Boost Graph Library Python bindings under Leopard
I've inherited some Python code which is importing boost.graph and I'm having an issue setting up the following under Mac OS X Leopard (I believe this is what I need to install to get it working): http://osl.iu.edu/~dgregor/bgl-python/ According to the readme I need to build with bjam, but I see the following error: [m...
[ "This error suggests the project is not a standalone, and is meant to be put inside the Boost source tree.\n" ]
[ 0 ]
[]
[]
[ "binding", "boost", "graph", "osx_leopard", "python" ]
stackoverflow_0001436182_binding_boost_graph_osx_leopard_python.txt
Q: Multiple Windows in PyQt4 I have a PyQt program used to visualize some python objects. I would like to do display multiple objects, each in its own window. What is the best way to achieve multi-window applications in PyQt4? Currently I have the following: from PyQt4 import QtGui class MainWindow(QtGui.QMainWindo...
Multiple Windows in PyQt4
I have a PyQt program used to visualize some python objects. I would like to do display multiple objects, each in its own window. What is the best way to achieve multi-window applications in PyQt4? Currently I have the following: from PyQt4 import QtGui class MainWindow(QtGui.QMainWindow): windowList = [] de...
[ "Why not using dialogs? In Qt you do not need to use the main window unless you want to use docks etc.. Using dialogs will have the same effect. \nI can also see a problem in your logic regarding the fact that you want your super class to be calling the constructor of its children, which of course can be any type. ...
[ 6, 0 ]
[]
[]
[ "inheritance", "pyqt4", "python" ]
stackoverflow_0001442128_inheritance_pyqt4_python.txt
Q: Is it possible to divert a module in python? (ResourceX diverted to ResourceXSimulated) I want to simulate MyApp that imports a module (ResourceX) which requires a resource that is not available at the time and will not work. A solution for this is to make and import a mock module of ResourceX (named ResourceXSim...
Is it possible to divert a module in python? (ResourceX diverted to ResourceXSimulated)
I want to simulate MyApp that imports a module (ResourceX) which requires a resource that is not available at the time and will not work. A solution for this is to make and import a mock module of ResourceX (named ResourceXSimulated) and divert it to MyApp as ResourceX. I want to do this in order to avoid breaking a l...
[ "Just change all lines import ResourceX in MyApp to import ResourceXSimulated as ResourceX, and lines like from ResourceX import Y to from ResourceXSimulated import Y.\nHowever if don't have access to MyApp source or there are other reasons not to change it, you can put your module into sys.modules before MyApp is ...
[ 4, 1, 1, 1, 0 ]
[]
[]
[ "mocking", "module", "monkeypatching", "python", "testing" ]
stackoverflow_0001443173_mocking_module_monkeypatching_python_testing.txt
Q: Django : Iterate over a query set without cache I have a dumb simple loop for alias in models.Alias.objects.all() : alias.update_points() but looking into the django QuerySet it seems to keep around a _result_cache of all the previous results. This is eating Gigs and Gigs of my machine and eventually everythi...
Django : Iterate over a query set without cache
I have a dumb simple loop for alias in models.Alias.objects.all() : alias.update_points() but looking into the django QuerySet it seems to keep around a _result_cache of all the previous results. This is eating Gigs and Gigs of my machine and eventually everything blows up. How can I throw away all the stuff that...
[ "Use the queryset's iterator() method to return the models in chunks, without populating the result cache:\nfor alias in models.Alias.objects.iterator() :\n alias.update_points()\n\n", "You should consider saving your changes back to the database.\nfor alias in models.Alias.objects.all() :\n alias.update_po...
[ 11, 0 ]
[]
[]
[ "caching", "django", "python" ]
stackoverflow_0001443279_caching_django_python.txt
Q: regular expression to parse network interface config I am wondering if problem down here can be solved with one regular expression or I should make standard loop and evaluate line by line, when I run included code I get ['Ethernet0/22', 'Ethernet0/24'], only result should be ['Ethernet0/23', 'Ethernet0/25']. any a...
regular expression to parse network interface config
I am wondering if problem down here can be solved with one regular expression or I should make standard loop and evaluate line by line, when I run included code I get ['Ethernet0/22', 'Ethernet0/24'], only result should be ['Ethernet0/23', 'Ethernet0/25']. any advice on this? import re txt='''# interface Ethernet0...
[ "Here is a little pyparsing parser for your file. Not only does this show a solution to your immediate problem, but the parser gives you a nice set of objects that you can use to easily access the data in each interface.\nHere is the parser:\nfrom pyparsing import *\n\n# set up the parser\ncomment = \"#\" + Option...
[ 5, 4, 2, 1 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0001443433_python_regex.txt