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: Right click contextMenu on QPushButton For my app I have created a GUI in Qt Designer and converted it into python(2.6) code. On some of the QPushButton (created with the designer) I want to add a right click context menu. The menu options depend on the application status. How to implement such a context menu ? A...
Right click contextMenu on QPushButton
For my app I have created a GUI in Qt Designer and converted it into python(2.6) code. On some of the QPushButton (created with the designer) I want to add a right click context menu. The menu options depend on the application status. How to implement such a context menu ?
[ "Check if an example below would work for you. The key thing is to set context menu policy for your widget to CustomContextMenu and connect to the widget's customContextMenuRequested signal:\nimport sys\nfrom PyQt4 import QtGui, QtCore\n\nclass MainForm(QtGui.QMainWindow):\n def __init__(self, parent=None):\n ...
[ 32 ]
[]
[]
[ "contextmenu", "pyqt", "pyqt4", "python", "qt" ]
stackoverflow_0004815925_contextmenu_pyqt_pyqt4_python_qt.txt
Q: How do I use Django's logger to log a traceback when I tell it to? try: print blah except KeyError: traceback.print_exc() I used to debug like this. I'd print to the console. Now, I want to log everything instead of print, since Apache doesn't allow printing. So, how do I log this entire traceback? A: ...
How do I use Django's logger to log a traceback when I tell it to?
try: print blah except KeyError: traceback.print_exc() I used to debug like this. I'd print to the console. Now, I want to log everything instead of print, since Apache doesn't allow printing. So, how do I log this entire traceback?
[ "You can use python's logging mechanism:\nimport logging\n...\n\nlogger = logging.getLogger(\"blabla\")\n...\n\ntry:\n print blah # You can use logger.debug(\"blah\") instead of print\nexcept KeyError:\n logger.exception(\"An error occurred\")\n\nThis will print the stack trace and will work with apache.\n", ...
[ 58, 8 ]
[]
[]
[ "django", "logging", "python", "traceback" ]
stackoverflow_0004839762_django_logging_python_traceback.txt
Q: Running a SWIG bound Python+C program gives a missing DLL error when running on another computer So I have compiled a small testing program that uses SWIG as a bridge between python and C. The main part of the program is the python file. The thing runs fine on my own pc, but as soon as I transfer it to another, it...
Running a SWIG bound Python+C program gives a missing DLL error when running on another computer
So I have compiled a small testing program that uses SWIG as a bridge between python and C. The main part of the program is the python file. The thing runs fine on my own pc, but as soon as I transfer it to another, it immediately throws a "ImportError: DLL load failed: The specified module could not be found." error. ...
[ "Everyone having this problem should probably check out the dependency walker, and see what DLLs are missing. It solved my problem.\n" ]
[ 6 ]
[]
[]
[ "c", "python", "swig" ]
stackoverflow_0004684697_c_python_swig.txt
Q: (mingW) Why does g++ not recognise my class definition when compiling a python extension? So I am working on a small python extension using the SWIG library. I use 3 commands to compile the extension. the first 2 ones use gcc, and the final one g++, giving a python extension as a result. My problem is that after g...
(mingW) Why does g++ not recognise my class definition when compiling a python extension?
So I am working on a small python extension using the SWIG library. I use 3 commands to compile the extension. the first 2 ones use gcc, and the final one g++, giving a python extension as a result. My problem is that after gcc compiles the code with no errors, g++ starts to complain it can not find one of my class def...
[ "It looks like the compiler is finding the declaration just fine, but not the definition. In other words, you've prototyped the constructor, but you haven't implemented it anywhere. From the compiler output it doesn't seem like you're linking in your .cpp file containing the implementation, which is likely the ca...
[ 4 ]
[]
[]
[ "c++", "mingw", "python", "swig" ]
stackoverflow_0004840051_c++_mingw_python_swig.txt
Q: Reading session/cookies from WSGI Is there any way to retrieve sessions right from the WSGI (using a middleware)? I know that it depends on your SessionMiddleware but I wonder if there are hints to figure out when a session is created. A: It's created by the session middle ware. There are no such thing as sessio...
Reading session/cookies from WSGI
Is there any way to retrieve sessions right from the WSGI (using a middleware)? I know that it depends on your SessionMiddleware but I wonder if there are hints to figure out when a session is created.
[ "It's created by the session middle ware. There are no such thing as sessions in http itself. It's usually done by setting a cookie, but can be done in other ways too. \nSo to answer the question of \"when\" it is created this is typically done by the session middleware, when it gets a request that does not already...
[ 2, 1 ]
[]
[]
[ "python", "session", "wsgi" ]
stackoverflow_0004815390_python_session_wsgi.txt
Q: What is the simplest way to stipple a Tkinter canvas widget? I have a Tkinter canvas widget and I'd like to create a stipple pattern on it. I know I could do it manually using the create_line method. However, I'd think there would seem to be a better way. Any help would be much appreciated. What I'm currently wor...
What is the simplest way to stipple a Tkinter canvas widget?
I have a Tkinter canvas widget and I'd like to create a stipple pattern on it. I know I could do it manually using the create_line method. However, I'd think there would seem to be a better way. Any help would be much appreciated. What I'm currently working with. (press Alt-F4 to exit the program) import Tkinter, re ...
[ "The simplest? That depends on your definition of \"simple\". One way is to use a drawing program to create the image you want for the background, then place that in the canvas. This presumes you know the size of the canvas ahead of time. There's nothing much simpler than inserting a single image to the canvas.\nA ...
[ 0 ]
[]
[]
[ "canvas", "python", "stipple", "tkinter" ]
stackoverflow_0004836163_canvas_python_stipple_tkinter.txt
Q: Can a value in a Python Dictionary have two values? For a test program I'm making a simple model of the NFL. I'd like to assign a record (wins and losses) to a team as a value in a dictionary? Is that possible? For example: afcNorth = ["Baltimore Ravens", "Pittsburgh Steelers", "Cleveland Browns", "Cincinatti Beng...
Can a value in a Python Dictionary have two values?
For a test program I'm making a simple model of the NFL. I'd like to assign a record (wins and losses) to a team as a value in a dictionary? Is that possible? For example: afcNorth = ["Baltimore Ravens", "Pittsburgh Steelers", "Cleveland Browns", "Cincinatti Bengals"] If the Ravens had 13 wins and 3 loses, can the dic...
[ "sure, just make the value a list or tuple:\nafc = {'Baltimore Ravens': (10,3), 'Pb Steelers': (3,4)}\n\nIf it gets more complicated, you might want to make a more complicated structure than a tuple - for example if you like dictionaries, you can put a dictionary in your dictionary so you can dictionary while you d...
[ 25, 4, 1 ]
[]
[]
[ "dictionary", "python" ]
stackoverflow_0004840249_dictionary_python.txt
Q: Creating an xml file w/ google app engine I m currently using db.Model to store a string (already in xml format) how do I make this xml string publicly accessible (in the form of example.appspot.com/xml_file so firefox will recgonize it as xml or even of example.appspot.com) I see there is a function to_xml() but ...
Creating an xml file w/ google app engine
I m currently using db.Model to store a string (already in xml format) how do I make this xml string publicly accessible (in the form of example.appspot.com/xml_file so firefox will recgonize it as xml or even of example.appspot.com) I see there is a function to_xml() but I dont know how to use it in such a way that fi...
[ "Set the response content type to \"text/xml\".\nIf you're using GAE's webapp framework use this in the request handler:\nself.response.headers['Content-Type'] = 'text/xml'\n\nIf you're using another framework, like Django, look up setting the content type in their docs.\n" ]
[ 4 ]
[]
[]
[ "datastore", "google_app_engine", "python", "xml" ]
stackoverflow_0004840297_datastore_google_app_engine_python_xml.txt
Q: Zoomed PyGTK image without scale pixbuf I want to display a gtk.Image with a high level of zoom, but scale the image to a new pixbuf with the gtk.gdk.Pixbuf methods waste a lot of memory and processor. Are there some simply way to display a zoomed image? A: it is not possible with gdk, i'm afraid. try cairo or ...
Zoomed PyGTK image without scale pixbuf
I want to display a gtk.Image with a high level of zoom, but scale the image to a new pixbuf with the gtk.gdk.Pixbuf methods waste a lot of memory and processor. Are there some simply way to display a zoomed image?
[ "it is not possible with gdk, i'm afraid.\ntry cairo or opengl.\n", "Maybe GtkImageView helps: http://trac.bjourne.webfactional.com/ \n", "I'll recommend Clutter http://www.clutter-project.org/\n" ]
[ 1, 1, 0 ]
[]
[]
[ "gnome", "gtk", "pygtk", "python" ]
stackoverflow_0002581687_gnome_gtk_pygtk_python.txt
Q: Are there limits to using string.lstrip() in python? Possible Duplicate: Is this a bug in Python 2.7? The .lstrip() function doesn't quite work as I expected on some strings (especially ones with underscores). e.g., In [1]: a='abcd_efg_hijk_lmno_pqrs_tuvw_xyz' In [2]: a.lstrip('abcd_efg') Out[2]: 'hijk_...
Are there limits to using string.lstrip() in python?
Possible Duplicate: Is this a bug in Python 2.7? The .lstrip() function doesn't quite work as I expected on some strings (especially ones with underscores). e.g., In [1]: a='abcd_efg_hijk_lmno_pqrs_tuvw_xyz' In [2]: a.lstrip('abcd_efg') Out[2]: 'hijk_lmno_pqrs_tuvw_xyz' Here, the '_' between 'g' and 'h' is...
[ ".lstrip() doesn't do what you think it does. It removes any of the provided characters from the left end of the string. The second underscore is as much an underscore as the first, so it got removed too.\n\"aaaaaaaabbbbbbbc\".lstrip(\"ab\") # \"c\"\n\n", "What you want:\nb = 'abcd_efg'\nif a.startswith(b):\n ...
[ 14, 7, 2 ]
[]
[]
[ "python" ]
stackoverflow_0004840789_python.txt
Q: ImportError: No module named xchat ImportError: No module named xchat I am getting this error when trying to load a Python script in xchat IRC. I have several other Python scripts which used the xchat module just fine, but this one script seems to be the only one giving me the error. Why does this happen and ho...
ImportError: No module named xchat
ImportError: No module named xchat I am getting this error when trying to load a Python script in xchat IRC. I have several other Python scripts which used the xchat module just fine, but this one script seems to be the only one giving me the error. Why does this happen and how can I fix it? Also, this is happening ...
[ "Since you haven't provided the actual stack traces that cause the problem, it's hard to say for sure where the problem is. It's likely that it's being caused by an import xchat statement somewhere -- but it'd be reassuring to see that trace, so please edit your question.\nWhen you know which line is causing the p...
[ 1 ]
[]
[]
[ "irc", "module", "python" ]
stackoverflow_0004840498_irc_module_python.txt
Q: Django file upload: filename not sticking I'm uploading files and storing metadata in a db. Part of the metadata is the file name itself. However, somewhere down the line, the filename seems to not be getting saved! I will paste only what I think are relevant parts of the code to keep this short. class UploadFi...
Django file upload: filename not sticking
I'm uploading files and storing metadata in a db. Part of the metadata is the file name itself. However, somewhere down the line, the filename seems to not be getting saved! I will paste only what I think are relevant parts of the code to keep this short. class UploadFile(models.Model): ... theFile = models.F...
[ "That's because form.filename is the form field, not the value it will be saving.\nYou are looking for something like this:\nclass UploadFileForm(ModelForm):\n def save(self, commit=True):\n instance = ModelForm.save(self, commit=False)\n instance.filename = self.files['theFile'].name\n\n if...
[ 2, 1, 0 ]
[]
[]
[ "django", "file", "python", "upload" ]
stackoverflow_0004840138_django_file_python_upload.txt
Q: Check if a string to interpolate provides expected placeholders Consider this fictitious Python function: def f(s): # accepts a string containing placeholders # returns an interpolated string return s % {'foo': 'OK', 'bar': 'OK'} How can I check that the string s provides all the expected placeholders...
Check if a string to interpolate provides expected placeholders
Consider this fictitious Python function: def f(s): # accepts a string containing placeholders # returns an interpolated string return s % {'foo': 'OK', 'bar': 'OK'} How can I check that the string s provides all the expected placeholders, and if not, make the function politely show the missing keys? My so...
[ "There's a way to see all of the named placeholders using the _formatter_parser method:\n>>>> y=\"A %{foo} is a %{bar}\"\n\n>>>> for a,b,c,d in y._formatter_parser(): print b\n\nfoo\n\nbar\n\nFor a \"public\" way:\n>>>> import string\n>>>> x = string.Formatter()\n>>>> elements = x.parse(y)\n>>>> for a,b,c,d in elem...
[ 3 ]
[]
[]
[ "python", "string_formatting", "string_interpolation" ]
stackoverflow_0004839121_python_string_formatting_string_interpolation.txt
Q: How to use cursor() for pagination? Can anyone point me to a practical application of cursor() to do pagination? I am not clear how to use cursor() as given in the documentation. This is my query: items = db.GqlQuery("SELECT * FROM Item ORDER BY date DESC LIMIT 30") which I render like this: ...
How to use cursor() for pagination?
Can anyone point me to a practical application of cursor() to do pagination? I am not clear how to use cursor() as given in the documentation. This is my query: items = db.GqlQuery("SELECT * FROM Item ORDER BY date DESC LIMIT 30") which I render like this: self.response.out.write("<ol>") for item ...
[ "Here's a simple example to get you started...\nquery = db.GqlQuery(\"SELECT * FROM Item ORDER BY date DESC\")\ncursor = self.request.get('cursor')\nif cursor: query.with_cursor(cursor)\nitems = query.fetch(30)\ncursor = query.cursor()\n\n... your regular output ...\n\nself.response.out.write('<a href=\"yoururl?cur...
[ 7 ]
[]
[]
[ "database_cursor", "google_app_engine", "pagination", "python" ]
stackoverflow_0004840731_database_cursor_google_app_engine_pagination_python.txt
Q: How to tokenize the sample string using Regular Expression in Python? I am new to regular expression. On top of finding out the pattern to match the following string, please also point out references and/or samples web sites. The data string 1. First1 Last1 - 20 (Long Description) 2. First2 Last2 - 40 (Anoth...
How to tokenize the sample string using Regular Expression in Python?
I am new to regular expression. On top of finding out the pattern to match the following string, please also point out references and/or samples web sites. The data string 1. First1 Last1 - 20 (Long Description) 2. First2 Last2 - 40 (Another Description) I want to be able to extract tuples {First1,Last1,20} and ...
[ "There is no need to use regex here:\nfoo = \"1. First1 Last1 - 20 (Long Description)\"\nfoo.split(\" \")\n>>> ['1.', '', 'First1', 'Last1', '-', '20', '(Long', 'Description)']\n\nYou can now select the elements you like (they will always be at the same indices).\nIn 2.7+ you can use itertools.compress to select t...
[ 2, 2, 0 ]
[]
[]
[ "lexical_analysis", "python", "regex", "tokenize" ]
stackoverflow_0004839972_lexical_analysis_python_regex_tokenize.txt
Q: Python mechanize: Submitting a form with a file (image)? There's a form with the following control (it's an upload image control) <FileControl(profile_image=<No files added>)> What am I supposed put in the "??????????": br = mechanize.Browser() br.open(mywebsite) br.select_form(nr=1) br.form['profile_image'] = ?...
Python mechanize: Submitting a form with a file (image)?
There's a form with the following control (it's an upload image control) <FileControl(profile_image=<No files added>)> What am I supposed put in the "??????????": br = mechanize.Browser() br.open(mywebsite) br.select_form(nr=1) br.form['profile_image'] = ?????????? br.submit() I've tried br.form['profile_image'] ...
[ "Do this: \nbr.form.add_file(open(FILENAME), 'text/plain', FILENAME)\nbr.form.set_all_readonly(False)\n\n" ]
[ 6 ]
[]
[]
[ "browser", "image", "mechanize", "python" ]
stackoverflow_0004841195_browser_image_mechanize_python.txt
Q: most efficient way to find partial string matches in large file of strings (python) I downloaded the Wikipedia article titles file which contains the name of every Wikipedia article. I need to search for all the article titles that may be a possible match. For example, I might have the word "hockey", but the Wiki...
most efficient way to find partial string matches in large file of strings (python)
I downloaded the Wikipedia article titles file which contains the name of every Wikipedia article. I need to search for all the article titles that may be a possible match. For example, I might have the word "hockey", but the Wikipedia article for hockey that I would want is "Ice_hockey". It should be a case-insensit...
[ "If you've got a fixed data set and variable queries, then the usual technique is to reorganise the data set into something that can be searched more easily. At an abstract level, you could break up each article title into individual lowercase words, and add each of them to a Python dictionary data structure. Then,...
[ 4, 3, 1 ]
[]
[]
[ "large_files", "python", "search", "string" ]
stackoverflow_0004839597_large_files_python_search_string.txt
Q: I want to develop a basic Linux Terminal IM Client I'm a 19 years old guy with "basic" programming skills mostly on C and PHP. I'm from Argentina, so sorry if i miss something in the grammar area. Well, i would LOVE to expand my programming skills, but i need a project, because the challenges and exercises with no...
I want to develop a basic Linux Terminal IM Client
I'm a 19 years old guy with "basic" programming skills mostly on C and PHP. I'm from Argentina, so sorry if i miss something in the grammar area. Well, i would LOVE to expand my programming skills, but i need a project, because the challenges and exercises with no target don't enthusiast me. And reading about the progr...
[ "You should look into socket programming with python as well as writing a simple client/server. Python is actually a very good language for this as it makes it easy to do socket programming. Much easier than, say, using C.\nThis is an excellent resource: http://heather.cs.ucdavis.edu/~matloff/Python/PyNet.pdf to ge...
[ 1 ]
[]
[]
[ "instant_messaging", "python" ]
stackoverflow_0004841323_instant_messaging_python.txt
Q: can python function smart enough to show it's capability? I want to define a function cluster can be chained and invoked in-a-go with the initial parameter given then get the final result, I want it may acting as Linux command pipe chain: test01() | test02() | test03() | test04() [init_paramet...
can python function smart enough to show it's capability?
I want to define a function cluster can be chained and invoked in-a-go with the initial parameter given then get the final result, I want it may acting as Linux command pipe chain: test01() | test02() | test03() | test04() [init_parameter] ----------------------------------------------------> [fi...
[ "I recently saw a slide presentation on Python generators that went through a lot of neat things you can do with generator functions that allows you to use them like a pipe-and-filter system. They're also evaluated \"lazily\", so when you process, say, a very long list, it will only process the portion that it nee...
[ 1 ]
[]
[]
[ "chaining", "error_handling", "function", "python" ]
stackoverflow_0004841250_chaining_error_handling_function_python.txt
Q: Submitting a Login Form using Python 3.1 I am trying to login to this website: http://www.artofproblemsolving.com/Forum/ucp.php?mode=login by using a Python 3.1.3 script. At the time, I have this: import webbrowser import urllib.request import cgi import cgitb import urllib.parse import hashlib import http.cookiej...
Submitting a Login Form using Python 3.1
I am trying to login to this website: http://www.artofproblemsolving.com/Forum/ucp.php?mode=login by using a Python 3.1.3 script. At the time, I have this: import webbrowser import urllib.request import cgi import cgitb import urllib.parse import hashlib import http.cookiejar p = urllib.parse.urlencode({'username':'MY...
[ "When I submit this form, the login button is submitted as &login=Login. Perhaps this form requires that you submit that also?\n", "You might be a lot better off using Mechanize. It's particularly useful for form submissions.\n" ]
[ 1, 0 ]
[]
[]
[ "networking", "python" ]
stackoverflow_0004841274_networking_python.txt
Q: Basic python. How to forbid functions to change the list? >>> def test(): ... a.remove(1) >>> a = [1,2] >>> test() >>> print a [2] Why does a equal [2] rather than [1,2]? A: List is mutable. If you pass it to a function, and the function changes it, it stays changed. Use an immutable structure: tuple: a = ...
Basic python. How to forbid functions to change the list?
>>> def test(): ... a.remove(1) >>> a = [1,2] >>> test() >>> print a [2] Why does a equal [2] rather than [1,2]?
[ "List is mutable. If you pass it to a function, and the function changes it, it stays changed.\n\nUse an immutable structure: tuple: a = (1,2)\nPass a copy of original list: b = list(a); b.remove(1) — now a and b have different contents, a hasn't changed.\n\nAlso, try not to use mutable global data. Either pass a t...
[ 6, 2, 0, 0 ]
[]
[]
[ "function", "list", "python" ]
stackoverflow_0004841929_function_list_python.txt
Q: Conditional Search and Replace in a file Python I have a large text file over 10MB when needs to have conditional search and replace. I want to replace every instance of "a" inside the file with "ā" if the character after "a" is either "r" or "m" or "n" or "u". For example: Input file Hamro sano ghar holata. Out...
Conditional Search and Replace in a file Python
I have a large text file over 10MB when needs to have conditional search and replace. I want to replace every instance of "a" inside the file with "ā" if the character after "a" is either "r" or "m" or "n" or "u". For example: Input file Hamro sano ghar holata. Output file Hāmro sāno ghār holata. EDIT Thanks guys, i...
[ "you need a simple regular expression here. Something like this?\n>>> import re\n>>> input = \"Hamro sano ghar holata.\"\n>>> regex = re.compile(ur'a([rmnu])') # the part in parens is remembered\n>>> print regex.sub(ur'ā\\1', input) # replace by ā plus remembered part\nHāmro sāno ghār holata.\n\nEdit:\nsome backgr...
[ 3, 2, 1 ]
[]
[]
[ "file_io", "python" ]
stackoverflow_0004841804_file_io_python.txt
Q: DIsable Python module Is there any way to disable a module from being loaded on my system? Let's say i would like to restrict my users from accessing the subprocess or popen2 module. Something like PHP's 'disabled_functions' or any similar method to achieve the same thing. A: As @Thomas points out, blacklisting ...
DIsable Python module
Is there any way to disable a module from being loaded on my system? Let's say i would like to restrict my users from accessing the subprocess or popen2 module. Something like PHP's 'disabled_functions' or any similar method to achieve the same thing.
[ "As @Thomas points out, blacklisting is a pretty poor mechanism for implementing any security mechanisms. Whitelisting is a much safer approach.\nBut a mechanism inside the interpreter isn't particularly excellent for any number of reasons: flaws in the interpreter that are exploitable at the source code level woul...
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0004842049_python.txt
Q: Is there a Django middleware/plugin that logs all my requests in a organized fashion? I want to log every request that ever comes through my sever. Is there a plugin/middleware for this? Ideally I'd like it to be queryable. A: Don't know if that's what you want, but django-sentry is a great app for logging erro...
Is there a Django middleware/plugin that logs all my requests in a organized fashion?
I want to log every request that ever comes through my sever. Is there a plugin/middleware for this? Ideally I'd like it to be queryable.
[ "Don't know if that's what you want, but django-sentry is a great app for logging errors that occur in your Django site. They can be shown in a (well-designed!) web interface, allowing for sorting like number of occurrences of an error etc.\nIf you just want to log requests, Apache's access.log should be enough. An...
[ 4, 3, 2 ]
[]
[]
[ "django", "logging", "plugins", "python" ]
stackoverflow_0004839297_django_logging_plugins_python.txt
Q: Where do Django logs get logged to? http://docs.djangoproject.com/en/dev/topics/logging/#topic-logging-parts-loggers I'm reading this doc. What happens when you log something? Where does it go? A: They are saved to: /var/www/django/log
Where do Django logs get logged to?
http://docs.djangoproject.com/en/dev/topics/logging/#topic-logging-parts-loggers I'm reading this doc. What happens when you log something? Where does it go?
[ "They are saved to:\n/var/www/django/log\n\n" ]
[ 3 ]
[]
[]
[ "debugging", "django", "exception", "logging", "python" ]
stackoverflow_0004842209_debugging_django_exception_logging_python.txt
Q: What's a good resource to build my first python project? I'm tired of books and tutorials who walk me through how to print things before I can do anything fun. I want to build simple apps or programs. Any suggestions for where to start so I can make and learn at the same time? A: If you are tired of tutorials, t...
What's a good resource to build my first python project?
I'm tired of books and tutorials who walk me through how to print things before I can do anything fun. I want to build simple apps or programs. Any suggestions for where to start so I can make and learn at the same time?
[ "If you are tired of tutorials, then just start building something. Anything. If you get stuck, glance back over the tutorials, or consult the documentation. I'm a big fan of learning by doing.\nA short list of options from off the top of my head: \n\nIf you're into web development, Django is a popular python web f...
[ 3, 3, 0 ]
[]
[]
[ "python" ]
stackoverflow_0004840840_python.txt
Q: buildout MercurialRecipe breaks on multiple import I've been trying to import several packages which are actually dependencies to an egg I am building. Because these eggs are not on the cheese store, I am not able to use the install_requires = ['pack1', 'pack2'] in my setup.py script, so I am trying to add them to...
buildout MercurialRecipe breaks on multiple import
I've been trying to import several packages which are actually dependencies to an egg I am building. Because these eggs are not on the cheese store, I am not able to use the install_requires = ['pack1', 'pack2'] in my setup.py script, so I am trying to add them to my buildout config the following way : 1 [buildout] ...
[ "I would advise you to switch to using mr.developer for external SCM-managed dependencies in a buildout. mr.developer lets you pull in dependencies (eggs or otherwise) from Mercurial repositories as well as Git, Bazaar, Darcs, Subversion and even CVS repositories. You can treat these dependencies as development egg...
[ 3 ]
[]
[]
[ "buildout", "mercurial", "python", "recipe", "setup.py" ]
stackoverflow_0004835371_buildout_mercurial_python_recipe_setup.py.txt
Q: GreyScale translation issues I'm getting the following error: cv.error: Incorrect number of channels for this conversion code from the following piece of code: cv.CvtColor(frame, gray, cv.CV_BGR2GRAY) any recommendations? A: Check the number of channels of frame and gray. Either use a debugger, or put this li...
GreyScale translation issues
I'm getting the following error: cv.error: Incorrect number of channels for this conversion code from the following piece of code: cv.CvtColor(frame, gray, cv.CV_BGR2GRAY) any recommendations?
[ "Check the number of channels of frame and gray. Either use a debugger, or put this line before the conversion:\nprintf(\"frame.nChannels: %d gray.nChannels: %d\\n\", frame.nChannels, gray.nChannels);\n\nframe needs to be 3 channels (RGB). gray needs to be 1 channel. Anything other than that and the conversion w...
[ 2, 0 ]
[]
[]
[ "image_manipulation", "image_processing", "opencv", "python" ]
stackoverflow_0004839937_image_manipulation_image_processing_opencv_python.txt
Q: Application of Boundary Conditions in finite difference solution for the heat equation and Crank-Nicholson The code below solves the 1D heat equation that represents a rod whose ends are kept at zero temparature with initial condition 10*np.sin(np.pi*x). How are the Dirichlet boundary conditions (zero temp at bot...
Application of Boundary Conditions in finite difference solution for the heat equation and Crank-Nicholson
The code below solves the 1D heat equation that represents a rod whose ends are kept at zero temparature with initial condition 10*np.sin(np.pi*x). How are the Dirichlet boundary conditions (zero temp at both ends) worked into this calculation? I was told the upper, lower rows of matrix A contain two non-zero elements...
[ "Let's have a look at a simple example. We assume N = 3, i.e. three inner points, but we will first also include the boundary points in the matrix D2 describing the approximate second derivatives:\n 1 / 1 -2 1 0 0 \\\nD2 = --- | 0 1 -2 1 0 |\n h^2 \\ 0 0 1 -2 1 /\n\nThe first line means the a...
[ 5, 0 ]
[]
[]
[ "differential_equations", "math", "python", "scientific_computing", "scipy" ]
stackoverflow_0004843034_differential_equations_math_python_scientific_computing_scipy.txt
Q: Python dictionaries-How to keep the new value from overwriting the previous value? I want to create a Dictionary called "First" (as in First Name) that will store numerous first names which are all stored in the dictionary via a function. The idea is that the dictionary can support multiple names, so here is my ...
Python dictionaries-How to keep the new value from overwriting the previous value?
I want to create a Dictionary called "First" (as in First Name) that will store numerous first names which are all stored in the dictionary via a function. The idea is that the dictionary can support multiple names, so here is my problem: When I add a name to the dictionary, then I go to add a second one via the func...
[ "Turn data['Names']['first'] in a list and append to it:\ndata['Names'] = {}\ndata['Names']['first'] = []\n\ndef store(data, value):\n data['Names']['first'].append(value)\n\n", "Python < 2.5 doesn't have defaultdict, however you can achieve the same thing in with ordinary dict too.\n>>> names = {}\n>>> name_l...
[ 4, 2, 1, 0 ]
[]
[]
[ "dictionary", "nested", "python" ]
stackoverflow_0004841868_dictionary_nested_python.txt
Q: What's the Python equivalent of x = (10<n) ? 10 : n; I was wondering what the equivalent in python to this would be: n = 100 x = (10 < n) ? 10 : n; print x; For some reason this does not work in Python. I know I can use an if statement but I was just curious if there is some shorter syntax. Thanks. A: x = min(n...
What's the Python equivalent of x = (10<n) ? 10 : n;
I was wondering what the equivalent in python to this would be: n = 100 x = (10 < n) ? 10 : n; print x; For some reason this does not work in Python. I know I can use an if statement but I was just curious if there is some shorter syntax. Thanks.
[ "x = min(n, 10)\n\nOr, more generally:\nx = 10 if 10<n else n\n\n", "Here is the ternary operator in Python (also know as conditional expressions in the docs).\nx if cond else y\n\n", "There are various ways to make a ternary operation, the first one is the expression added with 2.5:\nn = foo if condition else ...
[ 17, 7, 4, 1, 1, 1 ]
[]
[]
[ "python", "ternary" ]
stackoverflow_0004843058_python_ternary.txt
Q: calling pdftotext from python script not working when I change from local machine to my webhosting I wrote a small python script to parse/extract info from a PDF. I tested it on my local machine, I have python 2.6.2 and pdftotext version 0.12.4. I am trying to run this on my webhosting server (dreamhost). It has p...
calling pdftotext from python script not working when I change from local machine to my webhosting
I wrote a small python script to parse/extract info from a PDF. I tested it on my local machine, I have python 2.6.2 and pdftotext version 0.12.4. I am trying to run this on my webhosting server (dreamhost). It has python version 2.5.2 and pdftotext version 3.02. But when I try to run the script I get the following err...
[ "The hint for the answer lay in Noufal's comment, to use the filename. But the os.tmpfile() doesn't have a filename. I had to use another module. The modified code is given below.\n#import tempfile\ndef ConvertPDFToText(currentPDF):\n pdfData = currentPDF.read()\n\n tf = tempfile.NamedTemporaryFile()\n tf....
[ 6, 4, 0 ]
[]
[]
[ "dreamhost", "pdftotext", "python", "scripting", "subprocess" ]
stackoverflow_0004837114_dreamhost_pdftotext_python_scripting_subprocess.txt
Q: How to create a completely autonomous Python environment? I want to create a completely autonomous Python environment on an USB pen drive that can run both on Windows and GNU/Linux.... How can I do that ? I've tried to build Python with `./' as prefix, but it doesn't works... anyone has another idea ? Thanks in ad...
How to create a completely autonomous Python environment?
I want to create a completely autonomous Python environment on an USB pen drive that can run both on Windows and GNU/Linux.... How can I do that ? I've tried to build Python with `./' as prefix, but it doesn't works... anyone has another idea ? Thanks in advance...
[ "Ok, i've looked at http://svn.python.org/projects/python/branches/release31-maint/ and i found an interesting «readme» talking about a «pyconfig.h» file.\nIn http://svn.python.org/projects/python/branches/release31-maint/PC/pyconfig.h at line 82-83, there is the solution of my problem:\n#ifndef PYTHONPATH\n# def...
[ 4 ]
[]
[]
[ "python", "usb_drive" ]
stackoverflow_0004843051_python_usb_drive.txt
Q: Amazon API signed requests isn't working properly Here's the code: import urllib2 import base64,hashlib,hmac,time from urllib import urlencode from xml.dom import minidom AWS_ACCESS_KEY_ID = "secret" AWS_SECRET_ACCESS_KEY = "secret" base_url = "http://ecs.amazonaws.com/onca/xml" url_params = {"Version": "2010-09...
Amazon API signed requests isn't working properly
Here's the code: import urllib2 import base64,hashlib,hmac,time from urllib import urlencode from xml.dom import minidom AWS_ACCESS_KEY_ID = "secret" AWS_SECRET_ACCESS_KEY = "secret" base_url = "http://ecs.amazonaws.com/onca/xml" url_params = {"Version": "2010-09-01", "Operation": "ItemSearch", ...
[ "Adam Cox has posted a nice example for signing request URLs: Page not found\nOf course, you can just be lazy and use python-amazon-product-api. \nIf you need to use it on Google App Engine, look at this thread:\nUsing python-amazon-product-api on Google Appengine without lxml\n" ]
[ 2 ]
[]
[]
[ "amazon_web_services", "django", "python" ]
stackoverflow_0004004872_amazon_web_services_django_python.txt
Q: How to collect values from checkbox in App Engine (python)? I found an article for CherryPy and some articles on how to do this with Javascript, but is there a way to collect values from checkbox with webapp? Thanks. My naive attempt to append the <...name="article_tag"...> from the form to a list fails because it...
How to collect values from checkbox in App Engine (python)?
I found an article for CherryPy and some articles on how to do this with Javascript, but is there a way to collect values from checkbox with webapp? Thanks. My naive attempt to append the <...name="article_tag"...> from the form to a list fails because it only writes the first checked item (in this case "sputnik"): K =...
[ "I found the answer: \nhttp://code.google.com/appengine/docs/python/tools/webapp/requestclass.html#Request_get_all\nK = self.request.get_all(\"article_tag\")\n\n" ]
[ 2 ]
[]
[]
[ "checkbox", "google_app_engine", "python" ]
stackoverflow_0004843620_checkbox_google_app_engine_python.txt
Q: Problem sorting list of strings - Python I have a list of strings: cards = ['2S', '8D', '8C', '4C', 'TS', '9S', '9D', '9C', 'AC', '3D'] and the order in which I want to display the cards: CARD_ORDER = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] This is how I'm trying to order the list: sort...
Problem sorting list of strings - Python
I have a list of strings: cards = ['2S', '8D', '8C', '4C', 'TS', '9S', '9D', '9C', 'AC', '3D'] and the order in which I want to display the cards: CARD_ORDER = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] This is how I'm trying to order the list: sorted(cards, lambda x,y: CARD_ORDER.index(x[0]) ...
[ "it's \nsorted(cards, key=lambda x: CARD_ORDER.index(x[0]))\n\nkey parameter accepts a single value, by which to sort the main iterable. You're probably trying to use cmp parameter which is not recommended for quite some time.\n", "Try\nsorted(cards, key = lambda x: CARD_ORDER.index(x[0]) )\n\n" ]
[ 8, 2 ]
[]
[]
[ "python", "sorting" ]
stackoverflow_0004843795_python_sorting.txt
Q: How to determine whether specified file is placed inside of the specified folder? Let's say I have two paths: the first one (may be file or folder path): file_path, and the second one (may only be a folder path): folder_path. And I want to determine whether an object collocated with file_path is inside of the obje...
How to determine whether specified file is placed inside of the specified folder?
Let's say I have two paths: the first one (may be file or folder path): file_path, and the second one (may only be a folder path): folder_path. And I want to determine whether an object collocated with file_path is inside of the object collocated with folder_path. I have an idea of doing this: import os ... def is_insi...
[ "Use os.path.commonprefix. Here's an example based on your idea.\nimport os.path as _osp\n\ndef is_inside(file_path, folder_path):\n full_file_path = _osp.realpath(file_path)\n full_folder_path = _osp.realpath(folder_path)\n return _osp.commonprefix([full_file_path, full_folder_path]) == \\\n ful...
[ 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0004843782_python.txt
Q: python string splitting I have an input string like this: a1b2c30d40 and I want to tokenize the string to: a, 1, b, 2, c, 30, d, 40. I know I can read each character one by one and keep track of the previous character to determine if I should tokenize it or not (2 digits in a row means don't tokenize it) but is th...
python string splitting
I have an input string like this: a1b2c30d40 and I want to tokenize the string to: a, 1, b, 2, c, 30, d, 40. I know I can read each character one by one and keep track of the previous character to determine if I should tokenize it or not (2 digits in a row means don't tokenize it) but is there a more pythonic way of do...
[ ">>> re.split(r'(\\d+)', 'a1b2c30d40')\n['a', '1', 'b', '2', 'c', '30', 'd', '40', '']\n\nOn the pattern: as the comment says, \\d means \"match one digit\", + is a modifier that means \"match one or more\", so \\d+ means \"match as much digits as possible\". This is put into a group (), so the entire pattern in co...
[ 13 ]
[]
[]
[ "python", "split", "string" ]
stackoverflow_0004843841_python_split_string.txt
Q: struct.unpack_from in Java I've got the following instruction in Python I'd like to understand and translate in Java values = struct.unpack_from('>%dL' % 96, input_content, 0) What does >%dL mean? I've checked the doc from python http://docs.python.org/library/struct.html but nothing about the percentage. Shall ...
struct.unpack_from in Java
I've got the following instruction in Python I'd like to understand and translate in Java values = struct.unpack_from('>%dL' % 96, input_content, 0) What does >%dL mean? I've checked the doc from python http://docs.python.org/library/struct.html but nothing about the percentage. Shall I consider every returned value ...
[ "The %d is a Python string formatter similar to that found in C. What it says is put the thing that comes after the closing quote in place of the formatter, in this case 96 in place of %d. The %d specifies a signed integer decimal.\nThe '>%dL'%96 is an instruction to struct.unpack to say that the thing it needs to ...
[ 2, 2, 2 ]
[]
[]
[ "binary", "java", "python", "struct" ]
stackoverflow_0004842451_binary_java_python_struct.txt
Q: changing layout and inserting mathematical symbols with pydot I am having problem with drawing in pydot. The problem lies in defining the layout of the nodes created. Currently everything is drawn vertically and is not spread. This gives me the problem of going down to see the nodes created. Is there any way I ca...
changing layout and inserting mathematical symbols with pydot
I am having problem with drawing in pydot. The problem lies in defining the layout of the nodes created. Currently everything is drawn vertically and is not spread. This gives me the problem of going down to see the nodes created. Is there any way I can define the nodes to be created horizontally whenever they are ver...
[ "I found out that writing the string in unicode representation shows mathematical symbols as edges...\nFor example you can write node = pydot.Node(\"&#949;\",shape = \"ellipse\", style=\"filled\", fillcolor=\"turquoise\")\nUsing this we get epsilon as label of the node....\nSimilarly we can get rest of the mathemat...
[ 0 ]
[]
[]
[ "pydot", "python" ]
stackoverflow_0004638806_pydot_python.txt
Q: Python: the mechanism behind list comprehension When using list comprehension or the in keyword in a for loop context, i.e: for o in X: do_something_with(o) or l=[o for o in X] How does the mechanism behind in works? Which functions\methods within X does it call? If X can comply to more than one method, wh...
Python: the mechanism behind list comprehension
When using list comprehension or the in keyword in a for loop context, i.e: for o in X: do_something_with(o) or l=[o for o in X] How does the mechanism behind in works? Which functions\methods within X does it call? If X can comply to more than one method, what's the precedence? How to write an efficient X, s...
[ "The, afaik, complete and correct answer.\nfor, both in for loops and list comprehensions, calls iter() on X. iter() will return an iterable if X either has an __iter__ method or a __getitem__ method. If it implements both, __iter__ is used. If it has neither you get TypeError: 'Nothing' object is not iterable.\nTh...
[ 10, 5, 4, 3, 2, 0 ]
[]
[]
[ "implementation", "language_implementation", "list_comprehension", "python" ]
stackoverflow_0004844010_implementation_language_implementation_list_comprehension_python.txt
Q: google-api-java-client JSON parser on Android produces an empty self.request.body on GAE This is related to another question about URL shortener. The code for URL shortener works fine, on both standalone Java and on Android. However, when re-using this code to communicate to a custom Google App Engine application,...
google-api-java-client JSON parser on Android produces an empty self.request.body on GAE
This is related to another question about URL shortener. The code for URL shortener works fine, on both standalone Java and on Android. However, when re-using this code to communicate to a custom Google App Engine application, the code works perfectly fine on standalone Java, but produces an empty self.request.body whe...
[ "I've done some debugging, and this is what turns out:\n\nby default, implementation on Android picks Apache HTTP client to do the low level transport. The code there is bare minimum, and it looks as if it does not set properly the Content-Type and Content-Length of the request. The request goes out, but, some (mos...
[ 2 ]
[]
[]
[ "android", "google_api_java_client", "google_app_engine", "python" ]
stackoverflow_0004829383_android_google_api_java_client_google_app_engine_python.txt
Q: How come Django doesn't email me errors when my DEBUG = False? ADMINS = [("alex", "alex@mydomain.com"), ("matt", "matt@mydomain.com")] DEBUG = False How come Django doesn't email me errors? I set up the email settings correctly, and everything else can send email just fine. EMAIL_HOST = "mail.blah.com" EMAIL_POR...
How come Django doesn't email me errors when my DEBUG = False?
ADMINS = [("alex", "alex@mydomain.com"), ("matt", "matt@mydomain.com")] DEBUG = False How come Django doesn't email me errors? I set up the email settings correctly, and everything else can send email just fine. EMAIL_HOST = "mail.blah.com" EMAIL_PORT = 25 EMAIL_HOST_USER = "blah" EMAIL_HOST_PASSWORD = "blah" EMAIL_U...
[ "From django documentation on error-reporting:\n\nBy default, Django will send e-mail\n from root@localhost. However, some\n mail providers reject all e-mail from\n this address. To use a different\n sender address, modify the\n SERVER_EMAIL setting.\n\nMaybe this will help you.\n", "One thing I've found tha...
[ 3, 2 ]
[]
[]
[ "debugging", "django", "email", "python", "settings" ]
stackoverflow_0004839003_debugging_django_email_python_settings.txt
Q: how to handle "getaddrinfo failed"? Hallo, i have problem. i use mechanize, python 2.7 to connect some sites (the code is not important right now) i have list of sites and i connect to them one by now. When it happens the site from my list doesn't exist i get error: urllib2.URLError: [Errno 11004] getaddrinfo f...
how to handle "getaddrinfo failed"?
Hallo, i have problem. i use mechanize, python 2.7 to connect some sites (the code is not important right now) i have list of sites and i connect to them one by now. When it happens the site from my list doesn't exist i get error: urllib2.URLError: [Errno 11004] getaddrinfo failed I tried to handle it by doing this...
[ "Random guess but try:\nimport socket\n\ntry:\n ...\nexcept socket.gaierror:\n pass\n\nsocket.gaierror is the \"[Errno 11004] getaddrinfo failed\" error.\nYou can easily figure out the exception if you do\ntry:\n ...\nexcept:\n import sys\n # prints `type(e), e` where `e` is the last exception\n pri...
[ 10, 3 ]
[]
[]
[ "python", "urllib", "urllib2", "urlopen" ]
stackoverflow_0004844654_python_urllib_urllib2_urlopen.txt
Q: error when running git command inside Popen Disclaimer: I'm extremely new at Python programming so I could be doing things very wrong here All I want to do is run a git command from an open file. Here is the call that I am making subprocess.Popen( 'git status', cwd = os.path.dirname( path ), shell = True, stdout =...
error when running git command inside Popen
Disclaimer: I'm extremely new at Python programming so I could be doing things very wrong here All I want to do is run a git command from an open file. Here is the call that I am making subprocess.Popen( 'git status', cwd = os.path.dirname( path ), shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE ) and...
[ "As Amber said, do a 'which git' in a shell, it'll tell you where git is installed. Then call git with the full path, eq with /usr/bin/git :\nsubprocess.Popen( '/usr/bin/git status', cwd = os.path.dirname( path ), shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE )\n\n" ]
[ 3 ]
[]
[]
[ "python" ]
stackoverflow_0004844880_python.txt
Q: Python String Manipulation I have a file that looks like the following. All I want is the Voltage, what is easiest way to strip everything else from it? Time,Voltage,Peak 0.0,1.003911558621642,3 0.00390625,1.0327467181982755,0 0.0078125,0.9904463156237306,0 0.01171875,0.6867661682528724,0 0.015625,0.62368030736695...
Python String Manipulation
I have a file that looks like the following. All I want is the Voltage, what is easiest way to strip everything else from it? Time,Voltage,Peak 0.0,1.003911558621642,3 0.00390625,1.0327467181982755,0 0.0078125,0.9904463156237306,0 0.01171875,0.6867661682528724,0 0.015625,0.6236803073669519,0 0.01953125,0.29347112105032...
[ "This sound a job to the csv module\nimport csv\nwith open(\"input.txt\", \"rb\") as f:\n reader = csv.reader(f)\n next(reader)\n for i in reader:\n print float(i[1])\n\n", "with open(\"input.txt\") as f:\n for s in f:\n print(s.split(\",\")[1])\n\n", "This will skip the first line and...
[ 8, 4, 4, 3, 2 ]
[]
[]
[ "csv", "file", "parsing", "python", "string" ]
stackoverflow_0004844627_csv_file_parsing_python_string.txt
Q: outputting characters to a spot in the terminal in python I'm using python, and I was wondering how do I output characters to specific positions in the terminal (im using windows for this) A: The Console module has support for this (Windows only)
outputting characters to a spot in the terminal in python
I'm using python, and I was wondering how do I output characters to specific positions in the terminal (im using windows for this)
[ "The Console module has support for this (Windows only)\n" ]
[ 1 ]
[]
[]
[ "character", "python", "terminal", "text" ]
stackoverflow_0004845287_character_python_terminal_text.txt
Q: How do you compress a string, and get a string back using zlib? I am trying to utilize Zlib for text compression. For example I have a string T='blah blah blah blah' I need to compress it for this string. I am using S=zlib.compress(T) to compress it. Now what I want is to get the non-binary form of S so that I ca...
How do you compress a string, and get a string back using zlib?
I am trying to utilize Zlib for text compression. For example I have a string T='blah blah blah blah' I need to compress it for this string. I am using S=zlib.compress(T) to compress it. Now what I want is to get the non-binary form of S so that I can decompress T but in a different program. Thanks! EDIT: I guess I go...
[ "Program 1:\nT = 'blah blah blah blah'\nS = zlib.compress(T)\nwith open(\"temp.zlib\", \"wb\") as myfile:\n myfile.write(S)\n\nThis saves the compressed string in a file called temp.zlib so that program 2 can later retrieve and decompress it.\nProgram 2:\nwith open(\"temp.zlib\", \"rb\") as myfile:\n S = myfi...
[ 14 ]
[]
[]
[ "compression", "python" ]
stackoverflow_0004845339_compression_python.txt
Q: How Can I Determine a Region, Country, and Continent Based on a City Using Python? So, I have a list of a bunch of city and state/region combinations (where some cities do not have a paired state/region) and I'd like to use these to fill in country, continent, (and state/region where it's not supplied) information...
How Can I Determine a Region, Country, and Continent Based on a City Using Python?
So, I have a list of a bunch of city and state/region combinations (where some cities do not have a paired state/region) and I'd like to use these to fill in country, continent, (and state/region where it's not supplied) information. Where multiple regions would fit, I'm willing to accept any of them, though the bigges...
[ "Thanks to Kimvais and Lennart Regebro, I've figured out a pretty simple way of doing what I wanted, and I wanted to post the basic steps here for anyone else who has the same problem.\n\nInstall geopy (http://code.google.com/p/geopy/)\n\nUse the following:\n from geopy import geocoders\n\n gn = geocoders.Google()\...
[ 5, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0004844811_python.txt
Q: run as administrator problem with py2exe I am having this problem that we compiled our python project into an exe with py2exe and the resulting exe does not work unless it is executed as an administrator. I wanted to ask that is this supposed to happen ?? As in there are so many applications that we can run as not...
run as administrator problem with py2exe
I am having this problem that we compiled our python project into an exe with py2exe and the resulting exe does not work unless it is executed as an administrator. I wanted to ask that is this supposed to happen ?? As in there are so many applications that we can run as not an administrator so is there any way I can co...
[ "It sounds like your application is attempting to write to a directory for which the basic user doesn't have access; most likely the \"Program Files\" directory. I believe in Vista/Win7 this is not allowed, and the standard convention is to write to the user's appdata folder, for any user data you might wish to sto...
[ 4, 0 ]
[]
[]
[ "python" ]
stackoverflow_0004844100_python.txt
Q: What's wrong with this cumulative sum? I'm trying to get [1,3,6] as the result. Am I missing something really obvious? The error I got is: IndexError: list index out of range def cumulative_sum(n): cum_sum = [] y = 0 for i in n: y += n[i] cum_sum.append(y) print cum_sum a = [1,2,3...
What's wrong with this cumulative sum?
I'm trying to get [1,3,6] as the result. Am I missing something really obvious? The error I got is: IndexError: list index out of range def cumulative_sum(n): cum_sum = [] y = 0 for i in n: y += n[i] cum_sum.append(y) print cum_sum a = [1,2,3] cumulative_sum(a)
[ "def cumulative_sum(n):\n cum_sum = []\n y = 0\n for i in n: # <--- i will contain elements (not indices) from n\n y += i # <--- so you need to add i, not n[i]\n cum_sum.append(y)\n print cum_sum\n\na = [1,2,3]\ncumulative_sum(a)\n\nArrays are zero-based in Python, so when you confuse...
[ 8, 7, 6, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0004844399_python.txt
Q: Defining a decorator in a class, which is also usuable within the class definition I'm trying to implement a "subcommand" system as an inheritable class in Python. My expected use case is something like: from command import Command import sys class MyCommand(Command): @Command.subcommand def foo(self): ...
Defining a decorator in a class, which is also usuable within the class definition
I'm trying to implement a "subcommand" system as an inheritable class in Python. My expected use case is something like: from command import Command import sys class MyCommand(Command): @Command.subcommand def foo(self): print "this can be run as a subcommand" def bar(self): print "but th...
[ "There are two solutions to this problem that I can think of. The simplest is to make it a static method after you're done using it in the parent class:\nclass Command(object):\n def subcommand(method): # Regular function in class definition scope.\n method.is_subcommand = True\n\n return method\n\...
[ 5 ]
[]
[]
[ "class", "decorator", "python" ]
stackoverflow_0004845613_class_decorator_python.txt
Q: Spacified columnized on-the-left line formatting to columnized data? xxxxxxxxxxxxx1.11xxxxxxxxxx1.11xxxxxxxxxxx1.11 xxxxxxxxxxxxx1.11xxxxxxxxxx1.11xxxxxxxxxx11.11 Is there some ready module in Python with which I could easily do above like formatting 17signs, 14 signs and then 15 signs? How can you get the thing ...
Spacified columnized on-the-left line formatting to columnized data?
xxxxxxxxxxxxx1.11xxxxxxxxxx1.11xxxxxxxxxxx1.11 xxxxxxxxxxxxx1.11xxxxxxxxxx1.11xxxxxxxxxx11.11 Is there some ready module in Python with which I could easily do above like formatting 17signs, 14 signs and then 15 signs? How can you get the thing n.b. the small difference with 1.11 and 11.11? N.b. the numbers could be...
[ "You don't need a module or library to do this, use string formatting. To avoid the ValueError, specify what index your parameter is in the supplied values:\n\"{0:>17}\".format(11.1)\n\n", "String formatting is built-in:\n\nhttp://docs.python.org/library/string.html#format-specification-mini-language\n\nExamples ...
[ 2, 2, 1 ]
[]
[]
[ "python", "python_2.x", "string" ]
stackoverflow_0004845589_python_python_2.x_string.txt
Q: Natural Naming Scheme for a dynamic set of members The desire is for the user to instantiate a class that represents the transeint along with automatic access to a member item for each variable being represented (up to 200 variables). The set of variable class instances would be dynamic based on file based input d...
Natural Naming Scheme for a dynamic set of members
The desire is for the user to instantiate a class that represents the transeint along with automatic access to a member item for each variable being represented (up to 200 variables). The set of variable class instances would be dynamic based on file based input data and the desire is to use the file provided variable ...
[ "Your description of what you're trying to do isn't entirely clear, but automatically naming variables something1, something2, etc. are generally a bad idea. Use a list instead:\ntransientvariables = []\ntransientvariables.append(makenewtransientvariable())\n# ...\nfor tv in transientvariables:\n print tv\n\nEdi...
[ 2 ]
[]
[]
[ "dynamic", "python" ]
stackoverflow_0004845913_dynamic_python.txt
Q: Use class variable in another class Greetings everyone, I'm currently working on an app using Python and wxPython. In it I have a Dialog where several fields are filled in order to insert a "document" in a database. The layout of that Dialog consists basically of a wx.Notebook, with several "tabs", each containing...
Use class variable in another class
Greetings everyone, I'm currently working on an app using Python and wxPython. In it I have a Dialog where several fields are filled in order to insert a "document" in a database. The layout of that Dialog consists basically of a wx.Notebook, with several "tabs", each containing some sort of fields. # Dialog class clas...
[ "Your \"tabs\" aren't class variables, they are local variables inside the function __init__. Also you don't want class variables, you want instance variables. To read and write instance variables you need to access them as attributes of self, for example self1.pag1, not by writing their name.\nYou need to distingu...
[ 3 ]
[]
[]
[ "oop", "python", "wxpython" ]
stackoverflow_0004845834_oop_python_wxpython.txt
Q: element in dict I have a dict as below: v0 = {(7, 3): '7', (4, 7): '*', (1, 3): '*', (6, 6): '*', (3, 0): '2', (2, 8): '*', (8, 0): '3', (7, 8): '*', (5, 4): '*', (2, 1): '*', (5, 6): '4', (6, 2): '*', (1, 6): '*', (3, 7): '*', (5, 1): '*', (0, 3): '4', (8, 5): '2', (2, 5): '*', (7, 2): '*', (4, 0): '*', (1, 2): '...
element in dict
I have a dict as below: v0 = {(7, 3): '7', (4, 7): '*', (1, 3): '*', (6, 6): '*', (3, 0): '2', (2, 8): '*', (8, 0): '3', (7, 8): '*', (5, 4): '*', (2, 1): '*', (5, 6): '4', (6, 2): '*', (1, 6): '*', (3, 7): '*', (5, 1): '*', (0, 3): '4', (8, 5): '2', (2, 5): '*', (7, 2): '*', (4, 0): '*', (1, 2): '2', (3, 8): '6', (6, ...
[ "Have you tried this?\n>>> v0[(7,3)]\n'7'\n>>> v0[(7,0)]\n'1'\n\nOr in a function:\n>>> def retr(x, y):\n... return v0[(x, y)]\n... \n>>> retr(8,4)\n'8'\n\nEDIT:\nTechnically speaking, you do not have to use the parentheses within the braces, but it does make it clearer that the dictionary key is in fact a sing...
[ 4, 3, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0004846012_python.txt
Q: Sockets, communication stops I have a simple question about socket programming. I've done to implement a server and two clients as following codes, but all of sudden it stops while it communicates each other. I have no idea why it happens all the time. Would you give me advice, hint, or help? Thank you for your ti...
Sockets, communication stops
I have a simple question about socket programming. I've done to implement a server and two clients as following codes, but all of sudden it stops while it communicates each other. I have no idea why it happens all the time. Would you give me advice, hint, or help? Thank you for your time. Client # simple client import...
[ "except: pass\n\nYou're ignoring all exceptions. This is a bad idea, because it doesn't let you know when things go wrong. You'll need to remove that except handler before you can reasonably debug your code.\n", "One problem is you are setting non-blocking mode:\n\nclnt.setblocking(0)\n\nBut never checking that i...
[ 3, 2 ]
[]
[]
[ "client", "python", "sockets" ]
stackoverflow_0004730153_client_python_sockets.txt
Q: Removing Extended Ascii with retention of text How can a covert an string containing the extended ascii to represent a number raised to a power while retaining the exponent value? For example, if the string is 'm\xb3/h' which is intended to represent cubic meters per hour, I would like to return the string 'm3/h'....
Removing Extended Ascii with retention of text
How can a covert an string containing the extended ascii to represent a number raised to a power while retaining the exponent value? For example, if the string is 'm\xb3/h' which is intended to represent cubic meters per hour, I would like to return the string 'm3/h'. Or 'm\xb2' should return 'm2'. The code - varUnit =...
[ "Well, the first thing to know is that there is no one \"extended ascii\". Ascii has been extended in many different ways. A quick test suggests that you want \"latin_1\" or \"cp1252\". So, first, convert it to unicode (a way of storing any character at all):\nvarUnit = varUnit.decode(\"latin_1\")\n\nEDIT: If you j...
[ 2, 1 ]
[]
[]
[ "ascii", "python", "string" ]
stackoverflow_0004715108_ascii_python_string.txt
Q: In simple cases, is it better to except & recover or to avoid the exception? Consider: categories = {'foo':[4], 'mer':[2, 9, 0]} key = 'bar' value = 5 We could safely append to a list stored in a dictionary in either of the following ways: Being cautious, we always check whether the list exists before appending...
In simple cases, is it better to except & recover or to avoid the exception?
Consider: categories = {'foo':[4], 'mer':[2, 9, 0]} key = 'bar' value = 5 We could safely append to a list stored in a dictionary in either of the following ways: Being cautious, we always check whether the list exists before appending to it. if not somedict.has_key(key): somedict[key] = [] somedict[key].append(...
[ "What you'll find is that your option 1 \"being cautious\" is often remarkably slow. Also, it's subject to obscure errors because the test you tried to write to \"avoid\" the exception is incorrect.\nWhat you'll find is that your option 2 \"being direct\" is often much faster. It's also more likely to be correct,...
[ 3, 2, 1, 1, 0, 0 ]
[ "EFAP is a good habit to get into for Python.\nOne reason is that it avoids the race condition if someone wants to use your code in a multithreaded app\n" ]
[ -1 ]
[ "dictionary", "exception", "list", "python" ]
stackoverflow_0004845932_dictionary_exception_list_python.txt
Q: Error using cv.CreateHist in Python OpenCV as well as strange absence of certain cv attributes I am getting an error (see below) when trying to use cv.CreateHist in Python. I am also noticing another alarming problem. If I spit out all of the attributes of the cv module into a file, and then I search them, I find ...
Error using cv.CreateHist in Python OpenCV as well as strange absence of certain cv attributes
I am getting an error (see below) when trying to use cv.CreateHist in Python. I am also noticing another alarming problem. If I spit out all of the attributes of the cv module into a file, and then I search them, I find that a ton of common things are missing. For example, cv.TermCriteria() is not there; cv.ConnectedCo...
[ "As for CvRect, see the documentation. It says such types are represented as Pythonic tuples.\nAs for your call to CreateHist, you may be passing the arguments in wrong order. See createhist in the docs for python opencv.\n" ]
[ 0 ]
[]
[]
[ "attributes", "histogram", "opencv", "python" ]
stackoverflow_0004846174_attributes_histogram_opencv_python.txt
Q: python: __init__ template I noticed I often write the following: class X: def __init__(self, var1, var2, var3): self.var1 = var1 self.var2 = var2 self.var3 = var3 # more code here Is it a good idea to make a template that I can reuse instead of doing this every time? If so, how should I do that?...
python: __init__ template
I noticed I often write the following: class X: def __init__(self, var1, var2, var3): self.var1 = var1 self.var2 = var2 self.var3 = var3 # more code here Is it a good idea to make a template that I can reuse instead of doing this every time? If so, how should I do that?
[ "I wouldn't suggest using such templates in production code, because\nExplicit is better than implicit.\n\nFor throw-away prototypes it might be acceptable. Here is an example from the python recipes:\n\nhttp://code.activestate.com/recipes/577382-keyword-argument-injection-with-python-decorators/\n\nIt defines a de...
[ 1, 0 ]
[]
[]
[ "initialization", "python", "python_3.x" ]
stackoverflow_0004846438_initialization_python_python_3.x.txt
Q: Google App Engine Payload Object How to send a class object in the payload of a task in python? I want to send an object in the parameters of a task. When I use simplejson, I get the error: Object is not serializable. When I use pickle, I get KeyValue Error. How to do this ? This is the class which I want to ser...
Google App Engine Payload Object
How to send a class object in the payload of a task in python? I want to send an object in the parameters of a task. When I use simplejson, I get the error: Object is not serializable. When I use pickle, I get KeyValue Error. How to do this ? This is the class which I want to serialize class Matrix2D_icfg: name = "...
[ "The problem was with the type of data that was unloaded. I casted it to type str and everything seemed to work properly.\nI just changed it to \nicfg = Matrix2D_icfg(\"icfg\") #declaring object\nicfg_compress = pickle.dumps(icfg) #to pickle\n\nicfg = pickle.loads(str(icfg_compress)) # to unload\n\n", "Have you l...
[ 3, 1, 0 ]
[]
[]
[ "google_app_engine", "json", "pickle", "python", "task_queue" ]
stackoverflow_0004836697_google_app_engine_json_pickle_python_task_queue.txt
Q: Assign value to a string that is the same as a variable name in Python Suppose I have, class example(object) def __init__(var1 = 10, var2 = 15, var3 = 5) do a few things here Other methods here There are other classes which are not relevant for the question. To study the behavior of the system,...
Assign value to a string that is the same as a variable name in Python
Suppose I have, class example(object) def __init__(var1 = 10, var2 = 15, var3 = 5) do a few things here Other methods here There are other classes which are not relevant for the question. To study the behavior of the system, I vary the inputs in the __init__ method above, one at a time. I have anoth...
[ "If I understand you correctly, you want to specify the name of the parameter that should be set dynamically. You can use dictionary unpacking:\nexample_instance = example(**{var_under_study: value})\n\nThis will pass the contents of the dictionary as parameters to the function, where the keys are the parameter nam...
[ 3 ]
[]
[]
[ "python", "string", "variables" ]
stackoverflow_0004846509_python_string_variables.txt
Q: Threaded vs. asynchronous image processing? I have a Python function which generates an image once it is accessed. I can either invoke it directly upon a HTTP request, or do it asynchronously using Gearman. There are a lot of requests. Which way is better: Inline - create an image inline, will result in many imag...
Threaded vs. asynchronous image processing?
I have a Python function which generates an image once it is accessed. I can either invoke it directly upon a HTTP request, or do it asynchronously using Gearman. There are a lot of requests. Which way is better: Inline - create an image inline, will result in many images being generated at once Asynchronous - queue ...
[ "If your program is CPU bound in the interpreter then spawning multiple threads will actually slow down the result even if there are enough processors to run them all. This happens because the GIL (global interpreter lock) only allows one thread to run in the interpreter at a time.\nIf most of the work happens in ...
[ 1, 1 ]
[]
[]
[ "asynchronous", "gearman", "python" ]
stackoverflow_0004844166_asynchronous_gearman_python.txt
Q: Django template able to pass parameters? Getting the current user In my template, I use a method in a model as follows... The model is defined like this: class Category(model.Model): title = models.CharField('title', max_length=255) description = models.TextField('description', blank=True) def pu...
Django template able to pass parameters? Getting the current user
In my template, I use a method in a model as follows... The model is defined like this: class Category(model.Model): title = models.CharField('title', max_length=255) description = models.TextField('description', blank=True) def pub_set(self): ... return somedata The Template is use...
[ "I'm not 100% clear what you are asking. Inside of Category.pub_set() are you trying to access the request.user? If so, you can't do that unfortunately. There might be some sort of hack that will work, but it isn't the recommended way in Django.\nYou might want to check out template tags, they will allow you to pas...
[ 1 ]
[]
[]
[ "django", "django_templates", "python" ]
stackoverflow_0004846813_django_django_templates_python.txt
Q: How to run Pygame in Mac background Im wondering how to provide keyboard input to a running python/pygame program that is in my Mac's background. Have moved this question to: How to test if global key is pressed on Mac using PyObjC and Python. And no longer using Pygame. A: I think I interpret this question as: ...
How to run Pygame in Mac background
Im wondering how to provide keyboard input to a running python/pygame program that is in my Mac's background. Have moved this question to: How to test if global key is pressed on Mac using PyObjC and Python. And no longer using Pygame.
[ "I think I interpret this question as: \"I need to automate keyboard input\". If so, dogtail\nis a good idea. However, since your program is going to be in the background, this may complicate matters, do you have the source to the game you're trying to pass input to?\n" ]
[ 0 ]
[]
[]
[ "background", "input", "macos", "pygame", "python" ]
stackoverflow_0004846393_background_input_macos_pygame_python.txt
Q: Embedding an Image in a Tkinter Canvas widget using PIL I'm trying to embed an image in a Tkinter canvas using PIL, and for some reason it's not displaying. Any Ideas? There are no errors or warnings. Just a blank Tk window. My code: import Tkinter from PIL import ImageTk, Image class image_manip(Tkinter.Tk): ...
Embedding an Image in a Tkinter Canvas widget using PIL
I'm trying to embed an image in a Tkinter canvas using PIL, and for some reason it's not displaying. Any Ideas? There are no errors or warnings. Just a blank Tk window. My code: import Tkinter from PIL import ImageTk, Image class image_manip(Tkinter.Tk): def __init__(self,parent): Tkinter.Tk.__init__(se...
[ "My guess is that the image is getting garbage-collected. Try saving a reference to \"i\" (eg: self.image=i)\n" ]
[ 8 ]
[]
[]
[ "embed", "image", "python", "python_imaging_library", "tkinter" ]
stackoverflow_0004846838_embed_image_python_python_imaging_library_tkinter.txt
Q: python log view application I want to have GUI application or Web app where I can view the python log information. I can choose any formatter required. But it should work with standard logging module. I have configured my logs to file. But I wanted to have log to be stored to mysql db (it is possible) but I badly...
python log view application
I want to have GUI application or Web app where I can view the python log information. I can choose any formatter required. But it should work with standard logging module. I have configured my logs to file. But I wanted to have log to be stored to mysql db (it is possible) but I badly need user interface to view the ...
[ "You can write a database handler for logging as in this example using any Python DB-API 2.0 compliant database interface. Then, of course, you can view the logs using any framework which allows you to get and display data via the Web.\nOr, you can use log4j's Chainsaw GUI using the approach outlined here. Here's a...
[ 2, 0 ]
[]
[]
[ "logging", "mysql", "python" ]
stackoverflow_0002179918_logging_mysql_python.txt
Q: assign a attribute using getattr I try to assign value to attributes of some calss like the following: for name in dir(modelType): if request.get(name): getattr(model, name) = request.get(name) but get the excption: "can't assign to function call" how can I change attributes without knowing th...
assign a attribute using getattr
I try to assign value to attributes of some calss like the following: for name in dir(modelType): if request.get(name): getattr(model, name) = request.get(name) but get the excption: "can't assign to function call" how can I change attributes without knowing them at complie time?
[ "You use setattr() to assign values to attributes.\nSee: http://docs.python.org/library/functions.html#setattr\n", "setattr(model, name, request.get(name))\n\nbut I'd recommend saving request data in a dictionary, dedicated class, or accessing it directly - unless you're doing specific metaprogramming/introspect...
[ 24, 9 ]
[]
[]
[ "getattr", "python" ]
stackoverflow_0004847177_getattr_python.txt
Q: Maketrans in Python 2.6 I have got this nice little method to remove control characters from a string. Unfortunatelly, it does not work in Python 2.6 (only in Python 3.1). It states: mpa = str.maketrans(dict.fromkeys(control_chars)) AttributeError: type object 'str' has no attribute 'maketrans' def removeContro...
Maketrans in Python 2.6
I have got this nice little method to remove control characters from a string. Unfortunatelly, it does not work in Python 2.6 (only in Python 3.1). It states: mpa = str.maketrans(dict.fromkeys(control_chars)) AttributeError: type object 'str' has no attribute 'maketrans' def removeControlCharacters(line): control...
[ "In Python 2.6, maketrans is in the string module. Same with Python 2.7.\nSo instead of str.maketrans, you'd first import string and then use string.maketrans.\n", "For this instance, there is no need for maketrans for either byte strings or Unicode strings:\nPython 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC ...
[ 17, 8 ]
[]
[]
[ "python", "python_3.x" ]
stackoverflow_0004846802_python_python_3.x.txt
Q: Creating Blank Images in Python (allowing pixel by pixel manipulation) I have this code here that creates a Tkinter Canvas widget, then embeds an image within it. import Tkinter from PIL import ImageTk, Image class image_manip(Tkinter.Tk): def __init__(self): Tkinter.Tk.__init__(self) self....
Creating Blank Images in Python (allowing pixel by pixel manipulation)
I have this code here that creates a Tkinter Canvas widget, then embeds an image within it. import Tkinter from PIL import ImageTk, Image class image_manip(Tkinter.Tk): def __init__(self): Tkinter.Tk.__init__(self) self.configure(bg='red') self.ImbImage = Tkinter.Canvas(self, highlight...
[ "To create a new blank image (rather than opening one), you can use the Image.new(...) method in place of your Image.open(...). It is described in The Image Module.\nThen call self.i.put(...) to do pixel-by-pixel manipulation. (i is the PhotoImage object as in your example.)\nHere's some general information on Th...
[ 13 ]
[]
[]
[ "image_manipulation", "image_processing", "python", "python_imaging_library", "tkinter" ]
stackoverflow_0004847287_image_manipulation_image_processing_python_python_imaging_library_tkinter.txt
Q: A table with a composite Primary key, one of the fields with autoincrement Im using a table constraint to create a composite primary key, I would like the id field to autoincrement, is this possible? or what are the alternatives? CREATE TABLE IF NOT EXISTS atable( id INTEGER NOT NULL, --I want...
A table with a composite Primary key, one of the fields with autoincrement
Im using a table constraint to create a composite primary key, I would like the id field to autoincrement, is this possible? or what are the alternatives? CREATE TABLE IF NOT EXISTS atable( id INTEGER NOT NULL, --I want to autoincrement this one name TEXT NOT NULL, anotherCol T...
[ "No, there's only one primary key: that's the composite of id and name.\nIf you mean that you want id to be the primary key, and name to be an indexed alternate key, I'd say that you should give name a unique constraint and make id the primary key.\n", "Here's the link to the SQLite FAQ page where your question o...
[ 5, 0, 0 ]
[]
[]
[ "python", "sqlite" ]
stackoverflow_0004770870_python_sqlite.txt
Q: Request for suggestions to improve very simple PICKLE-based blog code In experimenting with pickle, I've put together some code for a (very) simple blog. It's intended to display time-stamped blog contents from a pickle'd list in reverse chron order. It then prompts whether you want to add to the blog. (As you ...
Request for suggestions to improve very simple PICKLE-based blog code
In experimenting with pickle, I've put together some code for a (very) simple blog. It's intended to display time-stamped blog contents from a pickle'd list in reverse chron order. It then prompts whether you want to add to the blog. (As you can see, I'm new to programming). Please critique this and/or suggest ways ...
[ "To answer your immediate question, you can run this code by using:\npython Journal.py\n\nand things should mostly work (I didn't test your code, just glanced at it). To improve upon it, you should look at Guido's guide to using main() here and possibly utilizing a #! (reference) so you can do:\n./Journal.py\n\n" ]
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0004847421_python.txt
Q: tty Python Sqlite app: Noob NameError, Unexpected EOF, and sqlite error I am porting a tcl script to python, because I can't seem to get the tclSqlite thing going on my Nokia N810. The script prompts for inputs, passes them to a sqlite db with 3 tables: Notes, Tags, and a NotesXTags many-to-many tbl. There are tri...
tty Python Sqlite app: Noob NameError, Unexpected EOF, and sqlite error
I am porting a tcl script to python, because I can't seem to get the tclSqlite thing going on my Nokia N810. The script prompts for inputs, passes them to a sqlite db with 3 tables: Notes, Tags, and a NotesXTags many-to-many tbl. There are triggers that keep me from storing any tags more than once. Being a noob/hobbyis...
[ "You'll want raw_input instead of input in your script. input evaluates what you type, which is why you have to enter quotes.\nYou can markdown code using the {} buttons above the input window. That actual markdown for code is a preceding 4 spaces.\ndb.commit needs to be db.commit().\nIf you do this:\n>>> import ...
[ 2, 1 ]
[]
[]
[ "python", "sqlite" ]
stackoverflow_0004847381_python_sqlite.txt
Q: Python: My dictionary that stores first names won't store more than one first name at a time So, I've created a Dictionary that stores first-names as a list within that dictionary. New names are added within the dictionary's list via a function. Now, this is where i have hit a snag: Main Obstacle: The function ove...
Python: My dictionary that stores first names won't store more than one first name at a time
So, I've created a Dictionary that stores first-names as a list within that dictionary. New names are added within the dictionary's list via a function. Now, this is where i have hit a snag: Main Obstacle: The function overwrites new names that I add. If I add the name "George" to the list via the function, it will sto...
[ "Didn't you ask this question already? (My previous answer)\nYou are always setting the data['names'] to an empty dictionary before appending value to it.\ndef add(data, value):\n data.setdefault('names', {}).setdefault('first', []).append(value)\n\nSee python docs on dict.setdefault\n" ]
[ 4 ]
[]
[]
[ "dictionary", "function", "python" ]
stackoverflow_0004847645_dictionary_function_python.txt
Q: Using PIL's ImageDraw Module I'm trying to do individual pixel manipulation using PIL's ImageDraw Module. The code bellow is supposed to create Tkinter canvas widget. Then open an image, change one pixel's color to red, then embed the image in the canvas widget. However, it doesn't seem to be working. My Code: imp...
Using PIL's ImageDraw Module
I'm trying to do individual pixel manipulation using PIL's ImageDraw Module. The code bellow is supposed to create Tkinter canvas widget. Then open an image, change one pixel's color to red, then embed the image in the canvas widget. However, it doesn't seem to be working. My Code: import Tkinter from PIL import ImageT...
[ "Your problem is you're reassigning im to multiple things.\nim = Image.open(r'C:\\Python26\\Suite\\test.png')\nim = ImageDraw.Draw(im)\nim = im.point((0, 0), fill=\"red\")\n\nWhen you call ImageTk.PhotoImage(im), the function expects a PIL image object, but you've already assigned im to the result of the point() fu...
[ 9 ]
[]
[]
[ "image_manipulation", "image_processing", "python", "python_imaging_library", "tkinter" ]
stackoverflow_0004847706_image_manipulation_image_processing_python_python_imaging_library_tkinter.txt
Q: Laying out MVC classes in Python I'm working on a project in Python, and I'm trying to follow a somewhat-strict MVC pattern for practice. My idea was to separate things out into packages named model, view and controller, plus have a Model, View and Controller class for each. Each package would have the supporting ...
Laying out MVC classes in Python
I'm working on a project in Python, and I'm trying to follow a somewhat-strict MVC pattern for practice. My idea was to separate things out into packages named model, view and controller, plus have a Model, View and Controller class for each. Each package would have the supporting files for each piece. My problem is th...
[ "I've seen some black magic in the django source that pulls classes from a base.py file into the __init__.py namespace. However I'm not sure how that's done. ( See comments for how to do this. )\nFrom what I do know, you can do one of two things.\nA - \ninside bar/controller/__init__.py\nimport os,sys\n# Make sure ...
[ 6, 2 ]
[]
[]
[ "model_view_controller", "python" ]
stackoverflow_0004847500_model_view_controller_python.txt
Q: gtk.Toolbar deprecation warning fix So I've been using a gtk.Toolbar object for a while and was using the append_item method but was getting a deprecation warning. So I tried the insert_item method and still got a deprecation warning. So I tried creating a gtk.ToolButton separately and then using the insert method...
gtk.Toolbar deprecation warning fix
So I've been using a gtk.Toolbar object for a while and was using the append_item method but was getting a deprecation warning. So I tried the insert_item method and still got a deprecation warning. So I tried creating a gtk.ToolButton separately and then using the insert method to add it which got rid of the warning b...
[ "The insert method appears to be the correct one. Did you make sure to show the toolbar somewhere, perhaps by using the show_all method of the parent? And if so, did you pack the toolbar into a box in the window, to make sure that the window itself actually is an ancestor of the toolbar?\n" ]
[ 2 ]
[]
[]
[ "gtk", "pygtk", "python", "user_interface" ]
stackoverflow_0004847794_gtk_pygtk_python_user_interface.txt
Q: modelling points on a surface My simulation model contains agents on a surface. Agent's are represented by class Agent, their locations by class Point, and the surface itself by class Surface. Each point is really just a pair of numbers. To model an agent's movement, I need to know which surface he's on (e.g., on ...
modelling points on a surface
My simulation model contains agents on a surface. Agent's are represented by class Agent, their locations by class Point, and the surface itself by class Surface. Each point is really just a pair of numbers. To model an agent's movement, I need to know which surface he's on (e.g., on a torus, he would never hit a land'...
[ "I'm not sure why adding an extra attribute is an efficiency problem - it won't affect the speed and it'll only increase the size of the object by 10 bytes or so. So unless you are dealing with millions of Agents (Missterrr Annnderssssonnn) I wouldn't worry about it.\nYou could alternatively have a single Surface w...
[ 1 ]
[]
[]
[ "oop", "python", "software_design" ]
stackoverflow_0004848965_oop_python_software_design.txt
Q: porting the piece of code I have following pieces of code: code1: lis = ["a", "s", "d"] string.join(lis) code2: lis = ["a", "s", "d"] ' '.join(lis) Results: For both the cases the result is 'a s d' Now, there should be certain cases (if I'm correct) when the value of 'sep' which is the default separation value...
porting the piece of code
I have following pieces of code: code1: lis = ["a", "s", "d"] string.join(lis) code2: lis = ["a", "s", "d"] ' '.join(lis) Results: For both the cases the result is 'a s d' Now, there should be certain cases (if I'm correct) when the value of 'sep' which is the default separation value differ from ' '. I would reall...
[ "I had to look it up - large parts of the string are obsolete (replaced by real methods on real str objects); because of this, you should propably use ' '.join even in Python 2. But no, there is no different - string.join defaults to joining by single spaces (i.e. ' '.join is equivalent).\n", "There is no signifi...
[ 2, 2, 1, 0 ]
[]
[]
[ "porting", "python" ]
stackoverflow_0004848862_porting_python.txt
Q: TEXT compression in python I have this text : 2,3,5,1,13,7,17,11,89,1,233,29,61,47,1597,19,37,41,421,199,28657,23,3001,521,53,281,514229,31,557,2207,19801,3571,141961,107,73,9349,135721,2161,2789,211,433494437,43,109441,139,2971215073,1103,97,101,6376021,90481,953,5779,661,14503,797,59,353,2521,4513,3010349,352396...
TEXT compression in python
I have this text : 2,3,5,1,13,7,17,11,89,1,233,29,61,47,1597,19,37,41,421,199,28657,23,3001,521,53,281,514229,31,557,2207,19801,3571,141961,107,73,9349,135721,2161,2789,211,433494437,43,109441,139,2971215073,1103,97,101,6376021,90481,953,5779,661,14503,797,59,353,2521,4513,3010349,35239681,1087,14736206161,9901,269,67,...
[ "Sure you can do this:\nimport base64\nimport zlib\ncompressed = 'eJwdktkNgDAMQxfqR+5j/8V4QUJQUttx3Nrzl0+f+uunPPpm+Tf3Z/tKX1DM5bXP+wUFA777bCob4HMRfUk14QwfDYPrrA5gcuQB49lQQxdZpdr+1oN2bEA3pW5Nf8NGOFsR19NBszyX7G2raQpkVUEBdbTLuwSRlcDCYiW7GeBaRYJrgImrM3lmI/WsIxFXNd+aszXoRXuZ1PnZRdwKJeqYYYKq6y1++PXOYdgM0TlZcymCOdKqR7HYmY...
[ 9, 4, 2 ]
[]
[]
[ "python", "text_compression" ]
stackoverflow_0004844907_python_text_compression.txt
Q: How to reduce the font of the text in the legend box printed in the plot? I am trying to plot around 10 plots in a single figure. I also could put the legend box separately. But, I am unable to reduce the size of the font in the legend box. Can anybody suggest me the procedure to reduce the font size in the leng...
How to reduce the font of the text in the legend box printed in the plot?
I am trying to plot around 10 plots in a single figure. I also could put the legend box separately. But, I am unable to reduce the size of the font in the legend box. Can anybody suggest me the procedure to reduce the font size in the lengend box. I am herewith giving the instructions that I have used: But it is not ...
[ "You're using matplotlb, aren't you?\nSomething like this may help:\nlegend_font_props = FontProperties()\nlegend_font_props.set_size('small')\nax.legend(loc='center left', bbox_to_anchor=(1, 0.5), numpoints=1, prop=legend_font_props)\n\nSee http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.le...
[ 2 ]
[]
[]
[ "font_size", "legend", "matplotlib", "python" ]
stackoverflow_0004848262_font_size_legend_matplotlib_python.txt
Q: python: sampling without replacement from a 2D grid I need a sample, without replacement, from among all possible tuples of numbers from range(n). That is, I have a collection of (0,0), (0,1), ..., (0,n), (1,0), (1,1), ..., (1,n), ..., (n,0), (n,1), (n,n), and I'm trying to get a sample of k of those elements. I a...
python: sampling without replacement from a 2D grid
I need a sample, without replacement, from among all possible tuples of numbers from range(n). That is, I have a collection of (0,0), (0,1), ..., (0,n), (1,0), (1,1), ..., (1,n), ..., (n,0), (n,1), (n,n), and I'm trying to get a sample of k of those elements. I am hoping to avoid explicitly building this collection. I ...
[ "Depending on how many of these you're selecting, it might be simplest to just keep track of what things you've already picked (via a set) and then re-pick until you get something that you haven't picked already.\nThe other option is to just use some simple math:\nnumbers_in_nxn = random.sample(range(n*n), k) # Use...
[ 7, 0 ]
[ "Without trying (no python at hand):\nrandom.shuffle(range(n))[:k]\n\n\nsee comments. Didn't sleep enough...\n" ]
[ -1 ]
[ "algorithm", "python", "python_3.x", "random" ]
stackoverflow_0004848237_algorithm_python_python_3.x_random.txt
Q: PGP signatures from Python? What is the easiest way to create and verify PGP/GPG signatures from within a Python application? I can call pgp or gpg using subprocess and parse the output, but I was looking for a way that didn't require an external program to be installed (my application is cross-platform mac/windo...
PGP signatures from Python?
What is the easiest way to create and verify PGP/GPG signatures from within a Python application? I can call pgp or gpg using subprocess and parse the output, but I was looking for a way that didn't require an external program to be installed (my application is cross-platform mac/windows/unix).
[ "I think GPGME and the PyMe Python wrapper should do what you need.\n", "In addition to PyMe, consider python-gnupg and the gnupginterface.\n" ]
[ 8, 2 ]
[]
[]
[ "cross_platform", "gnupg", "python", "security" ]
stackoverflow_0000039929_cross_platform_gnupg_python_security.txt
Q: Google App Engine Python If Else Usage in Html Template I am creating a web site in google app engine using python. Unfortunately, I could not find anything concerning my problem. I have to distinguish a variable according to its content. For example i am going to send variables like this content = { 'mail...
Google App Engine Python If Else Usage in Html Template
I am creating a web site in google app engine using python. Unfortunately, I could not find anything concerning my problem. I have to distinguish a variable according to its content. For example i am going to send variables like this content = { 'mail':session.get('user_mail',''), 'role':'Admin', ...
[ "There is no elif in django templates. Use something like this:\n{% if role == 'Login' %}\n ... stuff\n{% else %}{% if role eq 'Admin' %}\n ... stuff\n{% endif %}\n\nOr, with ifequal:\n{% ifequal role \"Login\" %}\n ... stuff\n{% else %}{% ifequal role \"Admin\" %}\n ... stuff\n{% endifequal %}\n\n", "Put the log...
[ 5, 4 ]
[]
[]
[ "django_templates", "google_app_engine", "html", "python" ]
stackoverflow_0004849224_django_templates_google_app_engine_html_python.txt
Q: Python memcache preserve order in get_multi() How can I preserve the order of the values fetched with memcache's get_multi() function? By default, the order returned is random. Thanks. A: Python's Memcache library returns a dictionary, and dictionaries in python are unordered, so you have to get the values fro...
Python memcache preserve order in get_multi()
How can I preserve the order of the values fetched with memcache's get_multi() function? By default, the order returned is random. Thanks.
[ "Python's Memcache library returns a dictionary, and dictionaries in python are unordered, so you have to get the values from the dictionary in the right order manually:\nresult = cache.get_multi(keys)\nvalues = [result.get(key) for key in keys]\n\n", "as I remember memcache has flag GET PRESERVE ORDER, try addin...
[ 3, 0 ]
[]
[]
[ "memcached", "memcachedb", "python" ]
stackoverflow_0004372870_memcached_memcachedb_python.txt
Q: Inheriting behaviours for set and frozenset seem to differ Can someone explain the following behaviour: class derivedset1(frozenset): def __new__(cls,*args): return frozenset.__new__(cls,args) class derivedset2(set): def __new__(cls,*args): return set.__new__(cls,args) a=derivedset1...
Inheriting behaviours for set and frozenset seem to differ
Can someone explain the following behaviour: class derivedset1(frozenset): def __new__(cls,*args): return frozenset.__new__(cls,args) class derivedset2(set): def __new__(cls,*args): return set.__new__(cls,args) a=derivedset1('item1','item2') # WORKS b=derivedset2('item1','item2') # DOES...
[ "From the Python documentation:\n\nIf __new__() returns an instance of cls, then the new instance’s __init__() method will be invoked like __init__(self[, ...]), where self is the new instance and the remaining arguments are the same as were passed to __new__().\n\nset.__init__ only takes one argument, an iterable ...
[ 4 ]
[]
[]
[ "built_in_types", "immutability", "inheritance", "python" ]
stackoverflow_0004850370_built_in_types_immutability_inheritance_python.txt
Q: How to move a local django made site into another machine? I have tried hard searching for the solution to my query but with no luck. I have made a website using django in my local machine. Now i want to install the same django made website in another machine. MySQL is the database i am using. How do i move the lo...
How to move a local django made site into another machine?
I have tried hard searching for the solution to my query but with no luck. I have made a website using django in my local machine. Now i want to install the same django made website in another machine. MySQL is the database i am using. How do i move the local django made website into another machine? If this question h...
[ "To set up the same Django site on a different machine, you can just copy the code across. When you try and run it, you'll get errors if anything isn't set up correctly which you can resolve one by one. A few errors you are likely to get are:\n\nMake sure Python is installed on the new box\nMake sure Django and any...
[ 17, 3 ]
[]
[]
[ "django", "python" ]
stackoverflow_0004850311_django_python.txt
Q: [Errno 32]Broken pipe in Python Script in Crontab I am running a Python script which downloads PDF files from the FTP. The script when run manually works perfectly but when i put it in crontab in my ubuntu machine and execute it i get a an error [Errno 32] Broken pipe. Any idea why this happens and how do i handle...
[Errno 32]Broken pipe in Python Script in Crontab
I am running a Python script which downloads PDF files from the FTP. The script when run manually works perfectly but when i put it in crontab in my ubuntu machine and execute it i get a an error [Errno 32] Broken pipe. Any idea why this happens and how do i handle this?
[ "Hi I dnt know y the error occurs but when i directed the print statements from my script to another file this error did not come and my script ran successfully \nExample: Myscript.py > test.log\n" ]
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0004836450_python.txt
Q: avoid having to scroll in GTK popup menu I am working on a Gnome Panel Applet that displays a pop-up menu on clicking it's icon. The problem is, with lots of entries, the menu does not pop up with the first items visible, but somewhere in the middle. This makes it necessary to scroll up to see the top item (a sub-...
avoid having to scroll in GTK popup menu
I am working on a Gnome Panel Applet that displays a pop-up menu on clicking it's icon. The problem is, with lots of entries, the menu does not pop up with the first items visible, but somewhere in the middle. This makes it necessary to scroll up to see the top item (a sub-menu) and the first ones under it. These are r...
[ "would this work...?\nmenu.set_active(0)\n\n" ]
[ 1 ]
[]
[]
[ "gtk", "linux", "pygtk", "python" ]
stackoverflow_0004799294_gtk_linux_pygtk_python.txt
Q: How to specify psycopg2 parameter for an array for timestamps (datetimes) I'd like to run a PostgreSQL query in Python using psycopg2, which filters by a column of type timestamp without timezone. I have a long list of allowed values for the timestamp (rather than a range) and psycopg2 conveniently handles arrays,...
How to specify psycopg2 parameter for an array for timestamps (datetimes)
I'd like to run a PostgreSQL query in Python using psycopg2, which filters by a column of type timestamp without timezone. I have a long list of allowed values for the timestamp (rather than a range) and psycopg2 conveniently handles arrays, so I thought that this should work: SELECT somestuff FROM mytable WHERE thetim...
[ "Try it like this:\nSELECT somestuff\nFROM mytable\nWHERE thetimestamp = ANY (%(times)s::timestamp[])\n\n", "If you use psycopg2 version 2.2.0 or newer, your original code should work, if you wrap the values in Timestamp() constructors, as you suggested.\nThe reason that it didn't work before was a bug in the psy...
[ 13, 3 ]
[]
[]
[ "postgresql", "psycopg2", "python", "python_db_api", "timestamp" ]
stackoverflow_0001978586_postgresql_psycopg2_python_python_db_api_timestamp.txt
Q: Authentication using any OpenID with Tipfy I am developing the authentication part of my app and I've run into issues with coding authentication using OpenID. I've looked at the Tipfy example code, but it seems written under the assumption that the OpenID provider is hard-coded to google. I would like the user to ...
Authentication using any OpenID with Tipfy
I am developing the authentication part of my app and I've run into issues with coding authentication using OpenID. I've looked at the Tipfy example code, but it seems written under the assumption that the OpenID provider is hard-coded to google. I would like the user to be able to provide any OpenID they desire (isn't...
[ "Does Tipfy allow any OpenID authentication? \nIf you want to authenticate any OpenID Url with Tipfy, you can't do it out of the box.\nOne main reason is because Tipfy does not have any discovery mechanism to retrieve the OpenID Endpoint from a given OpenID user url.\nWhat Tipfy is missing?\nTipfy does not allow th...
[ 6, 2 ]
[]
[]
[ "google_app_engine", "openid", "python", "tipfy" ]
stackoverflow_0004851536_google_app_engine_openid_python_tipfy.txt
Q: Django checkbox question Hello I have a template form which displays a list of items. This template is called edit_order.html. I want to be able to add a new item from another list of items. From the other list of items is a template called items.html, showing a list of items. In items.html, each item has a checkb...
Django checkbox question
Hello I have a template form which displays a list of items. This template is called edit_order.html. I want to be able to add a new item from another list of items. From the other list of items is a template called items.html, showing a list of items. In items.html, each item has a checkbox besides an item. Now, what ...
[ "I'm a bit confused as to what you are attempting to do. However, I would suggest, if possible, that you make use of the forms library included with Django instead of rendering a bunch of form elements manually in the template. Here is an example of a simple form with custom/dynamic choices rendered as checkboxes....
[ 3 ]
[]
[]
[ "checkbox", "django", "django_templates", "python", "views" ]
stackoverflow_0004850748_checkbox_django_django_templates_python_views.txt
Q: Python 3.1 - Memory Error during sampling of a large list The input list can be more than 1 million numbers. When I run the following code with smaller 'repeats', its fine; def sample(x): length = 1000000 new_array = random.sample((list(x)),length) return (new_array) def repeat_sample(x): i =...
Python 3.1 - Memory Error during sampling of a large list
The input list can be more than 1 million numbers. When I run the following code with smaller 'repeats', its fine; def sample(x): length = 1000000 new_array = random.sample((list(x)),length) return (new_array) def repeat_sample(x): i = 0 repeats = 100 list_of_samples = [] for i in rang...
[ "Expanding on my comment:\nLet's say the processing you do to each sample is calculate its mean.\ndef mean(samplelists):\n means = []\n n = float(len(samplelists[0]))\n for sample in samplelists:\n mean = sum(sample)/n\n means.append(mean)\n return means\n\ncalc_means(repeat_sample(large_a...
[ 5, 4, 1, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0004706151_python.txt
Q: Simple python CGI cookie script, get's data from form Hello all I am trying to create a very simple python CGI script that takes form data and puts it in a COOKIE. Here is my code. #!/usr/bin/python print "Content-type: text/html" print import Cookie, cgi, os, cgitb, smtplib, sys cgitb.enable() form = cgi.Field...
Simple python CGI cookie script, get's data from form
Hello all I am trying to create a very simple python CGI script that takes form data and puts it in a COOKIE. Here is my code. #!/usr/bin/python print "Content-type: text/html" print import Cookie, cgi, os, cgitb, smtplib, sys cgitb.enable() form = cgi.FieldStorage() ID = form.getvalue('ID') name = form.getvalue('n...
[ "If I'm not mistaken, it looks like you're printing out the Content-type header twice: once on line 2, and again when set_clientCookie() is run.\nAre you able to post the raw output from Fiddler or Firebug maybe?\n", "Copy-pasting your code onto my server shows no errors. You might try to remove all imports you d...
[ 2, 0 ]
[]
[]
[ "cgi", "cookies", "python" ]
stackoverflow_0004832428_cgi_cookies_python.txt
Q: What is faster for loop using enumerate or for loop using xrange in Python? What is faster, a for loop using enumerate or using xrange? EDIT: I have tested, and I just see minimal differences. A: Enumerate is slightly faster. Tested in Python 3: >>>import pygame >>>pygame.init() >>>clock = pygame.time.Clock() >>...
What is faster for loop using enumerate or for loop using xrange in Python?
What is faster, a for loop using enumerate or using xrange? EDIT: I have tested, and I just see minimal differences.
[ "Enumerate is slightly faster. Tested in Python 3:\n>>>import pygame\n>>>pygame.init()\n>>>clock = pygame.time.Clock()\n>>>a = list(range(100000))\n>>>def do_with_range():\n... clock.tick()\n... k = 0\n... for i in range(len(a)):\n... k += a[i]\n... print(clock.tick())\n>>>def do_with_enumerate()...
[ 8, 6, 0 ]
[]
[]
[ "loops", "python", "xrange" ]
stackoverflow_0004852944_loops_python_xrange.txt
Q: select.select() with regular files Does anybody know if select.select() works with regular files or just with sockets/pipes? I've tried on Solaris, Linux and Mac OS X - it doesn't block on select.select() call. It just explodes my brain, trying something like this with no luck import os import select fds = [ os.o...
select.select() with regular files
Does anybody know if select.select() works with regular files or just with sockets/pipes? I've tried on Solaris, Linux and Mac OS X - it doesn't block on select.select() call. It just explodes my brain, trying something like this with no luck import os import select fds = [ os.open("read.txt", os.O_RDONLY) ] while Tr...
[ "From the documentation:\n\nNote that on Windows, it only works\n for sockets; on other operating\n systems, it also works for other file\n types (in particular, on Unix, it\n works on pipes). It cannot be used on\n regular files to determine whether a\n file has grown since it was last read.\n\nDoes that hel...
[ 2, 1 ]
[]
[]
[ "file_io", "python", "select" ]
stackoverflow_0004853533_file_io_python_select.txt
Q: What's the fastest way to get a random element from a tuple? (python) Can you do better than this basic implementation: import random def get_random_element(_tuple): return _tuple[randint(0, len(_tuple) - 1)] A: >>> import random >>> x = tuple(range(100)) >>> random.choice(x) 8 random.choice @Updated as as...
What's the fastest way to get a random element from a tuple? (python)
Can you do better than this basic implementation: import random def get_random_element(_tuple): return _tuple[randint(0, len(_tuple) - 1)]
[ ">>> import random\n>>> x = tuple(range(100))\n>>> random.choice(x)\n8\n\nrandom.choice\n@Updated as asked by S. Lott:\ndef first(_tuple):\n return _tuple[randint(0, len(_tuple) - 1)]\n\ndef second(_tuple):\n return choice(_tuple)\n\nprint timeit('first(t)', 'from __main__ import first; t = tuple(range(10))')...
[ 15, 4, 2 ]
[]
[]
[ "python", "tuples" ]
stackoverflow_0004854224_python_tuples.txt
Q: Python CouchDB/httplib - error: [Errno 61] Connection refused Did any one get this error? Please advice! There seems to be some problem with httplib python library. Python 2.7 (r27:82508, Jul 3 2010, 20:17:05) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "copyright", "credits" or "license()" for more infor...
Python CouchDB/httplib - error: [Errno 61] Connection refused
Did any one get this error? Please advice! There seems to be some problem with httplib python library. Python 2.7 (r27:82508, Jul 3 2010, 20:17:05) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "copyright", "credits" or "license()" for more information. >>> import couchdb >>> couch = couchdb.Server() >>> couch....
[ "Are you behind a proxy ? check by doing:\npython -c \"import urllib; print urllib.getproxies()\"\n" ]
[ 0 ]
[]
[]
[ "couchdb", "httplib2", "python" ]
stackoverflow_0004802600_couchdb_httplib2_python.txt
Q: How can I highlight text in Scintilla? I am writing an editor using Scintilla. I am already using a lexer to do automatic syntax highlighting but now I would like to mark search results. If I want to mark only one hit I can set the selection there, however, I would like to mark (e.g. with yellow background) all th...
How can I highlight text in Scintilla?
I am writing an editor using Scintilla. I am already using a lexer to do automatic syntax highlighting but now I would like to mark search results. If I want to mark only one hit I can set the selection there, however, I would like to mark (e.g. with yellow background) all the hits. I writing this in Perl but if you ha...
[ "Have you read the Markers reference in Scintilla doc?\nThis reference can be a bit obscure, so I advise to take a look at the source code of SciTE as well. This text editor was originally a testbed for Scintilla. It grown to a full fledged editor, but it is still a good implementation reference for all things Scin...
[ 9, 2, 1 ]
[]
[]
[ "c#", "ide", "perl", "python", "scintilla" ]
stackoverflow_0000092565_c#_ide_perl_python_scintilla.txt