content
stringlengths
85
101k
title
stringlengths
0
150
question
stringlengths
15
48k
answers
list
answers_scores
list
non_answers
list
non_answers_scores
list
tags
list
name
stringlengths
35
137
Q: python regex to find php functions in files I’m looking for a regular expression to match all functions blocks (from start to end) in php files. For example: function test_function($var) { if ($var == 'somethin') { print 'hi'; } etc. } I need the start offset and end offset of the block. What regex can I use?...
python regex to find php functions in files
I’m looking for a regular expression to match all functions blocks (from start to end) in php files. For example: function test_function($var) { if ($var == 'somethin') { print 'hi'; } etc. } I need the start offset and end offset of the block. What regex can I use?
[ "It is very very complicated and can't be done with one regular expression.\nYou may think that you can easily match `the beginning of a function like this:\n\\bfunction\\b\\s+\\S+[^\\(](\\s+)?\\(.*?\\)\\s+\\{\n\nBut you can't because what is if there is this in a code?\n$string = \"function myfunction() {}\";\n\nS...
[ 1, 1 ]
[]
[]
[ "php", "python", "regex" ]
stackoverflow_0008630125_php_python_regex.txt
Q: Getting all public variables and methods in SWIG If my C++ class has been wrapped by SWIG and exposed to the python interpreter. Is there a way to retrieve a collection of all public variables and methods in python? Thanks! A: This is not SWIG-related, so it might not solve your specific problem, but you might w...
Getting all public variables and methods in SWIG
If my C++ class has been wrapped by SWIG and exposed to the python interpreter. Is there a way to retrieve a collection of all public variables and methods in python? Thanks!
[ "This is not SWIG-related, so it might not solve your specific problem, but you might want to look at Python's dir and __dir__ functions. There's a related question here.\n" ]
[ 0 ]
[]
[]
[ "public_method", "python", "swig" ]
stackoverflow_0008630066_public_method_python_swig.txt
Q: Python IMAP getting emails before a date, and also UNSEEN So I know how to get emails that are unseen And I know how to get emails before a certain date. But how do I combine these 2 to get all emails that are unseen before a certain date? conn = imaplib.IMAP4_SSL("imap.gmail.com", 993) typ, data = conn.search(Non...
Python IMAP getting emails before a date, and also UNSEEN
So I know how to get emails that are unseen And I know how to get emails before a certain date. But how do I combine these 2 to get all emails that are unseen before a certain date? conn = imaplib.IMAP4_SSL("imap.gmail.com", 993) typ, data = conn.search(None, 'BEFORE', before_date) //before a date typ, data = conn.sear...
[ "Just put your two conditions one after the other, like this:\ntyp, data = conn.search(None, 'BEFORE', before_date, 'UNSEEN')\n\nReference: section 6.4.4 of the IMAP RFC (RFC3501) says this:\n\nWhen multiple keys are specified, the result is the intersection\n (AND function) of all the messages that match those ke...
[ 5 ]
[]
[]
[ "imap", "python" ]
stackoverflow_0008612159_imap_python.txt
Q: boost python sleep wrapper causes whole python program to sleep i have a multithreaded library in which i call sleep(3) in different threads. i have written python bindings for it using boost python. now it looks like boost python is messing up with the sleep(3) function as it pauses the whole python program to wa...
boost python sleep wrapper causes whole python program to sleep
i have a multithreaded library in which i call sleep(3) in different threads. i have written python bindings for it using boost python. now it looks like boost python is messing up with the sleep(3) function as it pauses the whole python program to wait. please consider i have this boostmod.cpp file #include <boost/pyt...
[ "first of all, i have seen that the time.sleep function in python is not using the sleep(3) systemcall. it uses a timing out call of select(2) on stdin ( in function \"floatsleep\" ) so that it can be interrupted.\nHowever i have also found out that if you write a wrapper with Py_BEGIN_ALLOW_THREADS and Py_END_ALLO...
[ 1 ]
[]
[]
[ "boost", "linux", "python", "sleep", "thread_sleep" ]
stackoverflow_0008627191_boost_linux_python_sleep_thread_sleep.txt
Q: Automate Opening and Closing the Database Connection I am writing a class for database queries with SQLite3 in my application. Most of the methods of the class are very similar to this: def getPrice(self, symbol, date): date = dt.datetime.strptime(date, '%Y-%m-%d') conn = sqlite3.connect('stocks.db') c...
Automate Opening and Closing the Database Connection
I am writing a class for database queries with SQLite3 in my application. Most of the methods of the class are very similar to this: def getPrice(self, symbol, date): date = dt.datetime.strptime(date, '%Y-%m-%d') conn = sqlite3.connect('stocks.db') curs =conn.cursor() curs.execute('''SELECT close FROM p...
[ "First. You'll be much, much happier with one -- and only one -- global connection. Configuration changes are much easier if you do this in exactly one place.\nSecond, use the with statement and the context manager library.\nfrom contextlib import closing\nfrom my_database_module import the_global_connection\n\nd...
[ 4, 2, 1 ]
[]
[]
[ "class", "database_connection", "python" ]
stackoverflow_0008630423_class_database_connection_python.txt
Q: Hyperlinks in web.py How do I make web.py fetch a page when I click on a link? I have this in my template: <a href='add.html'>Home</a> When I click on 'Home', I get 'not found'. In my application, I have '/add' mapped to the 'Add' class which returns 'Boom!' using the template add.html. urls = ('/', 'Index', '...
Hyperlinks in web.py
How do I make web.py fetch a page when I click on a link? I have this in my template: <a href='add.html'>Home</a> When I click on 'Home', I get 'not found'. In my application, I have '/add' mapped to the 'Add' class which returns 'Boom!' using the template add.html. urls = ('/', 'Index', '/add','Add') class Add(ob...
[ "The origin of a page URI ending in .html lilke /add.html is that in static hosting environments those were traditionally really single text files with html-content and the file ending for such a file is .html\nBut your system is dynamic and creates web pages on the fly. It does not necessarily need the pages endin...
[ 8, 5 ]
[]
[]
[ "python", "web.py" ]
stackoverflow_0008630456_python_web.py.txt
Q: Python lists search A better way of searching the list? Any suggestions appreciated: for key in nodelist.keys(): if len(nodelist[key]) > 0: if key == "sample_node": print key + ":" print nodelist[key] A: It is simpler to write this code: key = "sample_node" if key in nodelist:...
Python lists search
A better way of searching the list? Any suggestions appreciated: for key in nodelist.keys(): if len(nodelist[key]) > 0: if key == "sample_node": print key + ":" print nodelist[key]
[ "It is simpler to write this code:\nkey = \"sample_node\"\nif key in nodelist: # loop not needed, and .keys() not needed\n value = nodelist[key]\n if value: # len() not needed\n print key + \":\"\n print value\n\n", "key = \"sample_node\"\nif key in nodelist:\n print ''.join([key, \":\", ...
[ 4, 2, 2, 1, 1 ]
[]
[]
[ "list", "python" ]
stackoverflow_0008628248_list_python.txt
Q: Add current day to a specified hour and minute in Python A user is specifying an hour and minute in my interface. I'd like to attach the current date to a datetime object in Python. First I tried this: a = datetime.strptime("8:30pm", "%I:%M%p") print a But this yields: 1900-01-01 20:30:00 Then I tried: b = date....
Add current day to a specified hour and minute in Python
A user is specifying an hour and minute in my interface. I'd like to attach the current date to a datetime object in Python. First I tried this: a = datetime.strptime("8:30pm", "%I:%M%p") print a But this yields: 1900-01-01 20:30:00 Then I tried: b = date.today() a = datetime.strptime(str(b.year) + "-" + str(b.month)...
[ "Yes, use datetime.datetime.combine:\nimport datetime\na = datetime.datetime.strptime(\"8:30pm\", \"%I:%M%p\")\ntoday = datetime.datetime.today()\n\nresult = datetime.datetime.combine(today.date(), a.time())\n\n# result == datetime.datetime(2011, 12, 25, 20, 30)\n\n" ]
[ 4 ]
[]
[]
[ "datetime", "python" ]
stackoverflow_0008630497_datetime_python.txt
Q: How do I order by date when using ReferenceProperty? I have a simple one-to-many structure like this: class User(db.Model): userEmail = db.StringProperty() class Comment(db.Model): user = db.ReferenceProperty(User, collection_name="comments") comment = db.StringProperty() date = db.DateTimePropert...
How do I order by date when using ReferenceProperty?
I have a simple one-to-many structure like this: class User(db.Model): userEmail = db.StringProperty() class Comment(db.Model): user = db.ReferenceProperty(User, collection_name="comments") comment = db.StringProperty() date = db.DateTimeProperty() I fetch a user from by his email: q = User.all() # pr...
[ "You will want to use the key keyword argument of the built-in sorted function, and use the \"date\" property as the key:\nimport operator\nsorted_comments = sorted(this_users_comments, key=operator.attrgetter(\"date\"))\n# The comments will probably be sorted with earlier comments at the front of the list\n# If yo...
[ 2, 0 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0008627729_google_app_engine_python.txt
Q: Change IntegerProperty to FloatProperty of existing AppEngine DataStore I built an appengine application (python) which need to convert existing datastore entities in integer value (100) to float value (100.00) for currency conversion issue. How's the right way doing this? Since my query returning error when i jus...
Change IntegerProperty to FloatProperty of existing AppEngine DataStore
I built an appengine application (python) which need to convert existing datastore entities in integer value (100) to float value (100.00) for currency conversion issue. How's the right way doing this? Since my query returning error when i just change property type in my model. Old Model: class Learn(search.SearchableM...
[ "The easiest way to do this is to change the model to inherit from db.Expando, and delete the integer properties from the definion. Then, load each instance and do \"instance.foo = float(instance.foo)\" on each, before saving them back to the datastore - you'll probably want to use the mapreduce API for this. Final...
[ 12, 7, 0 ]
[ "From the Edit Entity page in the data store admin interface:\n\nEnter information for the entity\n below. If you'd like to change a\n property's type, set it to Null, save\n the entity, edit the entity again, and\n change the type\n\n" ]
[ -1 ]
[ "django", "google_app_engine", "google_cloud_datastore", "python" ]
stackoverflow_0004742875_django_google_app_engine_google_cloud_datastore_python.txt
Q: python class HTMLParser incorrectly giving parse error Consider the following html input: <html> <head> <script> function open_tools(tool_div) { document.getElementById("tool1").innerHTML = "<a href='javascript:void(0);' onclick=\"javascript:clos_tools('""');\"><img src='menu.gif' border='0' /></a>"; document....
python class HTMLParser incorrectly giving parse error
Consider the following html input: <html> <head> <script> function open_tools(tool_div) { document.getElementById("tool1").innerHTML = "<a href='javascript:void(0);' onclick=\"javascript:clos_tools('""');\"><img src='menu.gif' border='0' /></a>"; document.getElementById("tool").innerHTML = "<a href='javascript:voi...
[ "\nit seems it is finding end of script tag in </a> of first statement\n\nYes, and it is correct to do so according to the HTML4 standard.\nIn HTML<5 (and SGML from which this behaviour is inherited), a CDATA-element like <script> or <style> is ended by the </ (ETAGO) sequence. It is an error for that sequence not ...
[ 4, 2 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0008626641_python_regex.txt
Q: mapping one class to two tables from different database in SQLAlchemy I want to make a management script which read a lot from slave db, surely replicated from master, and write sometimes into master db. Tables that I'm accessing are the same. one from slave, and one from master. So I'd like to use just one mappin...
mapping one class to two tables from different database in SQLAlchemy
I want to make a management script which read a lot from slave db, surely replicated from master, and write sometimes into master db. Tables that I'm accessing are the same. one from slave, and one from master. So I'd like to use just one mapping class for both of them. how can I map this class to two tables from diffe...
[ "It sounds like you might be interested in database routing. There is a master/slave example on this page:\nhttps://docs.djangoproject.com/en/dev/topics/db/multi-db/\n" ]
[ 0 ]
[]
[]
[ "mysql", "orm", "python", "sqlalchemy" ]
stackoverflow_0008618512_mysql_orm_python_sqlalchemy.txt
Q: How can I write float value in python that can be read natively in Java? How can I write float value to file in python so that it can be later read in Java with ObjectInputStream#readFloat? I need high read performance, so I'd like to avoid parsing the float from String. A: Use the struct module (documentation),...
How can I write float value in python that can be read natively in Java?
How can I write float value to file in python so that it can be later read in Java with ObjectInputStream#readFloat? I need high read performance, so I'd like to avoid parsing the float from String.
[ "Use the struct module (documentation), specifying the data as a float.\n" ]
[ 1 ]
[]
[]
[ "java", "python" ]
stackoverflow_0008630341_java_python.txt
Q: Python regex remove string I have records in my text witch start with PHOTO and ends with \n how can I remove this text with regular expression. A: I am putting down a couple of ways of doing it. Slice the string: >>> string = "PHOTOThe text which should be present\n" >>> string[5:-1] 'The text which should be ...
Python regex remove string
I have records in my text witch start with PHOTO and ends with \n how can I remove this text with regular expression.
[ "I am putting down a couple of ways of doing it. \nSlice the string:\n>>> string = \"PHOTOThe text which should be present\\n\"\n>>> string[5:-1]\n'The text which should be present'\n\nUsing regular expression:\n>>> import re\n>>> match = re.match(\"PHOTO(.+)\\n\", string)\n>>> match.groups()\n('The text which shou...
[ 11, 3, 2 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0008630918_python_regex.txt
Q: applying python functions directly to Qt designer as signals I am new to Qt and GUI programming overall but i have done a fair bit of coding in python - writing modules and so on. I need to develop simple GUIs for some of my old modules. What i am trying to do can be represented by the following simple example: de...
applying python functions directly to Qt designer as signals
I am new to Qt and GUI programming overall but i have done a fair bit of coding in python - writing modules and so on. I need to develop simple GUIs for some of my old modules. What i am trying to do can be represented by the following simple example: def f(x, y): z = x + y return z For this function i will gi...
[ "The basic workflow when writing a PyQt4 gui is:\n\nDesign the UI using Qt Designer.\nGenerate a Python module from the UI file using pyuic4.\nCreate an Application module for the main program logic.\nImport the GUI class into the Application module.\nConnect the GUI to the program logic.\n\nSo, given the UI file c...
[ 16 ]
[]
[]
[ "pyqt", "pyqt4", "python", "qt_designer", "signals_slots" ]
stackoverflow_0008630749_pyqt_pyqt4_python_qt_designer_signals_slots.txt
Q: MySQLdb is error in making a Primary key which is too long I am creating a table in using MYSQLdb in Python tdesc = "CREATE TABLE " + self.table_name + " (" tdesc = tdesc + "title VARCHAR(500), " tdesc = tdesc + "DbLink VARCHAR(500), " tdesc = tdesc + "abstract VARCHAR(3000), " ...
MySQLdb is error in making a Primary key which is too long
I am creating a table in using MYSQLdb in Python tdesc = "CREATE TABLE " + self.table_name + " (" tdesc = tdesc + "title VARCHAR(500), " tdesc = tdesc + "DbLink VARCHAR(500), " tdesc = tdesc + "abstract VARCHAR(3000), " tdesc = tdesc + "WikiLink VARCHAR(5000)," tdesc = tdes...
[ "Without telling us what that DBLink column is supposed to do it is kind of hard to solve this ...\nYour key is too long, there are no two ways about it. You can do two things, either you make the DBLink column smaller. Or, alternatively, you could create a new primary key, say an auto-incremented id, and add a uni...
[ 2, 0, 0 ]
[]
[]
[ "mysql", "mysql_python", "python" ]
stackoverflow_0008574999_mysql_mysql_python_python.txt
Q: Leaving one item out in a python list and print paths Given a large number of research subjects ("SUBJ"), I need to create blocks of absolute paths (as strings) that leave one subject out each time. For example, I need something like: /path/to/data/SUBJ02 /path/to/data/SUBJ03 /path/to/data/SUBJ04 /path/to/data/...
Leaving one item out in a python list and print paths
Given a large number of research subjects ("SUBJ"), I need to create blocks of absolute paths (as strings) that leave one subject out each time. For example, I need something like: /path/to/data/SUBJ02 /path/to/data/SUBJ03 /path/to/data/SUBJ04 /path/to/data/SUBJ05 /path/to/data/SUBJ01 /path/to/data/SUBJ03 /path/t...
[ "what about\ndirectory = \"c:\\\\...\"\nimport os.path\npaths = [os.path.join(directory, filename) for filename in filenames]\n\n?\nBtw you can save the repetitions of your subject names by a function like\ndef loo(x):\n return [[el for el in x if el!=x[i]] for i in range(len(x))]\n\nUpdate ok everything togethe...
[ 3 ]
[]
[]
[ "python", "string" ]
stackoverflow_0008631279_python_string.txt
Q: prevent BufferedReader from closing the file for a list of files I have a class which extends BufferedReader, and a list of file streams b.close() is called for all except the last stream, I want to keep the streams open How do I do this? thanks class TestReader(BufferedReader): pass def test(streams): f...
prevent BufferedReader from closing the file for a list of files
I have a class which extends BufferedReader, and a list of file streams b.close() is called for all except the last stream, I want to keep the streams open How do I do this? thanks class TestReader(BufferedReader): pass def test(streams): for stream in streams: b=TestReader(stream) do_somethi...
[ "Even though in the implementation BufferedIOBase classes wrap an IOBase object, their interface is a stream (everything inherits from IOBase), so the ordinary behavior of a IOBase object is to close themselves when they go out of scope. BufferedIOBase just delegates the close() call to the underlying stream.\nYou ...
[ 5 ]
[]
[]
[ "bufferedreader", "python" ]
stackoverflow_0008631302_bufferedreader_python.txt
Q: Django on appegine and tutorial I am new to Django and Appengine. I found that Django 1.2 version is supported by Google Appengine. Does it mean that Django 1.2 comes with the installation of Google Appengine SDK? Or should we install djangoappengine Any pointers, experiences and tutorials on running Django on Ap...
Django on appegine and tutorial
I am new to Django and Appengine. I found that Django 1.2 version is supported by Google Appengine. Does it mean that Django 1.2 comes with the installation of Google Appengine SDK? Or should we install djangoappengine Any pointers, experiences and tutorials on running Django on Appengine is appreciated. Thanks in adv...
[ "I think djangoappengine would be a good start. It seems like an active project. Please also note that Google offers SQL backend as of October 2011 so whether you need SQL or NoSQL, you should be able to use Django for it.\nGeneral note: If you are new to both Django and GAE, you probably should start with learning...
[ 3, 2, 0 ]
[]
[]
[ "django", "djangoappengine", "google_app_engine", "python" ]
stackoverflow_0008629927_django_djangoappengine_google_app_engine_python.txt
Q: How can I read and edit Google Spreadsheets using Python 3.x? I know I can read and edit Google Spreadsheets with gdata, but there is no gdata version for Python 3. Is there a (not really really complicated) way to edit Google Spreadsheet even though I want to use Python 3? A: I've authored an alternative Python...
How can I read and edit Google Spreadsheets using Python 3.x?
I know I can read and edit Google Spreadsheets with gdata, but there is no gdata version for Python 3. Is there a (not really really complicated) way to edit Google Spreadsheet even though I want to use Python 3?
[ "I've authored an alternative Python library for Google Spreadsheets. It supports Python 3 and has a less verbose API. You're welcome to check it out.\n", "As far as I know, no, not yet. Well, except for exporting it as CSV, using Python on that, and uploading it again. But I guess that's not quite what you're af...
[ 11, 1 ]
[]
[]
[ "google_sheets", "python", "python_3.x" ]
stackoverflow_0004886052_google_sheets_python_python_3.x.txt
Q: Unexpected: flufl.enum prints integer value Using Python 3, I unpackaged the flufl.enum code into my application source tree just to try it. Sample code: from taurine.flufl.enum import Enum class Colors(Enum): red = 1 green = 2 blue = 3 print(Colors.red) red = Colors.red print("red == Colors.red "+s...
Unexpected: flufl.enum prints integer value
Using Python 3, I unpackaged the flufl.enum code into my application source tree just to try it. Sample code: from taurine.flufl.enum import Enum class Colors(Enum): red = 1 green = 2 blue = 3 print(Colors.red) red = Colors.red print("red == Colors.red "+str(red == Colors.red)) print("red == Colors.blue ...
[ "I realized init wasn't even being called on EnumMetaclass. I think the following code in _enum.py is meant to make inheriting from Enum all you'd need to do, but something about it doesn't work and it's beyond me:\nclass Enum:\n __metaclass__ = EnumMetaclass\n\nThis works:\nclass Colors(metaclass=EnumMetaclass...
[ 3 ]
[]
[]
[ "enums", "python" ]
stackoverflow_0008631410_enums_python.txt
Q: In python, create md5 hash from the last 4KB of a file In python, given a really large file (~700MB), how can I create an md5 hash only from the last 4096kb of that file? A: You can use seek to move the file pointer to the end of the file, and hashlib for MD5: import hashlib with open('really-large-file', 'rb') ...
In python, create md5 hash from the last 4KB of a file
In python, given a really large file (~700MB), how can I create an md5 hash only from the last 4096kb of that file?
[ "You can use seek to move the file pointer to the end of the file, and hashlib for MD5:\nimport hashlib\nwith open('really-large-file', 'rb') as f:\n f.seek(- 4096 * 1024, 2)\n print (hashlib.md5(f.read()).hexdigest())\n\n" ]
[ 10 ]
[]
[]
[ "hash", "python" ]
stackoverflow_0008631688_hash_python.txt
Q: Syntax error in simple Python 3.2.2 program This code is example code from a book on python. It is a simple program to enter integers and display the sum, total count, and average of the integers. However, when I try to run the code, I receive a syntax error at line 18, the colon. This code looks perfectly fine to...
Syntax error in simple Python 3.2.2 program
This code is example code from a book on python. It is a simple program to enter integers and display the sum, total count, and average of the integers. However, when I try to run the code, I receive a syntax error at line 18, the colon. This code looks perfectly fine to me. Any ideas? print("type integers, each follow...
[ "line 9 seems to missing a ) \nchange:\nline = input(\"integer: \"\n\ninto\nline = input(\"integer: \")\n\nThe except line need to be indented to match the try\nand the lines:\ntotal += number\ncount += 1\n\nneeds to be indented as well otherwise, the if and the else statements don't line up. I.e. code should be so...
[ 6, 1, 1, 0, 0 ]
[]
[]
[ "python", "syntax" ]
stackoverflow_0008631657_python_syntax.txt
Q: Easiest way to calculate execution time of a python script? What's the easiest way to calculate the execution time of a Python script? A: timeit module is designed specifically for this purpose. Silly example as follows def test(): """Stupid test function""" L = [] for i in range(100): L.appe...
Easiest way to calculate execution time of a python script?
What's the easiest way to calculate the execution time of a Python script?
[ "timeit module is designed specifically for this purpose.\nSilly example as follows\ndef test():\n \"\"\"Stupid test function\"\"\"\n L = []\n for i in range(100):\n L.append(i)\n\nif __name__ == '__main__':\n from timeit import Timer\n t = Timer(\"test()\", \"from __main__ import test\")\n ...
[ 8, 5, 1, 0 ]
[]
[]
[ "performance_testing", "python" ]
stackoverflow_0008631743_performance_testing_python.txt
Q: Where in an image is the exif tag located? In Python, how can I find out where in an image file the EXIF tag is located? I'm assuming it's in the beginning of the file, but I have some proprietary image formats and want to make sure this is always the case. Thanks. A: That depends not only on EXIF iself, but als...
Where in an image is the exif tag located?
In Python, how can I find out where in an image file the EXIF tag is located? I'm assuming it's in the beginning of the file, but I have some proprietary image formats and want to make sure this is always the case. Thanks.
[ "That depends not only on EXIF iself, but also in the file type.\nI assume that you're interested in JPEG files, so looking at the wikipedia page I see the following paragraph:\n\nStrictly speaking, the JFIF and Exif standards are incompatible because they each specify that their marker segment (APP0 or APP1, respe...
[ 2 ]
[]
[]
[ "exif", "image", "python" ]
stackoverflow_0008631800_exif_image_python.txt
Q: How to set useragent as QuickTime in Python script? The server only allows access to the videos if the useragent is QT, how to add it to this script ? #!/usr/bin/env python from os import pardir, rename, listdir, getcwd from os.path import join from urllib import urlopen, urlretrieve, FancyURLopener class MyOpener...
How to set useragent as QuickTime in Python script?
The server only allows access to the videos if the useragent is QT, how to add it to this script ? #!/usr/bin/env python from os import pardir, rename, listdir, getcwd from os.path import join from urllib import urlopen, urlretrieve, FancyURLopener class MyOpener(FancyURLopener): version = 'QuickTime/7.6.2 (verqt=7...
[ "You can change it like this:\nhttp://wolfprojects.altervista.org/changeua.php\nThen try:\nopener = MyOpener()\nopener.retrieve(url, fpath)\n\nInstead of using urllib directly and that should do the trick.\n(I am not sure why overriding urllib internals does not work, but they are internals and poking them is not g...
[ 1, 1 ]
[]
[]
[ "python", "user_agent" ]
stackoverflow_0008618984_python_user_agent.txt
Q: How can I get the properties of a DLL with Python? I want to get the properties(file version, company, language, etc) of a DLL file using Python and the Windows API. A: Try this import os, win32api ver_strings=('Comments','InternalName','ProductName', 'CompanyName','LegalCopyright','ProductVersion', ...
How can I get the properties of a DLL with Python?
I want to get the properties(file version, company, language, etc) of a DLL file using Python and the Windows API.
[ "Try this \nimport os, win32api\n\nver_strings=('Comments','InternalName','ProductName', \n 'CompanyName','LegalCopyright','ProductVersion', \n 'FileDescription','LegalTrademarks','PrivateBuild', \n 'FileVersion','OriginalFilename','SpecialBuild')\nfname = os.environ[\"comspec\"]\nd=win32api.GetFileVersion...
[ 1 ]
[]
[]
[ "api", "python", "windows" ]
stackoverflow_0008631569_api_python_windows.txt
Q: Using eq_ with nose tests, is there a way to know which line # and position # two strings differ? Coming from some other technologies, there have been string comparison assertions for use in unit tests that show string 1 on one line (in the console output) and string 2 on the second line, and clue you to what posi...
Using eq_ with nose tests, is there a way to know which line # and position # two strings differ?
Coming from some other technologies, there have been string comparison assertions for use in unit tests that show string 1 on one line (in the console output) and string 2 on the second line, and clue you to what position # is the first difference (when there is a difference). I think I can write a helper easily enough...
[ "If you're using unittest with nose, you are probably looking for unittest.TestCase.assertMultilineEqual.\n" ]
[ 3 ]
[]
[]
[ "nosetests", "pycharm", "python" ]
stackoverflow_0008631947_nosetests_pycharm_python.txt
Q: Unique image hash that does not change if EXIF info updated I'm looking for a way to create a unique hash for images in python and php. I thought about using md5 sums for the original file because they can be generated quickly, but when I update EXIF information (sometimes the timezone is off) it changes the sum a...
Unique image hash that does not change if EXIF info updated
I'm looking for a way to create a unique hash for images in python and php. I thought about using md5 sums for the original file because they can be generated quickly, but when I update EXIF information (sometimes the timezone is off) it changes the sum and the hash changes. Are there any other ways I can create a hash...
[ "Imagemagick already provides a method to get the image signature. According to the PHP documentation:\n\nGenerates an SHA-256 message digest for the image pixel stream. \n\nSo my understanding is that the signature isn't affected by changes in the exif information.\nAlso, I've checked that the PythonMagick.Image.s...
[ 2, 1 ]
[]
[]
[ "imagemagick", "php", "python" ]
stackoverflow_0008631378_imagemagick_php_python.txt
Q: get MAC address for mobile broadband modem in python I want to get the MAC address for my network interface on Linux. I am using Python with PyQt4 modules. When I run this code: form PyQt4.QtNetwork import * def getinfo(): all_info = QNetworkInterface().allInterfaces() for interface in all_info: print ...
get MAC address for mobile broadband modem in python
I want to get the MAC address for my network interface on Linux. I am using Python with PyQt4 modules. When I run this code: form PyQt4.QtNetwork import * def getinfo(): all_info = QNetworkInterface().allInterfaces() for interface in all_info: print interface.hardwareAddress()," ",interface.humanReadableNam...
[ "ppp doesn't use a MAC (hardware) address:\nppp0 Link encap:Point-to-Point Protocol\n inet addr:172.27.42.1 P-t-P:172.27.42.17 Mask:255.255.255.255\n UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1\n RX packets:416 errors:0 dropped:0 overruns:0 frame:0\n TX pack...
[ 3 ]
[]
[]
[ "mac_address", "networking", "ppp", "pyqt4", "python" ]
stackoverflow_0008631744_mac_address_networking_ppp_pyqt4_python.txt
Q: Changing "global" array with pool processes Apologies first for the small code dump to follow, but I've spent the evening taking my first baby steps into the multiprocessing module; with my previous knowledge coming from openMPI fortran. I'm having issues with the below code in that although all the threads spawn ...
Changing "global" array with pool processes
Apologies first for the small code dump to follow, but I've spent the evening taking my first baby steps into the multiprocessing module; with my previous knowledge coming from openMPI fortran. I'm having issues with the below code in that although all the threads spawn and run etc and have access to all the correct va...
[ "If you're using multiprocessing.pool, it's not threads, it's full processes you're spawning here. The doc says:\n\nThe multiprocessing package offers both local and remote concurrency,\n effectively side-stepping the Global Interpreter Lock by using\n subprocesses instead of threads.\n\nEDIT: Alternatively, ther...
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0005679533_python.txt
Q: Why do I keep getting this title match error with my Python program? When I run the following code, I keep getting this error: Traceback (most recent call last): File "C:\Users\Robert\Documents\j-a-c-o-b\newlc.py", line 94, in <module> main() File "C:\Users\Robert\Documents\j-a-c-o-b\newlc.py", line 71, in...
Why do I keep getting this title match error with my Python program?
When I run the following code, I keep getting this error: Traceback (most recent call last): File "C:\Users\Robert\Documents\j-a-c-o-b\newlc.py", line 94, in <module> main() File "C:\Users\Robert\Documents\j-a-c-o-b\newlc.py", line 71, in main for final_url in pool.imap(handle_listing, listings): File "C:...
[ "Quoting from your error:\n\ntitle, = TITLE_MATCH.match(listing_title).groups()\n AttributeError: 'NoneType' object has no attribute 'groups'\n\nTITLE_MATCH.match(listing_title) returns None, so you can't call .groups().\n", "When a re .match does not find anything to match, it returns None. Since you cannot ca...
[ 4, 2 ]
[]
[]
[ "python" ]
stackoverflow_0008632600_python.txt
Q: Does mod_wsgi create interpreter for each port My develop environment is Windows, which means the Apache MPM could only be 'winnt'. Here I find the strange thing: 1. Apache only listens to 8080 and I have set no virtual hosts, but in error log, why it creates two interpreters for 'myhost.com:8080|' and 'myhost.c...
Does mod_wsgi create interpreter for each port
My develop environment is Windows, which means the Apache MPM could only be 'winnt'. Here I find the strange thing: 1. Apache only listens to 8080 and I have set no virtual hosts, but in error log, why it creates two interpreters for 'myhost.com:8080|' and 'myhost.com|'? It supposes to be only 8080 one. access.log:...
[ "By default, requests against port 80 and 443 will would be handled in same sub interpreter. Requests against any other port are processed in different interpreter. This is documented in mod_wsgi documentation.\nhttp://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIApplicationGroup\nAs to why you are se...
[ 1 ]
[]
[]
[ "apache", "mod_wsgi", "python" ]
stackoverflow_0008632669_apache_mod_wsgi_python.txt
Q: Django static files loading for front page of site only I am using Django 1.3.1 and Python 2.7 on WinVista. I am experiencing the same problem whether on the local dev serer or when deployed to my host. On the main page of my site static media shows: http://www.drugpolicyreformmovement.com On secondary pages CSS,...
Django static files loading for front page of site only
I am using Django 1.3.1 and Python 2.7 on WinVista. I am experiencing the same problem whether on the local dev serer or when deployed to my host. On the main page of my site static media shows: http://www.drugpolicyreformmovement.com On secondary pages CSS, images, etc. do not display: http://www.drugpolicyreformmove...
[ "Your url in first page is\nhttp://www.drugpolicyreformmovement.com/static/css/blueprint/print.css\n\nin inner page \nhttp://www.drugpolicyreformmovement.com/newsarchive2003/static/css/blueprint/print.css\n\njust add / in url or use {{ STATIC_URL }}\nfor example \n\n/static/css/blueprint/print.css\n\nor \n\n<img sr...
[ 2, 1, 1 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008632819_django_python.txt
Q: Hadoop - Saving Log Data and Developing GUI I am doing research for my new project, Following is the details of my project, research and questions: Project: Save the Logs (ex. format is TimeStamp,LOG Entry,Location,Remarks etc ) from different sources. Here Different sources is like, gettting the LOG data from th...
Hadoop - Saving Log Data and Developing GUI
I am doing research for my new project, Following is the details of my project, research and questions: Project: Save the Logs (ex. format is TimeStamp,LOG Entry,Location,Remarks etc ) from different sources. Here Different sources is like, gettting the LOG data from the different systems world wide (Just an Overview)...
[ "Have you looked at Datameer ? It provides a GUI to import all these types of files, and create reports as well as dashboards.\n", "I think you can use HIVE. Even I am new to Hadoop but read some where that HIVE is for hadoop analytics. Not sure whether it has GUI or not, but for sure it has SQL capability to que...
[ 1, 0 ]
[]
[]
[ "hadoop", "java", "python" ]
stackoverflow_0008633112_hadoop_java_python.txt
Q: PyQt4 - Ambiguity in QLayout Spacing I have a QHBoxLayout which I add widgets to, one by one. I alternate by adding a Custom Widget, than a QLabel (repeating). The QHBoxLayout is owned by a QGroupBox. However, I notice that the spacing between the Custom Widget and the QLabel is 'irregular' when there are few widg...
PyQt4 - Ambiguity in QLayout Spacing
I have a QHBoxLayout which I add widgets to, one by one. I alternate by adding a Custom Widget, than a QLabel (repeating). The QHBoxLayout is owned by a QGroupBox. However, I notice that the spacing between the Custom Widget and the QLabel is 'irregular' when there are few widgets added to the Layout. I intend for the ...
[ "Here is a simple example script which is a reasonable approximation of the UI in the question, but without any of the layout issues:\nfrom PyQt4 import QtGui, QtCore\n\nclass Window(QtGui.QWidget):\n def __init__(self):\n QtGui.QWidget.__init__(self)\n self.groupBox = QtGui.QGroupBox(self)\n ...
[ 2, 0 ]
[]
[]
[ "layout", "pyqt", "pyqt4", "python", "spacing" ]
stackoverflow_0008589877_layout_pyqt_pyqt4_python_spacing.txt
Q: How to make a specific attribute as a primary key in python I had a small requirement of making a specific attribute as primary key, such that by using this attribute I want to access the other attributes of the same row. Could any one help me please. Description:: I had 4 arrays and I want to retrieve the data in...
How to make a specific attribute as a primary key in python
I had a small requirement of making a specific attribute as primary key, such that by using this attribute I want to access the other attributes of the same row. Could any one help me please. Description:: I had 4 arrays and I want to retrieve the data in the arrays corresponding to the row I have selected.In simple te...
[ "Replying to original question (it's been erased):\nYou could use a python dict: http://docs.python.org/library/stdtypes.html#dict.\ndataset = {}\ndataset['key1'] = (value_1_1, value_1_2, value_1_3, value_1_4)\ndataset['key2'] = (value_2_1, value_2_2, value_2_3, value_2_4)\n\nThen if you wanted the values associate...
[ 2, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008633128_python.txt
Q: Using the same option more than one time from the commandline in python How can I use the option more than one time? for example the command cpdoc: cpdoc -d text -s x -s y -s z I would like to have x,y,z in one array/data structure import optparse import os import shutil def main(): p = optparse.OptionParser...
Using the same option more than one time from the commandline in python
How can I use the option more than one time? for example the command cpdoc: cpdoc -d text -s x -s y -s z I would like to have x,y,z in one array/data structure import optparse import os import shutil def main(): p = optparse.OptionParser() folder = [] p.add_option('--source', '-s',help="source folder") ...
[ "use the argparse module instead\nStolen without shame from the docs:\nparser.add_option(\"-t\", \"--tracks\", action=\"append\", type=\"int\")\n\nIf -t3 is seen on the command-line, optparse does the equivalent of:\noptions.tracks = []\noptions.tracks.append(int(\"3\"))\n\nIf, a little later on, --tracks=4 is seen...
[ 3, 2 ]
[]
[]
[ "command_line", "python" ]
stackoverflow_0008633491_command_line_python.txt
Q: trouble getting python up and running I'm a newcomer to python. I just downloaded the 2.x version and am trying to write a simple 'Hello world' program in an editor, and run it in the interpreter. This is my code (what i have in IDLE): #!C:\Python27\python.exe #Filename: helloworld.py print('Hello World') This i...
trouble getting python up and running
I'm a newcomer to python. I just downloaded the 2.x version and am trying to write a simple 'Hello world' program in an editor, and run it in the interpreter. This is my code (what i have in IDLE): #!C:\Python27\python.exe #Filename: helloworld.py print('Hello World') This is what I run in the interpreter: python hel...
[ "print isn't a function in Python 2.7. You would have to say print \"Hello world!\" instead.\n", "python 3.0 and 2.7 both support parens on print... Part of the later 2.x changes were increasing support for 3.x syntax to ease transition. Anyone saying that 2.7 can't have parens is just plain wrong, they both work...
[ 1, 1, 1, 0 ]
[ "In python3\nprint(\"helloworld\")\n\nIn python2.7\nprint \"helloworld\"\n\n" ]
[ -2 ]
[ "python" ]
stackoverflow_0008633365_python.txt
Q: tornado twittermixin couldn't redirect and tornado told me a 500 error class AuthHandler(BaseHandler, tornado.auth.TwitterMixin): @tornado.web.asynchronous def get(self): if self.get_argument("oauth_token", None): self.get_authenticated_user(self.async_callback(self._on_auth)) return self.a...
tornado twittermixin couldn't redirect and tornado told me a 500 error
class AuthHandler(BaseHandler, tornado.auth.TwitterMixin): @tornado.web.asynchronous def get(self): if self.get_argument("oauth_token", None): self.get_authenticated_user(self.async_callback(self._on_auth)) return self.authenticate_redirect() print 1 def _on_auth(self, user): if not use...
[ "Your server couldn't connect to http://api.twitter.com/oauth/authenticate to get 'request token' from twitter\n" ]
[ 0 ]
[]
[]
[ "oauth", "python", "tornado", "twitter" ]
stackoverflow_0008585365_oauth_python_tornado_twitter.txt
Q: Is there a way to make Eclipse+PyDev display function documentation like Python's help() would? I would like to force Eclipse to show Python's help output in the popup instead of the whole function, i.e. given: def myFunc(arg): '''Function description''' return 1 I would like the code assist popup to cont...
Is there a way to make Eclipse+PyDev display function documentation like Python's help() would?
I would like to force Eclipse to show Python's help output in the popup instead of the whole function, i.e. given: def myFunc(arg): '''Function description''' return 1 I would like the code assist popup to contain only "Function description" and not "return 1"
[ "Try ticking 'Show docstrings?' in 'Window -> Preferences -> Pydev -> Editor -> Hover'.\n" ]
[ 4 ]
[]
[]
[ "docstring", "eclipse", "popup", "pydev", "python" ]
stackoverflow_0007034875_docstring_eclipse_popup_pydev_python.txt
Q: Shortest Repeating Sub-String I am looking for an efficient way to extract the shortest repeating substring. For example: input1 = 'dabcdbcdbcdd' ouput1 = 'bcd' input2 = 'cbabababac' output2 = 'ba' I would appreciate any answer or information related to the problem. Also, in this post, people suggest that we ca...
Shortest Repeating Sub-String
I am looking for an efficient way to extract the shortest repeating substring. For example: input1 = 'dabcdbcdbcdd' ouput1 = 'bcd' input2 = 'cbabababac' output2 = 'ba' I would appreciate any answer or information related to the problem. Also, in this post, people suggest that we can use the regular expression like r...
[ "A quick fix for this pattern could be\n(.+?)\\1+\n\nYour regex failed because it anchored the repeating string to the start and end of the line, only allowing strings like abcabcabc but not xabcabcabcx. Also, the minimum length of the repeated string should be 1, not 0 (or any string would match), therefore .+? in...
[ 15, 3 ]
[]
[]
[ "python", "regex", "string_matching" ]
stackoverflow_0008633996_python_regex_string_matching.txt
Q: How to schedule a periodic Celery task per Django model instance? I have a bunch of Feed objects in my database, and I'm trying to get each Feed to be updated every hour. My issue here is that I need to make sure there aren't any duplicate updates -- it needs to happen no more than once an hour, but I also don't ...
How to schedule a periodic Celery task per Django model instance?
I have a bunch of Feed objects in my database, and I'm trying to get each Feed to be updated every hour. My issue here is that I need to make sure there aren't any duplicate updates -- it needs to happen no more than once an hour, but I also don't want feeds waiting two hours for an update. (It's okay if it happens ev...
[ "To be clear, the Celery recipe is not using memcached per se, but rather Django's caching middleware. There are a number of other caching methods that would suit your needs without the downside of memcached. See the Django caching documentation for details.\n" ]
[ 0 ]
[]
[]
[ "celery", "django", "django_celery", "python" ]
stackoverflow_0008630542_celery_django_django_celery_python.txt
Q: PyGTK, Threads and WebKit In my PyGTK app, on button click I need to: Fetch some html (can take some time) Show it in new window While fetching html, I want to keep GUI responsive, so I decided to do it in separate thread. I use WebKit to render html. The problem is I get empty page in WebView when it is in sepa...
PyGTK, Threads and WebKit
In my PyGTK app, on button click I need to: Fetch some html (can take some time) Show it in new window While fetching html, I want to keep GUI responsive, so I decided to do it in separate thread. I use WebKit to render html. The problem is I get empty page in WebView when it is in separated thread. This works: impo...
[ "According to my experience, one of the things that sometimes doesn't work as you expect with gtk is the update of widgets in separate threads.\nTo workaround this problem, you can work with the data in threads, and use glib.idle_add to schedule the update of the widget in the main thread once the data has been pro...
[ 3, 0 ]
[]
[]
[ "multithreading", "pygtk", "python", "webkit" ]
stackoverflow_0008630606_multithreading_pygtk_python_webkit.txt
Q: How to have usernames with webapp2's User model? I successfully with webapp2 can authenticate and login/logout users and I have a decorator to know whether a user is logged in and this works: class MyPageHandler(NewBaseHandler): """ Only accessible to users that are logged in """ @user_required ...
How to have usernames with webapp2's User model?
I successfully with webapp2 can authenticate and login/logout users and I have a decorator to know whether a user is logged in and this works: class MyPageHandler(NewBaseHandler): """ Only accessible to users that are logged in """ @user_required def get(self): user = self.auth.get_user_by_s...
[ "hope this help\nfrom webapp2_extras.appengine.auth.models import User\nfrom ndb import key, model\n\nclass MUser(User): # child class of User\n displayname = model.StringProperty() # show on screen, auto create 'user-{id}'\n lastaccess = model.DateTimeProperty(auto_now=True)\n\n @classmethod\n def upda...
[ 4 ]
[]
[]
[ "google_app_engine", "python", "session", "webapp2" ]
stackoverflow_0008614978_google_app_engine_python_session_webapp2.txt
Q: Storing the result of an SHA hash as a db.StringProperty() property I'm creating a small app using python 2.7 with google app engine and I'm trying to store a hash similar to... import hashlib def PassHash(self): return hashlib.sha256( hashlib.sha256(self.username).digest() + self.passwor...
Storing the result of an SHA hash as a db.StringProperty() property
I'm creating a small app using python 2.7 with google app engine and I'm trying to store a hash similar to... import hashlib def PassHash(self): return hashlib.sha256( hashlib.sha256(self.username).digest() + self.password ).hexdigest() + '' This returns a string of hexadecimal ...
[ "I would try without the multiline attribute for the password. I could store sha hashed variables like the following:\ncrypted_password = db.StringProperty() \nsalt = db.StringProperty() \n\ndef __encrypt(self, plaintext, salt=''):\n \"\"\"returns the SHA1 hexdigest of a plaintext and salt\"\"\"\n\n phrase =...
[ 0 ]
[]
[]
[ "google_app_engine", "python", "sha" ]
stackoverflow_0008633203_google_app_engine_python_sha.txt
Q: More pythonic way to iterate in Numpy I am an engineering student and I'm accustomed to write code in Fortran, but now I'm trying to get more into Python for my numerical recipes using Numpy. If I needed to perform a calculation repeatedly using elements from several arrays, the immediate translation from what I'd...
More pythonic way to iterate in Numpy
I am an engineering student and I'm accustomed to write code in Fortran, but now I'm trying to get more into Python for my numerical recipes using Numpy. If I needed to perform a calculation repeatedly using elements from several arrays, the immediate translation from what I'd write in Fortran would be k = np.zeros(N, ...
[ "Almost all numpy operations are performed element-wise. So instead of writing an explicit loop, try defining k using an array-based formula:\nr_shifted = np.roll(x, shift = 1)\nk = ... # some formula in terms of u, M, r, r_shifted\n\nFor example, instead of \nimport numpy as np\n\nN=5\nk = np.zeros(N, dtype=np.flo...
[ 7 ]
[ "I like list comprehensions\nk = [ x ** y for x, y in zip(some_array, some_other_array) ]\n\nothers like map\nmap( lambda x, y : x*y , zip(some_array, some_other_array) )\n\nwill multiply two arrays and return you a list or generator. (Of course you there are other ways of doing that particular task in numpy.) ...
[ -1 ]
[ "iterator", "numpy", "python", "scientific_computing" ]
stackoverflow_0008634850_iterator_numpy_python_scientific_computing.txt
Q: Python, communicating variables between a script and .exe I have a python script: main.py, which executes a cx_frozen python script: test.exe I have created. main.py needs to send variables to test.exe. If the frozen script is able to send variables back that would be great too. I have, up to this point been savin...
Python, communicating variables between a script and .exe
I have a python script: main.py, which executes a cx_frozen python script: test.exe I have created. main.py needs to send variables to test.exe. If the frozen script is able to send variables back that would be great too. I have, up to this point been saving out .txt files from main.py and accepting them from test.exe ...
[ "The easiest way to send variables to a sub-program is using command line arguments or environment variables. If you want bidirectional communication you can use pipes to transmit the info that you are currently sending over the text files (even on Windows). The python subprocess (http://docs.python.org/library/s...
[ 1 ]
[]
[]
[ "executable", "input", "python", "variables" ]
stackoverflow_0008634943_executable_input_python_variables.txt
Q: Python itertools.combinations' results I don't get the number of results I should obtain from that function in the Title, so I'm hoping in your help. Looking at the Docs http://docs.python.org/library/itertools.html#itertools.combinations the number of results should be The number of items returned is n! / r! / (...
Python itertools.combinations' results
I don't get the number of results I should obtain from that function in the Title, so I'm hoping in your help. Looking at the Docs http://docs.python.org/library/itertools.html#itertools.combinations the number of results should be The number of items returned is n! / r! / (n-r)! when 0 <= r <= n or zero when r > n....
[ "itertools.combinations should be returning an iterator with 20 items:\nIn [40]: len(list(itertools.combinations('ABCDEF',3)))\nOut[40]: 20\n\nNote that \nIn [41]: len(list(itertools.combinations('ABCDEF',2)))\nOut[41]: 15\n\nand the output posted \ncombinations('ABCDEF', 3) --> AB AC AD AE AF BC BD BE BF CD CE CF ...
[ 22 ]
[]
[]
[ "combinations", "python", "python_itertools" ]
stackoverflow_0008635073_combinations_python_python_itertools.txt
Q: How to kill while loop? For example, I have code: while (1): bla-bla-bal time.sleep(10) How to change this code, for kill this loop ( NOT KILL -9 ) or Keyboard interrrupt ( Ctrl-C ) ? A: Use break or change the boolean variable in while while True: doit if something: break alternative...
How to kill while loop?
For example, I have code: while (1): bla-bla-bal time.sleep(10) How to change this code, for kill this loop ( NOT KILL -9 ) or Keyboard interrrupt ( Ctrl-C ) ?
[ "Use break or change the boolean variable in while\nwhile True:\n doit\n if something:\n break\n\nalternatively:\ni_go = True\nwhile i_go:\n doit\n if something:\n i_go = False\n\n", "There has to be a condition that exists which the loop no longer needs to be performed. Depending on w...
[ 3, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008634862_python.txt
Q: Django-south not detecting DB changes I have updated our project from svn and I have new migration files. When I use : ./work/manage.py schemamigration mypackage --auto I have this message: Nothing seems to have changed. But the database has changed! Why south couldn't detect any change? Thanks in advance A: I...
Django-south not detecting DB changes
I have updated our project from svn and I have new migration files. When I use : ./work/manage.py schemamigration mypackage --auto I have this message: Nothing seems to have changed. But the database has changed! Why south couldn't detect any change? Thanks in advance
[ "If you already have the migration files, there is no need to run schemamigration as that just generates the migration files. To apply the migration files to the database, run:\n./work/manage.py migrate mypackage --merge\n\nThe merge flag will run any missed migrations as a result of an SVN update.\n" ]
[ 2 ]
[]
[]
[ "django", "django_south", "python" ]
stackoverflow_0008635492_django_django_south_python.txt
Q: Automake datadir and prefix in python Say I have my_application.py.in for automake to generate my_application.py. How do I get the datadir into my application with ${prefix} expanded? Right now the best I can figure is to use replace() in my python application, but, I'm assuming there is a more appropriate way. if...
Automake datadir and prefix in python
Say I have my_application.py.in for automake to generate my_application.py. How do I get the datadir into my application with ${prefix} expanded? Right now the best I can figure is to use replace() in my python application, but, I'm assuming there is a more appropriate way. if __name__ == "__main__": app = Applicat...
[ "You need to do the substitution at make time. This is easier in C, where you can set a #define, but for Python, I'd try something like this:\nfoo.py: foo.py.in\n [ -f $@ ] && rm -f $@\n $(SED) -e \"s:[@]datarootdir@:$(datarootdir):\" $< > $@\n chmod a-w $@\n\n(add AC_PROG_SED to configure.ac)\...
[ 3, 0 ]
[]
[]
[ "automake", "autotools", "python" ]
stackoverflow_0008625960_automake_autotools_python.txt
Q: What is the meaning of this Python statement? More specifically, I'm not sure what the "%" and "\" symbols coming right after each other are supposed to mean: return 'guitar { id: %d, relevant_properties: (%.02f, %.02f, %.02f), irrelevant_properties: (%.02f, %.02f, %.02f) }' % \ (self.id, a, b, c, d, e, f) Is...
What is the meaning of this Python statement?
More specifically, I'm not sure what the "%" and "\" symbols coming right after each other are supposed to mean: return 'guitar { id: %d, relevant_properties: (%.02f, %.02f, %.02f), irrelevant_properties: (%.02f, %.02f, %.02f) }' % \ (self.id, a, b, c, d, e, f) Is this return statement considered to be one line of...
[ "The % symbol is known as the string formatting or string interpolation operator and is described in String Formatting Operations. Also, note that in my examples I moved the % symbol to the next line instead of leaving it on the end of the previous line. Both forms are valid, however putting it on the same line as ...
[ 6, 3, 1, 1, 1, 1 ]
[]
[]
[ "correctness", "formatting", "line_endings", "python", "string" ]
stackoverflow_0008626835_correctness_formatting_line_endings_python_string.txt
Q: Is it possible to write a program to grab the online search result? Is it possible to write a program to grab the online search result? Specifically, I want the data from http://portal.uspto.gov/external/portal/pair sample data are application numbers, for example 9078871,10595401 Yes, they have CAPTCHAs, and I'm...
Is it possible to write a program to grab the online search result?
Is it possible to write a program to grab the online search result? Specifically, I want the data from http://portal.uspto.gov/external/portal/pair sample data are application numbers, for example 9078871,10595401 Yes, they have CAPTCHAs, and I'm willing to type those in by hand. The problem is I have more than 500 ap...
[ "Sure it is possible and why should it not.\nI do not know your gap in knowledge that would enable you to archieve this task as you didn't pointed that out.\nStep by Step...\n\nAnalyze the Website' s code to see how links and content are generated.\nDownload the source code programaticly\nGenerate the hyperlinks to...
[ 0 ]
[]
[]
[ "c++", "database", "javascript", "python" ]
stackoverflow_0008634600_c++_database_javascript_python.txt
Q: Xcode 4.2 (build 4D199) + Python: Console output is different to the expected (e.g. no UTF-8 characters) I am using Python 3.2.2 in Xcode 4.2 (build 4D199) on Mac OS X 10.7.2 and as follows: main.py #coding=utf-8 print("ľťď", 1+1) print("ľťď") Output in the console (Shift+Cmd+C): ('\xc4\xbe\xc5\xa5\xc4\x8f', 2) ľ...
Xcode 4.2 (build 4D199) + Python: Console output is different to the expected (e.g. no UTF-8 characters)
I am using Python 3.2.2 in Xcode 4.2 (build 4D199) on Mac OS X 10.7.2 and as follows: main.py #coding=utf-8 print("ľťď", 1+1) print("ľťď") Output in the console (Shift+Cmd+C): ('\xc4\xbe\xc5\xa5\xc4\x8f', 2) ľťď Expected output (e.g. IDLE works well): ľťď 2 ľťď Now given the fact that it also includes the brackets, ...
[ "\nNow given the fact that it also includes the brackets, apostrophes and comma, I presume that this behaviour is a result of the console's debugging nature\n\nIt's not. This is the difference between Python 2 and 3.\n$ python2\n>>> print(\"ľťď\", 1+1)\n('\\xc4\\xbe\\xc5\\xa5\\xc4\\x8f', 2)\n\n$ python3\n>>> print(...
[ 1 ]
[]
[]
[ "python", "utf_8", "xcode", "xcode4.2" ]
stackoverflow_0008636248_python_utf_8_xcode_xcode4.2.txt
Q: Parsing HTML data with lxml I'm a beginner in coding and a friend of mine told me to use BeautifulSoup instead of htmlparser. After running into some problems I got a tip to use lxml instead of BeaytifulSoup because it's 10x better. I'm hoping someone can give me a hint how to scrape the text I'm looking for. Wh...
Parsing HTML data with lxml
I'm a beginner in coding and a friend of mine told me to use BeautifulSoup instead of htmlparser. After running into some problems I got a tip to use lxml instead of BeaytifulSoup because it's 10x better. I'm hoping someone can give me a hint how to scrape the text I'm looking for. What I want is to find a table with...
[ "I use the xpath: td/a[not(contains(.,\"spam\"))]/@href | td[not(a)]/text()\n$ python3\n>>> import lxml.html\n>>> doc = lxml.html.parse('data.xml')\n>>> [[j for j in i.xpath('td/a[not(contains(.,\"spam\"))]/@href | td[not(a)]/text()')] for i in doc.xpath('//tr')]\n[['website1.com', 'info1', 'info2'], ['website2.com...
[ 4, 4, 1 ]
[]
[]
[ "html_parsing", "lxml", "python" ]
stackoverflow_0008635903_html_parsing_lxml_python.txt
Q: How to make a chat like UI using Python Urwid? I alreay can implement chat daemons using gevent and zeromq, but I'd like to make a console UI for them. My first attempt with ncurses failed, so I tried Urwid and found out that the project nigiri was going exactly what I wanted: I studied the source code, but being...
How to make a chat like UI using Python Urwid?
I alreay can implement chat daemons using gevent and zeromq, but I'd like to make a console UI for them. My first attempt with ncurses failed, so I tried Urwid and found out that the project nigiri was going exactly what I wanted: I studied the source code, but being unfamiliar with console UI programming, I failed fi...
[ "In computing, if you are not smart, you gotta be patient. I just applied the good old try/except keyword to my programming method:\n\nremove something from the source that doesn't relate to my feature\nif ok, go to 1 until the is only the essential code remains\nif it crashes, understand this part and why it's ess...
[ 4 ]
[]
[]
[ "chat", "console", "python", "urwid", "user_interface" ]
stackoverflow_0008635299_chat_console_python_urwid_user_interface.txt
Q: urls.py in django Here is the problem, the urls.py file in a django project look like this: urlpatterns = patterns('', ... url(r'^admin/', include(admin.site.urls)), url(r'^testapp/', include('testapp.urls')), #Here is the problem. ) And I got an app installed, it is called 'testapp', so I wrote the ...
urls.py in django
Here is the problem, the urls.py file in a django project look like this: urlpatterns = patterns('', ... url(r'^admin/', include(admin.site.urls)), url(r'^testapp/', include('testapp.urls')), #Here is the problem. ) And I got an app installed, it is called 'testapp', so I wrote the include('testapp.urls')...
[ "Your must import app in urls.py\nimport testapp\n\nurlpatterns = patterns('',\n ...\n url(r'^admin/', include(admin.site.urls)),\n url(r'^testapp/', include(testapp.urls)),\n)\n\n", "ad3w has answered your question. If you want to learn a little more about it check this out: http://www.djangobook.com/...
[ 4, 1 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008635177_django_python.txt
Q: what python package for rsa algorithm looking to do RSA encryption on a short string in python. This is for a piece of user data that I want to store without staff (incl myself) being able to see it. The private key will be on a thumbdrive in my safety deposit box for when we get subpoenaed. my question: is there ...
what python package for rsa algorithm
looking to do RSA encryption on a short string in python. This is for a piece of user data that I want to store without staff (incl myself) being able to see it. The private key will be on a thumbdrive in my safety deposit box for when we get subpoenaed. my question: is there a 'probably correct' python package for asy...
[ "PyCrypto\n", "pycryptopp\n", "Encryption of short strings with RSA can be problematic. There are certain pieces of data you can encrypt with RSA that reveal details about your private key. In your case it will probably be fine since it will be obscure enough your staff won't figure it out. But in the genera...
[ 3, 2, 1, 1 ]
[]
[]
[ "cryptography", "encryption_asymmetric", "privacy", "python", "rsa" ]
stackoverflow_0003596328_cryptography_encryption_asymmetric_privacy_python_rsa.txt
Q: How to pause a python script running in terminal I have a web crawling python script running in terminal for several hours, which is continuously populating my database. It has several nested for loops. For some reasons I need to restart my computer and continue my script from exactly the place where I left. Is it...
How to pause a python script running in terminal
I have a web crawling python script running in terminal for several hours, which is continuously populating my database. It has several nested for loops. For some reasons I need to restart my computer and continue my script from exactly the place where I left. Is it possible to preserve the pointer state and resume the...
[ "You might try suspending your computer or running in a virtual machine which you can subsequently suspend. But as your script is working with network connections chances are your script won't work from the point you left once you bring up the system. Suspending a computer and restoring it or saving a Virtual M/C a...
[ 4, 2, 1, 1, 0, 0 ]
[]
[]
[ "pausing_execution", "python", "terminal" ]
stackoverflow_0008630573_pausing_execution_python_terminal.txt
Q: Extract chain sequences with python I have a dictionary in Python, that describes some kinds of binaries running on various hosts. Some of them are connected each to other. The question is - how can I construct chains from them? If input and output are the same, then binaries are connected. For example: {"binary1"...
Extract chain sequences with python
I have a dictionary in Python, that describes some kinds of binaries running on various hosts. Some of them are connected each to other. The question is - how can I construct chains from them? If input and output are the same, then binaries are connected. For example: {"binary1": "bin1", "input": "127.0.0.1:2222", "out...
[ "Writing custom code to do what you ask would be quite simple, but since you specified you want \"links to python modules\", then my suggestion would be to look into python-graphs. From the look of it, your problem seems equivalent to build directed graphs...\nEDIT: This also answers your bonus question about plott...
[ 3 ]
[]
[]
[ "python" ]
stackoverflow_0008636391_python.txt
Q: Python Overwriting files after parsing I'm new to Python, and I need to do a parsing exercise. I got a file, and I need to parse it (just the headers), but after the process, i need to keep the file the same format, the same extension, and at the same place in disk, but only with the differences of new headers.. ...
Python Overwriting files after parsing
I'm new to Python, and I need to do a parsing exercise. I got a file, and I need to parse it (just the headers), but after the process, i need to keep the file the same format, the same extension, and at the same place in disk, but only with the differences of new headers.. I tried this code... for line in open ('/ho...
[ "The easiest way, but not the most efficient (by far, and especially for long files) would be to rewrite the complete file. \nYou could do this by opening a second file handle and rewriting each line, except in the case of the header, you'd write the parsed header. For example,\nfr = open('/home/name/db/str/dir/n...
[ 4, 2, 0 ]
[ "newlines = []\nfor line in open ('/home/name/db/str/dir/numbers/str.phy').readlines():\n if line.startswith('ENS'):\n linepars = re.sub ('ENS([A-Z]+)0+([0-9]{6})','\\\\1\\\\2',line)\n newlines.append( linepars )\nopen ('/home/name/db/str/dir/numbers/str.phy', 'w').write('\\n'.join(newlines))\n\n",...
[ -1, -1 ]
[ "file", "overwrite", "parsing", "python" ]
stackoverflow_0006062738_file_overwrite_parsing_python.txt
Q: How do I debug this error with Python? My code that I will post below gives me this error and I can't figure out why or how to fix it. If anyone could help I would greatly appreciate it. Thanks! Traceback (most recent call last): File "C:\Users\Robert\Documents\j-a-c-o-b\newlc.py", line 99, in <module> main(...
How do I debug this error with Python?
My code that I will post below gives me this error and I can't figure out why or how to fix it. If anyone could help I would greatly appreciate it. Thanks! Traceback (most recent call last): File "C:\Users\Robert\Documents\j-a-c-o-b\newlc.py", line 99, in <module> main() File "C:\Users\Robert\Documents\j-a-c-o-...
[ "A very common mistake made by novices using any language that supports exceptions is that they catch exceptions that they do not actually handle. This leads to hard-to-debug errors since it disrupts the normal flow of the program.\nSpecifically, catching urllib2.HTTPError in download() is preventing actual problem...
[ 3 ]
[]
[]
[ "debugging", "python" ]
stackoverflow_0008636595_debugging_python.txt
Q: Python tkinter grid manager? I just learned how to use tkinter in Python (3.2.2), and I'm having some problem using the grid manager. When I put button.grid(sticky=SE), for example, the button is not being put in the bottom-right and is just being put in the upper-left, ignoring the sticky value. What am I doing w...
Python tkinter grid manager?
I just learned how to use tkinter in Python (3.2.2), and I'm having some problem using the grid manager. When I put button.grid(sticky=SE), for example, the button is not being put in the bottom-right and is just being put in the upper-left, ignoring the sticky value. What am I doing wrong here? I tried to search it bu...
[ "You probably need to set a minimum size for the widget containing the button.\nIf you don't, the container widget may shrink to occupy only the space required to display the button. If so, the sticky option will be meaningless since the container widget gives no space to show any difference.\nFor example, using a ...
[ 4, 1 ]
[]
[]
[ "grid", "python", "python_3.x", "sticky", "tkinter" ]
stackoverflow_0008636260_grid_python_python_3.x_sticky_tkinter.txt
Q: how to create a new workbook of excel with python getin data from other workbook how to create a new workbook of excel with python getin data from other workbook with python? I need automatically create a table, taking data from 5 other tables in a specific order know some method to this? thanks for your answer...
how to create a new workbook of excel with python getin data from other workbook
how to create a new workbook of excel with python getin data from other workbook with python? I need automatically create a table, taking data from 5 other tables in a specific order know some method to this? thanks for your answers!!
[ "I would use a combination of the xlrd and xlwt modules. Perhaps, the xlutils copy method can be of help.\n" ]
[ 0 ]
[]
[]
[ "excel", "python" ]
stackoverflow_0008636746_excel_python.txt
Q: from input() reading and converting i have a dict as utf-8 file and reading from the commandline the word and search it in the dictionary keys. But my file have the characters turkish and arabic word = 'şüyûh' mydictionary[word] my program give me the word 'şüyûh' as KeyError this 'şüyûh' back. how can i fix it...
from input() reading and converting
i have a dict as utf-8 file and reading from the commandline the word and search it in the dictionary keys. But my file have the characters turkish and arabic word = 'şüyûh' mydictionary[word] my program give me the word 'şüyûh' as KeyError this 'şüyûh' back. how can i fix it.
[ "Handle everything as unicode.\nUnicode in Python, Completely Demystified\"\n", "If you're reading from a file, you'll need to tell python how to interpret the bytes in the file (files can only contain bytes) into the characters as you understand them.\nThe most basic way of doing so is to open the file using cod...
[ 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008636756_python.txt
Q: Creating links to django views using HTMLCalendar I'm trying to override the standard HTMLCalendar formatting to create links in my calendar that go to a specific Django view (the generic "date_based.archive.day" view). Here's what I've done: class EventsCalendar(HTMLCalendar): def formatday(self, day, weekday...
Creating links to django views using HTMLCalendar
I'm trying to override the standard HTMLCalendar formatting to create links in my calendar that go to a specific Django view (the generic "date_based.archive.day" view). Here's what I've done: class EventsCalendar(HTMLCalendar): def formatday(self, day, weekday): """ Return a day as a table cell. ...
[ "You can access to it in formatmonth method:\ndef formatmonth(self, year, month):\n self.year, self.month = year, month\n return super(EventsCalendar, self).formatmonth(year, month)\n\nAnd then use self.year and self.month in you method.\n" ]
[ 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008636897_django_python.txt
Q: Grouping Similar Strings I'm trying to analyze a bunch of search terms, so many that individually they don't tell much. That said, I'd like to group the terms because I think similar terms should have similar effectiveness. For example, Term Group NBA Basketball 1 Basketball NBA 1 Basketbal...
Grouping Similar Strings
I'm trying to analyze a bunch of search terms, so many that individually they don't tell much. That said, I'd like to group the terms because I think similar terms should have similar effectiveness. For example, Term Group NBA Basketball 1 Basketball NBA 1 Basketball 1 Baseball ...
[ "You'll want to cluster these terms, and for the similarity metric I recommend Dice's Coefficient at the character-gram level. For example, partition the strings into two-letter sequences to compare (term1=\"NB\", \"BA\", \"A \", \" B\", \"Ba\"...).\nnltk appears to provide dice as nltk.metrics.association.BigramAs...
[ 9 ]
[]
[]
[ "nlp", "nltk", "python" ]
stackoverflow_0008631199_nlp_nltk_python.txt
Q: why my python file can run in IDEL but can not in Eclipse? I am just learning Python with Programming Python,and when I run some examples in this book in Eclipse,there comes with a lot of error warning,and I can't run them successfully.But when I run them in IDEL3,they works.There are two files ,one is initdata.py...
why my python file can run in IDEL but can not in Eclipse?
I am just learning Python with Programming Python,and when I run some examples in this book in Eclipse,there comes with a lot of error warning,and I can't run them successfully.But when I run them in IDEL3,they works.There are two files ,one is initdata.py ,another is makefile.py. Here is the makefile.py'code: dbfilena...
[ "This indentation in initdata.py looks wrong.\ndb['tom']=tom \n if __name__=='__main__':\n\nTry to undindent whole if __name__...db[key]) block.\n" ]
[ 0 ]
[]
[]
[ "eclipse", "python" ]
stackoverflow_0008636978_eclipse_python.txt
Q: Where does Django store the project path? I want to rename a project which I created with: django-admin.py startproject But after renaming the folder and all the references inside my project, I still can't get it to start. It says myproject.settings is not in the pythonpath. Since the old project name is neither ...
Where does Django store the project path?
I want to rename a project which I created with: django-admin.py startproject But after renaming the folder and all the references inside my project, I still can't get it to start. It says myproject.settings is not in the pythonpath. Since the old project name is neither in the pythonpath i figure that django must kee...
[ "It doesn't store the project path anywhere. Everything is calculated relative to the path you specified for the settings module.\nIf you renamed your project folder and it's still trying to load the old settings, it's possible that you still have the old settings file configured somewhere, e.g. in the environment ...
[ 2, 0 ]
[]
[]
[ "django", "python", "pythonpath" ]
stackoverflow_0008614776_django_python_pythonpath.txt
Q: How to return images in flask response? As an example, this URL: http://example.com/get_image?type=1 should return a response with a image/gif MIME type. I have two static .gif images, and if type is 1, it should return ok.gif, else return error.gif. How to do that in flask? A: You use something like from flask...
How to return images in flask response?
As an example, this URL: http://example.com/get_image?type=1 should return a response with a image/gif MIME type. I have two static .gif images, and if type is 1, it should return ok.gif, else return error.gif. How to do that in flask?
[ "You use something like\nfrom flask import send_file\n\n@app.route('/get_image')\ndef get_image():\n if request.args.get('type') == '1':\n filename = 'ok.gif'\n else:\n filename = 'error.gif'\n return send_file(filename, mimetype='image/gif')\n\nto send back ok.gif or error.gif, depending on th...
[ 238 ]
[]
[]
[ "flask", "python" ]
stackoverflow_0008637153_flask_python.txt
Q: filtering fields of an inlineformset_factory I have these models: class TourItem(models.Model): Tour=models.ForeignKey(Tour) TourItemType=models.ForeignKey(TourItemType) Transfer=models.ForeignKey(Transfer) Accommodate=models.ForeignKey(Accommodate) Visit=models.ForeignKey(Visit) and: class Tour(mo...
filtering fields of an inlineformset_factory
I have these models: class TourItem(models.Model): Tour=models.ForeignKey(Tour) TourItemType=models.ForeignKey(TourItemType) Transfer=models.ForeignKey(Transfer) Accommodate=models.ForeignKey(Accommodate) Visit=models.ForeignKey(Visit) and: class Tour(models.Model): Lang_Choices=( ('fa',ugettex...
[ "Try this from within your view:\nTourItemFormSet = inlineformset_factory(Tour,TourItem,can_delete=True,extra=4)\nTourItemFormSet.form.base_fields[\"TourItemType\"].queryset = TourItemType.objects.filter(Lang__iexact=request.LANGUAGE_CODE)\n# then create an instance of TourItemFormSet and add to template context\n\...
[ 2 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008636937_django_python.txt
Q: NumPy: vectorize sum of distances to a set of points I'm trying to implementing a k-medoids clustering algorithm in Python/NumPy. As part of this algo, I have to compute the sum of distances from objects to their "medoids" (cluster representatives). I have: a distance matrix on five points n_samples = 5 D = np.arr...
NumPy: vectorize sum of distances to a set of points
I'm trying to implementing a k-medoids clustering algorithm in Python/NumPy. As part of this algo, I have to compute the sum of distances from objects to their "medoids" (cluster representatives). I have: a distance matrix on five points n_samples = 5 D = np.array([[ 0. , 3.04959014, 4.74341649, 3.72424489, ...
[ "How about:\nIn [17]: D[np.arange(n_samples),medoids[cl]].sum()\nOut[17]: 10.777269629999999\n\n" ]
[ 1 ]
[]
[]
[ "numpy", "python", "vectorization" ]
stackoverflow_0008637475_numpy_python_vectorization.txt
Q: How to use Python string formatting to convert an integer representing cents to a float representing dollars? I have an integer representing a price in cents. Using Python format strings, how can I convert this value into dollars with two decimal places? Examples: 1234 => 12.34 5 => 0.05 999 => 9.99 EDIT: I sho...
How to use Python string formatting to convert an integer representing cents to a float representing dollars?
I have an integer representing a price in cents. Using Python format strings, how can I convert this value into dollars with two decimal places? Examples: 1234 => 12.34 5 => 0.05 999 => 9.99 EDIT: I should give some background. I am storing prices in a database as integers in order to make sure I don't loose precis...
[ "You should try hard to avoid ever using floats to represent money (numerical inaccuracy can too easily creep in). The decimal module provides a useful datatype for representing money as it can exactly represent decimal numbers such as 0.05.\nIt can be used like this:\nimport decimal\ncents = 999\ndollars = decimal...
[ 16, 7, 6 ]
[]
[]
[ "currency", "django_templates", "python", "string_formatting" ]
stackoverflow_0008637628_currency_django_templates_python_string_formatting.txt
Q: When using python-markdown what determines the "final" look of the page? When using python-markdown what determines the final look of the page? I.e. what do I need to change, for example and more importantly where, to let's say, change the color of the H1 headers from black to light blue? A: As @JBernardo pointe...
When using python-markdown what determines the "final" look of the page?
When using python-markdown what determines the final look of the page? I.e. what do I need to change, for example and more importantly where, to let's say, change the color of the H1 headers from black to light blue?
[ "As @JBernardo pointed out in his comment you'll need some CSS. This means that since the HTML output from python-markdown doesn't contain any style, you have to add it yourself to the HTML document and the easiest way to do that is with CSS.\nTo do that, just make sure that you add a reference to the CSS file in t...
[ 0 ]
[]
[]
[ "markdown", "python" ]
stackoverflow_0008637497_markdown_python.txt
Q: Qt - How to get the pixel length of a string in a QLabel? I have a QLabel of a fixed width. I need to check (periodically) that the entire string fits inside the QLabel at its current width, so I can resize it appropriately. To do this, I need to obtain the 'pixel length' of the string. (The total amount of horizo...
Qt - How to get the pixel length of a string in a QLabel?
I have a QLabel of a fixed width. I need to check (periodically) that the entire string fits inside the QLabel at its current width, so I can resize it appropriately. To do this, I need to obtain the 'pixel length' of the string. (The total amount of horizontal pixels required to display the string). It should be noted...
[ "To get the precise pixel-width of the text, you must use QFontMetrics.boundingRect.\nDo not use QFontMetrics.width, because it takes into account the left and right bearing of the characters. This will often (but not always) lead to results which can be several pixels more or less than the full pixel-width.\nSo, t...
[ 34 ]
[]
[]
[ "pyqt", "pyqt4", "python", "qlabel", "width" ]
stackoverflow_0008633433_pyqt_pyqt4_python_qlabel_width.txt
Q: How to add differently shaped numpy arrays? I have 2 numpy arrays. One is a 2*2 array. a = [[1,2],[3,4]] The other is a 2*2*4 array. b = [[[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0]]] I want to add them so that I have a 2*2*4 array, c. c = [[[1,0,0,0],[2,0,0,0]],[[3,0,0,0],[4,0,0,0]]] What's the correct numpytho...
How to add differently shaped numpy arrays?
I have 2 numpy arrays. One is a 2*2 array. a = [[1,2],[3,4]] The other is a 2*2*4 array. b = [[[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0]]] I want to add them so that I have a 2*2*4 array, c. c = [[[1,0,0,0],[2,0,0,0]],[[3,0,0,0],[4,0,0,0]]] What's the correct numpythonic way to do this? Edit: This appears to work ...
[ "Not sure whether you can do the sum in one single steps. Here it is in two steps:\nc = b.copy()\nc[...,0] += a\n\n" ]
[ 0 ]
[]
[]
[ "multidimensional_array", "numpy", "python" ]
stackoverflow_0008638156_multidimensional_array_numpy_python.txt
Q: How can I send a URL request to the server with Python without actually opening my browser ("without using the webbrowser module")? I want to send this URL as a request to the server to change something on the website while I am logged in. The problem is, when I use mechanize or urllib2 to open the URL it doesn't ...
How can I send a URL request to the server with Python without actually opening my browser ("without using the webbrowser module")?
I want to send this URL as a request to the server to change something on the website while I am logged in. The problem is, when I use mechanize or urllib2 to open the URL it doesn't change anything on the website. However, when I use the webbrowser module, it does change things on the website. I want to do what the we...
[ "First you should write url variable with quotes:\nurl = \"http://www.locationary.com/access/proxy.jsp?ACTION_TOKEN=proxy_jsp$JspView$SaveAction&inPlaceID=1020634218&xxx_c_1_f_987=http%3A%2F%2Fwww.yellowpages.com%2Fpittsburgh-pa%2Fmip%2Ffamily-dollar-store-1349194%3Flid%3D1349194\"\n\nAnd if you wanna send request ...
[ 1, 0 ]
[]
[]
[ "browser", "mechanize", "python", "urllib2" ]
stackoverflow_0008638284_browser_mechanize_python_urllib2.txt
Q: Python row.count error I am very new to python and have no idea what I'm doing but I am trying to learn as I program as this is what I have done in the past with C, C++, and Cocoa. I am writing a program with a matrix. I want to count the number of occurrences of x (x being a value in my matrix.) When I try to do...
Python row.count error
I am very new to python and have no idea what I'm doing but I am trying to learn as I program as this is what I have done in the past with C, C++, and Cocoa. I am writing a program with a matrix. I want to count the number of occurrences of x (x being a value in my matrix.) When I try to do this though I am not exactl...
[ "You're not exactly getting a \"matrix\" here, it's really a list of lists.\nWhat you're getting from your for row in matrix block is the number of times a particular number has occurred, say 9 for the first time around. You're also not printing any other value besides the occurrence of 0.\nlist.insert(i, v) will ...
[ 4 ]
[]
[]
[ "python" ]
stackoverflow_0008638511_python.txt
Q: Calculate position of star with PyEphem How to calculate postion of stars with PyEphem on particulary date. I writed code but it calculate only today obs = ephem.Observer() obs.date = "2010/12/10" Sirrah = ephem.star("Sirrah") Sirrah.compute(obs) Thank's for help ...
Calculate position of star with PyEphem
How to calculate postion of stars with PyEphem on particulary date. I writed code but it calculate only today obs = ephem.Observer() obs.date = "2010/12/10" Sirrah = ephem.star("Sirrah") Sirrah.compute(obs) Thank's for help
[ "Maybe someone will find it usefull: \nimport ephem\nimport ephem.stars\nglobal stars\nstars = {}\nobs = ephem.Observer()\nobs.long = ephem.degrees('15.17')\nobs.lat = ephem.degrees('44.4')\nobs.elevation = 200\nobs.date = \"2010/09/12\"\nfor star in ephem.stars.db.split(\"\\n\"): \n name = star.split(\",\")...
[ 2 ]
[]
[]
[ "astronomy", "pyephem", "python" ]
stackoverflow_0008634664_astronomy_pyephem_python.txt
Q: sqlalchemy UnicodeDecodeError: 'utf8' codec can't decode byte 0xe7 when trying to select all from msssql 2005 table I'm building an application that works with the db of another application, using mssql 2005 (I can't change that or change the existing table definition). w the mssql table collate is: "hebrew bin",...
sqlalchemy UnicodeDecodeError: 'utf8' codec can't decode byte 0xe7 when trying to select all from msssql 2005 table
I'm building an application that works with the db of another application, using mssql 2005 (I can't change that or change the existing table definition). w the mssql table collate is: "hebrew bin", and the application shows perfect hebrew from the table, all the py files are encoded utf-8 notice! there is no problem ...
[ "Based on what you say, it is highly likely that text columns in the database table are encoded in cp1255 (Windows Hebrew) but your code is expecting UTF-8, perhaps in default of being explicitly told anything about the encoding.\nYou need to find what call into sqlalchemy or pyodbc needs to modified to correct the...
[ 1, 0 ]
[]
[]
[ "python", "sql_server_2005", "sqlalchemy", "turbogears2" ]
stackoverflow_0008637894_python_sql_server_2005_sqlalchemy_turbogears2.txt
Q: Python 3's input() returns a str that is not same object as the same str literal I've come across an interesting behavior with Python 3 that I don't understand. I've understood that with the built-in immutable types like str, int, etc, that not only are two variables of the same value (both contain 'x') equal, the...
Python 3's input() returns a str that is not same object as the same str literal
I've come across an interesting behavior with Python 3 that I don't understand. I've understood that with the built-in immutable types like str, int, etc, that not only are two variables of the same value (both contain 'x') equal, they are literally the same object, which allows the use of the is operator. However, whe...
[ "\nI've understood that with the built-in immutable types like str, int, etc, that not only are two variables of the same value (both contain 'x') equal, they are literally the same object, which allows the use of the is operator.\n\nThis is your misconception: concerning the ints and longs, that is valid only for ...
[ 2, 1, 1, 0, 0 ]
[]
[]
[ "python", "string" ]
stackoverflow_0008638880_python_string.txt
Q: Best way of integrating url addresses from database to django url patterns I'm currently playing with django to get acquainted with it. I want to build a litte cms by myself. In an apps model i define a string database-field which represents the url, a field for the bodytext etc. Now i wonder what would be the bes...
Best way of integrating url addresses from database to django url patterns
I'm currently playing with django to get acquainted with it. I want to build a litte cms by myself. In an apps model i define a string database-field which represents the url, a field for the bodytext etc. Now i wonder what would be the best way to integrate the url and its corresponding content from the set of data. D...
[ "I've read this question several times and I'm still not sure exactly what you're asking.\nThe tutorial tells you exactly how to resolve addresses to db entries: capture the components of the URL in your urlconf, pass them to the view, and query your models in the view dependent on the parameters passed from the UR...
[ 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008638966_django_python.txt
Q: How can i extend a model through a reusable app? I wrote an app that is mainly allowing the user to drag tags to objects via jQuery. I want to allow that app to work for multiple models, so that i can tag ie. a user or an image. For this i thought about adding a class containing a "dropcode" to each models represe...
How can i extend a model through a reusable app?
I wrote an app that is mainly allowing the user to drag tags to objects via jQuery. I want to allow that app to work for multiple models, so that i can tag ie. a user or an image. For this i thought about adding a class containing a "dropcode" to each models representation on the page: <div class="droppable" dropcode="...
[ "If your application should work with any model, then you should use the contentypes framework:\n\nDjango includes a contenttypes application that can track all of the\n models installed in your Django-powered project, providing a\n high-level, generic interface for working with your models.\n\nImplementing this ...
[ 0, 0, 0 ]
[]
[]
[ "django", "django_models", "python" ]
stackoverflow_0008637982_django_django_models_python.txt
Q: Python 2.7.2 if/or unexpected behaviour I am learning Python at the moment and I have hit an issue. Observe this code: while 1: print "How many lines do you want to add to this file?" number_of_lines = raw_input(">").strip() if not(number_of_lines.isdigit()) or number_of_lines > 10: print "Pl...
Python 2.7.2 if/or unexpected behaviour
I am learning Python at the moment and I have hit an issue. Observe this code: while 1: print "How many lines do you want to add to this file?" number_of_lines = raw_input(">").strip() if not(number_of_lines.isdigit()) or number_of_lines > 10: print "Please try a number between 1 and 10 inclusive....
[ "When returned from raw_input, your number_of_lines variable is a string. You need to convert it to an integer before comparing with 10:\nnot(number_of_lines.isdigit()) or int(number_of_lines) > 10\n\n", "I'd try to convert the string into an integer first, catch the error if they put in something else. This als...
[ 5, 3 ]
[]
[]
[ "logic", "python" ]
stackoverflow_0008639437_logic_python.txt
Q: How to keep tornado call async? While doing an async mongodb query like the one in the below class how is this call really non-blocking if I still have access to an argument like self.get_argument("ip_address") inside the callback function? Or should I not access to the argument like this to keep the call async? c...
How to keep tornado call async?
While doing an async mongodb query like the one in the below class how is this call really non-blocking if I still have access to an argument like self.get_argument("ip_address") inside the callback function? Or should I not access to the argument like this to keep the call async? class MainHandler(tornado.web.RequestH...
[ "The instance self referenced in the callback function will be hanging around until the end of the callback function, therefore self.arguments will always be available inside _valid_app.\nMaybe you can be confused by what would happen if another request to the same handler were made during the async call to Mongo. ...
[ 0 ]
[]
[]
[ "mongodb", "python", "tornado" ]
stackoverflow_0008638612_mongodb_python_tornado.txt
Q: Create edgelist from a python dictionary I have a dictionary of dictionaries with the following structure: 1:{'Amendment': '1', 'status': 'Stadf\xc3\xa6stet', 'Name': 'Bodil Kornbek', 'title': 'L 1 Forslag til till\xc3\xa6gsbevillingslov for 2004.', 'fremsat': '2005-03-04', 'Vote.Numeric': '2',...
Create edgelist from a python dictionary
I have a dictionary of dictionaries with the following structure: 1:{'Amendment': '1', 'status': 'Stadf\xc3\xa6stet', 'Name': 'Bodil Kornbek', 'title': 'L 1 Forslag til till\xc3\xa6gsbevillingslov for 2004.', 'fremsat': '2005-03-04', 'Vote.Numeric': '2', 'PSession': '1', 'vedtaget': '2005-04...
[ "First, let's transform the data (I will make some assumptions here) so that the keys of the dictionary are the members of parliament (identified by Name), and the data for each is a mapping of how they voted (Vote.Numeric) on each issue (Voteid), so the Voteids are keys in that sub-dictionary. We can discard the r...
[ 4 ]
[]
[]
[ "dictionary", "python" ]
stackoverflow_0008639378_dictionary_python.txt
Q: error importing tables in python I have installed python 2.6, numpy 1.6.1, tables 2.3.1 y numexpr 2.0 under windows 32bits. However import tables gives me this error: Traceback (most recent call last): File "...\src\test\test6.py", line 1, in <module> import tables File "C:\Python26\Lib\site-packages\table...
error importing tables in python
I have installed python 2.6, numpy 1.6.1, tables 2.3.1 y numexpr 2.0 under windows 32bits. However import tables gives me this error: Traceback (most recent call last): File "...\src\test\test6.py", line 1, in <module> import tables File "C:\Python26\Lib\site-packages\tables\__init__.py", line 96, in <module> ...
[ "You'd need to compile interpreter.c which isn't that easy in windows. Would it be ok if you used numexpr 1.4? You can use a precompiled installer that way http://code.google.com/p/numexpr/downloads/list\n" ]
[ 1 ]
[]
[]
[ "importerror", "linker_errors", "pytables", "python" ]
stackoverflow_0008639297_importerror_linker_errors_pytables_python.txt
Q: Separate lists of format M=[(a,x), (b,y)] into M1=[a,b] and M2=[x,y] I have a list M below which came from an external file (This is a large list in reality, len(M)>10000). M=[(1, 100), (2, 200), (3, 300), (4, 400)] However, I want to separate it into M1=[1,2,3,4] and M2=[100,200,300,400]. Here is how I do it ...
Separate lists of format M=[(a,x), (b,y)] into M1=[a,b] and M2=[x,y]
I have a list M below which came from an external file (This is a large list in reality, len(M)>10000). M=[(1, 100), (2, 200), (3, 300), (4, 400)] However, I want to separate it into M1=[1,2,3,4] and M2=[100,200,300,400]. Here is how I do it at the moment, M1 = [] M2 = [] for M1,M2 in M: M1.append(M1) M2.ap...
[ "Just do it:\nM1, M2 = zip(*M)\n\nM1 and M2 will be tuples. You can transform them into lists if you want:\nM1, M2 = map(list, zip(*M))\n\nor with a genexp:\nM1, M2 = (list(i) for i in zip(*M))\n\n", "One solution, more efficient than yours because it uses implicit loops is:\n>>> [m1 for m1, _ in M]\n>>> [1, 2, 3...
[ 6, 2, 1 ]
[]
[]
[ "csv", "for_loop", "list", "python" ]
stackoverflow_0008639488_csv_for_loop_list_python.txt
Q: How can I read a copy of the data arriving at the master end of a PTY? I have the file descriptor of the master end of a pty. This pty is used by a library (libvte) to spawn and run subprocesses. I can poll and read from the file descriptor or duplicate of it, but then data never gets to the library. I can poll a...
How can I read a copy of the data arriving at the master end of a PTY?
I have the file descriptor of the master end of a pty. This pty is used by a library (libvte) to spawn and run subprocesses. I can poll and read from the file descriptor or duplicate of it, but then data never gets to the library. I can poll and read from the file descriptor, then write it back to the master, but then...
[ "Check out my pypty program - it's a Python reimplementation of /usr/bin/script with a bit of extra functionality, so it demonstrates both ends of PTY communication in Python:\nBTW, beware of signals with (relatively) naked system calls - they may return when only partially complete. See in particular the maybe_re...
[ 1 ]
[]
[]
[ "file_io", "linux", "posix", "python" ]
stackoverflow_0008639038_file_io_linux_posix_python.txt
Q: ZeroMQ pipeline pattern I'm implementing a messaging system where external programs called agents are able to communicate via ZeroMq producers. So, every time an event of interest occurs, agent sends a message to ZeroMq. I'm interested in implementing this using pipeline pattern. I found some examples (Ventilator...
ZeroMQ pipeline pattern
I'm implementing a messaging system where external programs called agents are able to communicate via ZeroMq producers. So, every time an event of interest occurs, agent sends a message to ZeroMq. I'm interested in implementing this using pipeline pattern. I found some examples (Ventilator-Worker-Results Manager), but...
[ "You shoud mix the patterns to achieve your solution. I think it should be an specialized broker which instantiates REP agent collectors for real REQ agents. Those agent collectors should take care of ordering before communicate with the system.\n", "REQ-REP is when you want a round trip. Sounds like you want a ...
[ 2, 1 ]
[]
[]
[ "python", "zeromq" ]
stackoverflow_0008212075_python_zeromq.txt
Q: Multiprocessing in Python on Windows I am trying out the examples listed in the python docs http://docs.python.org/library/multiprocessing.html particularly these two on Windows: 1) from multiprocessing import Process def f(name): print 'hello', name if __name__ == '__main__': p = Process(target=f, args=...
Multiprocessing in Python on Windows
I am trying out the examples listed in the python docs http://docs.python.org/library/multiprocessing.html particularly these two on Windows: 1) from multiprocessing import Process def f(name): print 'hello', name if __name__ == '__main__': p = Process(target=f, args=('bob',)) p.start() p.join() 2) f...
[ "example 1 works well.( I hope you saved the program in a file and then executed it else it will not recognise the function f at all).\nexample 2 won't work if u want the parent process's id. There is no getppid in windows.\nJust take the print os.getppid and execute, its brilliant as ever !\nPlease refer this for ...
[ 2 ]
[]
[]
[ "python", "windows" ]
stackoverflow_0008639745_python_windows.txt
Q: Disable django form field for a given time I want to disable django fields for 6 months after the date of update. I have saved update_time to a table. updated_time = a.update_time disabled_time = a.update_time + timedelta(180) I want to diable field that updated: self.fields['first_name'].widget.attrs['readonly']...
Disable django form field for a given time
I want to disable django fields for 6 months after the date of update. I have saved update_time to a table. updated_time = a.update_time disabled_time = a.update_time + timedelta(180) I want to diable field that updated: self.fields['first_name'].widget.attrs['readonly'] = True How can I disable self.fields['first_na...
[ "You can compare, and substract basic datetime objects and make some check at form initialization time:\nfrom datetime import timedelta, datetime\n...\nclass FooForm(ModelForm):\n def __init__(self, *args, **kwargs):\n super(FooForm, self).__init__(*args, **kwargs)\n # check if we already have a sa...
[ 1 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008639084_django_python.txt
Q: Python/Numpy/Scipy - Converting string to mathematical function I am in the somewhat unfortunate position to try to convert a program from the depths of CERN ROOT to python. In ROOT code (CINT in itself is an abomination imo), one can store mathematical functions as a "string" and pass these along to ROOT for fitt...
Python/Numpy/Scipy - Converting string to mathematical function
I am in the somewhat unfortunate position to try to convert a program from the depths of CERN ROOT to python. In ROOT code (CINT in itself is an abomination imo), one can store mathematical functions as a "string" and pass these along to ROOT for fitting, plotting, etc. because of how ROOT defines these as "strings." ...
[ "Since, presumably, you can trust the strings to be non-malicious, you could build a string which defines a function which evaluates the expression and use exec to execute that string as a statement. For example,\nimport numpy as np\nimport scipy.special as special\n\nexpr='(1+p[1])**(1+p[1])/special.gamma(1+p[1]) ...
[ 9 ]
[]
[]
[ "numpy", "python", "root_framework", "scipy" ]
stackoverflow_0008639871_numpy_python_root_framework_scipy.txt
Q: Full fledged local CGI Server I want to set up a local CGI Server that treats any any *.py file as a cgi-script and executes it. But using CGIHTTPServer.CGIHTTPRequestHandler does only execute files contained in the cgi_directories attribute. How can I achieve that any Python script is executed as cgi-script ? A:...
Full fledged local CGI Server
I want to set up a local CGI Server that treats any any *.py file as a cgi-script and executes it. But using CGIHTTPServer.CGIHTTPRequestHandler does only execute files contained in the cgi_directories attribute. How can I achieve that any Python script is executed as cgi-script ?
[ "Try replace the CGIHTTPServer.CGIHTTPRequestHandler.is_cgi function at your own risk:\nimport CGIHTTPServer\n\ndef is_cgi(self):\n if self.path.endswith('.py'):\n self.cgi_info = CGIHTTPServer._url_collapse_path_split(self.path)\n return True\n return False\n\nCGIHTTPServer.CGIHTTPRequestHandle...
[ 1, 0 ]
[]
[]
[ "cgi", "localhost", "python" ]
stackoverflow_0008638778_cgi_localhost_python.txt
Q: Persistent Hashing of Python Frozen Sets How would you convert a nesting of Python frozenset objects into a unique integer that was the same across Python sessions and platforms? e.g. I get different values from hash() on different platforms 32-bit Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on l...
Persistent Hashing of Python Frozen Sets
How would you convert a nesting of Python frozenset objects into a unique integer that was the same across Python sessions and platforms? e.g. I get different values from hash() on different platforms 32-bit Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "...
[ "\nHow would you convert a nesting of Python frozenset objects into a unique integer that was the same across Python sessions and platforms?\n\nAFAIK hashes are not guaranteed to be unique. In fact where they are used for lookup tables (like in dictionaries) hashes conflicts are quite common.\nThat said. If you wan...
[ 8, 0 ]
[]
[]
[ "linux", "python" ]
stackoverflow_0008639786_linux_python.txt
Q: QObject::killTimers error QThread PyQt I have a script I'm writing to batch download images from an imageboard via JSON/XML api. Previously, it had been purely CLI, but recently I've been trying to build a UI in PyQt, with great success but for one problem: thread blocking issues, nonresponsive GUI when actually c...
QObject::killTimers error QThread PyQt
I have a script I'm writing to batch download images from an imageboard via JSON/XML api. Previously, it had been purely CLI, but recently I've been trying to build a UI in PyQt, with great success but for one problem: thread blocking issues, nonresponsive GUI when actually calling the worker threads within my script. ...
[ "Thanks Avaris for your help, I fixed the connect to point towards my Url_Download() instance. The issue occurring apparently was very inadequately displayed on windows. On my linux VM I was given this error instead:\nQThread: Destroyed while thread is still running\nQThread: Destroyed while thread is still running...
[ 1 ]
[]
[]
[ "multithreading", "pyqt", "python", "windows" ]
stackoverflow_0008632846_multithreading_pyqt_python_windows.txt
Q: Convert Matplotlib figure to NumPy array without any borders/frame or axis I'm trying to compare a generated image in Python with an image/photo in a file. The best way I got to make this so far is by generating a figure in Matplotlib and then convert it to a numpy array and compare the values with the values I ge...
Convert Matplotlib figure to NumPy array without any borders/frame or axis
I'm trying to compare a generated image in Python with an image/photo in a file. The best way I got to make this so far is by generating a figure in Matplotlib and then convert it to a numpy array and compare the values with the values I get from my image. I got the following code to convert a Matplotlib figure to a 3D...
[ "Well, it's not really an answer to the problem at hand using Matplotlib, but I gave up on this lib for this job and just used PIL.\nIt's quite easy, altough it's also quite slow (but I don't know if it's slower than Matplotlib).\nThe code is the following:\ndef makeImage (triangle, largura, altura):\n \"\"\"\n ...
[ 0 ]
[]
[]
[ "figure", "image", "matplotlib", "python" ]
stackoverflow_0008632290_figure_image_matplotlib_python.txt
Q: figuring out y-intercept with a given slope in python I'm trying to compute the intercept of a slope but I can't all of my test units to work. I get the first test units to work but the last one I'm having some trouble. Can someone help me find the error? def test(actual, expected): """ Compare the actual to t...
figuring out y-intercept with a given slope in python
I'm trying to compute the intercept of a slope but I can't all of my test units to work. I get the first test units to work but the last one I'm having some trouble. Can someone help me find the error? def test(actual, expected): """ Compare the actual to the expected value, and print a suitable message. ...
[ "You are being given a clue by the test output: Expected '5.0', but got '8'. Note that the expected value is a floating point number, but the actual result is an integer.\nA quick fix is to change your slope function to:\ndef slope (x1, y1, x2, y2):\n x2 = (x2 - x1)\n y2 = (y2 - y1)\n\n m = (1.0*y2/x2)\n ...
[ 4, 2, 0 ]
[]
[]
[ "geometry", "math", "python" ]
stackoverflow_0008640316_geometry_math_python.txt
Q: Python ctypes pointer to pointer to structure I'm having problems getting a pointer to a pointer to a structure working. This is the code I have which throws the exception "ArgumentError: argument 1: : expected LP_LP_List instance instead of pointer to LP_LP_List". class List(Structure): _fields_ = ( ...
Python ctypes pointer to pointer to structure
I'm having problems getting a pointer to a pointer to a structure working. This is the code I have which throws the exception "ArgumentError: argument 1: : expected LP_LP_List instance instead of pointer to LP_LP_List". class List(Structure): _fields_ = ( ('head', POINTER(Node)), ('tail', POINTER(N...
[ "The API sounds like the pointer passed in by reference will be modified by create, so it has to be passed by reference, with the return value be the newly created list. \nIf this were written in \"C\", I'm guessing you would have some code like this:\nList *create(List **control);\nList *control;\nList *plist;\np...
[ 5 ]
[]
[]
[ "ctypes", "python" ]
stackoverflow_0008638942_ctypes_python.txt