content
stringlengths
85
101k
title
stringlengths
0
150
question
stringlengths
15
48k
answers
list
answers_scores
list
non_answers
list
non_answers_scores
list
tags
list
name
stringlengths
35
137
Q: How to plot with x-axis at the top of the figure? I would like to ask how to produce a plot similar to that in the figure below? Basically, how to have x-axis at the top of the figure. Thanks Image from: http://oceanographyclay1987.blogspot.com/2010/10/light-attenuation-in-ocean.html A: Use ax.xaxis.set_ticks_p...
How to plot with x-axis at the top of the figure?
I would like to ask how to produce a plot similar to that in the figure below? Basically, how to have x-axis at the top of the figure. Thanks Image from: http://oceanographyclay1987.blogspot.com/2010/10/light-attenuation-in-ocean.html
[ "Use\nax.xaxis.set_ticks_position(\"top\")\n\nFor example,\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nnumdata = 100\nt = np.linspace(0, 100, numdata)\ny = 1/t**(1/2.0)\n\nfig = plt.figure()\nax = fig.add_subplot(1, 1, 1)\nax.xaxis.set_ticks_position('top')\nax.yaxis.grid(linestyle = '-', color = 'gray'...
[ 10 ]
[]
[]
[ "matplotlib", "plot", "python" ]
stackoverflow_0008639973_matplotlib_plot_python.txt
Q: CSV DictReader only gets the first character of the CSV file I'm attempting to write a small python script that processes through CSV data. I read the URL and the data is there when I print the variable, but when I parse it using either csv.reader or csv.DictReader it only reads the first character as a field name...
CSV DictReader only gets the first character of the CSV file
I'm attempting to write a small python script that processes through CSV data. I read the URL and the data is there when I print the variable, but when I parse it using either csv.reader or csv.DictReader it only reads the first character as a field name and then the next character as the value for it. I don't understa...
[ "According to the csv module docs, you need to pass a file or file-like object to the reader, not a string. I'm not familiar with what urlopen returns, but you could try passing response to the reader. Or, you could use a StringIO object which is for just this purpose - html = StringIO.StringIO(response.read()) oug...
[ 2 ]
[ "why not just a regular for loop?\n response = urllib2.urlopen('http://ichart.finance.yahoo.com/table.csv?s=YHOO&d=0&e=28&f=2010&g=d&a=3&b=12&c=2009&ignore=.csv')\n for line in response.readlines():\n print line.split(',')\n\nYou already have the data as string, I don't understand why would you use csv m...
[ -1 ]
[ "csv", "python" ]
stackoverflow_0008640458_csv_python.txt
Q: Python - how to check if one of several conditions is met and then specifically if each of conditions is met? I am wondering if there is any shortcut to do the following: if a or b or c ... do p if a do x if b do y if c do z ... else do q Is it necessary to type out...
Python - how to check if one of several conditions is met and then specifically if each of conditions is met?
I am wondering if there is any shortcut to do the following: if a or b or c ... do p if a do x if b do y if c do z ... else do q Is it necessary to type out each of the conditions twice or is there any other way to do this?
[ "There is nothing wrong with your code, but if checking any of a, b or c is expensive, you could use a flag instead, as to check the condition only once:\nflag = False\nif a:\n flag = True\n do x\nif b:\n flag = True\n do y\nif c:\n flag = True\n do z\ndo (p if flag else q)\n\nI find this form als...
[ 3 ]
[]
[]
[ "python" ]
stackoverflow_0008640533_python.txt
Q: Converting bytes to integer in Python I need some help in retaining an integer datatype through serial communication. My setup right now is an Arduino microcontroller reading a temperature sensor which is outputting a float number through an XBee module via the serial port that looks like this: 76.82 for example. ...
Converting bytes to integer in Python
I need some help in retaining an integer datatype through serial communication. My setup right now is an Arduino microcontroller reading a temperature sensor which is outputting a float number through an XBee module via the serial port that looks like this: 76.82 for example. The XBee receiver is hooked up to my comput...
[ "Are you looking for this?\n>>> a = b'76.66\\r\\n'\n>>> float(a)\n76.66\n\nEDIT: If by \"retain the original datatype\" you mean \"keeping it as a string\":\n>>> a.strip()\n'76.66'\n\n", "To convert to a float:\nfloat(b'76.66\\r\\n')\n\nTo round that down to an int:\nmath.floor(float(b'76.66\\r\\n'))\n\n" ]
[ 4, 3 ]
[]
[]
[ "arduino", "python" ]
stackoverflow_0008640708_arduino_python.txt
Q: What is wrong with my regex Pattern to find recurring cycles in Python? I want to match any string that has a recurring cycle. Like in this data: 3333333333333333333333333333333333333333 / 1 digit cycle(3) 1666666666666666666666666666666666666666 / 1 digit cycle(6) 1428571428571428571428571428571428571428 / 6 dig...
What is wrong with my regex Pattern to find recurring cycles in Python?
I want to match any string that has a recurring cycle. Like in this data: 3333333333333333333333333333333333333333 / 1 digit cycle(3) 1666666666666666666666666666666666666666 / 1 digit cycle(6) 1428571428571428571428571428571428571428 / 6 digit cycle(142857) 1111111111111111111111111111111111111111 / 1 digit cycle(1) ...
[ "Add an r prefix: \nr\"([0-9]+?)\\1+\"\n\nThat will make the backslash a literal backslash instead of escaping the 1.\n" ]
[ 5 ]
[]
[]
[ "pattern_matching", "python", "regex", "regex_negation" ]
stackoverflow_0008640840_pattern_matching_python_regex_regex_negation.txt
Q: Optimizing Python Code Using SQLite3 + Mutagen I'm in the process of improving an open-source music database, which reads songs in from my collection and stores them to an SQLite database. In turn, I'm able to leverage the database to find duplicates, run queries on my collection, and (if I so desired) find dupli...
Optimizing Python Code Using SQLite3 + Mutagen
I'm in the process of improving an open-source music database, which reads songs in from my collection and stores them to an SQLite database. In turn, I'm able to leverage the database to find duplicates, run queries on my collection, and (if I so desired) find duplicate songs in the collection. To read the metadata ...
[ "If you feel up to it, you could dive into threading :) - It is quite easy in python.\nCreate two Queue objects, one for IN and one for OUT and in between multiple threads scan the files. (Worker threads, and Queue's are threadsafe)\nIt should be only ~80loc more code, and you probably can keep the current function...
[ 4 ]
[]
[]
[ "mutagen", "python", "refactoring", "sqlite" ]
stackoverflow_0008640701_mutagen_python_refactoring_sqlite.txt
Q: pymongo: how to use $or operator to an column that is an array? I have a collection like this: user_id albums 1 [1 2 3 4] 2 [3 5 7 8] I want to find out all the records that, the albums contains 3 or 7 or 8, I wrote the code like this but not working: or_array = [] or_array.append({"albums...
pymongo: how to use $or operator to an column that is an array?
I have a collection like this: user_id albums 1 [1 2 3 4] 2 [3 5 7 8] I want to find out all the records that, the albums contains 3 or 7 or 8, I wrote the code like this but not working: or_array = [] or_array.append({"albums":3}) or_array.append({"albums":7}) or_array.append({"albums":8}) co...
[ "try this\ncollection1.find({'albums': {'$in': [3, 7, 8]}})\n\nfrom the mongodb docs, [IN] allow[s] you to specify an array of possible matches\nIf that doesn't work, maybe back track and look at the actual types of 3 7 and 8 in the collection to ensure they are ints.\nprint type(collection1.find_one()['albums'][0]...
[ 7 ]
[]
[]
[ "mongodb", "pymongo", "python" ]
stackoverflow_0008640921_mongodb_pymongo_python.txt
Q: Python equivalent of LINQ All function? What is the idiomatic Python way to test if all elements in a collection satisfy a condition? (The .NET All() method fills this niche nicely in C#.) There's the obvious loop method: all_match = True for x in stuff: if not test(x): all_match = False break ...
Python equivalent of LINQ All function?
What is the idiomatic Python way to test if all elements in a collection satisfy a condition? (The .NET All() method fills this niche nicely in C#.) There's the obvious loop method: all_match = True for x in stuff: if not test(x): all_match = False break And a list comprehension could do the trick,...
[ "all_match = all(test(x) for x in stuff)\n\nThis short-circuits and doesn't require stuff to be a list -- anything iterable will work -- so has several nice features.\nThere's also the analogous\nany_match = any(test(x) for x in stuff)\n\n" ]
[ 28 ]
[]
[]
[ "linq", "python" ]
stackoverflow_0008641089_linq_python.txt
Q: what's the pythonic way to count the occurrence of an element in a list? this is what I did. is there a better way in python? for k in a_list: if kvMap.has_key(k): kvMap[k]=kvMap[k]+1 else: kvMap[k]=1 Thanks A: Use defaultdict from collections import defaultdict kvmap= defaultdict(int) for k ...
what's the pythonic way to count the occurrence of an element in a list?
this is what I did. is there a better way in python? for k in a_list: if kvMap.has_key(k): kvMap[k]=kvMap[k]+1 else: kvMap[k]=1 Thanks
[ "Use defaultdict\nfrom collections import defaultdict\nkvmap= defaultdict(int)\nfor k in a_list:\n kvmap[k] += 1\n\n", "Single element:\na_list.count(k)\n\nAll elements:\ncounts = dict((k, a_list.count(k)) for k in set(a_list))\n\n", "I dunno, it basically looks fine to me. Your code is simple and easy to r...
[ 16, 9, 7, 5, 3, 1 ]
[]
[]
[ "python" ]
stackoverflow_0000429414_python.txt
Q: How to compare multiple variables to the same value? I am using Python and I would like to have an if statement with many variables in it. Such as: if A, B, C, and D >= 2: print (A, B, C, and D) I realize that this is not the correct syntax and that is exactly the question I am asking — what is the correct P...
How to compare multiple variables to the same value?
I am using Python and I would like to have an if statement with many variables in it. Such as: if A, B, C, and D >= 2: print (A, B, C, and D) I realize that this is not the correct syntax and that is exactly the question I am asking — what is the correct Python syntax for this type of an if statement?
[ "You want to test a condition for all the variables:\nif all(x >= 2 for x in (A, B, C, D)):\n print(A, B, C, D)\n\nThis should be helpful if you're testing a long list of variables with the same condition.\n\nIf you needed to check:\nif A, B, C, or D >= 2:\n\nThen you want to test a condition for any of the vari...
[ 51, 21, 7, 3, 3, 2, 1 ]
[]
[]
[ "python" ]
stackoverflow_0008641008_python.txt
Q: How can I insert new modules in PYTHONPATH? I'm installing http://bitbucket.org/agr/ropemacs for my emacs. In README.txt it say: Note that rope and ropemacs should be in your PYTHONPATH for this to work. I check my sys.path python, but there is't any ropemacs there! but I have installed it! how can I instert ropem...
How can I insert new modules in PYTHONPATH?
I'm installing http://bitbucket.org/agr/ropemacs for my emacs. In README.txt it say: Note that rope and ropemacs should be in your PYTHONPATH for this to work. I check my sys.path python, but there is't any ropemacs there! but I have installed it! how can I instert ropemacs in PYTHONPATH?
[ "If you ran the included setup.py, then the package should be correctly installed and all is well, you can checky by importing it, open a python prompt and type import ropemacs.\nYou probably wouldn't see a directory just for this package, because setuptools normally installs python packages in your site-packages d...
[ 1, 1 ]
[]
[]
[ "emacs", "python", "pythonpath", "rope", "ropemacs" ]
stackoverflow_0008641435_emacs_python_pythonpath_rope_ropemacs.txt
Q: How to access documentation in javascript Is it possible to access the documentation in the javascript at runtime as we do in python like object__doc__ I am just looking for an easy way to discover about inbuilt functions rather then googling for them all the time. Also is there something equivalent to python's ...
How to access documentation in javascript
Is it possible to access the documentation in the javascript at runtime as we do in python like object__doc__ I am just looking for an easy way to discover about inbuilt functions rather then googling for them all the time. Also is there something equivalent to python's dir(object) , again I am looking for it because...
[ "No, JavaScript doesn't have that.\nYou can however write comments in a consistent way and parse the source code to generate documentation.\n\nAlso is there something equivalent to python's dir(object)?\n\nNot in JavaScript, but browsers generally have a console.dir() which performs a similar thing.\n", "Sadly, t...
[ 2, 2 ]
[]
[]
[ "javascript", "python" ]
stackoverflow_0008641687_javascript_python.txt
Q: Function parameters - Python def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'): print "-- This parrot wouldn’t", action print "if you put", voltage, "volts through it." print "-- Lovely plumage, the", type print "-- It’s", state, "!" I started learning python. I can call t...
Function parameters - Python
def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'): print "-- This parrot wouldn’t", action print "if you put", voltage, "volts through it." print "-- Lovely plumage, the", type print "-- It’s", state, "!" I started learning python. I can call this function using parrot(5,'dead'...
[ "You can't use a non-keyword argument ('arg_value') after a keyword argument (arg_name='arg_value'). This is because of how Python is designed.\nSee here: http://docs.python.org/tutorial/controlflow.html#keyword-arguments\nTherefore, you must enter all arguments following a keyword-argument as keyword-arguments...\...
[ 13 ]
[]
[]
[ "python" ]
stackoverflow_0008641934_python.txt
Q: Setting an initial width of a pyqt widget in a splitter I am using python and PyQt to design a simple interface. My question is this: How do I set an initial width of a pyqt widget in a splitter while still allowing it to be modified by the user when they drag the divider? I want one of the two widgets in the spli...
Setting an initial width of a pyqt widget in a splitter
I am using python and PyQt to design a simple interface. My question is this: How do I set an initial width of a pyqt widget in a splitter while still allowing it to be modified by the user when they drag the divider? I want one of the two widgets in the splitter to be narrower when the application first launches and I...
[ "Did you try?:\nQSplitter.setSizes (self, list-of-int list)\n###Sets the child widgets respective sizes to the values given in the list.\n\nYou have here a working example\n" ]
[ 4 ]
[]
[]
[ "pyqt", "python", "widget", "width" ]
stackoverflow_0008641005_pyqt_python_widget_width.txt
Q: generate a random number with fixed length I want to generate a random number with in two range, and i want it to have fixed length. I don't want to limit the range as offered i How to generate random number with the specific length in python as following: [10] -> [00010] [36554] ->[36554] [554] -> [00554] Could y...
generate a random number with fixed length
I want to generate a random number with in two range, and i want it to have fixed length. I don't want to limit the range as offered i How to generate random number with the specific length in python as following: [10] -> [00010] [36554] ->[36554] [554] -> [00554] Could you guide me please? Thanks
[ "import random\n'{0:05}'.format(random.randint(1, 100000))\n\ncreates fixed length string representation of a random number like '00554'.\n" ]
[ 9 ]
[]
[]
[ "python", "random" ]
stackoverflow_0008642295_python_random.txt
Q: pymongo: multiple to multiple mapping I have a database that contains the data of albums and photos, the album contains multiple photos, and photo can also be contained in multiple albums. eg) **photo collection** photo_id album_ids 1 [11 12 13 14] 2 [11 12 15 16] **album collection** album_...
pymongo: multiple to multiple mapping
I have a database that contains the data of albums and photos, the album contains multiple photos, and photo can also be contained in multiple albums. eg) **photo collection** photo_id album_ids 1 [11 12 13 14] 2 [11 12 15 16] **album collection** album_id photo_ids 11 [1 2] 12 ...
[ "With no access to join logic you basically have to do two queries:\n\nLoad the user and get his album list.\nQuery photos where album id in user's album list.\n\nThis is a common pattern in MongoDB whenever you have a many-to-many relationship. With no JOIN on the server, you basically have to write your own join ...
[ 1 ]
[]
[]
[ "mongodb", "pymongo", "python" ]
stackoverflow_0008640753_mongodb_pymongo_python.txt
Q: subclassing models.Manager I see no difference in sub classing the models.manager object and overriding the get_query_set method or simply creating a new method in the sub class and using the method. For the reason being I have taken example from the django book; class MaleManager(models.Manager): def get_quer...
subclassing models.Manager
I see no difference in sub classing the models.manager object and overriding the get_query_set method or simply creating a new method in the sub class and using the method. For the reason being I have taken example from the django book; class MaleManager(models.Manager): def get_query_set(self): return supe...
[ "\nUsually you don't want several managers for the model. It's better to extend default manager.\nclass PeopleManager(models.Manager):\n def get_male(self):\n return self.filter(sex='M')\n\n def get_female(self):\n return return self.filter(sex='F')\n\nclass Person(models.Model):\n ....\n ...
[ 3 ]
[]
[]
[ "django", "django_models", "model", "python" ]
stackoverflow_0008640809_django_django_models_model_python.txt
Q: apache error installing trac / wsgi / python I am experiencing a performance issue installing wsgi/trac/python for the first time. We're setting up trac for the first time ever and are having some issues. As far as I know I've got the components setup in the right places, my Apache is hosted via Wamp, and I will b...
apache error installing trac / wsgi / python
I am experiencing a performance issue installing wsgi/trac/python for the first time. We're setting up trac for the first time ever and are having some issues. As far as I know I've got the components setup in the right places, my Apache is hosted via Wamp, and I will be using MySql 5.x for the database back end. When ...
[ "When we install Python a registry is set by its installer in Windows so wsgi should be able to find Python modules easily without using ConfigurationDirectives.\nHKLM/Software/Python OR HKLM/Software/WOW6432Node/Python\nIn that registry PythonPath & InstallPath is specified from where it can search for modules, dl...
[ 1 ]
[]
[]
[ "apache", "python", "trac", "wsgi" ]
stackoverflow_0006985701_apache_python_trac_wsgi.txt
Q: Django - pip grappelli not on the good Python install I'm using Django 1.3 with Python 2.7 in Ubuntu. Trying to install django-grappelli with pip $ pip install django-grappelli It apparently installs for Python 2.6 (the distribution version) Requirement already satisfied: django-grappelli in /usr/local/lib/pyt...
Django - pip grappelli not on the good Python install
I'm using Django 1.3 with Python 2.7 in Ubuntu. Trying to install django-grappelli with pip $ pip install django-grappelli It apparently installs for Python 2.6 (the distribution version) Requirement already satisfied: django-grappelli in /usr/local/lib/python2.6/dist-packages Maybe because I installed pip with ap...
[ "Python 2.7 packages should be in a different place then Python 2.6 packages. For you then /usr/local/lib/python2.7/site-packages/ I think.\nYou can tell PIP to install into specific location by:\npip install --install-option=\"--prefix=/usr/local/lib/python2.7/site-packages/\" django-grapelli\n\nYou can also use v...
[ 1, 0 ]
[]
[]
[ "django", "django_grappelli", "pip", "python", "python_2.7" ]
stackoverflow_0008642546_django_django_grappelli_pip_python_python_2.7.txt
Q: Why do two algorithms for finding primes differ in speed so much even though they seem to do the same number of iterations? I have two algorithms of finding primes, in Python. The inner loop of each one seems to be executed the same number of times, and is equally simple. However, one of them takes 10 times as muc...
Why do two algorithms for finding primes differ in speed so much even though they seem to do the same number of iterations?
I have two algorithms of finding primes, in Python. The inner loop of each one seems to be executed the same number of times, and is equally simple. However, one of them takes 10 times as much as the other. My question is: Why? Is this some quirk of Python that can be optimized away (how?), or am I missing something e...
[ "The difference is an algorithmic one. In the first version, trial division, you test each candidate against all small primes - that you don't stop when the small prime exceeds candidate ** 0.5 doesn't matter for the range(10**9 - 10**5 ,10**9) if smallprimes has a good upper bound, but it would if the length of th...
[ 3 ]
[]
[]
[ "algorithm", "optimization", "primes", "profiling", "python" ]
stackoverflow_0008640934_algorithm_optimization_primes_profiling_python.txt
Q: Why does the code : os.popen('move *.bin tmp) only move one file? all, Currently, I write a python code in WIN, i'd like to run the command line code move *.bin tmp but only one file was removed. How can I make popen to finish this task? Best wish! A: I suggest using Pythons own modules instead of Windows tools...
Why does the code : os.popen('move *.bin tmp) only move one file?
all, Currently, I write a python code in WIN, i'd like to run the command line code move *.bin tmp but only one file was removed. How can I make popen to finish this task? Best wish!
[ "I suggest using Pythons own modules instead of Windows tools (as also Patrick suggest). I think something like this will work:\nimport glob\nimport shutil\n\ndest = 'c:/tmp/'\n\n# Get all the files as a list with glob\nfiles = glob.glob('c:/files/*.bin')\n\n# move each file seperatly\nfor filename in files:\n s...
[ 4, 2, 1 ]
[]
[]
[ "python" ]
stackoverflow_0008642420_python.txt
Q: Passing a C struct to a Python function I need a simple way to pass a C struct to a Python function. I have embedded Python into a game server, and I intend to write game logic in Python. I've scoured Google and mailing lists and found nothing useful. I have a complex structure in C (with pointers to other relativ...
Passing a C struct to a Python function
I need a simple way to pass a C struct to a Python function. I have embedded Python into a game server, and I intend to write game logic in Python. I've scoured Google and mailing lists and found nothing useful. I have a complex structure in C (with pointers to other relatively complex structures) and have found no rea...
[ "SWIG can do pointers, especially if you can treat them as opaque blobs in your Python code.\nYou might also get somewhere with Cython - it's a dialect of Python that allows you to intermix Python and C datatypes.\n", "Your best bet would be something like swig, but I would think the pointers will give you proble...
[ 2, 0, 0, 0 ]
[]
[]
[ "c", "python", "python_c_api", "python_c_extension" ]
stackoverflow_0008631741_c_python_python_c_api_python_c_extension.txt
Q: Delete/retrieve an element from an array When an element from an array is deleted using del, is it possible to retrieve the deleted element.. del_ele = [] arr=[1,2,3,4,5,6,7,8,9,10] del_ele.append(del arr[6]) A: Use the pop method. del_ele.append(arr.pop(6)) A: No, it's not possible. Quoting from (http://www....
Delete/retrieve an element from an array
When an element from an array is deleted using del, is it possible to retrieve the deleted element.. del_ele = [] arr=[1,2,3,4,5,6,7,8,9,10] del_ele.append(del arr[6])
[ "Use the pop method.\ndel_ele.append(arr.pop(6))\n\n", "No, it's not possible. \nQuoting from (http://www.python.org/doc//current/reference/simple_stmts.html#del): \nDeletion of a name removes the binding of that name from the local or global namespace,...\n" ]
[ 9, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008644305_python.txt
Q: list_filter to display only filtered records depending on user login in django How to show different records in the right-side list_filter depending on logged in user ? eg If superuser logs in the list filter can view all the branches of all the customers in the changelist_view of branch in the list_filter. But if...
list_filter to display only filtered records depending on user login in django
How to show different records in the right-side list_filter depending on logged in user ? eg If superuser logs in the list filter can view all the branches of all the customers in the changelist_view of branch in the list_filter. But if a customer logs in he should be able to see only his branches in the list_filter in...
[ "The current development version of django has support for custom list filters. As far as i know it is almost impossible to do in Django 1.3. If you really need this feature now you should consider switching to the dev branch. \n" ]
[ 1 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008643843_django_python.txt
Q: Python: Is it possible to know how many iterations are in an iterator object beforehand? So far if I wanted to know how many iterations there are in an iterator (in my case that's how many protein sequences in a file) I did: count = 0 for stuff in iterator: count += 1 print count However, I want to seperate t...
Python: Is it possible to know how many iterations are in an iterator object beforehand?
So far if I wanted to know how many iterations there are in an iterator (in my case that's how many protein sequences in a file) I did: count = 0 for stuff in iterator: count += 1 print count However, I want to seperate the iterator into half so I need to know the total amount of iterations. Is there a way to know...
[ "There is no way to know how many values an iterator will produce without consuming it until the end. Note that an iterator can also be infinite, so in that case the total count is not even defined.\nIf you can ensure the iterator to be finite, one way to do what you ask is to convert it to list (using list(iterato...
[ 10, 5, 1, 1, 0 ]
[]
[]
[ "iterator", "python" ]
stackoverflow_0008643315_iterator_python.txt
Q: PySFML build not working I'm trying to get PySFML-1.6 with Python 2.7 following these instructions. I direct to the SFML directory and enter python setup.py build -cmingw32 and I get this error c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot find d -lsfml-graphics c:/mingw/bin/../lib/...
PySFML build not working
I'm trying to get PySFML-1.6 with Python 2.7 following these instructions. I direct to the SFML directory and enter python setup.py build -cmingw32 and I get this error c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot find d -lsfml-graphics c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../...
[ "Did you follow it?\n\nIf you want to build PySFML from the source code, you must have the SFML C++ headers and libraries in the SFML-x.x directory (as well as the \"python\" folder)\n\nAnyway, why not just download pre-compiled files here?\n" ]
[ 1 ]
[]
[]
[ "build", "python", "sfml" ]
stackoverflow_0008641145_build_python_sfml.txt
Q: Modules imported twice. Possible bug in Python interpreter I've made a rather contrived import scheme in a project of mine and I think I might have discovered a bug in the Python interpreter that causes modules to be imported twice. Here's how my test project is set up: / Launcher.bat — Project is run from here....
Modules imported twice. Possible bug in Python interpreter
I've made a rather contrived import scheme in a project of mine and I think I might have discovered a bug in the Python interpreter that causes modules to be imported twice. Here's how my test project is set up: / Launcher.bat — Project is run from here. It launches 'main/__init__.py` using the Python 3.2 executable ...
[ "I don't think it's a bug. You should ask on the python-dev list for a more authoritative answer. You are executing once (when you run the script) and importing once (from external) so the line gets printed twice. It's not importing twice.\nHowever, this is a horrible setup. There are a lot of style violations here...
[ 2, 1 ]
[]
[]
[ "interpreter", "python" ]
stackoverflow_0008644596_interpreter_python.txt
Q: How to protect a Google App Engine app with a password? How would you implement simple password protection on a Google App Engine application? No users authentication, just simple requirement to enter a password in order to open specific page. The other requirement is that the target page should not be displayed i...
How to protect a Google App Engine app with a password?
How would you implement simple password protection on a Google App Engine application? No users authentication, just simple requirement to enter a password in order to open specific page. The other requirement is that the target page should not be displayed if its URL is entered directly. I'm looking for a solution usi...
[ "If you're protecting a single page and need no session persistence.\nclass MainPage(webapp.RequestHandler):\n def post(self):\n if self.request.get('user') == 'admin' and self.request.get('pass') == 'soopersecure':\n self.response.out.write('authorized');\n else:\n self.respo...
[ 5, 1 ]
[]
[]
[ "google_app_engine", "passwords", "python", "security" ]
stackoverflow_0003806016_google_app_engine_passwords_python_security.txt
Q: Get also elements that don't match fnmatch I'm using a recursive glob to find and copy files from a drive to another def recursive_glob(treeroot, pattern): results = [] for base, dirs, files in os.walk(treeroot): goodfiles = fnmatch.filter(files, pattern) results.extend(os.path.join(base, f) for...
Get also elements that don't match fnmatch
I'm using a recursive glob to find and copy files from a drive to another def recursive_glob(treeroot, pattern): results = [] for base, dirs, files in os.walk(treeroot): goodfiles = fnmatch.filter(files, pattern) results.extend(os.path.join(base, f) for f in goodfiles) return results Works fine. Bu...
[ "If order doesn't matter, use a set:\ngoodfiles = fnmatch.filter(files, pattern)\nbadfiles = set(files).difference(goodfiles)\n\n", "Another loop inside the os.walk loop can also be used:\ngoodfiles = []\nbadfiles = []\nfor f in files:\n if fnmatch.fnmatch(f, pattern):\n goodfiles.append(f)\n else:\n badf...
[ 5, 1 ]
[]
[]
[ "fnmatch", "glob", "python", "recursive_datastructures" ]
stackoverflow_0008645303_fnmatch_glob_python_recursive_datastructures.txt
Q: Why does select.select() work with disk files but not epoll()? The following code essentially cats a file with select.select(): f = open('node.py') fd = f.fileno() while True: r, w, e = select.select([fd], [], []) print '>', repr(os.read(fd, 10)) time.sleep(1) When I try a similar thing with epoll I g...
Why does select.select() work with disk files but not epoll()?
The following code essentially cats a file with select.select(): f = open('node.py') fd = f.fileno() while True: r, w, e = select.select([fd], [], []) print '>', repr(os.read(fd, 10)) time.sleep(1) When I try a similar thing with epoll I get an error: self._impl.register(fd, events | self.ERROR) IOError: [...
[ "select allows filedescriptors pointing to regular files to be monitored, however it will always report a file as readable/writable (i.e. it's somewhat useless, as it doesn't tell you whether a read/write would actually block).\nepoll just disallows monitoring of regular files, as it has no mechanism (on linux at l...
[ 8 ]
[]
[]
[ "epoll", "python", "select", "unix" ]
stackoverflow_0008645721_epoll_python_select_unix.txt
Q: Building a huge numpy array using pytables How can I create a huge numpy array using pytables. I tried this but gives me the "ValueError: array is too big." error: import numpy as np import tables as tb ndim = 60000 h5file = tb.openFile('test.h5', mode='w', title="Test Array") root = h5file.root h5file.createArray...
Building a huge numpy array using pytables
How can I create a huge numpy array using pytables. I tried this but gives me the "ValueError: array is too big." error: import numpy as np import tables as tb ndim = 60000 h5file = tb.openFile('test.h5', mode='w', title="Test Array") root = h5file.root h5file.createArray(root, "test", np.zeros((ndim,ndim), dtype=float...
[ "Piggybacking off of @b1r3k's response, to create an array that you are not going to access all at once (i.e. bring the whole thing into memory), you want to use a CArray (Chunked Array). The idea is that you would then fill and access it incrementally:\nimport numpy as np\nimport tables as tb\nndim = 60000\nh5file...
[ 15, 8 ]
[]
[]
[ "arrays", "numpy", "pytables", "python" ]
stackoverflow_0008642626_arrays_numpy_pytables_python.txt
Q: python exit infinite while loop with KeyboardInterrupt exception My while loop does not exit when Ctrl+C is pressed. It seemingly ignores my KeyboardInterrupt exception. The loop portion looks like this: while True: try: if subprocess_cnt <= max_subprocess: try: notifier.process_events() ...
python exit infinite while loop with KeyboardInterrupt exception
My while loop does not exit when Ctrl+C is pressed. It seemingly ignores my KeyboardInterrupt exception. The loop portion looks like this: while True: try: if subprocess_cnt <= max_subprocess: try: notifier.process_events() if notifier.check_events(): notifier.read_events() ...
[ "Replace your break statement with a raise statement, like below:\nwhile True:\n try:\n if subprocess_cnt <= max_subprocess:\n try:\n notifier.process_events()\n if notifier.check_events():\n notifier.read_events()\n except KeyboardInterrupt:\n notifier.stop()\n pr...
[ 15 ]
[]
[]
[ "infinite_loop", "keyboardinterrupt", "python", "systemexit", "try_except" ]
stackoverflow_0008645632_infinite_loop_keyboardinterrupt_python_systemexit_try_except.txt
Q: Check if wx.TextCtrl has been deselected, wxpython Is there some event that checks if the wx.TextCtrl widget has been deselected? Heres an example of what I want: myTextbox.Bind(wx.EVT_DESELECT, self.myfunction) A: Sounds like you are looking for the EVT_KILL_FOCUS.
Check if wx.TextCtrl has been deselected, wxpython
Is there some event that checks if the wx.TextCtrl widget has been deselected? Heres an example of what I want: myTextbox.Bind(wx.EVT_DESELECT, self.myfunction)
[ "Sounds like you are looking for the EVT_KILL_FOCUS.\n" ]
[ 2 ]
[]
[]
[ "python", "wxpython", "wxwidgets" ]
stackoverflow_0008646056_python_wxpython_wxwidgets.txt
Q: how to remove .py from the url in jython I am trying to remove .py extension from the url, I am using this tutorial: http://www.jython.org/jythonbook/en/1.0/SimpleWebApps.html my web.xml is as follows: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee...
how to remove .py from the url in jython
I am trying to remove .py extension from the url, I am using this tutorial: http://www.jython.org/jythonbook/en/1.0/SimpleWebApps.html my web.xml is as follows: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/X...
[ "Im wondering if the 'jythonapp' folder needs to be specified in the 'servlet-mapping' section. \nEG: \n<url-pattern>/jythonapp/NewJythonServlet</url-pattern>\n\n(I don't think that's quite right but its been a while since I've used Tomcat. )\nIm also thinking that the 'jythonapp' folder should be a sub of 'webap...
[ 0 ]
[]
[]
[ "java", "jython", "python", "url_rewriting" ]
stackoverflow_0008636156_java_jython_python_url_rewriting.txt
Q: How to look at only the 3rd value in all lists in a list I have a list of lists and I want to be able to refer to the 1st, 2nd, 3rd, etc. column in a list of lists. Here is my code for the list: matrix = [ [0, 0, 0, 5, 0, 0, 0, 0, 6], [8, 0, 0, 0, 4, 7, 5, 0, 3], [0, 5, 0, 0, 0, 3, 0, 0, 0], [0, 7,...
How to look at only the 3rd value in all lists in a list
I have a list of lists and I want to be able to refer to the 1st, 2nd, 3rd, etc. column in a list of lists. Here is my code for the list: matrix = [ [0, 0, 0, 5, 0, 0, 0, 0, 6], [8, 0, 0, 0, 4, 7, 5, 0, 3], [0, 5, 0, 0, 0, 3, 0, 0, 0], [0, 7, 0, 8, 0, 0, 0, 0, 9], [0, 0, 0, 0, 1, 0, 0, 0, 0], [9...
[ "The standard way to perform what you asked is to do a list comprehension\n\nif (The fourth column in this matrix does not have any 1's in it):\n\ntranslates in:\n>>>if not any([1 == row[3] for row in matrix])\n\nHowever, depending on how often you need to perform this operation, how big is your matrix, etc... you ...
[ 4, 2, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008646293_python.txt
Q: Yielding sub combinations I need a function which returns subsegments for a given segment. For example, sub_combinations("ABCD") should yield: ("A", "B", "C", "D") ("A", "B", "CD") ("A", "BC", "D") ("A", "BCD") ("AB", "C", "D") ("AB", "CD") ("ABC", "D") ("ABCD") ("ABD", "C") * ("AC", "BD") * ("AC", "B", "D") * ("A...
Yielding sub combinations
I need a function which returns subsegments for a given segment. For example, sub_combinations("ABCD") should yield: ("A", "B", "C", "D") ("A", "B", "CD") ("A", "BC", "D") ("A", "BCD") ("AB", "C", "D") ("AB", "CD") ("ABC", "D") ("ABCD") ("ABD", "C") * ("AC", "BD") * ("AC", "B", "D") * ("ACD", "B") * ("AD", "BC") * ("AD...
[ "You may change your code as follows:\ndef sub_combinations(segment):\n if len(segment) == 1:\n yield (segment,)\n else:\n for j in sub_combinations(segment[1:]):\n yield (segment[0],)+j\n for k in range(len(j)):\n yield (segment[0]+j[k],)+j[:k]+j[k+1:]\n\nIf your segment contains only one ...
[ 5, 1, 1, 1 ]
[]
[]
[ "algorithm", "python", "python_3.x" ]
stackoverflow_0008646186_algorithm_python_python_3.x.txt
Q: How to make python and linux shell interaction? Now,here is an executable program that I run in a shell. But It needs parameter.How can I use python to pass parameter to the program in a shell. I know a tool in unix named 'expect' which can interact with existing software. I want to know if python can do the same ...
How to make python and linux shell interaction?
Now,here is an executable program that I run in a shell. But It needs parameter.How can I use python to pass parameter to the program in a shell. I know a tool in unix named 'expect' which can interact with existing software. I want to know if python can do the same thing! My english is not good~sorry~
[ "Use the subprocess module. Basic example:\n>>> import subprocess as sub\n>>> sub.call([\"ls\", \"-l\"])\n\nBasically you can pass the command and its parameters as a list of strings.\n\nEDIT: Reading again your question I wonder if pexpect is indeed what you want.\n" ]
[ 4 ]
[]
[]
[ "python", "shell" ]
stackoverflow_0008646511_python_shell.txt
Q: How to get substring in between certain tokens? Say I have file that contains strings like 'STARTabcdEND', how should I extract all strings found between 'START' and 'END' in the file, in Python? A: import re s = 'STARTabcdENDefSTARTghiEND' a = 'START' b = 'END' out = re.findall(a+'(.+?)'+b, s) # out: ['abcd', ...
How to get substring in between certain tokens?
Say I have file that contains strings like 'STARTabcdEND', how should I extract all strings found between 'START' and 'END' in the file, in Python?
[ "import re\n\ns = 'STARTabcdENDefSTARTghiEND'\na = 'START'\nb = 'END'\nout = re.findall(a+'(.+?)'+b, s)\n# out: ['abcd', 'ghi']\n\n", "Here this would be one way to do it\ns = 'STARTabcdEND'\ns.partition('START')[2].rpartition('END')[0]\n\n" ]
[ 5, 0 ]
[]
[]
[ "python", "string" ]
stackoverflow_0008646496_python_string.txt
Q: How to iterate through a defaultdict(list) in Python? How do i iterate through a defaultdict(list) in Python? Is there a better way of having a dictionary of lists in Python? I've tried the normal iter(dict) but I've got the error: >>> import para >>> para.print_doc('./sentseg_en/essentials.txt') Traceback (most r...
How to iterate through a defaultdict(list) in Python?
How do i iterate through a defaultdict(list) in Python? Is there a better way of having a dictionary of lists in Python? I've tried the normal iter(dict) but I've got the error: >>> import para >>> para.print_doc('./sentseg_en/essentials.txt') Traceback (most recent call last): File "<stdin>", line 1, in <module> F...
[ "The problem you have with line\nfor para in iter(doc):\n\nis that doc is an instance of Paragraph, not a defaultdict. The default dict you use in the __init__ method goes out of scope and is lost. So you need to do two things:\n\nSave the doc created in the __init__ method as an instance variable (self.doc, for e...
[ 4, 2, 0, 0, 0 ]
[]
[]
[ "defaultdict", "dictionary", "iterator", "loops", "python" ]
stackoverflow_0008646583_defaultdict_dictionary_iterator_loops_python.txt
Q: CoffeeScript-like language written in Python Are there any languages targeting JavaScript (like CoffeeScript) and written in Python? I found Pyjamas, but it’s GWT of Python as I see. I want a language that doesn’t need heavy runtime library and is able to be compiled to JavaScript. I found Mascara also, and it ...
CoffeeScript-like language written in Python
Are there any languages targeting JavaScript (like CoffeeScript) and written in Python? I found Pyjamas, but it’s GWT of Python as I see. I want a language that doesn’t need heavy runtime library and is able to be compiled to JavaScript. I found Mascara also, and it very satisfies my requirements except it’s license...
[ "You might want to have a look at pyjaco (python to javascript compiler).\nHere's an example to get you started with manipulating the DOM in Python using jQuery:\nhttps://github.com/chrivers/pyjaco/tree/devel/examples/jquery\n", "Check this:\nPyvaScript: http://www.allbuttonspressed.com/blog/django/2010/07/PyvaSc...
[ 6, 2, 0 ]
[]
[]
[ "coffeescript", "compiler_construction", "javascript", "python" ]
stackoverflow_0008550119_coffeescript_compiler_construction_javascript_python.txt
Q: New database refuses to show up in web2py appadmin I am experimenting with a new blog database design and there are some tests I would like to run in web2py's administrative interface. I started by creating a new web2py application called newblog from web2py's admin interface. Next, I created newblog/models/appdb...
New database refuses to show up in web2py appadmin
I am experimenting with a new blog database design and there are some tests I would like to run in web2py's administrative interface. I started by creating a new web2py application called newblog from web2py's admin interface. Next, I created newblog/models/appdb.py, below Then I surfed to the admin interface at https...
[ "It sounds like you have the default db.py file in addition to your custom appdb.py file. Note, model files are executed in alphabetical order, so db.py is executed after your file. db.py assigns a different database connection to the variable db, so only that database is showing up in appadmin. You should either u...
[ 5 ]
[]
[]
[ "database", "python", "web2py" ]
stackoverflow_0008643664_database_python_web2py.txt
Q: Where are Django Admin Site's static media files? and How to configure? So far, I have been using a stable release of django: 1.3, and my settings.py looked like this (for admin site): STATIC_URL = '/static/' ADMIN_MEDIA_PREFIX = '/static/admin/' I just switched to development version, and once I ran the server, ...
Where are Django Admin Site's static media files? and How to configure?
So far, I have been using a stable release of django: 1.3, and my settings.py looked like this (for admin site): STATIC_URL = '/static/' ADMIN_MEDIA_PREFIX = '/static/admin/' I just switched to development version, and once I ran the server, got the following warning: DeprecationWarning: The ADMIN_MEDIA_PREFIX setting...
[ "In the next Django version, static files handling behave like the old django-staticfiles app:\n\nto ensure that you got all static files from all apps, convention is put each app static file in a subdir called 'static'\non dev, everything is served automatically by the dev server\non prod, everything is statically...
[ 2 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008222887_django_python.txt
Q: how to replace specific word in a sentence with python I have a sentence for example "hello this is hello stackoverflow hello". What I need to do is keep the first hello but remove other "hello"s in the sentence. How would I go about doing this? A: parts = old.split("hello") parts[1:1] = "hello" new = "".join(p...
how to replace specific word in a sentence with python
I have a sentence for example "hello this is hello stackoverflow hello". What I need to do is keep the first hello but remove other "hello"s in the sentence. How would I go about doing this?
[ "parts = old.split(\"hello\")\nparts[1:1] = \"hello\"\nnew = \"\".join(parts)\n\nSeems like there should be a better way...\n", "Must be faster than Ned's one, but the price is readability:\n>>> idx = s.find('hello') + len('hello')\n>>> s[:idx] + s[idx:].replace('hello', '')\n'hello this is stackoverflow '\n\n",...
[ 1, 1, 1, 0, 0, 0 ]
[]
[]
[ "python", "replace", "string" ]
stackoverflow_0008647166_python_replace_string.txt
Q: Get the length in characters of a PyGTK TextView I have a gtk TextView in a maximized window and I want to know how many characters a line can fit before you have to scroll. A: (Friendly reminder, please stop putting answers in the comments, people.) To summarize: It depends on the size of the TextView, size of ...
Get the length in characters of a PyGTK TextView
I have a gtk TextView in a maximized window and I want to know how many characters a line can fit before you have to scroll.
[ "(Friendly reminder, please stop putting answers in the comments, people.)\nTo summarize:\nIt depends on the size of the TextView, size of the window, size of the font, and as Alex Martelli said, the particular font and the usage of letters...\"i\" is a narrow letter, \"m\" is a wide letter, thus you can fit more \...
[ 0 ]
[]
[]
[ "gtk", "pygtk", "python" ]
stackoverflow_0003328241_gtk_pygtk_python.txt
Q: Using python PIL to get the number displayed in an image I want get the number in this image, using python and PIL: my code: #!/usr/bin/env python #encoding=utf-8 import Image,ImageEnhance,ImageFilter import Data DEBUG = False def d_print(*msg): global DEBUG if DEBUG: for i in msg: ...
Using python PIL to get the number displayed in an image
I want get the number in this image, using python and PIL: my code: #!/usr/bin/env python #encoding=utf-8 import Image,ImageEnhance,ImageFilter import Data DEBUG = False def d_print(*msg): global DEBUG if DEBUG: for i in msg: print(i), print else: pass def Get_Num(l...
[ "PIL is not the tool you want to use. What you are trying to do is perform image recognition, which is a typical [and quite complex] AI task.\nThe canonical free-as-in-freedom library for performing this kind of operations is OpenCV, for which you can find the python bindings documentation here.\nBTW: the reason fo...
[ 6 ]
[]
[]
[ "python", "python_imaging_library" ]
stackoverflow_0008647005_python_python_imaging_library.txt
Q: Parsing CSV files, and writing them into another CSV format The format of my import CSV fetched using urllib2 and put into folders are like so: number,season,episode,production code,airdate,title,special?,tvrage 1,1,1,"101",24/Sep/07,"Pilot",n,"http://www.tvrage.com/Chuck/episodes/579282" Now I am successfully co...
Parsing CSV files, and writing them into another CSV format
The format of my import CSV fetched using urllib2 and put into folders are like so: number,season,episode,production code,airdate,title,special?,tvrage 1,1,1,"101",24/Sep/07,"Pilot",n,"http://www.tvrage.com/Chuck/episodes/579282" Now I am successfully converting that into SQL statments as well as another CSV file that...
[ "I'm not sure exactly what are all the errors, but here are a few tips:\n\nprocessFile(line), line is a bit of a bad name as it isn't a string line, it's a row or list of elements. That's what confused Tim and me as well at first sight.\nYou should verify that line has at least 6 elements as your script requires.\n...
[ 1, 0 ]
[]
[]
[ "csv", "python" ]
stackoverflow_0008638823_csv_python.txt
Q: AssertionError: No api proxy found for service "rdbms" I got a simple test to work when deployed, but I get the following error from the development server: File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/api...
AssertionError: No api proxy found for service "rdbms"
I got a simple test to work when deployed, but I get the following error from the development server: File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 301, in MakeSyncCall assert stu...
[]
[]
[ "I tried to replicate this, and got the following warning when starting the SDK dev server:\n\nWARNING 2011-12-27 03:50:59,069 rdbms_mysqldb.py:90] The rdbms API is\n not available because the MySQLdb library could not be loaded.\n\nWhat this means is that the Python-MySQL connector library is not installed on my...
[ -2 ]
[ "google_app_engine", "python" ]
stackoverflow_0008619192_google_app_engine_python.txt
Q: Tkinter Listbox I want to execute function with one click on listbox. This is my idea: from Tkinter import * import Tkinter def immediately(): print Lb1.curselection() top = Tk() Lb1 = Listbox(top) Lb1.insert(1, "Python") Lb1.insert(2, "Perl") Lb1.insert(3, "C") Lb1.insert(4, "PHP") Lb1.insert(5, "JSP") Lb...
Tkinter Listbox
I want to execute function with one click on listbox. This is my idea: from Tkinter import * import Tkinter def immediately(): print Lb1.curselection() top = Tk() Lb1 = Listbox(top) Lb1.insert(1, "Python") Lb1.insert(2, "Perl") Lb1.insert(3, "C") Lb1.insert(4, "PHP") Lb1.insert(5, "JSP") Lb1.insert(6, "Ruby") ...
[ "You can bind to the <<ListboxSelect>> event as described in this post: Getting a callback when a Tkinter Listbox selection is changed? \nTKinter is somewhat strange in that the information does not seemed to be contained within the event that is sent to the handler. Also note, there is no need to create a lambda t...
[ 9 ]
[]
[]
[ "listbox", "python", "tkinter" ]
stackoverflow_0008647735_listbox_python_tkinter.txt
Q: Python2.6 IF Using AND OR I can't compare one variable with multiple values. For example I need that variable called _query must be different from Sleep and Binlog. if (query != "Sleep") or (query != "Binlog Dump"): print query[4] With the above code my script is not working. Could you help me? Thanks. A: T...
Python2.6 IF Using AND OR
I can't compare one variable with multiple values. For example I need that variable called _query must be different from Sleep and Binlog. if (query != "Sleep") or (query != "Binlog Dump"): print query[4] With the above code my script is not working. Could you help me? Thanks.
[ "Think about it. query will always be not equal to either \"Sleep\" or \"Binlog Dump\" -- it can't ever be equal to both of them -- and an or expression is true if either of its arguments is true. So your condition will always be true! What you want is:\nif not (query == \"Sleep\" or query == \"Binlog Dump\"):\n\nW...
[ 2, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008647892_python.txt
Q: How to add lib directory to sys.path when installed with custom prefix I come from a C background with Autotools (./configure, make, make install) but have recently started to use Python. With Autotools I can install a program more or less anywhere on the system by doing a ./configure --prefix=/foo/bar. I've found...
How to add lib directory to sys.path when installed with custom prefix
I come from a C background with Autotools (./configure, make, make install) but have recently started to use Python. With Autotools I can install a program more or less anywhere on the system by doing a ./configure --prefix=/foo/bar. I've found that most Python programs uses a similar system based on distutils, usually...
[ "If your custom installdir is \"foo\", your python-root is \"bar\" and your package-root is \"lib\"\nyou might add this to your script:\nimport sys\nfrom os.path import join\nfoo = \"foo\"\nbar = \"bar\"\nlib = \"lib\"\nnewbase = join(foo, bar, lib)\nsys.path.append(newbase)\n\nin your example:\nfoo ='foo'\nbar = '...
[ 1, 0 ]
[]
[]
[ "distutils", "python", "setup.py" ]
stackoverflow_0008642982_distutils_python_setup.py.txt
Q: PostgreSQL and Django Query I'm trying to make a (Django) query to my database using the following syntax: Derp.objects.all() I have a production database and a default (development) database. So obviously, by default, that query above will use the default database. I'm having trouble figuring out how to select m...
PostgreSQL and Django Query
I'm trying to make a (Django) query to my database using the following syntax: Derp.objects.all() I have a production database and a default (development) database. So obviously, by default, that query above will use the default database. I'm having trouble figuring out how to select my other database. A coworker sugg...
[ "Your syntax is slightly off:\nDerp.objects.using('production').all()\n\nObviously, the 'production' key needs to match whatever you've labeled your DB in settings.py.\n" ]
[ 2 ]
[]
[]
[ "django", "postgresql", "python" ]
stackoverflow_0008648056_django_postgresql_python.txt
Q: PyDev/Python3.1 Subprocess Error - no encoding declared When I run Parent.py which calls the subprocess child.exe the following error occurs File "child.exe", line 1 SyntaxError: Non-UTF-8 code starting with '\x90' in file child.exe on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ fo...
PyDev/Python3.1 Subprocess Error - no encoding declared
When I run Parent.py which calls the subprocess child.exe the following error occurs File "child.exe", line 1 SyntaxError: Non-UTF-8 code starting with '\x90' in file child.exe on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details If I run the Parent.py with child.py, the executio...
[ "subprocess.Popen(['python', 'child.exe', pipearg], ...\n\nThe problem is that you are trying to make python read a binary file, if child.exe is a normal windows executable. The error raises because the bytes of the binary files are out of the standard ascii - utf8 standard so the interpreter can't read it.\nMaybe ...
[ 2 ]
[]
[]
[ "encoding", "pydev", "python", "subprocess" ]
stackoverflow_0008642713_encoding_pydev_python_subprocess.txt
Q: django non-rel / Managing per-field indexes on App Engine I'm trying to move my gae webapp project to django non-rel. I'm pretty new to Python and Django (non-rel). Right now I'm setting up the admin backend. When I want to look at the history of a model entry I encounter this problem: Caught DatabaseError while r...
django non-rel / Managing per-field indexes on App Engine
I'm trying to move my gae webapp project to django non-rel. I'm pretty new to Python and Django (non-rel). Right now I'm setting up the admin backend. When I want to look at the history of a model entry I encounter this problem: Caught DatabaseError while rendering: TextField is not indexed, by default, so you can't f...
[ "There is a letter missing in 'GAE_SETTINGS_MODULE'.\nThe correct version is :\nGAE_SETTINGS_MODULES = (\n 'maps.gae_models_settings',\n)\n\n", "if you put ae_models_settings.py in the same level as settings.py, I think it should be:\nGAE_SETTINGS_MODULES = (\n'gae_models_settings',\n)\n\nworks for me.\n" ]
[ 2, 2 ]
[]
[]
[ "django", "django_nonrel", "python" ]
stackoverflow_0005816811_django_django_nonrel_python.txt
Q: How does this for loop work? I am trying to learn python and I am going through the book programming python. I know java pretty well so I decided to give python a try as well. I am going through an example using loops and I am confused about what is happening in this code for person in people: for (name, value) ...
How does this for loop work?
I am trying to learn python and I am going through the book programming python. I know java pretty well so I decided to give python a try as well. I am going through an example using loops and I am confused about what is happening in this code for person in people: for (name, value) in person: if name == 'name': ...
[ "Most likely it's supposed to deal with three dimensional list of the following format:\npeople = [\n [['name', 'John'], ['age', 21]],\n [['name', 'Ann'], ['age', 45]],\n [['name', 'Tom'], ['age', 32]],\n]\n\nfor person in people:\n # person is like [['name', 'Ann'], ['age', 45]] here\n for (name, val...
[ 8, 3, 1, 1, 1 ]
[]
[]
[ "for_loop", "python" ]
stackoverflow_0008648532_for_loop_python.txt
Q: documenting txt files in Doxygen I am using Doxygen to document a Python project. The application uses some small txt files, containing e.g. config info, logs etc. For obvious reasons, no Doxygen information can be included in those files directly (problems with parsing, these files might not exist) - I need to wr...
documenting txt files in Doxygen
I am using Doxygen to document a Python project. The application uses some small txt files, containing e.g. config info, logs etc. For obvious reasons, no Doxygen information can be included in those files directly (problems with parsing, these files might not exist) - I need to write this doc in other files (containin...
[ "You might be able to accomplish this with the @file attribute in a documentation block, something like:\n/**\n * @file project/data/gallery/types.info\n * Documentation for types.info in project/data/gallery/.\n */\n\nIn order for this to work, you'll also need to add types.info as a valid doxygen input file name ...
[ 0 ]
[]
[]
[ "doxygen", "python" ]
stackoverflow_0007928637_doxygen_python.txt
Q: app engine python is this bug: when open switch interactive console While I am working at localhost:8080, when I open interactive console and do some operations, like getting list of Kind etc (address: http://localhost:8080/_ah/admin/interactive) then it gives me this error: <class 'google.appengine.dist._library...
app engine python is this bug: when open switch interactive console
While I am working at localhost:8080, when I open interactive console and do some operations, like getting list of Kind etc (address: http://localhost:8080/_ah/admin/interactive) then it gives me this error: <class 'google.appengine.dist._library.UnacceptableVersionError'>: django 1.2 was requested, but 0.96.4.None is...
[ "my index.ymal in root folder says: \n# AUTOGENERATED\n\n# This index.yaml is automatically updated whenever the dev_appserver\n# detects that a new type of query is run. If you want to manage the\n# index.yaml file manually, remove the above marker line (the line\n# saying \"# AUTOGENERATED\"). If you want to m...
[ 0 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0008629826_google_app_engine_python.txt
Q: How to get help of PyGTK methods? in pygtk when I set the label mylabel = gtk.Label("Hello World!") I can get the string of label from it by mylabel.get() method. but in python interpreter I can't get the docstring of this method: help(gtk.Label.get). Anyone know why? A: Because the method gtk.Label.get is an ob...
How to get help of PyGTK methods?
in pygtk when I set the label mylabel = gtk.Label("Hello World!") I can get the string of label from it by mylabel.get() method. but in python interpreter I can't get the docstring of this method: help(gtk.Label.get). Anyone know why?
[ "Because the method gtk.Label.get is an object itself, and has some attributes. The builtin function help looks the __doc__ attribute and some other dictionaries of the object and the Class of the object up and returns them (formatted). You could do a help(help) for example! ;-) so help(gtk.Label.get) returns the a...
[ 3, 3, 2 ]
[]
[]
[ "docstring", "gtk", "pygtk", "python" ]
stackoverflow_0008648537_docstring_gtk_pygtk_python.txt
Q: How to hatch PolyCollection instance? Is it possible to hatch PolyCollection instance? I want to hath a PolyCollection returned from fill_betweenx. import matplotlib.mlab as mlab from matplotlib.pyplot import figure, show import numpy as np x = np.arange(0.0, 2, 0.01) y1 = np.sin(2*np.pi*x) y2 = 1.2*np.sin(4*np.p...
How to hatch PolyCollection instance?
Is it possible to hatch PolyCollection instance? I want to hath a PolyCollection returned from fill_betweenx. import matplotlib.mlab as mlab from matplotlib.pyplot import figure, show import numpy as np x = np.arange(0.0, 2, 0.01) y1 = np.sin(2*np.pi*x) y2 = 1.2*np.sin(4*np.pi*x) fig = figure() ax1 = fig.add_subplot(...
[ "It's a bit of a hack, but you should be able to do something like this:\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom matplotlib.patches import PathPatch\n\nx = np.arange(0.0, 2, 0.01)\ny1 = np.sin(2*np.pi*x)\ny2 = 1.2*np.sin(4*np.pi*x)\n\nfig, ax = plt.subplots()\npc = ax.fill_betweenx(x, 0, y1, colo...
[ 2 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0008640951_matplotlib_python.txt
Q: use slice in for loop to build a list I would like to build up a list using a for loop and am trying to use a slice notation. My desired output would be a list with the structure: known_result[i] = (record.query_id, (align.title, align.title,align.title....)) However I am having trouble getting the slice operato...
use slice in for loop to build a list
I would like to build up a list using a for loop and am trying to use a slice notation. My desired output would be a list with the structure: known_result[i] = (record.query_id, (align.title, align.title,align.title....)) However I am having trouble getting the slice operator to work: knowns = "output.xml" i=0 for r...
[ "You cannot assign a value to a list at an index that doesn't exist. The way to add an element (at the end of the list, which is the common use case) is to use the .append method of the list.\nIn your case, the lines\nknown_results[i] = record.query_id \nknown_results[i][1] = (align.title for align in record.al...
[ 2, 1, 1 ]
[]
[]
[ "list", "python", "slice" ]
stackoverflow_0008648595_list_python_slice.txt
Q: dir() function in commandline vs IDLE I've tried running the following code in IDLE: import sys dir(sys) There is no result: >>> But when I run it in the command line, i get this: >>> dir(sys) ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__stderr__', '__stdin__', '__stdout__', '_c...
dir() function in commandline vs IDLE
I've tried running the following code in IDLE: import sys dir(sys) There is no result: >>> But when I run it in the command line, i get this: >>> dir(sys) ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_getf...
[ "The root of the problem is a misunderstanding of what dir() does. If you use it at the interactive Python prompt >>>, it is easy to think it means \"print the names available in the given object.\" However, what it actually does is return the names available in the given object.\nAs a convenience, the interactive ...
[ 4, 2, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008648507_python.txt
Q: Python model not referencing correct database when saved So I have two databases, my development (default) database and my live database. My model looks like so: class Derp(models.Model): company = models.ForeignKey(Co) The rest of the model isn't really relevant. The problem is, when I go to save a new "Der...
Python model not referencing correct database when saved
So I have two databases, my development (default) database and my live database. My model looks like so: class Derp(models.Model): company = models.ForeignKey(Co) The rest of the model isn't really relevant. The problem is, when I go to save a new "Derp", if you'll allow the silliness, I get an "Integrity Error" ...
[ "You really shouldn't be using Django's multiple database feature to distinguish between development and production databases.\nWhen running in development, you should only have access to the dev db, and in production, just the production one. There should be no possibility of confusion. \n" ]
[ 3 ]
[]
[]
[ "django", "postgresql", "python" ]
stackoverflow_0008648913_django_postgresql_python.txt
Q: Have memory error when using scipy to do SVD I tried to use LSI to generate vectors to represent documents. I am using the svd package in Scipy library. But the program throws a memory error. The size of my matrix is 100*13057. Is this too big for my 8G RAM? I searched this problem in stackflow. Somebody said I ju...
Have memory error when using scipy to do SVD
I tried to use LSI to generate vectors to represent documents. I am using the svd package in Scipy library. But the program throws a memory error. The size of my matrix is 100*13057. Is this too big for my 8G RAM? I searched this problem in stackflow. Somebody said I just have to install 64-bit Python on my 64-bit OS. ...
[ "Your V matrix will take 13057*13057*8 bytes of memory if you're using the default dtype=np.float, which is approx. 1.4GB. My hunch is that that's too large for your 32-bit Python. Try using 32-bit floating point numbers, that is dtype=np.float32, to cut memory use in half, or start using scipy.sparse (almost alway...
[ 0 ]
[]
[]
[ "python", "scipy", "svd" ]
stackoverflow_0008649181_python_scipy_svd.txt
Q: Why is it not illegal in Python to be able to add attributes after a class is already defined? For example: class Car: pass jeep = Car() jeep.color = 'blue' This is perfectly legal and runs fine. I understand that python is pretty dynamic but doesn't this violate some principle of oop? A: http://docs.python.o...
Why is it not illegal in Python to be able to add attributes after a class is already defined?
For example: class Car: pass jeep = Car() jeep.color = 'blue' This is perfectly legal and runs fine. I understand that python is pretty dynamic but doesn't this violate some principle of oop?
[ "http://docs.python.org/tutorial/classes.html#odds-and-ends\nTo dynamically set up the fields and value when they can only be known at run time.\nPython does not prevent you from dynamically creating instance properties, though you can decide not to do so if you have no very good reason to do so. Python is quite a ...
[ 2 ]
[]
[]
[ "oop", "python" ]
stackoverflow_0008649279_oop_python.txt
Q: How to get Djangos urls.py to look into database and take urls from it? Is that even a good idea? I'm new to Django and I have some problems to gasp how to deal with dynamic urls. I want to use the django admin backend to add pages which are saved into a database via an app model. For example i have a field in the...
How to get Djangos urls.py to look into database and take urls from it? Is that even a good idea?
I'm new to Django and I have some problems to gasp how to deal with dynamic urls. I want to use the django admin backend to add pages which are saved into a database via an app model. For example i have a field in the database called page_url generated by my apps models.py. In my Django backend one can choose a unique ...
[ "Well, you should do the following: define your URL:\nurlpatterns = patterns('',\n (r'^$',index),\n )\n\nand in the view index you can access your url from request variable. Then you can read your database and compare url to one in database. Note that there are frameworks which will do that for you like flatp...
[ 3 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008649253_django_python.txt
Q: Convert SCCS repository to SVN I'm investigating migrating a source code repository currently kept under SCCS on an aging Digital UNIX box to Subversion on a Windows box. My initial searching has led me to a python script, sccs2svn, which looks like it would do the job - with some restrictions. A du -sk on the SCC...
Convert SCCS repository to SVN
I'm investigating migrating a source code repository currently kept under SCCS on an aging Digital UNIX box to Subversion on a Windows box. My initial searching has led me to a python script, sccs2svn, which looks like it would do the job - with some restrictions. A du -sk on the SCCS directory shows it to be about 550...
[ "If you use FSFS backend, you can just move the repository to your target platform. FSFS Repositories are truely platform indipendent. They are also standard setup since svn 1.3 so you should not have any problems by creating the repository and then copy it to your final server via any file transfer.\n", "If sccs...
[ 3, 0 ]
[]
[]
[ "python", "svn", "version_control" ]
stackoverflow_0001456757_python_svn_version_control.txt
Q: Framework for Implementing REST web service in Django I'm looking to implement a RESTful interface for a Django application. It is primarily a data-service application - the interface will be (at this point) read-only. The question is which Django toolsets / frameworks make the most sense for this task. I see...
Framework for Implementing REST web service in Django
I'm looking to implement a RESTful interface for a Django application. It is primarily a data-service application - the interface will be (at this point) read-only. The question is which Django toolsets / frameworks make the most sense for this task. I see Django-rest and Django-piston. There's also the option of...
[ "\nNOTE: Since this post was written, django-piston is no longer\n actively maintained. As others have mentioned, look into tastypie\n or django-rest-framework.\n\nIndeed, you can roll your own, but there's a lot of boilerplate involved.\ndjango-piston is an exceptionally easy to use, and extensible, micro-frame...
[ 18, 9, 4, 4, 2 ]
[]
[]
[ "django", "python", "rest", "web_services" ]
stackoverflow_0002488325_django_python_rest_web_services.txt
Q: faster way to compare dictionaries than using set I have two large dictionaries with unique keys but possibly overlapping values. I want to compare each set of dictionary values against each other and find the number of overlaps. I have done this using two for loops and set but am wondering if there is a faster/mo...
faster way to compare dictionaries than using set
I have two large dictionaries with unique keys but possibly overlapping values. I want to compare each set of dictionary values against each other and find the number of overlaps. I have done this using two for loops and set but am wondering if there is a faster/more elegant way to do this. dic1 = {'a': ['1','2','3'], ...
[ "You want to \"invert\" one (or both) of your dictionaries.\nval1 = defaultdict(list)\nfor k in dic1:\n for v in dic1[k]:\n val[v].append( k )\n# val1 is a dictionary with each value mapped to the list of keys that contain that value.\n\nfor k in dic2: \n for v in dic2[k]:\n val1[v] is the list ...
[ 2 ]
[]
[]
[ "dictionary", "python", "set" ]
stackoverflow_0008649802_dictionary_python_set.txt
Q: Django FileField.save() makes duplicate files I have user submitted content that I am trying to write to a file and then save to a FileField. so I have a model that looks like this: class Revision(models.Model): def custom_revision_file_path(instance, filename): return '/'.join(['content/revisions', ...
Django FileField.save() makes duplicate files
I have user submitted content that I am trying to write to a file and then save to a FileField. so I have a model that looks like this: class Revision(models.Model): def custom_revision_file_path(instance, filename): return '/'.join(['content/revisions', filename]) path = models.FileField(upload_to=cu...
[ "First of all, you should never use something like that to create a path :\n'/'.join(['content/revisions', filename])\n\nbut :\nos.path.join(\"my_dir\", \"my_subdir\", ..., \"filename.txt\")\n\nYou are not supposed to know if your application runs on Unix-like or on Windows (yes, some people use Windows as webserve...
[ 3 ]
[]
[]
[ "django", "django_file_upload", "python" ]
stackoverflow_0008649170_django_django_file_upload_python.txt
Q: Manually giving the twisted (web) network stack a packet to process? I am running an HTTP server using the twisted framework. Is there any way I can "manually" ask it to process some payload? For example, if I've constructed some Ethernet frame can I ask twisted's reactor to handle it just as if it had just arri...
Manually giving the twisted (web) network stack a packet to process?
I am running an HTTP server using the twisted framework. Is there any way I can "manually" ask it to process some payload? For example, if I've constructed some Ethernet frame can I ask twisted's reactor to handle it just as if it had just arrived on my network card?
[ "You can do something like this:\nfrom twisted.web import server\nfrom twisted.web.resource import Resource\nfrom twisted.internet import reactor\nfrom twisted.internet.protocol import Protocol, ClientFactory\n\nclass SomeWebThing(Resource):\n def render_GET(self, request):\n return \"hello\\n\"\n\nclass ...
[ 2, 0 ]
[]
[]
[ "python", "twisted" ]
stackoverflow_0001546745_python_twisted.txt
Q: Issue with running the sample pyramid program. Giving ImportError: No module named execptions error I am new to python and Pyramid. I have installed pyramid today and i already have python 2.7.1 pre-installed on my mac machine. I have installed pyramid with the instructions mentioned in the official website. I h...
Issue with running the sample pyramid program. Giving ImportError: No module named execptions error
I am new to python and Pyramid. I have installed pyramid today and i already have python 2.7.1 pre-installed on my mac machine. I have installed pyramid with the instructions mentioned in the official website. I have used the virtualenv with nositepackages as mentioned in the website and i installed pyramid in my /us...
[ "The first error indicates you have a typo in your program. Most likely, you wrote\nfrom pyramid.execptions import NotFound\n\ninstead of\nfrom pyramid.exceptions import NotFound\n# ^^\n\nAnd since you've installed pylons/pyramid into a virtualenv, you need to activate it first, with source bin/activat...
[ 5 ]
[]
[]
[ "pyramid", "python" ]
stackoverflow_0008650143_pyramid_python.txt
Q: Where did lxml's Element.getAttribute() method call go? I've been diggin' and diggin' about 2 hours but I couldn't find a reason for this error: 1) JBoss 2) Tomcat Select an application: 1 <App id="1" type="JBoss" path="" state="ok"/> Traceback (most recent call last): File "/root/RService.py", line 47, in <mod...
Where did lxml's Element.getAttribute() method call go?
I've been diggin' and diggin' about 2 hours but I couldn't find a reason for this error: 1) JBoss 2) Tomcat Select an application: 1 <App id="1" type="JBoss" path="" state="ok"/> Traceback (most recent call last): File "/root/RService.py", line 47, in <module> Stats = app.getAttribute('state') AttributeError: 'l...
[ "Try app.get('state') instead. That works for me with LXML 2.2.7.\n" ]
[ 1 ]
[]
[]
[ "lxml", "python" ]
stackoverflow_0008650263_lxml_python.txt
Q: python-paramiko - run command in background If I use command ssh -f server 'cp /file1 /file2 & >/dev/null 2>/dev/null ; disown;' it detaches well and command is runned in the background. But is there any variant of -f key for paramiko? A: You have to create new thread/process, for example using Python threading ...
python-paramiko - run command in background
If I use command ssh -f server 'cp /file1 /file2 & >/dev/null 2>/dev/null ; disown;' it detaches well and command is runned in the background. But is there any variant of -f key for paramiko?
[ "You have to create new thread/process, for example using Python threading module. Paramiko has to write to socket after finishing Django request.\n" ]
[ 0 ]
[]
[]
[ "paramiko", "python", "ssh" ]
stackoverflow_0008650148_paramiko_python_ssh.txt
Q: Sorting class instances in python What does python 2.7 use to sort vanilla class instances? I'm interested in the default sorting behavior. Suppose I have the class class S(): pass Then I can create a couple of instances, and sort them: a = S(); b = S(); c = S() l = [(a,'a'), (b,'b') ,(c, 'c')] sorted(l) Th...
Sorting class instances in python
What does python 2.7 use to sort vanilla class instances? I'm interested in the default sorting behavior. Suppose I have the class class S(): pass Then I can create a couple of instances, and sort them: a = S(); b = S(); c = S() l = [(a,'a'), (b,'b') ,(c, 'c')] sorted(l) This will print some sorting of the objec...
[ "Python 3's built-in sorting makes use of the __lt__ method in your class.\nThe rich comparison methods are special in Python, since they can return a special NotImplemented type if there is not __lt__ defined - take a look at the docs on this page: http://docs.python.org/reference/datamodel.html#the-standard-type-...
[ 6, 4, 1 ]
[]
[]
[ "python", "sorting" ]
stackoverflow_0008650401_python_sorting.txt
Q: threading: It is not safe to use pixmaps outside the GUI thread I'm building a music player, that checks the status with SqueezePlay, which is a SqueezeBox controller app. To cut a long story short, I'm checking the status of Squeezeplay ever 5 seconds by using threading. If the song title changes, I let it update...
threading: It is not safe to use pixmaps outside the GUI thread
I'm building a music player, that checks the status with SqueezePlay, which is a SqueezeBox controller app. To cut a long story short, I'm checking the status of Squeezeplay ever 5 seconds by using threading. If the song title changes, I let it update the labels (Qlabel, album artwork (QPixmap), etc. However, when I as...
[ "All graphical Qt operations should happen in the main thread. Other threads are not really allowed to call Qt graphical operations (including probably pixmaps).\nThey could emit Qt signals to the main thread. Or simply (on Linux) write into a pipe, and have the main thread wait for input on that pipe.\nOf course, ...
[ 7, 4, 1, 0 ]
[]
[]
[ "multithreading", "pyqt", "python", "qpixmap", "qt" ]
stackoverflow_0008649233_multithreading_pyqt_python_qpixmap_qt.txt
Q: Python command line script. Two scenarios of using. How to implement arguments parsing? I have a python command line script that may be used in two different ways. First scenario is like this: script.py -max MAX -min MIN -delta DELTA where -max and -min are required arguments and -delta is optional. The second s...
Python command line script. Two scenarios of using. How to implement arguments parsing?
I have a python command line script that may be used in two different ways. First scenario is like this: script.py -max MAX -min MIN -delta DELTA where -max and -min are required arguments and -delta is optional. The second scenario is: script.py some_file.txt -f where some_file.txt is required positional argument a...
[ "I'd do that this way: \nparser = OptionParser()\nparser.add_option(\"-max\", dest=\"max\")\nparser.add_option(\"-min\", dest=\"min\")\nparser.add_option(\"-delta\", dest=\"delta\")\nparser.add_option(\"-f\", dest=\"f_thing\", action=\"store_true\")\n\n(options,args) = parser.parse_args()\n\nif not args:\n if ...
[ 6, 2, 0 ]
[]
[]
[ "argparse", "args", "command_line_arguments", "parsing", "python" ]
stackoverflow_0008565119_argparse_args_command_line_arguments_parsing_python.txt
Q: Form Submission with Python I have recently been messing with form submission and I was making a Python script to see if I could create Steam accounts through only entering the Captcha. For reference, the site I am submitting to is https://store.steampowered.com/join/. As shown by a mechanize request, the forms to...
Form Submission with Python
I have recently been messing with form submission and I was making a Python script to see if I could create Steam accounts through only entering the Captcha. For reference, the site I am submitting to is https://store.steampowered.com/join/. As shown by a mechanize request, the forms to fill are shown below: <create_ac...
[ "Fetch page https://store.steampowered.com/join/ and search for regexp <input type=\"hidden\" id=\"captchagid\" name=\"captchagid\" value=\"(.+)\">.\nCaptcha URL will be https://store.steampowered.com/public/captcha.php?gid=<gid>.\nFetch https://store.steampowered.com/join/createaccount/ with POST data:\n accoun...
[ 0 ]
[]
[]
[ "mechanize", "python" ]
stackoverflow_0008650499_mechanize_python.txt
Q: Correct method to initialize a database table with web2py DAL.define_table() I am trying to dynamically build tables called db.blog and db.code with exactly the same SQL definitions. After I define them, I want to populate them with 10 rows of random data, and never execute that initialization code again. My prob...
Correct method to initialize a database table with web2py DAL.define_table()
I am trying to dynamically build tables called db.blog and db.code with exactly the same SQL definitions. After I define them, I want to populate them with 10 rows of random data, and never execute that initialization code again. My problem is that the initialization code executes every time I hit refresh on the brows...
[ "You can add a fixtures file, which basically contains default data to be inserted once, when the table is created.\nAn example is given here: http://thadeusb.com/weblog/2010/4/21/using_fixtures_in_web2py \n" ]
[ 5 ]
[]
[]
[ "database", "python", "web2py" ]
stackoverflow_0008650622_database_python_web2py.txt
Q: Converting strings read from a file into a array or list I have python code that generates sets of numbers as arrays and stores them in a file, the file looks like follows set([0, 2, 3]) set([0, 1, 3]) set([0, 1, 2]) I have another python code that reads this file and needs to convert the text line back ...
Converting strings read from a file into a array or list
I have python code that generates sets of numbers as arrays and stores them in a file, the file looks like follows set([0, 2, 3]) set([0, 1, 3]) set([0, 1, 2]) I have another python code that reads this file and needs to convert the text line back to a array. Method to read the file def get_sets_from_file (se...
[ "you can apply this to each line in your file:\n>>> line = \"set([0, 2, 3])\" #or \"set([0, 2, 3]),\"\n\n>>> import re\n>>> r = \"set\\(\\[(.*)\\]\\)\"\n>>> m = re.search(r, line)\n>>> match = m.group(1)\n>>> a = [int(item.strip()) for item in match.split(',')]\n>>> a\n[0, 2, 3]\n>>> \n\nthat could be implemente...
[ 1, 0, 0 ]
[ "Why don't you serialize your data in something that you can easily deserialize from a string ?\nJSON perfectly fits here. \n" ]
[ -2 ]
[ "python" ]
stackoverflow_0008649915_python.txt
Q: python data type to track duplicates I often keep track of duplicates with something like this: processed = set() for big_string in strings_generator: if big_string not in processed: processed.add(big_string) process(big_string) I am dealing with massive amounts of data so don't want to maint...
python data type to track duplicates
I often keep track of duplicates with something like this: processed = set() for big_string in strings_generator: if big_string not in processed: processed.add(big_string) process(big_string) I am dealing with massive amounts of data so don't want to maintain the processed set in memory. I have a ...
[ "I'm going to assume you are hashing web pages. You have to hash at most 55 billion web pages (and that measure almost certainly overlooks some overlap). \nYou are willing to accept a less than one in a billion chance of collision, which means that if we look at a hash function which number of collisions is close t...
[ 4, 2, 1, 1, 1, 0, 0, 0, 0, 0 ]
[]
[]
[ "hash", "memory", "python", "types" ]
stackoverflow_0004424397_hash_memory_python_types.txt
Q: Portion of code running only in the first iteration through a for loop in python So I have this code. But it runs correctly only for the first iteration through. On the second iteration, the inner for loop is not initiated. Ideas why? Extra info if it helps: d is a DictReader object, searchtermslist is a list of s...
Portion of code running only in the first iteration through a for loop in python
So I have this code. But it runs correctly only for the first iteration through. On the second iteration, the inner for loop is not initiated. Ideas why? Extra info if it helps: d is a DictReader object, searchtermslist is a list of strings. When I write a print line at Point 1, it prints every time I would expect it t...
[ "Your first loop iteration consumes d, leaving it unavailable for subsequent iterations. Read it into a list or tuple before trying to use it.\n", "If d is a csv.DictReader object, then when you iterate over it, it reads lines from a CSV file until the file is exhausted (i.e. End-of-file). Attempting to iterate o...
[ 1, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008650818_python.txt
Q: Does anybody understand why this doesn't compile? I'm attempting to parse an svg path W3C SVG Paths, with this pattern. EDIT: Ok I've changed my pattern and have a sample with a new problem. See I got some things to work with a new pattern. I'm now working on the line_to regex, and the svg specification demands th...
Does anybody understand why this doesn't compile?
I'm attempting to parse an svg path W3C SVG Paths, with this pattern. EDIT: Ok I've changed my pattern and have a sample with a new problem. See I got some things to work with a new pattern. I'm now working on the line_to regex, and the svg specification demands that values be able to support one point like: L100,200 t...
[ "You haven't provided any code, actual error messages, sample input, or anything else. So I'm just going to guess:\nI don't believe you can use the ?P<label> syntax outside of a match group. So when you have this:\n?P<point>(\\d[(,)|\\s]\\d)\n\nYou actually need these:\n(?P<point>(\\d[(,)|\\s]\\d))\n\nNotice the ...
[ 3 ]
[]
[]
[ "python", "python_3.x", "regex", "svg" ]
stackoverflow_0008650870_python_python_3.x_regex_svg.txt
Q: Matplotlib no object 'Use' or '__version__' Matplotlib seems to be broken on Ubuntu 10.04 LTS. I'm not sure what could've changed from a few days ago. Can somebody offer any suggestions to fix the fact that I cannot import attributes from matplotlib? Thanks - I installed (and re-installed) using: git clone git://g...
Matplotlib no object 'Use' or '__version__'
Matplotlib seems to be broken on Ubuntu 10.04 LTS. I'm not sure what could've changed from a few days ago. Can somebody offer any suggestions to fix the fact that I cannot import attributes from matplotlib? Thanks - I installed (and re-installed) using: git clone git://github.com/matplotlib/matplotlib.git cd matplotlib...
[ "This error could happen if you named a script matplotlib.py and have it in a directory listed your PYTHONPATH. Your matplotlib.py script may be masking the \"real\" package.\nOne way to test if this is the case is to look at matplotlib.__file__.\n>>> matplotlib.use('Agg')\nTraceback (most recent call last):\n Fil...
[ 2 ]
[]
[]
[ "django", "matplotlib", "python" ]
stackoverflow_0008650957_django_matplotlib_python.txt
Q: GDB to do find pointers in a given memory area I want to input Python script into GDB,this script is used to create a new command,assuming its name as 'fp', its function is to search in a given memory area, to check whether this area contains the pointers which are in the program,if there are pointers in this memo...
GDB to do find pointers in a given memory area
I want to input Python script into GDB,this script is used to create a new command,assuming its name as 'fp', its function is to search in a given memory area, to check whether this area contains the pointers which are in the program,if there are pointers in this memory area,the command will print the address of the po...
[ "You may be looking for the GDB built-in find command. Documentation here.\n\nIf there is a pointer called S in the debugging program, its address is 0x442033\n\nIf there is a pointer S, its address is almost certainly not 0x442033, because loading unaligned data carries a significant performance penalties.\nIf you...
[ 1 ]
[]
[]
[ "gdb", "memory", "python" ]
stackoverflow_0008650746_gdb_memory_python.txt
Q: template languages and ajax widgets I have a really noob question about ajax widgets. It's really an extension of a question I asked a while ago: ajax widgets in pyramid and chameleon If you look at this question and the contents of the file account_login_widget.pt, you'll see the 'widget' uses syntax like ${user...
template languages and ajax widgets
I have a really noob question about ajax widgets. It's really an extension of a question I asked a while ago: ajax widgets in pyramid and chameleon If you look at this question and the contents of the file account_login_widget.pt, you'll see the 'widget' uses syntax like ${username}. This works again for a login widg...
[ "I feel like you're doing way too much work just for a like button and I hate javascript so I try to avoid it as much as possible, especially on document loads since it lags the user's browser. I'm going to post what I use for \"subscriptions\", and hopefully it helps you in some way.\nIn the controller, I have a t...
[ 1 ]
[]
[]
[ "ajax", "chameleon", "javascript", "pyramid", "python" ]
stackoverflow_0008641813_ajax_chameleon_javascript_pyramid_python.txt
Q: Thermostat Control Algorithms I am wondering exactly how a thermostat program would work and wanted to see if anyone had a better opinion on it. From what I know, there are a few control algorithms that could be used, some being Bang-Bang (On/Off), Proportional Control Algorithms, and PID Control. Looking on Wikip...
Thermostat Control Algorithms
I am wondering exactly how a thermostat program would work and wanted to see if anyone had a better opinion on it. From what I know, there are a few control algorithms that could be used, some being Bang-Bang (On/Off), Proportional Control Algorithms, and PID Control. Looking on Wikipedia, there is a great deal of expl...
[ "The issue is overshooting the setpoint temperature.\nIf you simply run the device until the set point temperature is reached, you will overshoot, wasting energy (and possibly doing damage, depending on what the thermostat controls.)\nYou need to \"ease up to\" the setpoint so that you arrive at the set point just ...
[ 4 ]
[]
[]
[ "algorithm", "python" ]
stackoverflow_0008651063_algorithm_python.txt
Q: How do I debug refcounts in a Python C-extension the easiest way? So I have put together a few Python C-extensions and although their respective behaviors are verified, I'd like to verify this by some refcount debugging. How can I verify that I have inserted the INC/DEC refcounts properly? I want to do this verifi...
How do I debug refcounts in a Python C-extension the easiest way?
So I have put together a few Python C-extensions and although their respective behaviors are verified, I'd like to verify this by some refcount debugging. How can I verify that I have inserted the INC/DEC refcounts properly? I want to do this verification from a black box perspective, that is, how should a function's i...
[ "One suggestion: Compile the Python interpreter in debug mode (--with-pydebug). Use this interpreter to compile and test your extension. The interpreter displays the count of the total number of objects and this total shouldn't increase as you repeated run your tests. Make sure to test all the possible exit paths o...
[ 1 ]
[]
[]
[ "c", "debugging", "python", "refcounting" ]
stackoverflow_0008650972_c_debugging_python_refcounting.txt
Q: Python String Overflow? For some reason, the below results in an output of 0. I'm using a very large string (100,000 characters), and looking for a large integer, in the hundred billions, e.g 500,000,000,000. Is there something special I need to do? The goal is to find the number of sub-sequences of 1,2,3 in the f...
Python String Overflow?
For some reason, the below results in an output of 0. I'm using a very large string (100,000 characters), and looking for a large integer, in the hundred billions, e.g 500,000,000,000. Is there something special I need to do? The goal is to find the number of sub-sequences of 1,2,3 in the first 100,000 digits of pi. I ...
[ "The simplest and fastest way is probably this:\nsubSeqTotal = pi100k.count(\"123\")\n\n", "pi100k = \"3.14159[100,000 digits of pi]\"\nsubSeqInit = 0\nsubSeqTotal = 0\n\nfor c in pi100k:\n if c == '1':\n subSeqInit = 1\n elif c == '2' and subSeqInit == 1:\n subSeqInit = 2\n elif c == '3' a...
[ 4, 3, 0 ]
[]
[]
[ "for_loop", "loops", "pi", "python", "string" ]
stackoverflow_0006195378_for_loop_loops_pi_python_string.txt
Q: How to use all of the flash memory on an embedded unix system I want to stress test the flash memory in an embedded Ubuntu system. For example, create files and store in the flash memory until there is no room. Is there a straight forward way of accomplishing this? I'm thinking that bash or a python script would b...
How to use all of the flash memory on an embedded unix system
I want to stress test the flash memory in an embedded Ubuntu system. For example, create files and store in the flash memory until there is no room. Is there a straight forward way of accomplishing this? I'm thinking that bash or a python script would be instrumental in testing this? Thanks for any assistance.
[ "My favorite way of doing this is redirecting the output from the yes command to a file.\n $ yes > /path/to/my/device/yes.txt\n\nYou can limit it by using head:\n $ yes | head -n1000000 > /path/to/my/device/yes.txt\n\nA bit more of an explanation. yes will continuously output the letter \"y\" followed by a newline....
[ 2 ]
[]
[]
[ "bash", "python" ]
stackoverflow_0008651398_bash_python.txt
Q: Marking favorites in django object set I have a table called Tip and table called FavoritedTips. Users favorite Tips in my app and the tip ID and user ID are added to the favoritedTips table. class FavoritedTip(models.Model): tip = models.ForeignKey(Tip) user = models.ForeignKey(User) I now need to put a ...
Marking favorites in django object set
I have a table called Tip and table called FavoritedTips. Users favorite Tips in my app and the tip ID and user ID are added to the favoritedTips table. class FavoritedTip(models.Model): tip = models.ForeignKey(Tip) user = models.ForeignKey(User) I now need to put a star next to the tip when the tips appear in...
[ "I presume you want to display a list of tips and for each one you need to know if this is a favorite of the current user.\nYou can do it with a custom templatetag if you really want to do that at the template level, but you'd better build your data structure in the view :\ntips = Tips.objects.filter(my_filters)\nu...
[ 1, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008651336_django_python.txt
Q: Regex to match a capturing group one or more times I'm trying to match pair of digits in a string and capture them in groups, however i seem to be only able to capture the last group. Regex: (\d\d){1,3} Input String: 123456 789101 Match 1: 123456 Group 1: 56 Match 2: 789101 Group 1: 01 Wh...
Regex to match a capturing group one or more times
I'm trying to match pair of digits in a string and capture them in groups, however i seem to be only able to capture the last group. Regex: (\d\d){1,3} Input String: 123456 789101 Match 1: 123456 Group 1: 56 Match 2: 789101 Group 1: 01 What I want is to capture all the groups like this: Match ...
[ "You cannot do that using just a single regular expression. It is a special case of counting, which you cannot do with just a regex pattern. \\d\\d will get you:\nGroup1: 12\nGroup2: 23\nGroup3: 34\n... \nregex library in python comes with a non-overlapping routine namely re.findall() that does the trick. as in:\n...
[ 6, 2, 2, 1 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0008651347_python_regex.txt
Q: Python Tornado Request Handler Mapping I'm just getting started with Tornado and I was wondering how i can define a mapping so that all requests like below are are handled by a single handler. /products/list /products/find/123 /products/copy/123 /products/{action}/{argument1}/{argument2}/{argument3} class Appli...
Python Tornado Request Handler Mapping
I'm just getting started with Tornado and I was wondering how i can define a mapping so that all requests like below are are handled by a single handler. /products/list /products/find/123 /products/copy/123 /products/{action}/{argument1}/{argument2}/{argument3} class Application(tornado.web.Application): def __i...
[ "You aren't limited to listing a RequestHandler just once in the url matching, so you can do one of two things: Add a pattern explicitly matching each of the patterns you mention above like so:\ndef __init__(self):\n handlers = [\n (r\"/\", home.HomeHandler),\n (r\"/products/list/([0-9]+)\", produc...
[ 1 ]
[]
[]
[ "python", "tornado", "web.py", "wsgi" ]
stackoverflow_0008650703_python_tornado_web.py_wsgi.txt
Q: Whats wrong with these 3 lines of python code? I get an error after i put in an input, how can i fix it? print('Type ROLL to roll for your stats') roll = input() if roll == ROLL: # ... A: You should have been more elaborate on the error. Anyway seeing your code, the indentation error is obvious. The if st...
Whats wrong with these 3 lines of python code?
I get an error after i put in an input, how can i fix it? print('Type ROLL to roll for your stats') roll = input() if roll == ROLL: # ...
[ "You should have been more elaborate on the error. Anyway seeing your code, the indentation error is obvious. The if statement should not be indented but must be at the same level w.r.t the previous statement. Another error is that, in the comparison the string should be quoted like 'ROLL'\nprint('Type ROLL to roll...
[ 1, 0, 0 ]
[]
[]
[ "input", "python", "string" ]
stackoverflow_0008651705_input_python_string.txt
Q: Python - Get list of every permutation of a list of a set number of characters I have a list of 7 characters. How would I programmatically create every permutation of the the letters shuffled (I know that the number of lists would be 7 factorial). I know how to shuffle a list, but I assume that wouldn't be effici...
Python - Get list of every permutation of a list of a set number of characters
I have a list of 7 characters. How would I programmatically create every permutation of the the letters shuffled (I know that the number of lists would be 7 factorial). I know how to shuffle a list, but I assume that wouldn't be efficient to just keep shuffling the list, and then checking if i've already created that ...
[ "Use itertools.permutations:\n>>> list(itertools.permutations(\"abc\"))\n[('a', 'b', 'c'), ('a', 'c', 'b'), ('b', 'a', 'c'), ('b', 'c', 'a'), ('c', 'a', 'b'), ('c', 'b', 'a')]\n\n", "Couldn't you use the permutations function from the itertools module?\n" ]
[ 7, 1 ]
[]
[]
[ "python" ]
stackoverflow_0008651794_python.txt
Q: Celery worker variable sharing issues I am using Python and celery in a project. In the project, I have two files: celeryconfig.py BROKER_URL = "amqp://guest:guest@localhost:5672//" CELERY_RESULT_BACKEND = "amqp" CELERY_IMPORTS = ("example",) CELERYD_CONCURRENCY = 2 and example.py from celery.task import task imp...
Celery worker variable sharing issues
I am using Python and celery in a project. In the project, I have two files: celeryconfig.py BROKER_URL = "amqp://guest:guest@localhost:5672//" CELERY_RESULT_BACKEND = "amqp" CELERY_IMPORTS = ("example",) CELERYD_CONCURRENCY = 2 and example.py from celery.task import task import hashlib md5 = hashlib.md5() @task def...
[ "They're using the same object because you're explicitly telling them to in your code. By creating the object outside the scope of the task and using it within the task, you are giving all workers access to the shared object. This is a concurrency issue, not necessarily a Celery issue. You could use a copy of the o...
[ 7 ]
[]
[]
[ "celery", "celery_task", "celeryd", "multiprocessing", "python" ]
stackoverflow_0008651363_celery_celery_task_celeryd_multiprocessing_python.txt
Q: Python code to parse and inspect c++ Is there a library for Python that will allow me to parse c++ code? For example, let's say I want to parse some c++ code and find the names of all classes and their member functions/variables. I can think of a few ways to hack it together using regular expressions, but if ther...
Python code to parse and inspect c++
Is there a library for Python that will allow me to parse c++ code? For example, let's say I want to parse some c++ code and find the names of all classes and their member functions/variables. I can think of a few ways to hack it together using regular expressions, but if there is an existing library it would be more ...
[ "In the past I've used for such purposes gccxml (a C++ parser that emits easily-parseable XML) -- I hacked up my own Python interfaces to it, but now there's a pygccxml which should package that up nicely for you.\n", "Parsing C++ accurately is light-years from something you can do with a regular expression.\nYou...
[ 9, 5, 1, 1, 0 ]
[]
[]
[ "c++", "python" ]
stackoverflow_0002393527_c++_python.txt
Q: Calling a function in python with pointer address I have a simple function I want to call in two separate program executions. The first time I run the program it saves the function pointer into a file: import cPickle def test(): pass def main(): a = test pFile = open('test.txt', 'wb') cPickle.dum...
Calling a function in python with pointer address
I have a simple function I want to call in two separate program executions. The first time I run the program it saves the function pointer into a file: import cPickle def test(): pass def main(): a = test pFile = open('test.txt', 'wb') cPickle.dump(a, pFile) pFile.close() The second time I want t...
[ "You cannot execute a function at a given address. \nYes, reference address changes at run time. When cPickle loads the file, it creates a function and what you see is that function. It will not have the same address as the original function.\n", "See the pickle documentation:\n\nThe following types can be pickle...
[ 3, 2 ]
[]
[]
[ "python" ]
stackoverflow_0008651928_python.txt
Q: writing backup program in python I found this tutorial in A Byte of Python, but do not understand it: import os import time source = [r'C:\Users\Desktop\Stuff'] target_dir = 'C:\Users\Backup' target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip' zip_command = 'zip -qr "%s" %s' % (target, ' '.join(source...
writing backup program in python
I found this tutorial in A Byte of Python, but do not understand it: import os import time source = [r'C:\Users\Desktop\Stuff'] target_dir = 'C:\Users\Backup' target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip' zip_command = 'zip -qr "%s" %s' % (target, ' '.join(source)) if os.system(zip_command) == 0: ...
[ "help(os.system) says:\nsystem(...)\n system(command) -> exit_status\n\n Execute the command (a string) in a subshell.\n\nSo, it executes the command you pass as a parameter and returns the exit_status of that command.\nWhen a program returns 0 as result, it means it was executed succesfully and if it returns...
[ 3, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008651987_python.txt
Q: Is there a built-in Python function to generate 100 numbers from 0 to 1? I am looking for something like range, but one that will allow me to specify the start and the end value, along with how many numbers I need in the collection which I want to use in a similar fashion range is used in for loops. A: Python do...
Is there a built-in Python function to generate 100 numbers from 0 to 1?
I am looking for something like range, but one that will allow me to specify the start and the end value, along with how many numbers I need in the collection which I want to use in a similar fashion range is used in for loops.
[ "Python doesn't have a floating point range function but you can simulate one easily with a list comprehension:\n>>> lo = 2.0\n>>> hi = 12.0\n>>> n = 20\n>>> [(hi - lo) / n * i + lo for i in range(n)]\n[2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0, 10.5, 11.0, 11.5]\n\nNote, ...
[ 7, 3, 2, 2 ]
[]
[]
[ "loops", "math", "python", "range", "sequence" ]
stackoverflow_0008652006_loops_math_python_range_sequence.txt
Q: Using python with selenium to scrape dynamic web pages On the site, there are a couple of links at the top labeled 1, 2, 3, and next. If a link labeled by a number is pressed, it dynamically loads in some data into a content div. If next is pressed, it goes to a page with labels 4, 5, 6, next and the data for page...
Using python with selenium to scrape dynamic web pages
On the site, there are a couple of links at the top labeled 1, 2, 3, and next. If a link labeled by a number is pressed, it dynamically loads in some data into a content div. If next is pressed, it goes to a page with labels 4, 5, 6, next and the data for page 4 is shown. I want to scrape the data from the content div ...
[ "General layout (not tested):\n#!/usr/bin/env python\nfrom contextlib import closing\nfrom selenium.webdriver import Firefox # pip install selenium\n\nurl = \"http://example.com\"\n\n# use firefox to get page with javascript generated content\nwith closing(Firefox()) as browser:\n n = 1\n while n < 10:\n ...
[ 11 ]
[]
[]
[ "python", "selenium" ]
stackoverflow_0008650999_python_selenium.txt
Q: Python3 tkinter multiple arguments I now know that to make a widget with tkinter with a command parameter with an argument I use lambda to do it. (e.g. Button(root, text="button", command=lambda: function(argument))) But what if I want to pass in multiple arguments, or in my case right now two arguments? When I ju...
Python3 tkinter multiple arguments
I now know that to make a widget with tkinter with a command parameter with an argument I use lambda to do it. (e.g. Button(root, text="button", command=lambda: function(argument))) But what if I want to pass in multiple arguments, or in my case right now two arguments? When I just put it as lambda: function(argument1,...
[ "The way of using lambdas with several arguments is:\nlambda arg1, arg2: function(arg1, arg2)\n\nsee some examples here and here\n" ]
[ 0 ]
[]
[]
[ "arguments", "python", "python_3.x", "tkinter", "widget" ]
stackoverflow_0008652102_arguments_python_python_3.x_tkinter_widget.txt