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: Unable to login to admin interface in Django Nonrel As many people, I can't login to Django (Nonrel) admin interface, and the solution other users have given don't work in my situation. I'm running Python 2.7 and Google App Engine 1.6.0. Let's see. I have this in my urls.py: from django.contrib import admin admin....
Unable to login to admin interface in Django Nonrel
As many people, I can't login to Django (Nonrel) admin interface, and the solution other users have given don't work in my situation. I'm running Python 2.7 and Google App Engine 1.6.0. Let's see. I have this in my urls.py: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^$', 'dj...
[ "Alright. I partially solved the problem.\nI downloaded again each file from djangoappengine, however, this time I used the clone link instead of the direct zip files (the ones that have /get/tip.zip). I modified settings.py and urls.py to enable administration. \nAfter that, I was able to log in to the admin inter...
[ 0 ]
[]
[]
[ "django", "google_app_engine", "python" ]
stackoverflow_0008085422_django_google_app_engine_python.txt
Q: A very simple lightweight video editor I want to make an editor that does the following: 1) takes an mp3 audio file 2) Takes a picture --a jpg file 3) Outputs a simple video format e.g. .mov which consists of the jpg file with the mp3 file in the background 4) Does NOTHING else I want to use this as a project to l...
A very simple lightweight video editor
I want to make an editor that does the following: 1) takes an mp3 audio file 2) Takes a picture --a jpg file 3) Outputs a simple video format e.g. .mov which consists of the jpg file with the mp3 file in the background 4) Does NOTHING else I want to use this as a project to learn just the basics of all this stuff howev...
[ "If you want to code such a solution yourself - forget Python, compile ffmpeg and use it's classes directly from your code after you carefully read them (or maybe use pyffmpeg, which still requires you to know ffmpeg internals). \nHowever, I'm pretty sure that what you want could be done with ffmpeg executable alon...
[ 0, 0, 0 ]
[]
[]
[ "codec", "ffmpeg", "media", "python", "video" ]
stackoverflow_0008001016_codec_ffmpeg_media_python_video.txt
Q: transpose/rotate a block of a matrix in python i have a 6x6 matrix as a list of lists in python. The matrix is divided into 4 square blocks of size 3x3. I want a way to take a transpose of only 1 block. I can do it using the traditional method of going through each element and copying it into another array and bac...
transpose/rotate a block of a matrix in python
i have a 6x6 matrix as a list of lists in python. The matrix is divided into 4 square blocks of size 3x3. I want a way to take a transpose of only 1 block. I can do it using the traditional method of going through each element and copying it into another array and back and so on but I want to see if there is a better w...
[ "Building on Sven Marnach's idea to use np.rot90, here is a version which rotates the quadrant clockwise (as requested?). In the key step\nblock3[:] = np.rot90(block3.copy(),-1)\n\na copy() is used on the right-hand side (RHS). Without the copy(), as values are assigned to block3, the underlying data used on the RH...
[ 5, 4, 0, 0 ]
[]
[]
[ "matrix", "python", "transpose" ]
stackoverflow_0008087485_matrix_python_transpose.txt
Q: How can I clean up app.yaml leaving only top page for each script? I need help with my app.yaml and url management. I have the scripts ting.py, searchandler.py and toplawfirms.py. I created ting.py first and I have in app.yaml - url: /.* script: ting.py and all other pages are declared in ting.py. But I think I...
How can I clean up app.yaml leaving only top page for each script?
I need help with my app.yaml and url management. I have the scripts ting.py, searchandler.py and toplawfirms.py. I created ting.py first and I have in app.yaml - url: /.* script: ting.py and all other pages are declared in ting.py. But I think I made a mistake with searchhandler.py and toplawfirms.py by not making t...
[ "The easiest way to do this is to create a single WSGI app in ting.py, and add all the handlers for all your URLs to it. Then delete all but the /.* mapping.\n", "I use handlers from different modules. I just put this at the end of everthing then above I can do whatever else:\n...\n# All other URLs use main.app\n...
[ 1, 0 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0008088295_google_app_engine_python.txt
Q: Basic Python/Beautiful Soup Parsing Say I have used date = r.find('abbr') to get <abbr class="dtstart" title="2012-11-16T00:00:00-05:00">November 16, 2012</abbr> I just want to print November 16, 2012, but if I try print date.string I get AttributeError: 'NoneType' object has no attribute 'string' What am I d...
Basic Python/Beautiful Soup Parsing
Say I have used date = r.find('abbr') to get <abbr class="dtstart" title="2012-11-16T00:00:00-05:00">November 16, 2012</abbr> I just want to print November 16, 2012, but if I try print date.string I get AttributeError: 'NoneType' object has no attribute 'string' What am I doing wrong? ANSWER: Here's my final work...
[ "soup.find('abbr').string should work fine. There must be something wrong with date.\nfrom BeautifulSoup import BeautifulSoup\n\ndoc = '<abbr class=\"dtstart\" title=\"2012-11-16T00:00:00-05:00\">November 16, 2012</abbr>'\n\nsoup = BeautifulSoup(doc)\n\nfor abbr in soup.findAll('abbr'):\n print abbr.string\n\nRe...
[ 2, 0 ]
[]
[]
[ "beautifulsoup", "html", "python" ]
stackoverflow_0008089062_beautifulsoup_html_python.txt
Q: Tkinter event on key release Is there a way to make the <Return> event call on the key release, instead of press? If you use <KeyRelease>, then event.char is blank for any special key, not just return. A: You can explicitly set a binding on the release of the return key by binding to <KeyRelease-Return>. For ex...
Tkinter event on key release
Is there a way to make the <Return> event call on the key release, instead of press? If you use <KeyRelease>, then event.char is blank for any special key, not just return.
[ "You can explicitly set a binding on the release of the return key by binding to <KeyRelease-Return>.\nFor example:\nimport Tkinter as tk\n\nclass SampleApp(tk.Tk):\n def __init__(self, *args, **kwargs):\n tk.Tk.__init__(self, *args, **kwargs)\n self.text = tk.Text(self)\n self.text.pack()\n...
[ 11, 3 ]
[]
[]
[ "python", "tk_toolkit", "tkinter" ]
stackoverflow_0008082277_python_tk_toolkit_tkinter.txt
Q: Where does numpy.ndarray's iterable behavior come from? numpy's ndarray class is defined as class ndarray(__builtin__.objects) From what I can gather, __builtin__.objects is not an iterable type? For this reason I find this behavior surprising: Arr = numpy.array('As Far As I Know'.split()) => array(['As', 'Far', ...
Where does numpy.ndarray's iterable behavior come from?
numpy's ndarray class is defined as class ndarray(__builtin__.objects) From what I can gather, __builtin__.objects is not an iterable type? For this reason I find this behavior surprising: Arr = numpy.array('As Far As I Know'.split()) => array(['As', 'Far', 'As', 'I', 'Know'], dtype='|S4') print map(lambda x: x[0],Arr...
[ "numpy.ndarray defines __iter__(), which the usual (and only) mechanism to make instances of a type iterable. Note that numpy.ndarray is a C extension type, but this doesn't matter for the question why it is iterable. Both, types you define in Python and C extension types can be made iterable by defining __iter__...
[ 7 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0008089475_numpy_python.txt
Q: Inheritance and base class method call python I would like a method in a base class to call another method in the same class instead of the overriding method in an inherited class. I would like the following code to print out Class B: 6 Class A: 9 Can this be done? # Base class definition class ClassA(object): ...
Inheritance and base class method call python
I would like a method in a base class to call another method in the same class instead of the overriding method in an inherited class. I would like the following code to print out Class B: 6 Class A: 9 Can this be done? # Base class definition class ClassA(object): def __init__(self): print("Initializing ...
[ "Congratulations, you've discovered the motivating use case for Python's double-underscore name mangling :-)\nFor the details and a worked-out example see: http://docs.python.org/tutorial/classes.html#private-variables and at http://docs.python.org/reference/expressions.html#atom-identifiers .\nHere's how to use it...
[ 50, -5 ]
[]
[]
[ "inheritance", "python" ]
stackoverflow_0007841812_inheritance_python.txt
Q: How do I change the default Python version in my Mac Snow Leopard? How do I change the default Python version used in my Mac Snow Leopard? I'm trying to switch from v2.5 to v3.0 A: Is is not recommended to change the system Python installation on any system without any need. Better install Python 3.X in a differ...
How do I change the default Python version in my Mac Snow Leopard?
How do I change the default Python version used in my Mac Snow Leopard? I'm trying to switch from v2.5 to v3.0
[ "Is is not recommended to change the system Python installation on any system without any need.\nBetter install Python 3.X in a different location and adjust your $PATH as needed. The Python installation may be needed for further functionality under the hood. So leave it as it is and install arbitrary Python interp...
[ 3, 2, 1, 1, 0 ]
[]
[]
[ "macos", "python" ]
stackoverflow_0005752753_macos_python.txt
Q: Why is this python script slowly chewing up my RAM? This script slowly eats my RAM. When I run it, I can see the RAM usage of Python creep up by approx 1mb with each loop, but I can't figure out why. I have figured out that it is the iteration of the query that adds the RAM, but that's all I can figure out. Any...
Why is this python script slowly chewing up my RAM?
This script slowly eats my RAM. When I run it, I can see the RAM usage of Python creep up by approx 1mb with each loop, but I can't figure out why. I have figured out that it is the iteration of the query that adds the RAM, but that's all I can figure out. Any help would be awesome. from haystack.pmod import piliPla...
[ "After stripping it right back, and chatting to a guy on the SA IRC channel, it appeared to be a Mac OSX only problem. So I set it up on Linux but the same thing occured. In the end, I resorted to running the script on a crontab. Works fine now.\nM\n", "You might want to see if mdb is slowly getting larger as ...
[ 2, 0, 0 ]
[]
[]
[ "pymongo", "python", "sqlalchemy" ]
stackoverflow_0008087663_pymongo_python_sqlalchemy.txt
Q: using tor with scrapy framework I am trying to crawl website, which is sophisticated enough to stop bots, I mean it is permitting only a few requests, after that Scrapy hangs. Question 1: is there a way, if Scrapy hangs I can restart my crawling process from the same point. To get rid of this problem, I wrote my s...
using tor with scrapy framework
I am trying to crawl website, which is sophisticated enough to stop bots, I mean it is permitting only a few requests, after that Scrapy hangs. Question 1: is there a way, if Scrapy hangs I can restart my crawling process from the same point. To get rid of this problem, I wrote my settings file like this BOT_NAME = 'MO...
[ "TOR by itself is not an http proxy, the port 8118 and the connection refused error suggest that you don't have privoxy[1] running properly. Try setting up privoxy correctly and then try again using the environment variable http_proxy=http://localhost:8118.\nI have done crawling through TOR using privoxy with scrap...
[ 4 ]
[]
[]
[ "python", "scrapy", "tor" ]
stackoverflow_0008084423_python_scrapy_tor.txt
Q: scrapy xpath help needed I'm new to xpath so please bear with me. Currently, I'm looking to use scrapy to scrape some content off some webpages, and the content looks something like this: <td colspan="3" valign="top" class="regular">Landsize: 84,000sq with an extensive shoreline 750m<br /> <br /> Call Or Emai...
scrapy xpath help needed
I'm new to xpath so please bear with me. Currently, I'm looking to use scrapy to scrape some content off some webpages, and the content looks something like this: <td colspan="3" valign="top" class="regular">Landsize: 84,000sq with an extensive shoreline 750m<br /> <br /> Call Or Email for more info<br /> . Full-...
[ "Judging from your commentto Evan's correct answer, you want to skip the NLs.\nIn this case, try:\nnormalize-space(//tr[contains(td,\"Description\")]/following-sibling::tr[1]/td)\n\nNote:\n\nIf the argument to normalize-space() selects more than one node, this function will return the result of processing only the ...
[ 3, 0, 0 ]
[]
[]
[ "python", "scrapy", "xpath" ]
stackoverflow_0008084484_python_scrapy_xpath.txt
Q: What's the fastest way to strip certain html tags in a Python string? I'd like to strip all html / javascript except for: <b></b> <ul></ul> <li></li> <a></a> Thanks. A: Do you want a way that's fast or a way that's correct? A regex-based approach is unlikely to be correct and may open you up to XSS attacks. You...
What's the fastest way to strip certain html tags in a Python string?
I'd like to strip all html / javascript except for: <b></b> <ul></ul> <li></li> <a></a> Thanks.
[ "Do you want a way that's fast or a way that's correct? A regex-based approach is unlikely to be correct and may open you up to XSS attacks.\nYou should use an HTML parser like Beautiful Soup or even htmllib.\nAlso, <a> can contain javascript: hrefs and there are also the various on* attributes which are javascript...
[ 4, 2, 0 ]
[]
[]
[ "html_parsing", "python" ]
stackoverflow_0004419532_html_parsing_python.txt
Q: YouTube Average Rating in Python How can I call the gd:rating XML file using the Python YouTube GData API? I have the YouTube video_id as a variable and I know it's possible to return this: <gd:rating average='4.553648' max='5' min='1' numRaters='233' rel='http://schemas.google.com/g/2005#overall'/> I just can't ...
YouTube Average Rating in Python
How can I call the gd:rating XML file using the Python YouTube GData API? I have the YouTube video_id as a variable and I know it's possible to return this: <gd:rating average='4.553648' max='5' min='1' numRaters='233' rel='http://schemas.google.com/g/2005#overall'/> I just can't figure out how to do it in Python.
[ "In your previous question you've already demonstrated the code that retrieves an entry given a video_id.\nRun python:\n>>> from gdata.youtube.service import YouTubeService\n>>> yt = YouTubeService()\n>>> entry = yt.GetYouTubeVideoEntry(video_id='pP9VjGmmhfo')\n>>> entry.rating\n<gdata.youtube.Rating object at 0x27...
[ 1 ]
[]
[]
[ "python", "youtube", "youtube_api" ]
stackoverflow_0008088304_python_youtube_youtube_api.txt
Q: If x is a value in this dict I want to do this: d = {1: 2, 3: 4} if 4 in d: print('Aha!') but I want to read from the values and not the keys. What's the Pythonic way to do this? A: Use values1: d = {1: 2, 3: 4} if 4 in d.values(): print('Aha!') Note that this will be much slower than a key lookup beca...
If x is a value in this dict
I want to do this: d = {1: 2, 3: 4} if 4 in d: print('Aha!') but I want to read from the values and not the keys. What's the Pythonic way to do this?
[ "Use values1:\nd = {1: 2, 3: 4}\nif 4 in d.values():\n print('Aha!')\n\nNote that this will be much slower than a key lookup because it will potentially require inspecting all values in the dictionary. If you need to perform this operation often you might want to consider storing the values in a set.\n\n1iterval...
[ 7, 3 ]
[]
[]
[ "dictionary", "python" ]
stackoverflow_0008090391_dictionary_python.txt
Q: Reassign multiple records to record array? I want to apply a transformation to certain columns of a record array and reassign these values. What is the canonical way to do this? List = [['a',.3,.3], ['b',-.5,.4]] Arr = np.rec.fromrecords(List,names=['id','var1','var2']) And I want to apply some scaling t...
Reassign multiple records to record array?
I want to apply a transformation to certain columns of a record array and reassign these values. What is the canonical way to do this? List = [['a',.3,.3], ['b',-.5,.4]] Arr = np.rec.fromrecords(List,names=['id','var1','var2']) And I want to apply some scaling to some variables. I'll let this be an example bu...
[ "Why don't you scale variables one by one?\nIn [13]: %paste\nimport numpy as np\n\nList = [['a',.3,.3],\n ['b',-.5,.4]]\n\nscale = lambda x: x - x.mean()\nArr = np.rec.fromrecords(List,names=['id','var1','var2'])\n\nvars_to_scale = ['var1', 'var2']\nfor var in vars_to_scale:\n Arr[var] = scale(Arr[var])\n...
[ 1 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0008089401_numpy_python.txt
Q: My hot-deploying (toy) server: need your design inputs (homework) from multiprocessing import Process a=Process(target=worker, args=()) a.start() I am making a multiple worker-process app (don't laugh yet) in which each worker can gracefully reload. Whenever the code is updated, new requests are served by ne...
My hot-deploying (toy) server: need your design inputs (homework)
from multiprocessing import Process a=Process(target=worker, args=()) a.start() I am making a multiple worker-process app (don't laugh yet) in which each worker can gracefully reload. Whenever the code is updated, new requests are served by new worker processes with the new code. This is such that A newly launch...
[ "Reloading code in python is a notoriously difficult problem.\nHere's how I would deal with it:\n\nat server startup, listen on your HTTP port (but do not start accepting connections)\nUse multiprocessing or some such to create some worker processes; this should happen after the socket starts listening so that the...
[ 2, 1 ]
[]
[]
[ "python", "zeromq" ]
stackoverflow_0007598857_python_zeromq.txt
Q: Inconsistent file behavior I'm trying to track down a Python UnicodeDecodeError in the following log line: 10.210.141.123 - - [09/Nov/2011:14:41:04 -0800] "gfR\x15¢\x09ì|Äbk\x0F[×ÐÖà\x11CEÐÌy\x5C¿DÌj\x08Ï ®At\x07å!;f>\x08éPW¤\x1C\x02ö*6+\x5C\x15{,ªIkCRA\x22 xþP9â\x13h\x01­¢è´\x1DzõWiË\x5C\x10sòʨR)¶²\x1F8äl¾¢{ÆNw\...
Inconsistent file behavior
I'm trying to track down a Python UnicodeDecodeError in the following log line: 10.210.141.123 - - [09/Nov/2011:14:41:04 -0800] "gfR\x15¢\x09ì|Äbk\x0F[×ÐÖà\x11CEÐÌy\x5C¿DÌj\x08Ï ®At\x07å!;f>\x08éPW¤\x1C\x02ö*6+\x5C\x15{,ªIkCRA\x22 xþP9â\x13h\x01­¢è´\x1DzõWiË\x5C\x10sòʨR)¶²\x1F8äl¾¢{ÆNw\x08÷@ï" 400 166 0.000 "-" "-" I...
[ "Your question: How can I track this down?\nAnswer:\n(1) Show us the full text of the error message that you got -- without knowing what encoding that you were trying to use, we can't tell you anything. A traceback and a snippet of code that reads the file and reproduces the error would also be handy.\n(2) Write a...
[ 1 ]
[]
[]
[ "file_encodings", "python", "unicode" ]
stackoverflow_0008089878_file_encodings_python_unicode.txt
Q: SQLAlchemy Recursion I'm having a great time learning Python, but I've just gotten a bit stuck on trying to incorporate a recursive function into SQLAlchemy. Essentially, have a function which creates a instance of a class to be put in the database. Inside this function, I get user input on whether the instance...
SQLAlchemy Recursion
I'm having a great time learning Python, but I've just gotten a bit stuck on trying to incorporate a recursive function into SQLAlchemy. Essentially, have a function which creates a instance of a class to be put in the database. Inside this function, I get user input on whether the instance has a parent class (defin...
[ "I think you have couple of bugs/typos which make your code not work. I assume that you created a small code sample to show the issue, and I hope that once you fix those in the original code, you problem will be solved as well:\n\ninstead of newIng.parentIng = parentIngObj you should have newIng.parent = parentIngO...
[ 3, 0 ]
[]
[]
[ "python", "recursion", "sqlalchemy" ]
stackoverflow_0008062157_python_recursion_sqlalchemy.txt
Q: Python : How `len()` is executed Possible Duplicate: Cost of len() function How Python calculates length of a list(using len() function )?Does it go through a for or while loop to do the same or it has some internal variable that stores the length of the list ? A: Yes, CPython lists have an internal variable f...
Python : How `len()` is executed
Possible Duplicate: Cost of len() function How Python calculates length of a list(using len() function )?Does it go through a for or while loop to do the same or it has some internal variable that stores the length of the list ?
[ "Yes, CPython lists have an internal variable for the length.\nIt's called ob_size; all variable-sized objects have it.\n", "It uses an internal variable that stores the length of the list (as do all other variable-length object types in Python). So len() is an O(1) operation regardless of the size of the list (i...
[ 5, 5, 4, 3 ]
[]
[]
[ "python" ]
stackoverflow_0008091641_python.txt
Q: Dictionary works for len(string) multiple of 3. Function deletes remainders but now doesn't translate with dictionary. Python 2.7.1 I made a function with a dictionary. The purpose of the function is to separate the input string into sets of 3 . If the input string value is not a multiple of 3, I want to delete t...
Dictionary works for len(string) multiple of 3. Function deletes remainders but now doesn't translate with dictionary. Python 2.7.1
I made a function with a dictionary. The purpose of the function is to separate the input string into sets of 3 . If the input string value is not a multiple of 3, I want to delete the remainder [1 or 2] my function was working perfectly until I added the part for deleting the remainders def func(fx): d={'AAA':1,'...
[ "You are returning fx when you probably should be reassigning it\ndef func(fx):\n d={'AAA':1,'BBB':2,'CCC':3}\n length=len(fx)\n if length % 3 == 0:\n pass\n elif length % 3 == 1:\n fx = fx[:-1]\n elif length % 3 == 2:\n fx = fx[:-2]\n Fx=fx.upper()\n Fx3=[Fx[i:i+3] for i i...
[ 1, 0, 0 ]
[]
[]
[ "function", "python", "split", "string" ]
stackoverflow_0008090203_function_python_split_string.txt
Q: How do I avoid inserting duplicate data in PostgreSQL? How to avoid inserting duplicate data? I only want to insert data that does not already exist. I have written following queries but its not working properly. I'm using PostgreSQL. title_exits = cursor.execute ("SELECT title,pageid FROM movie_movie WHERE title ...
How do I avoid inserting duplicate data in PostgreSQL?
How to avoid inserting duplicate data? I only want to insert data that does not already exist. I have written following queries but its not working properly. I'm using PostgreSQL. title_exits = cursor.execute ("SELECT title,pageid FROM movie_movie WHERE title = %s AND pageid = %s;",(title,pageid)) if title_exits ==...
[ "Try to define title field as unique(must define as varchar(constant_length)). Then try insert title into database if title exists, db return error else will insert\n", "As I suspected (and @tony points out) cursor.execute does not return the number of rows. It always return None.\n", "Answer related to your up...
[ 0, 0, 0 ]
[]
[]
[ "postgresql", "python" ]
stackoverflow_0008091211_postgresql_python.txt
Q: PyQT + Django system architecture. Is Python a good way? I need to create 2 level web-system. I choose Python as my tool. I want use PyQt to develop 1st level: TCP/IP-server, and Django as 2nd level: Data visualization through Ajax(Front-End). System sketch on picture: http://i.stack.imgur.com/pprv9.jpg 1st level...
PyQT + Django system architecture. Is Python a good way?
I need to create 2 level web-system. I choose Python as my tool. I want use PyQt to develop 1st level: TCP/IP-server, and Django as 2nd level: Data visualization through Ajax(Front-End). System sketch on picture: http://i.stack.imgur.com/pprv9.jpg 1st level will "chat" with about 1000 objects. And web-app with about 2...
[ "While PyQt's networking module provides tools for writing TCP servers, I'm not sure you really need that dependency, since TCP servers can be written just in Python using only the standard library, and in fact Python already comes with a simple HTTP server built-in (and so does Django, by the way).\nI have nothing...
[ 4 ]
[]
[]
[ "django", "pyqt", "python", "web_applications" ]
stackoverflow_0008092035_django_pyqt_python_web_applications.txt
Q: How to Write a valid Class Decorator in Python? I just wrote a class decorator like below, tried to add debug support for every method in the target class: import unittest import inspect def Debug(targetCls): for name, func in inspect.getmembers(targetCls, inspect.ismethod): def wrapper(*args, **kwargs):...
How to Write a valid Class Decorator in Python?
I just wrote a class decorator like below, tried to add debug support for every method in the target class: import unittest import inspect def Debug(targetCls): for name, func in inspect.getmembers(targetCls, inspect.ismethod): def wrapper(*args, **kwargs): print ("Start debug support for %s.%s()" % ...
[ "Consider this loop:\nfor name, func in inspect.getmembers(targetCls, inspect.ismethod):\n def wrapper(*args, **kwargs):\n print (\"Start debug support for %s.%s()\" % (targetCls.__name__, name))\n\nWhen wrapper is eventually called, it looks up the value of name. Not finding it in locals(), it lo...
[ 3, 0, 0 ]
[]
[]
[ "class", "closures", "decorator", "python", "scope" ]
stackoverflow_0008091948_class_closures_decorator_python_scope.txt
Q: Customizing the Django User admin I have a Django application where users have additional data. That data is collected in a Profile model with a OneToOneField pointing to User. This is fine and works perfectly for most purposes, but I have trouble customizing the admin for User. In particular: I would like to be ...
Customizing the Django User admin
I have a Django application where users have additional data. That data is collected in a Profile model with a OneToOneField pointing to User. This is fine and works perfectly for most purposes, but I have trouble customizing the admin for User. In particular: I would like to be able to show a Profile field inside lis...
[ "You only have to edit the admin classes in admin.py. You can use admin.inline* class to help you. Example from Django website that will add Book to the Author's admin page:\nclass BookInline(admin.TabularInline):\n model = Book\n\nclass AuthorAdmin(admin.ModelAdmin):\n inlines = [\n BookInline,\n ]...
[ 1, 0 ]
[]
[]
[ "django", "django_admin", "django_models", "python" ]
stackoverflow_0008092254_django_django_admin_django_models_python.txt
Q: 404 on requests without trailing slash to i18n urls Because of the APPEND_SLASH = True setting all requests with "/whatever/path" will be redirected to "/whatever/path/". BUT urls definded within a i18n_patterns() don't redirect for some reason even the test works: ./runtests.py --settings=test_sqlite i18n.URLRedi...
404 on requests without trailing slash to i18n urls
Because of the APPEND_SLASH = True setting all requests with "/whatever/path" will be redirected to "/whatever/path/". BUT urls definded within a i18n_patterns() don't redirect for some reason even the test works: ./runtests.py --settings=test_sqlite i18n.URLRedirectWithoutTrailingSlashTests
[ "it doesn't work properly if the middleware's aren't in order.\nsee:\nhttps://docs.djangoproject.com/en/1.5/topics/i18n/translation/#how-django-discovers-language-preference\nthat's how it should look like:\nMIDDLEWARE_CLASSES = (\n 'django.contrib.sessions.middleware.SessionMiddleware',\n 'django.middleware.lo...
[ 20 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008092695_django_python.txt
Q: Empty declarator error when cythoning a class? I am trying to compile the following .pyx file using Cython: import collections nil = object() # used to distinguish from None class TrieNode(object): __slots__ = ['char', 'output', 'fail', 'children'] def __init__(self, char): self.char = char ...
Empty declarator error when cythoning a class?
I am trying to compile the following .pyx file using Cython: import collections nil = object() # used to distinguish from None class TrieNode(object): __slots__ = ['char', 'output', 'fail', 'children'] def __init__(self, char): self.char = char self.output = nil self.fail = nil ...
[ "In your __init__ method, you have a variable named char. If you Cythonize a .py module this is fine. However, in a Cython .pyx file, even Python def functions can have C type declarations in the parameters.\n" ]
[ 7 ]
[]
[]
[ "compiler_construction", "compiler_errors", "cython", "python" ]
stackoverflow_0008089412_compiler_construction_compiler_errors_cython_python.txt
Q: style, formatting the slice operator PEP 8 doesn't mention the slice operator. From my understanding, unlike other operators, it should not be surrounded with whitespace spam[3:5] # OK spam[3 : 5] # NOT OK Does this hold when using complex expressions, that is, which one is considered better style 1. spam...
style, formatting the slice operator
PEP 8 doesn't mention the slice operator. From my understanding, unlike other operators, it should not be surrounded with whitespace spam[3:5] # OK spam[3 : 5] # NOT OK Does this hold when using complex expressions, that is, which one is considered better style 1. spam[ham(66)//3:44+eggs()] 2. spam[ham(66...
[ "As you already mentioned, PEP8 doesn't explicitly mention the slice operator in that format, but spam[3:5] is definitely more common and IMHO more readable.\nIf pep8 checker is anything to go by, the space before : will be flagged up\n[me@home]$ pep8 <(echo \"spam[3:44]\") # no warnings\n[me@home]$ pep8 <(echo...
[ 12, 4, 3 ]
[]
[]
[ "coding_style", "python" ]
stackoverflow_0008092513_coding_style_python.txt
Q: Extracting information from AJAX based sites using Python I am trying to retrieve query results on sites based on ajax like www.snapbird.org using Python. Since it doesn't show in the page source, I am not sure how to proceed. I am a Python newbie and hence it would be great if I could get a pointer in the right d...
Extracting information from AJAX based sites using Python
I am trying to retrieve query results on sites based on ajax like www.snapbird.org using Python. Since it doesn't show in the page source, I am not sure how to proceed. I am a Python newbie and hence it would be great if I could get a pointer in the right direction. I am also open to some other approach to the task if...
[ "This is going to be complex but as a start, ppen firebug and find the URL that gets called when the AJAX request is handled. You can call that directly in your Python program and parse the output. \n", "You could use Selenium's Python client driver to parse the page source. I usually use this in conjunction with...
[ 0, 0, 0, 0 ]
[]
[]
[ "ajax", "data_mining", "python" ]
stackoverflow_0008084707_ajax_data_mining_python.txt
Q: How can I get a window's icon name in Xorg? I am attempting to get a window's icon name with python, for use in a pyclutter-based taskbar. I have gotten the XID via wnck, but wnck seems to only be capable of giving me a gtk.gdk.Pixbuf, which is not useful for clutter. I am sure there is some way to do this with py...
How can I get a window's icon name in Xorg?
I am attempting to get a window's icon name with python, for use in a pyclutter-based taskbar. I have gotten the XID via wnck, but wnck seems to only be capable of giving me a gtk.gdk.Pixbuf, which is not useful for clutter. I am sure there is some way to do this with python-xlib or python-xcb, I just can't find it :-)...
[ "you can use a gdk.Pixbuf to get the icon data and assign it to a clutter.Texture - the C version is:\n\nclutter_texture_set_from_rgb_data (texture,\n gdk_pixbuf_get_pixels (pixbuf),\n gdk_pixbuf_get_has_alpha (pixbuf),\n ...
[ 1 ]
[]
[]
[ "clutter", "python", "wnck", "xcb", "xlib" ]
stackoverflow_0008088258_clutter_python_wnck_xcb_xlib.txt
Q: A very simple for loop Why does this: for i in reader: for j in empsTbl: if i[0] == j.inmptl_wiw_userid: print "Match" print over 500 results And this: for i in empsTbl: for j in reader: if j[0] == i.inmptl_wiw_userid: print "Match" print n...
A very simple for loop
Why does this: for i in reader: for j in empsTbl: if i[0] == j.inmptl_wiw_userid: print "Match" print over 500 results And this: for i in empsTbl: for j in reader: if j[0] == i.inmptl_wiw_userid: print "Match" print no results?
[ "Looks like your reader is a generator, that can be read only once. Maybe a file reader?\nIn the first case you read it only once and compare each value to all elements of empsTbl, which is apparently a list (or tuple or set or dict, i.e. can be read as much as you want).\nIn the second case, you read it completely...
[ 8, 0, 0 ]
[]
[]
[ "for_loop", "python" ]
stackoverflow_0008093745_for_loop_python.txt
Q: Python Variables and Strings I need to know if a variable in Python is a string(name) or a number. I want to check out the degree of graphs, however I need to know if "i" iterator, is a number inside of the string or a name inside of the string, showing the degree of graphs at the end. Is there something wrong in ...
Python Variables and Strings
I need to know if a variable in Python is a string(name) or a number. I want to check out the degree of graphs, however I need to know if "i" iterator, is a number inside of the string or a name inside of the string, showing the degree of graphs at the end. Is there something wrong in this code? import csv, sys import ...
[ "They must be strings since \",\".join(i) would have returned a TypeError if i were an int.\nBut, in general, to find out the type of a variable, use type:\nprint(type(i))\n\n", "I hope this helps\n>>> s = 'hello'\n>>> type(s)\n<type 'str'>\n>>> type(s) is str\nTrue\n>>> n = 6\n>>> type(n)\n<type 'int'>\n>>> type...
[ 2, 1 ]
[]
[]
[ "python", "types" ]
stackoverflow_0008094032_python_types.txt
Q: Ways to manage DB migrations with SQLAlchemy? I've looked at sqlalchemy-migrate, but it just seems like a lot of work and I haven't been able to find any useful examples. Anyone care to share how they handle this? A: Check out new project Alembic: http://readthedocs.org/docs/alembic/en/latest/index.html A: I ...
Ways to manage DB migrations with SQLAlchemy?
I've looked at sqlalchemy-migrate, but it just seems like a lot of work and I haven't been able to find any useful examples. Anyone care to share how they handle this?
[ "Check out new project Alembic: http://readthedocs.org/docs/alembic/en/latest/index.html\n", "I don't have any personal experience with sqlalchemy-migrate, but here's a tutorial:\nhttp://caneypuggies.alwaysreformed.com/wiki/DevelopingWithMigrations\nIf you use the scripts mentioned there, you can create migration...
[ 18, 1 ]
[]
[]
[ "database_migration", "python", "sqlalchemy" ]
stackoverflow_0005293669_database_migration_python_sqlalchemy.txt
Q: Python Minidom : Change Value of Node I'm using Python's minidom library to try and manipulate some XML files. Here is an example file : <document> <item> <link>http://www.this-is-a-url.com/</link> <description>This is some information!</description> </item> <item> ...
Python Minidom : Change Value of Node
I'm using Python's minidom library to try and manipulate some XML files. Here is an example file : <document> <item> <link>http://www.this-is-a-url.com/</link> <description>This is some information!</description> </item> <item> <link>http://www.this-is-a-url.com/</link> ...
[ "I'm not sure you can modify the DOM in place with xml.dom.minidom (creating the whole document from scratch with new values should work though).\nAnyway, if you accept a solution based on xml.etree.ElementTree (I strongly recommend using it since it provides a friendlier interface), then you could use the followin...
[ 5 ]
[]
[]
[ "minidom", "python", "xml" ]
stackoverflow_0008076928_minidom_python_xml.txt
Q: Convert path to polygon I'm trying to figure if a point is in a SVG path using Python. The algorithm that I'll use is the raycasting algorithm. But for this algorithm i need to have the polygon sides, but all I have is the the pathdata for the svg path: <path d="m 362.26878,978.51017 c 20.15947,-20.15479 23.082...
Convert path to polygon
I'm trying to figure if a point is in a SVG path using Python. The algorithm that I'll use is the raycasting algorithm. But for this algorithm i need to have the polygon sides, but all I have is the the pathdata for the svg path: <path d="m 362.26878,978.51017 c 20.15947,-20.15479 23.0826,-25.35876 20.51836,...
[ "You can convert a path into a polygon as shown in my example here:\nhttp://phrogz.net/svg/convert_path_to_polygon.xhtml\nThe simpler algorithm from that page (in JavaScript) is:\nfunction polygonSampledFromPath(path,samples){\n var doc = path.ownerDocument;\n var poly = doc.createElementNS('http://www.w3.org/200...
[ 5 ]
[]
[]
[ "python", "raycasting", "svg" ]
stackoverflow_0008091983_python_raycasting_svg.txt
Q: how to read japanese characters from request? I have the below url which is already encoded to pass japanese characters into browser's URL address bar. http://localhost:8000/service/social/acc?auth=true&body=%7B%22site%22%3A%22twitter%22%2C%22account%22%3A% 22twitter_1%22%2C%22name%22%3A%22%93X%95%DC1%22%7D I can...
how to read japanese characters from request?
I have the below url which is already encoded to pass japanese characters into browser's URL address bar. http://localhost:8000/service/social/acc?auth=true&body=%7B%22site%22%3A%22twitter%22%2C%22account%22%3A% 22twitter_1%22%2C%22name%22%3A%22%93X%95%DC1%22%7D I can get the value from request but it is garbled or ga...
[ "I try this. '店舗' means 'shop' in Japanese. \n>In [1]: from urlparse import *\n>\n>In [2]: url = urlparse('http://localhost:8000/service/social/acc?auth=true&body=%7B%22site%22%3A%22twitter%22%2C%22account%22%3A%22twitter_1%22%2C%22name%22%3A%22%93X%95%DC1%22%7D')\n>\n>In [3]: url\n>Out[3]: ParseResult(scheme='htt...
[ 3, 1 ]
[]
[]
[ "django", "geodjango", "python", "request", "unicode" ]
stackoverflow_0008093135_django_geodjango_python_request_unicode.txt
Q: pyqt designer and layout for central widget I started new clear Main Window project, There are 4 Objects: MainWindow, centralWidget, menubar, and statusbar. I need to set default layout inside the window, so probably for centralWidget. But I didnt found way how to do it. I can get LayoutWidget with some particular...
pyqt designer and layout for central widget
I started new clear Main Window project, There are 4 Objects: MainWindow, centralWidget, menubar, and statusbar. I need to set default layout inside the window, so probably for centralWidget. But I didnt found way how to do it. I can get LayoutWidget with some particular size into centralWidget. But I want to set layou...
[ "Right click anywhere within your centralWidget go to the Lay Out sub menu and select the Layout you want. This will be applied automatically to all contents of your centralWidget. \nIn order to see how it works place inside it 2 or 3 push buttons and try changing the layouts. \n", "Add some widgets to the centra...
[ 3, 1 ]
[]
[]
[ "layout", "pyqt", "python", "qt", "qt_designer" ]
stackoverflow_0008095062_layout_pyqt_python_qt_qt_designer.txt
Q: ctypes.windll.shell32.IsUserAdmin() not returning 1 when user is in admins group I am trying to use ctypes.windll.shell32.IsUserAdmin() to determine if the running process was started by a user in the Admins group, but I am getting inconsistent / incorrect results. On a windows 7 professional install, when logging...
ctypes.windll.shell32.IsUserAdmin() not returning 1 when user is in admins group
I am trying to use ctypes.windll.shell32.IsUserAdmin() to determine if the running process was started by a user in the Admins group, but I am getting inconsistent / incorrect results. On a windows 7 professional install, when logging in as a user that is not Administrator but is a memebr of the administrators group, I...
[ "This is UAC. If you run elevated, you will see the behaviour you expect. But with a standard token under UAC your user doesn't have administrator rights, even when in the admin group.\nFor the special Administrator user account, UAC does not apply and processes under that special user are always given a privileged...
[ 11 ]
[]
[]
[ "administrator", "ctypes", "python", "windows" ]
stackoverflow_0008095187_administrator_ctypes_python_windows.txt
Q: How to output the running path instead of the location path? I have the following: % more a.py import os os.system('pwd') % python a.py /Users/yl/test/f % cd .. % python ./f/a.py /Users/yl/test Basically I want the last output to be "/Users/yl/test/f", which is the path where the script is located (not wher...
How to output the running path instead of the location path?
I have the following: % more a.py import os os.system('pwd') % python a.py /Users/yl/test/f % cd .. % python ./f/a.py /Users/yl/test Basically I want the last output to be "/Users/yl/test/f", which is the path where the script is located (not where python was invoked). Have played around but didn't find a good s...
[ "import os\napp_dir = os.path.dirname(__file__)\nprint(app_dir)\n\n", "import os\nprint (os.path.dirname(os.path.abspath(__file__)))\n\n" ]
[ 2, 2 ]
[]
[]
[ "python" ]
stackoverflow_0008095431_python.txt
Q: How to use gaesessions in google-app-engine I'm new to Python (as well as GAE), I'm trying to include gaesessions in my application, this is exactly what I did: I copied the gaesessions folder to my src folder (the folder includes __init__.py file) and added this to my working code: from gaesessions import get_cur...
How to use gaesessions in google-app-engine
I'm new to Python (as well as GAE), I'm trying to include gaesessions in my application, this is exactly what I did: I copied the gaesessions folder to my src folder (the folder includes __init__.py file) and added this to my working code: from gaesessions import get_current_session session = get_current_session() I ...
[ "You've omitted the actual exception from your stack trace, but I'm guessing it's this:\n\nAttributeError: 'local' object has no attribute 'current_session'\n\nIf so, you've most likely skipped the middleware configuration step. Create an appengine_config.py per the instructions and restart the dev server; this sho...
[ 7 ]
[]
[]
[ "google_app_engine", "python", "session" ]
stackoverflow_0008095426_google_app_engine_python_session.txt
Q: Jython Swing: Passing more than self and event on a button press I'm creating a couple of swing JButtons buttons in a loop in Jython. On press, each button should call the same function, but with one different parameter. I'm having trouble passing any parameters outside of self, and event. This works: for x in ra...
Jython Swing: Passing more than self and event on a button press
I'm creating a couple of swing JButtons buttons in a loop in Jython. On press, each button should call the same function, but with one different parameter. I'm having trouble passing any parameters outside of self, and event. This works: for x in range(0,3): name = JButton(str(x)) name.actionPerformed = self.f...
[ "A callback only takes what the code calling it (the GUI toolkit) passes in. If you want to pass in more and you can't convince said caller to pass on something extra, you're out of luck.\nBut luckily, there's a loophole: You can pass arbitrary callables, and you can construct partial functions, which are functions...
[ 4, 1 ]
[]
[]
[ "jython", "python", "swing" ]
stackoverflow_0008084679_jython_python_swing.txt
Q: Getting the name of a checkbox submitted by GET So I'm trying to use the CGI module that comes with Python, on a Python Server Page. I want to know if there is any way to pull the name of the checkbox, when it is submitted. I don't actually need to know the status of whether it is on or off (because off won't subm...
Getting the name of a checkbox submitted by GET
So I'm trying to use the CGI module that comes with Python, on a Python Server Page. I want to know if there is any way to pull the name of the checkbox, when it is submitted. I don't actually need to know the status of whether it is on or off (because off won't submit to the new page), just what the name is, because t...
[ "cgi.FieldStorage() returns a dictionary containing the parameters of the request.\n" ]
[ 1 ]
[]
[]
[ "get", "html", "python" ]
stackoverflow_0008095851_get_html_python.txt
Q: form object has no attribute 'cleaned_data' I am trying to generate a form using django documentation. I am continously getting the error: 'TestForm' object has no attribute 'cleaned_data' even though form.is_valid is True (it prints the 'form is valid' line of my code). Following are the relevant portions of my...
form object has no attribute 'cleaned_data'
I am trying to generate a form using django documentation. I am continously getting the error: 'TestForm' object has no attribute 'cleaned_data' even though form.is_valid is True (it prints the 'form is valid' line of my code). Following are the relevant portions of my code. urls.py url(r'^test/',views.test), forms....
[ "You are not triggering the cleaning and validation of the form, this is made by calling the is_valid() method (note the parentheses () ), that's why you have no cleaned data.\nCorrection:\nif request.method == 'POST':\n form = TestForm(request.POST)\n if form.is_valid():\n print 'form is valid'\n ...
[ 51 ]
[]
[]
[ "django_forms", "django_templates", "django_views", "python" ]
stackoverflow_0008090891_django_forms_django_templates_django_views_python.txt
Q: Broken pipe error in Django Nonrel when loading localhost Running Django Nonrel, with Google App Engine 2.6.0 and Python 2.7, I'm getting this exception when trying to load for the first time localhost and localhost/admin (I expect it will happen with any page, though): Exception happened during processing of requ...
Broken pipe error in Django Nonrel when loading localhost
Running Django Nonrel, with Google App Engine 2.6.0 and Python 2.7, I'm getting this exception when trying to load for the first time localhost and localhost/admin (I expect it will happen with any page, though): Exception happened during processing of request from ('127.0.0.1', 57011) Traceback (most recent call l...
[ "There have been a few similar reports of race condition issues between Chrome and dev_appserver.py. The usual story is that Chrome opens multiple concurrent connections to the server, but sends a request on the second connection first. Because dev_appserver is single-threaded, the first request blocks, and the ser...
[ 6 ]
[]
[]
[ "django_nonrel", "google_app_engine", "python" ]
stackoverflow_0008088941_django_nonrel_google_app_engine_python.txt
Q: how to learn computer vision programming and real-time image processing basic concepts I am searching in the Computer Vision topic, I don't have any previous experience.I found a good library OpenCv with python interfacing .I have started reading it's documentation, but I have faced many new concepts and names, th...
how to learn computer vision programming and real-time image processing basic concepts
I am searching in the Computer Vision topic, I don't have any previous experience.I found a good library OpenCv with python interfacing .I have started reading it's documentation, but I have faced many new concepts and names, that I am not familiar with, such as Compute the Laplacian , GoodFeaturesToTrack, CreateMat an...
[ "I would recommend a book by OpenCV author Gary Bradski - Learning OpenCV: Computer Vision with the OpenCV Library.\nIt is not only a refence how to use OpenCV, but also a comprehensive book on many computer vision topics, with many images that illustrate the concepts. It guides you through OpenCV basics, then trou...
[ 6, 1 ]
[]
[]
[ "algorithm", "computer_vision", "image_processing", "opencv", "python" ]
stackoverflow_0008096388_algorithm_computer_vision_image_processing_opencv_python.txt
Q: Using numpy.where() to return the indexes of a full array where the tested condition is on a sliced one I have the following 3 x 3 x 3 numpy array called a (the comments will make sense after you read the rest of the question): array([[[8, 1, 0], # irrelevant 1 (is at position 1 rather than 0) [1, 7, 5...
Using numpy.where() to return the indexes of a full array where the tested condition is on a sliced one
I have the following 3 x 3 x 3 numpy array called a (the comments will make sense after you read the rest of the question): array([[[8, 1, 0], # irrelevant 1 (is at position 1 rather than 0) [1, 7, 5], # the 1 on this line is what I am after! [1, 4, 9]], # irrelevant 1 (out of the "cross") ...
[ "You can translate the indices back using idx:\n>>> w = np.where(a[..., 0][idx] == 1)[0]\n>>> array(idx).T[w]\narray([[0, 1],\n [1, 1]])\n\n" ]
[ 5 ]
[]
[]
[ "numpy", "python", "python_2.7" ]
stackoverflow_0008096620_numpy_python_python_2.7.txt
Q: Python: Find a Sentence between some website-tags using regex I want to find a sentence between the ...class="question-hyperlink"> tags. With this code: import urllib2 import re response = urllib2.urlopen('https://stackoverflow.com/questions/tagged/python') html = response.read(20000) a = re.search('question-hyp...
Python: Find a Sentence between some website-tags using regex
I want to find a sentence between the ...class="question-hyperlink"> tags. With this code: import urllib2 import re response = urllib2.urlopen('https://stackoverflow.com/questions/tagged/python') html = response.read(20000) a = re.search('question-hyperlink', html) print html[a.end()+3:a.end()+100] I get: DF5 for Py...
[ "If you must do it with regular expressions, try something like this:\na = re.finditer('<a.+?question-hyperlink\">(.+?)</a>', html)\nfor m in a: \n print m.group(1)\n\nJust for the reference, this code does the same, but in a far more robust way:\ndoc = BeautifulSoup(html)\nfor a in doc.findAll('a', 'question-hy...
[ 4 ]
[]
[]
[ "html", "python", "regex", "tags", "urllib2" ]
stackoverflow_0008096798_html_python_regex_tags_urllib2.txt
Q: numpy(.ma) array: Number of values since last value change? i have a status-signal (measured, of a heatpump) in an numpy.ma-array, together with timestamps. What i want is the lengths of the periods it was on and the length of the periods it was off. (NOT the daily running time or something, that would be easy..) ...
numpy(.ma) array: Number of values since last value change?
i have a status-signal (measured, of a heatpump) in an numpy.ma-array, together with timestamps. What i want is the lengths of the periods it was on and the length of the periods it was off. (NOT the daily running time or something, that would be easy..) What i have (exemplary, in fact i have minute-values over 16month...
[ "Well, finally i got i for myself. But millions of thanks to the answer of Joe Kington, which highly inspired me and teached me the whole stuff :)\nScript\nimport numpy as np\n\ndef main():\n # Generate some data...\n t = np.linspace(0, 10*np.pi, 30)\n x = np.sin(t)\n condition = np.where(x>0,1,0)\n ...
[ 3, 1, 0, 0 ]
[]
[]
[ "arrays", "numpy", "python" ]
stackoverflow_0008077146_arrays_numpy_python.txt
Q: How to randomly delete a number of lines from a big file? I have a big text file of 13 GB with 158,609,739 lines and I want to randomly select 155,000,000 lines. I have tried to scramble the file and then cut the 155000000 first lines, but it's seem that my ram memory (16GB) isn't enough big to do this. The pipeli...
How to randomly delete a number of lines from a big file?
I have a big text file of 13 GB with 158,609,739 lines and I want to randomly select 155,000,000 lines. I have tried to scramble the file and then cut the 155000000 first lines, but it's seem that my ram memory (16GB) isn't enough big to do this. The pipelines i have tried are: shuf file | head -n 155000000 sort -R fil...
[ "As you copy each line of the file to the output, assess its probability that it should be deleted. The first line should have a 3,609,739/158,609,739 chance of being deleted. If you generate a random number between 0 and 1 and that number is less than that ratio, don't copy it to the output. Now the odds for the s...
[ 13, 10, 3, 2, 2, 0 ]
[ "With the $RANDOM variable you can get a random number between 0 and 32,767.\nWith this, you could read in each line, and see if $RANDOM is less than 155,000,000 / 158,609,739 * 32,767 (which is 32,021), and if so, let the line through.\nOf course, this wouldn't give you exactly 150,000,000 lines, but pretty close ...
[ -1 ]
[ "awk", "bash", "python", "random", "sed" ]
stackoverflow_0008087313_awk_bash_python_random_sed.txt
Q: Getting MySQL Error Trying to run a MySQL script via Python and it keeps giving me errors. Here is my MySQL: c.execute("""INSERT into DATA(checkup_date) VALUES(%s) WHERE machine_name = %s """, (date, machine)) What am I doing wrong? ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual ...
Getting MySQL Error
Trying to run a MySQL script via Python and it keeps giving me errors. Here is my MySQL: c.execute("""INSERT into DATA(checkup_date) VALUES(%s) WHERE machine_name = %s """, (date, machine)) What am I doing wrong? ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your ...
[ "INSERT INTO ... VALUES ... WHERE ... isn't valid SQL. You can't add a WHERE clause to an INSERT statement.\nI'm guessing you want to update the checkup_date column for a row currently in the DATA table, as opposed to inserting a new row. If that's the case, try\nUPDATE DATA SET checkup_date = %s WHERE machine_na...
[ 3, 0 ]
[]
[]
[ "mysql", "python" ]
stackoverflow_0008097189_mysql_python.txt
Q: how to kill running subprocess while another subprocess is completed (in multiprocessing) I came across a problem with multiprocessing: class PythonHelper(object): @staticmethod def run_in_parallel(*functions): processes=list() for function in functions: process=Process(target=f...
how to kill running subprocess while another subprocess is completed (in multiprocessing)
I came across a problem with multiprocessing: class PythonHelper(object): @staticmethod def run_in_parallel(*functions): processes=list() for function in functions: process=Process(target=function) process.start() processes.append(process) for process ...
[ "You may achieve that by changing run_in_parallel() slightly:\ndef run_in_parallel(*functions):\n processes={}\n for function in functions:\n process=Process(target=function)\n process.start()\n processes[process.pid]=process\n # wait for any process to complete\n pid, status = os.w...
[ 2 ]
[]
[]
[ "multiprocessing", "python" ]
stackoverflow_0008095944_multiprocessing_python.txt
Q: :: in strings in Python I've been learning Python and I must say I loved it. But as a new learners I am having some other problems as well: Could you guys tell me whether it is a feature of Python or the library of itself. I am checking how to connect to sqllite database and I came up with this article and there i...
:: in strings in Python
I've been learning Python and I must say I loved it. But as a new learners I am having some other problems as well: Could you guys tell me whether it is a feature of Python or the library of itself. I am checking how to connect to sqllite database and I came up with this article and there is a code sample over there as...
[ "The ':memory:' string is entirely database dependent. As explained in the documentation for sqlite:\n\nYou can use \":memory:\" to open a database connection to a database that resides in RAM instead of on disk.\n\nAs far as the Python language is concerned, ':memory:' is just a string like any other.\n", "from:...
[ 5, 2, 1 ]
[]
[]
[ "python" ]
stackoverflow_0008097490_python.txt
Q: Add function on AppEngine Memcache Im using memcache to store a json, and it's working. But the problem is that the cache size grow if I call that line above many times: memcache.Client.add(memcache.Client(),"searchindex",json) So I looked at the memcache viewer and the content still the same, since Im using a...
Add function on AppEngine Memcache
Im using memcache to store a json, and it's working. But the problem is that the cache size grow if I call that line above many times: memcache.Client.add(memcache.Client(),"searchindex",json) So I looked at the memcache viewer and the content still the same, since Im using a key that's already on cache. But, even ...
[ "First off, that's a really odd way to invoke an instance method. Normally you would do this:\nmemcache.Client().add(\"searchindex\", json)\n\nOr simply:\nmemcache.add(\"searchindex\", json)\n\nSince add will not overwrite a key that already exists in cache, calling it repeatedly should have no impact on the behavi...
[ 5 ]
[]
[]
[ "google_app_engine", "memcached", "python" ]
stackoverflow_0008097071_google_app_engine_memcached_python.txt
Q: duplicating a print in python I have a problen when I try to print the result of a function several times. lets say for example that after several commands the result is that dreawing ()()() ()() () now I want to duplicate it according to a function so i used a loop but it will only print it again in a vertica...
duplicating a print in python
I have a problen when I try to print the result of a function several times. lets say for example that after several commands the result is that dreawing ()()() ()() () now I want to duplicate it according to a function so i used a loop but it will only print it again in a vertical way like that: ()()() ()() () ...
[ "Here is a working solution to your problem.\nlines = [\n\"()()()\",\n\" ()()\",\n\" ()\"\n]\n\ndef replicate(lines, n):\n width = reduce(max, map(len, lines))\n return (' '.join([line.ljust(width)] * n) for line in lines)\n\nfor line in replicate(lines, 3):\n print line\n\nedit:\nadded spacing management...
[ 4 ]
[]
[]
[ "python", "python_2.7" ]
stackoverflow_0008097542_python_python_2.7.txt
Q: How do I confirm a form has been submitted with django? I'm submitting a form and instead of redirecting to a success url I would like to just show "Form has been submitted" in text on the page when the form has been submitted. Does anyone know how I can do so? A: In your view: if request.POST: # validate fo...
How do I confirm a form has been submitted with django?
I'm submitting a form and instead of redirecting to a success url I would like to just show "Form has been submitted" in text on the page when the form has been submitted. Does anyone know how I can do so?
[ "In your view:\nif request.POST:\n # validate form, do what you need\n if form_is_valid():\n message = 'Form has been submitted'\n return render_to_response('path/to/template.html', {'message': message})\n\nAnd then use code in your template like:\n{% if message %}\n <h4>{{ message }}</h4>\n{...
[ 4, 0, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0008097644_django_python.txt
Q: How to create a list of word pairs I want to create a list of word pairs, separated by tabs, from a word list. I think one option could be to create a matrix with "range" because i want to have all words combined with each other. I need the list of word pairs to make further analyses. From a word list: mama papa s...
How to create a list of word pairs
I want to create a list of word pairs, separated by tabs, from a word list. I think one option could be to create a matrix with "range" because i want to have all words combined with each other. I need the list of word pairs to make further analyses. From a word list: mama papa sister brother should be the output mama...
[ "words = [\"mama\", \"papa\", \"sister\", \"brother\"]\npairs = list(itertools.product(words, repeat=2))\nprint pairs\n\nprints\n[('mama', 'mama'),\n ('mama', 'papa'),\n ('mama', 'sister'),\n ('mama', 'brother'),\n ('papa', 'mama'),\n ('papa', 'papa'),\n ('papa', 'sister'),\n ('papa', 'brother'),\n ('sister', 'mama...
[ 7, 5 ]
[]
[]
[ "list", "python", "word" ]
stackoverflow_0008097574_list_python_word.txt
Q: is unicode( codecs.BOM_UTF8, "utf8" ) necessary in Python 2.7/3? In a code review I came across the following code: # Python bug that renders the unicode identifier (0xEF 0xBB 0xBF) # as a character. # If untreated, it can prevent the page from validating or rendering # properly. bom = unicode( codecs.BOM_UTF8, ...
is unicode( codecs.BOM_UTF8, "utf8" ) necessary in Python 2.7/3?
In a code review I came across the following code: # Python bug that renders the unicode identifier (0xEF 0xBB 0xBF) # as a character. # If untreated, it can prevent the page from validating or rendering # properly. bom = unicode( codecs.BOM_UTF8, "utf8" ) r = r.replace(bom, '') This is in a function that passes a s...
[ "The Unicode standard states that the character \\ufeff has two distinct meanings. At the start of a data stream, it should be used as a byte-order and/or encoding signature, but elsewhere it should be interpreted as a zero-width non-breaking space.\nSo the code\nbom = unicode(codecs.BOM_UTF8, \"utf8\" )\nr = r.rep...
[ 7, 0 ]
[]
[]
[ "byte_order_mark", "python", "unicode", "utf_8" ]
stackoverflow_0008096078_byte_order_mark_python_unicode_utf_8.txt
Q: Multiple Inheritance with same Base Classes in Python I'm trying to wrap my head around multiple inheritance in python. Suppose I have the following base class: class Structure(object): def build(self, *args): print "I am building a structure!" self.components = args And let's say I have two c...
Multiple Inheritance with same Base Classes in Python
I'm trying to wrap my head around multiple inheritance in python. Suppose I have the following base class: class Structure(object): def build(self, *args): print "I am building a structure!" self.components = args And let's say I have two classes that inherit from it: class House(Structure): de...
[ "Your super() call in SchoolHouse is wrong.\nIt is:\nsuper(School, self).build(*args)\n\nIt should be:\nsuper(SchoolHouse, self).build(*args)\n\n" ]
[ 16 ]
[]
[]
[ "multiple_inheritance", "python" ]
stackoverflow_0008097877_multiple_inheritance_python.txt
Q: urllib2.urlopen - close faster when given a wrong link I want my program to try to open the page and get the data in time interval [0,t], if that time expires connection should be close. I'm using urllib2 to try to accomplish the task. t=1 url="http://example.com" response=urllib2.urlopen(url,timeout=t) html=resp...
urllib2.urlopen - close faster when given a wrong link
I want my program to try to open the page and get the data in time interval [0,t], if that time expires connection should be close. I'm using urllib2 to try to accomplish the task. t=1 url="http://example.com" response=urllib2.urlopen(url,timeout=t) html=response.read() This seems to work if url exists. However, if y...
[ "If you're just checking if the link is correct, use a HEAD request.\n", "I'm not sure why you're experiencing such long delays.\nWhen I try and make a request to a non-existant domain, I get urllib2.URLError: <urlopen error [Errno 11004] getaddrinfo failed> raised in about 0.2 seconds.\nWhat's the exact code you...
[ 1, 1 ]
[]
[]
[ "python", "urllib2" ]
stackoverflow_0008097817_python_urllib2.txt
Q: Django edit template for ModelForm is not being filled in with values I have a ModelForm that I have created a view and template with to add an instance to the database. I am now trying to extend this to be editable when the user clicks a button - but when they do that the form/template page appears and I get the ...
Django edit template for ModelForm is not being filled in with values
I have a ModelForm that I have created a view and template with to add an instance to the database. I am now trying to extend this to be editable when the user clicks a button - but when they do that the form/template page appears and I get the "This Field is required message" but all fields are empty instead of pre-p...
[ "@xizor use a link instead a button to redirect to the edition form, becasue with the button you are probably sending a post to the view.\nPS: Please forgive my English, edit this answer if you think it is right to make it more useful.\n" ]
[ 3 ]
[]
[]
[ "django", "django_forms", "modelform", "python" ]
stackoverflow_0008098312_django_django_forms_modelform_python.txt
Q: Is there a simple way to generate bitmaps with a gradient using Python? I am producing a simple, Python-based program that produces graphviz graphs as output. I would like to use custom nodes that depict data from the program. Using custom nodes is simple enough once you have the image, but I am having trouble f...
Is there a simple way to generate bitmaps with a gradient using Python?
I am producing a simple, Python-based program that produces graphviz graphs as output. I would like to use custom nodes that depict data from the program. Using custom nodes is simple enough once you have the image, but I am having trouble figuring out a convenient method of producing the images I want. Specifically,...
[ "One way to accomplish this is with matplotlib, as you suggested in your tags. To do this, I would \n\nuse numpy to create an NxN array to represent image_gradient. \ncreate a figure that has a square shape with size in inches correlated to the radius of your circle (image_circle_radius), for which you'll need to k...
[ 2 ]
[]
[]
[ "graphviz", "image", "matplotlib", "python" ]
stackoverflow_0008095134_graphviz_image_matplotlib_python.txt
Q: Possibilities for Python classes organized across files? I'm used to the Java model where you can have one public class per file. Python doesn't have this restriction, and I'm wondering what's the best practice for organizing classes. A: A Python file is called a "module" and it's one way to organize your softw...
Possibilities for Python classes organized across files?
I'm used to the Java model where you can have one public class per file. Python doesn't have this restriction, and I'm wondering what's the best practice for organizing classes.
[ "A Python file is called a \"module\" and it's one way to organize your software so that it makes \"sense\". Another is a directory, called a \"package\".\nA module is a distinct thing that may have one or two dozen closely-related classes. The trick is that a module is something you'll import, and you need that ...
[ 360, 41, 30, 15, 10, 7 ]
[]
[]
[ "class", "project_structure", "python" ]
stackoverflow_0000106896_class_project_structure_python.txt
Q: SQLAlchemy is convoluted? This may seems rather argumentative, but I just went through SQLAlchemy's ORM tutorial and ended up with the following code: from sqlalchemy import create_engine from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey from sqlalchemy.ext.declarative import declarative_...
SQLAlchemy is convoluted?
This may seems rather argumentative, but I just went through SQLAlchemy's ORM tutorial and ended up with the following code: from sqlalchemy import create_engine from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import...
[ "Well, there is one thing you are missing: the tutorial you mention doesn't \"build\" a complete example, the different snippets of code are not meant to be concatenated into one source file. Rather, they describe the different ways the library can be used. No need to try and do the same thing over and over again y...
[ 88, 10, 1, 1, 1, 0 ]
[]
[]
[ "orm", "python", "sqlalchemy" ]
stackoverflow_0000860313_orm_python_sqlalchemy.txt
Q: Implementing Task Farm messaging pattern with zeromq I am using zeromq to solve a problem which involves several hundred (potentially thousands) clients request tasks to be carried out. Each client would request for a specific task to be carried out, and the result(s), when completed, whould be returned back to th...
Implementing Task Farm messaging pattern with zeromq
I am using zeromq to solve a problem which involves several hundred (potentially thousands) clients request tasks to be carried out. Each client would request for a specific task to be carried out, and the result(s), when completed, whould be returned back to the client that issued that request. These are the actors th...
[ "There are a variety of approaches to this, and IPython.parallel includes two such implementations with ZeroMQ - one simple and pure-zmq, and another that is more elaborate, with the Controller implemented in Python.\nWe split the Controller into two actors:\n\nHub - an out-of-the-way process that sees all traffic,...
[ 5, 3 ]
[]
[]
[ "c", "c++", "php", "python", "zeromq" ]
stackoverflow_0007809200_c_c++_php_python_zeromq.txt
Q: Sort list of lists by multiple values in Python I need to sort a list of lists, where each entry in the outer list is a list of three integers like this: [[3,1,0],[1,2,3],[3,2,0],[3,1,1]] The trick is that I need to sort it by entry[0], and if there's a tie, then sort them by entry[1], and if that's also a tie, s...
Sort list of lists by multiple values in Python
I need to sort a list of lists, where each entry in the outer list is a list of three integers like this: [[3,1,0],[1,2,3],[3,2,0],[3,1,1]] The trick is that I need to sort it by entry[0], and if there's a tie, then sort them by entry[1], and if that's also a tie, sort by entry[2], so the list above should be: [[3,2,0...
[ "It's a default behaviour for comparing lists.\nx = [[3,1,0],[1,2,3],[3,2,0],[3,1,1]]\nx.sort(reverse = True)\nprint(x)\n\n" ]
[ 8 ]
[]
[]
[ "list", "python", "sorting" ]
stackoverflow_0008098779_list_python_sorting.txt
Q: Time zones and Localisation I'm currently storing all times in UTC, to make things easier for when I start bringing multiple sites and servers online. The problem comes in when translating date and datetime objects into strings in my templates and when accepting user input. 6:00PM UTC doesn't mean a whole lot to ...
Time zones and Localisation
I'm currently storing all times in UTC, to make things easier for when I start bringing multiple sites and servers online. The problem comes in when translating date and datetime objects into strings in my templates and when accepting user input. 6:00PM UTC doesn't mean a whole lot to someone who is in PST. Likewise,...
[ "I've done it like this. You may need to easy_install pytz for timezone objects.\nimport pytz\nimport time\nimport datetime\nd = time.time()\n\nprint datetime.datetime.fromtimestamp(d, pytz.timezone('US/Eastern'))\nprint datetime.datetime.fromtimestamp(d, pytz.timezone('US/Central'))\nprint datetime.datetime.fromt...
[ 1, 1, 0, 0, 0 ]
[]
[]
[ "django", "python", "python_datetime", "timezone" ]
stackoverflow_0008075052_django_python_python_datetime_timezone.txt
Q: Python Twisted WebSocket client Having worked with Twisted in the past I'd like to know if there is a way to get WebSocket client support to work. Looking around the documentation I can only find server implementations. A: Tavendo Autobahn is a very featureful websockets implementation. One of those features is...
Python Twisted WebSocket client
Having worked with Twisted in the past I'd like to know if there is a way to get WebSocket client support to work. Looking around the documentation I can only find server implementations.
[ "Tavendo Autobahn is a very featureful websockets implementation. One of those features is a Python WebSockets client with Twisted support.\n" ]
[ 8 ]
[]
[]
[ "python", "twisted", "websocket" ]
stackoverflow_0008096237_python_twisted_websocket.txt
Q: How do you run a python script from within Eclipse PyDev using -m flag My python script is executed via the -m flag: python -m MyPythonModule.MyPhythonModule command_line_arg1 command_line_arg2 However, I can't seem to get to this to work in Eclipse PyDev using the run configuration. Using that tool, it seems I a...
How do you run a python script from within Eclipse PyDev using -m flag
My python script is executed via the -m flag: python -m MyPythonModule.MyPhythonModule command_line_arg1 command_line_arg2 However, I can't seem to get to this to work in Eclipse PyDev using the run configuration. Using that tool, it seems I always need to specify a .py file to run. Is there a way I can configure the ...
[ "It's not possible at this time.\n" ]
[ 0 ]
[]
[]
[ "eclipse", "pydev", "python" ]
stackoverflow_0007493045_eclipse_pydev_python.txt
Q: python will not release memory for tuple, will it? According to this article I read, it looks like immutable type may become immortal. http://effbot.org/pyfaq/why-doesnt-python-release-the-memory-when-i-delete-a-large-object.htm I am currently working on solve a memory usage problem for my web service which runnin...
python will not release memory for tuple, will it?
According to this article I read, it looks like immutable type may become immortal. http://effbot.org/pyfaq/why-doesnt-python-release-the-memory-when-i-delete-a-large-object.htm I am currently working on solve a memory usage problem for my web service which running on google app engine. Does "use too much tuple" could ...
[ "This article doesn't specify immutable types - it specifies: \n\nAnother possible cause for excessive memory usage is that Python uses so-called “free lists” for certain object types, including integers and floats.\n\nI don't know what information you can get on a GAE process, but you can try this experiment on yo...
[ 5, 1, 1 ]
[]
[]
[ "backend", "google_app_engine", "memory_leaks", "python", "tuples" ]
stackoverflow_0008099083_backend_google_app_engine_memory_leaks_python_tuples.txt
Q: undefined method `highlight' Python+Pygments I am using python 2.6.6 and Pygments version 1.4 on RHEL 6 i386 but always get this error message when I try to create a new project in gitlabhq. gem list reveals: pygments.rb (0.2.3), rubypython (0.5.1) among others. After running rails s -e production I see the follow...
undefined method `highlight' Python+Pygments
I am using python 2.6.6 and Pygments version 1.4 on RHEL 6 i386 but always get this error message when I try to create a new project in gitlabhq. gem list reveals: pygments.rb (0.2.3), rubypython (0.5.1) among others. After running rails s -e production I see the following error in stdout. This error happens first: Com...
[ "linker error, fix: yum install python-devel\n" ]
[ 1 ]
[]
[]
[ "pygments", "python", "ruby_on_rails_3" ]
stackoverflow_0008070065_pygments_python_ruby_on_rails_3.txt
Q: Python - Building a string from a loop I have a set of points that have latitude and longitude values and I am trying to create a string in the following format in order to work with the Gmaps API: LatitudeX,LongitudeX|LatitudeY,LongitudeY The final string will be built using an unknown number of lat long pairs....
Python - Building a string from a loop
I have a set of points that have latitude and longitude values and I am trying to create a string in the following format in order to work with the Gmaps API: LatitudeX,LongitudeX|LatitudeY,LongitudeY The final string will be built using an unknown number of lat long pairs. My previous experience is with PHP and, whi...
[ "Use str.join:\nwaypoints = '|'.join(\"{0},{1}\".format(p.latitude, p.longitude) for p in points)\n\n" ]
[ 11 ]
[]
[]
[ "python", "string" ]
stackoverflow_0008099584_python_string.txt
Q: How to use and set axes in a 3D scene I'm creating a simulator coded in python and based on ODE (Open Dynamics Engine). For visualization I chose VTK. For every object in the simulation, I create a corresponding source (e.g. vtkCubeSource), mapper and actor. I am able to show objects correctly and update them as t...
How to use and set axes in a 3D scene
I'm creating a simulator coded in python and based on ODE (Open Dynamics Engine). For visualization I chose VTK. For every object in the simulation, I create a corresponding source (e.g. vtkCubeSource), mapper and actor. I am able to show objects correctly and update them as the simulation runs. I want to add axes to h...
[ "Well, if you do not mess with objects' transformation matrix for display\npurposes, it could probably be sufficient to just put your camera into a\ndifferent position while using axes approach 2. The easy methods to adjust\nyour camera position are: Pitch(), Azimuth() and Roll().\nIf you mess with object transform...
[ 1 ]
[]
[]
[ "c++", "python", "vtk" ]
stackoverflow_0007810632_c++_python_vtk.txt
Q: group detection in large data sets python I am a newbie in python and have been trying my hands on different problems which introduce me to different modules and functionalities (I find it as a good way of learning). I have googled around a lot but haven't found anything close to a solution to the problem. I have...
group detection in large data sets python
I am a newbie in python and have been trying my hands on different problems which introduce me to different modules and functionalities (I find it as a good way of learning). I have googled around a lot but haven't found anything close to a solution to the problem. I have a large data set of facebook posts from variou...
[ "Assuming you have a function called geturls that takes a string and returns a list of urls contained within, I would do it like this:\nfrom collections import defaultdict\n\ngroups = defaultdict(list):\nfor post in facebook_posts:\n for url in geturls(post):\n groups[url].append(post)\n\n", "That great...
[ 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0008071936_python.txt
Q: Accessing a remote service in Java through it's web interface using JAX-WS for SOAP I have a public EJB class that I want accessible online as a web service. I have generated a WSDL and the SOAP mesasging seems to work. I used soapUI to test the connection. What I'm not clear about is how would I then use this ex...
Accessing a remote service in Java through it's web interface using JAX-WS for SOAP
I have a public EJB class that I want accessible online as a web service. I have generated a WSDL and the SOAP mesasging seems to work. I used soapUI to test the connection. What I'm not clear about is how would I then use this exposed web service. I'd like to try another language like Python to then make calls throug...
[ "Take a look at ZSI\nBut ZSI is too complex and spends more time to generate proxies\nI suggest you to use suds. suds generates the proxies On the fly and so fast, i used it in some projects.\nanother packages are available:\n\nsoaplib\nSOAPy\npysimplesoap\n\n" ]
[ 0 ]
[]
[]
[ "java", "jax_ws", "python", "soap" ]
stackoverflow_0008099601_java_jax_ws_python_soap.txt
Q: How to catch exit() in embedded C++ module from python code? I am embedding a c++ library (binding done with SIP) in my python application. Under certain circonstances (error cases), this library uses exit(), which causes my entire application to exit. Is there a way to catch this event, or do I need to modify th...
How to catch exit() in embedded C++ module from python code?
I am embedding a c++ library (binding done with SIP) in my python application. Under certain circonstances (error cases), this library uses exit(), which causes my entire application to exit. Is there a way to catch this event, or do I need to modify the library to handle error cases differently ? Thank you very much...
[ "You must modify the source of the library. There is no \"exception handling\" in C and exit() does not return to the calling code under any circumstances.\n", "You can override the library linking with LD_LIBRARY_PATH and make your own exit function. Works fine.\n" ]
[ 7, 0 ]
[]
[]
[ "binding", "exception", "exit", "python" ]
stackoverflow_0001439533_binding_exception_exit_python.txt
Q: Sending data through the web to a remote program using python I have a program that I wrote in python that collects data. I want to be able to store the data on the internet somewhere and allow for another user to access it from another computer somewhere else, anywhere in the world that has an internet connection...
Sending data through the web to a remote program using python
I have a program that I wrote in python that collects data. I want to be able to store the data on the internet somewhere and allow for another user to access it from another computer somewhere else, anywhere in the world that has an internet connection. My original idea was to use an e-mail client, such as g-mail, to ...
[ "I would suggest taking a look at setting up a simple site in google app engine. It's free and you can use python to do the site. Than it would just be a matter of creating a simple restful service that you could send a POST to with your pickled data and store it in a database. Than just create a simple web front e...
[ 2, 1, 0, 0 ]
[]
[]
[ "networking", "python" ]
stackoverflow_0008098068_networking_python.txt
Q: Dynamic method name generation using xmlrpc How using Python I can dynamically generate my call to my xmlrpc server using xmlrpc lib? something like def call_method(method_name) server = Server(self.URL, transport=ProxiedTransport()) server.method_name(params) The resolution takes method_name instead of fo...
Dynamic method name generation using xmlrpc
How using Python I can dynamically generate my call to my xmlrpc server using xmlrpc lib? something like def call_method(method_name) server = Server(self.URL, transport=ProxiedTransport()) server.method_name(params) The resolution takes method_name instead of for example if method_name=get_time: server.get_tim...
[ "The source of xmlrpclib contains this comment, which you might find applicable outside its original context.\n # note: to call a remote object with an non-standard name, use\n # result getattr(server, \"strange-python-name\")(args)\n\nIt's a general Python idiom.\n" ]
[ 2 ]
[]
[]
[ "python", "xmlrpclib" ]
stackoverflow_0008099906_python_xmlrpclib.txt
Q: Unittest setUpClass not working I am trying to get started with unittest, but I am having a problem getting setUpClass() to work. Here is my test code... import unittest class TestRepGen(unittest.TestCase): """ Contains methods for training data testing """ testvar = None @classmethod def setUp...
Unittest setUpClass not working
I am trying to get started with unittest, but I am having a problem getting setUpClass() to work. Here is my test code... import unittest class TestRepGen(unittest.TestCase): """ Contains methods for training data testing """ testvar = None @classmethod def setUpClass(cls): cls.testvar = 6 ...
[ "setUpClass is new to the unittest framework as of 2.7 and 3.2. If you want to use it with an older version you will need to use nose as your test runner instead of unittest.\n", "I'm going to guess you aren't calling this test class directly, but a derived class.\nIf that's the case, you have to call up to set...
[ 10, 7, 1 ]
[]
[]
[ "python", "python_3.x", "unit_testing" ]
stackoverflow_0007020781_python_python_3.x_unit_testing.txt
Q: Duplicate a list of lists in python? I need to be able to duplicate a list of lists in python. so for example right now I have a function that returns a list. this is always lists within a list. for example: myList = [[1,2,3],[4,5,6],[7,8,9]] now I need to create two copies of this list (myList1, and myList2),...
Duplicate a list of lists in python?
I need to be able to duplicate a list of lists in python. so for example right now I have a function that returns a list. this is always lists within a list. for example: myList = [[1,2,3],[4,5,6],[7,8,9]] now I need to create two copies of this list (myList1, and myList2), each of which is separately mutable (for ...
[ "Everything you have tried so far only creates a shallow copy of the outer list. To create a deep copy, use either\ncopied_list = [x[:] for x in my_list]\n\nusing a list comprehension or\ncopied_list = copy.deepcopy(my_list)\n\nusing the copy.deepcopy() function.\n", "Use copy.deepcopy.\nmyList2 = copy.deepcopy(...
[ 8, 3 ]
[]
[]
[ "duplicates", "list", "python" ]
stackoverflow_0008100187_duplicates_list_python.txt
Q: should I reuse the cursor in the python MySQLdb module I'm writing a python CGI script that will query a MySQL database. I'm using the MySQLdb module. Since the database will be queryed repeatedly, I wrote this function.... def getDatabaseResult(sqlQuery,connectioninfohere): # connect to the database vDa...
should I reuse the cursor in the python MySQLdb module
I'm writing a python CGI script that will query a MySQL database. I'm using the MySQLdb module. Since the database will be queryed repeatedly, I wrote this function.... def getDatabaseResult(sqlQuery,connectioninfohere): # connect to the database vDatabase = MySQLdb.connect(connectioninfohere) # create a ...
[ "The MySQLdb developer recommends building an application specific API that does the DB access stuff for you so that you don't have to worry about the mysql query strings in the application code. It'll make the code a bit more extendable (link).\nAs for the cursors my understanding is that the best thing is to crea...
[ 23 ]
[]
[]
[ "cgi", "mysql", "python" ]
stackoverflow_0008099902_cgi_mysql_python.txt
Q: Extracting part of a scanned document (personal ID) - which library and method to choose? I have to process a lot of scanned IDs and I need to extract photos from them for further processing. Here's a fictional example: The problem is that the scans are not perfectly aligned (rotated up to 10 degrees). So I need...
Extracting part of a scanned document (personal ID) - which library and method to choose?
I have to process a lot of scanned IDs and I need to extract photos from them for further processing. Here's a fictional example: The problem is that the scans are not perfectly aligned (rotated up to 10 degrees). So I need to find their position, rotate them and cut out the photo. This turned out to be a lot harder ...
[ "If you don't find another ideal solution, one method I ended up using for OCR preprocessing in the past was to convert the source images to PPM and use unpaper in Ubuntu. You can attempt to deskew the image based on whichever sides you specify as having clearly-defined edges, and there is an option to bypass the ...
[ 1 ]
[]
[]
[ "c", "c++", "image_processing", "python" ]
stackoverflow_0008073135_c_c++_image_processing_python.txt
Q: Saving an Excel worksheet as a Text file from IronPython I'm trying to use IronPython to export a series of Excel Worksheets to delimited text files using Interop. I I think I should be using the SaveAs method, but I'm not clear what the equivalent python syntax is for it. My current code keeps the worksheet in ...
Saving an Excel worksheet as a Text file from IronPython
I'm trying to use IronPython to export a series of Excel Worksheets to delimited text files using Interop. I I think I should be using the SaveAs method, but I'm not clear what the equivalent python syntax is for it. My current code keeps the worksheet in Excel format because the most obvious syntax would be SaveAs(f...
[ "ws.SaveAs(file \".txt\", Excel.XlFileFormat.xlUnicodeText) was what I was looking for. I found that here\n", "The new version of Python Tools for Visual has a new library for improved interaction with excel. This was recently posted by Dino V to the IronPython Users list.\n\nDino Viehland dinov@.com via pytho...
[ 0, 0 ]
[]
[]
[ "excel", "excel_interop", "ironpython", "python", "vba" ]
stackoverflow_0008070227_excel_excel_interop_ironpython_python_vba.txt
Q: Django application does not create tables So, I have created a django app here: http://fpaste.org/bkFf/ without using django-admin. I want the model that I have created in models.py (http://fpaste.org/i1Vd/) to automatically create the table in the database, as specified in settings.py (http://fpaste.org/GBz0/). ...
Django application does not create tables
So, I have created a django app here: http://fpaste.org/bkFf/ without using django-admin. I want the model that I have created in models.py (http://fpaste.org/i1Vd/) to automatically create the table in the database, as specified in settings.py (http://fpaste.org/GBz0/). I run the command django-admin syncdb --setting...
[ "\nI have no 'project' - so I have no application to add to an INSTALLED_APPS\n\nThis makes no sense at all. Projects have nothing to do with INSTALLED_APPS. You have a settings.py, and you have a models.py. Put the name of the module containing models.py into INSTALLED_APPS, and things will work.\n" ]
[ 4 ]
[]
[]
[ "django", "python", "wsgi" ]
stackoverflow_0008100336_django_python_wsgi.txt
Q: How to get and compare date and time of given files in python Is there any handy functions can retrieve timestamp from given files or even compare them? My ideal usage would be like this: time_diff = date(file_path_a) - date(file_path_b) # time_diff would be a formatted string such as 2days 3hrs 16 mins I know th...
How to get and compare date and time of given files in python
Is there any handy functions can retrieve timestamp from given files or even compare them? My ideal usage would be like this: time_diff = date(file_path_a) - date(file_path_b) # time_diff would be a formatted string such as 2days 3hrs 16 mins I know there is a built-in datetime module in python, but I haven't found an...
[ "import datetime, os\ndef mtime(filename):\n return datetime.datetime.fromtimestamp(os.stat(filename).st_mtime)\ntime_diff = mtime(file_path_a) - mtime(file_path_b)\n\n… and then format the resulting datetime.timedelta object in the desired way.\n", "You can use the time.ctime and os.path.getctime or getmtime ...
[ 7, 3 ]
[]
[]
[ "python" ]
stackoverflow_0008100306_python.txt
Q: Finding matches in a list property, in a list of class Instances I have a class, 'Foo', which has a name (string) and a set of data (a list of integers). I need to be able to find 'test' any string/list combination against a list of Foo's, to find any matches. Like this: class Foo: def __init__(self, name, dat...
Finding matches in a list property, in a list of class Instances
I have a class, 'Foo', which has a name (string) and a set of data (a list of integers). I need to be able to find 'test' any string/list combination against a list of Foo's, to find any matches. Like this: class Foo: def __init__(self, name, data): self.name = str(name) self.data = list(data) foo...
[ "It seems like you can restructure a number of things in your code to make it work a bit better.\nFirst, instead of having data be a list, I'd consider a set. That would allow you to use data.intersection(otherdata) to get the overlap.\nNext, instead of a list of Foo instances, perhaps a dictionary keyed by their ...
[ 4, 1, 0 ]
[]
[]
[ "generator", "list_comprehension", "python" ]
stackoverflow_0008086069_generator_list_comprehension_python.txt
Q: How can I Cause a Deadlock in MySQL for Testing Purposes I want to make my Python library working with MySQLdb be able to detect deadlocks and try again. I believe I've coded a good solution, and now I want to test it. Any ideas for the simplest queries I could run using MySQLdb to create a deadlock condition wou...
How can I Cause a Deadlock in MySQL for Testing Purposes
I want to make my Python library working with MySQLdb be able to detect deadlocks and try again. I believe I've coded a good solution, and now I want to test it. Any ideas for the simplest queries I could run using MySQLdb to create a deadlock condition would be? system info: MySQL 5.0.19 Client 5.1.11 Windows XP P...
[ "Here's some pseudocode for how i do it in PHP:\nScript 1:\nSTART TRANSACTION;\nINSERT INTO table <anything you want>;\nSLEEP(5);\nUPDATE table SET field = 'foo';\nCOMMIT;\n\nScript 2:\nSTART TRANSACTION;\nUPDATE table SET field = 'foo';\nSLEEP(5);\nINSERT INTO table <anything you want>;\nCOMMIT;\n\nExecute script ...
[ 4, 1, 1, 1, 1 ]
[]
[]
[ "database", "deadlock", "mysql", "python" ]
stackoverflow_0000269676_database_deadlock_mysql_python.txt
Q: String searching library's outcome - bug or feature or my coding error? I am using this python library that implements the Aho-Corasick string searching algorithm that finds a set of patterns in a given string in one pass. The output is not what I am expecting: In [4]: import ahocorasick In [5]: import collections...
String searching library's outcome - bug or feature or my coding error?
I am using this python library that implements the Aho-Corasick string searching algorithm that finds a set of patterns in a given string in one pass. The output is not what I am expecting: In [4]: import ahocorasick In [5]: import collections In [6]: tree = ahocorasick.KeywordTree() In [7]: ss = "this is the first s...
[ "The way I understand the Aho-Corasick algorithm and the way I've implemented it would have me agree with your expected output. It looks like the Python library you're using is in error, or perhaps there's a flag that you can tell it to give you all matches starting at a position rather than just the longest match ...
[ 1, 1 ]
[]
[]
[ "algorithm", "python", "search", "string", "text" ]
stackoverflow_0008100233_algorithm_python_search_string_text.txt
Q: How can I use a SOCKS 4/5 proxy with urllib2? How can I use a SOCKS 4/5 proxy with urllib2 to download a web page? A: You can use SocksiPy module. Simply copy the file "socks.py" to your Python's lib/site-packages directory, and you're ready to go. You must use socks before urllib2. (Try it pip install PySocks ...
How can I use a SOCKS 4/5 proxy with urllib2?
How can I use a SOCKS 4/5 proxy with urllib2 to download a web page?
[ "You can use SocksiPy module. Simply copy the file \"socks.py\" to your Python's lib/site-packages directory, and you're ready to go. \nYou must use socks before urllib2. (Try it pip install PySocks )\nFor example:\nimport socks\nimport socket\nsocks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, \"127.0.0.1\", 8080)\nso...
[ 67, 21, 4 ]
[]
[]
[ "proxy", "python", "socks", "urllib2" ]
stackoverflow_0002317849_proxy_python_socks_urllib2.txt
Q: python: convert telnet application to ssh I write a python telnet client to communicate with a server through telnet. However, many people tell me that it's no secure. How can I convert it to ssh? Should I need to totally rewrite my program? A: While Telnet is insecure, it's essentially just a serial console ove...
python: convert telnet application to ssh
I write a python telnet client to communicate with a server through telnet. However, many people tell me that it's no secure. How can I convert it to ssh? Should I need to totally rewrite my program?
[ "While Telnet is insecure, it's essentially just a serial console over a network, which makes it easy to code for. SSH is much, much more complex. There's encryption, authentication, negotiation, etc to do. And it's very easy to get wrong in spectacular fashion.\nThere's nothing wrong with Telnet per se, but if you...
[ 1, 1, 1 ]
[]
[]
[ "python", "security", "ssh", "telnet" ]
stackoverflow_0008088742_python_security_ssh_telnet.txt
Q: How to resize gtk.gdk.Pixmap I am created an instance of gtk.gdk.Pixmap, and painted on it something. For example: pixmap = gtk.gdk.Pixmap(widget.window,100,800) pixmap.draw_rectangle(gc, True, 0, 0, 100, 800) pixmap.draw_line(gc, 0, 0,100, 800) How can I to resize the Pixmap? One way that I see is to copy the P...
How to resize gtk.gdk.Pixmap
I am created an instance of gtk.gdk.Pixmap, and painted on it something. For example: pixmap = gtk.gdk.Pixmap(widget.window,100,800) pixmap.draw_rectangle(gc, True, 0, 0, 100, 800) pixmap.draw_line(gc, 0, 0,100, 800) How can I to resize the Pixmap? One way that I see is to copy the Pixmap into a PixBuf using gtk.gdk....
[ "Unfortunately it's not possible without all this copying. Please note that GdkPixmap and GdkPixbuf are deprecated in favor of Cairo.\n", "Indeed, those are deprecated.\nMore importantly, GdkPixmap is a server-side resource - the contents of the pixmap live in the X server's memory. When you do get_from_drawable...
[ 1, 1 ]
[]
[]
[ "gdk", "gdkpixbuf", "gtk", "pygtk", "python" ]
stackoverflow_0008076759_gdk_gdkpixbuf_gtk_pygtk_python.txt
Q: Bug with re.split function and re.DOTALL flag in re module of Python 2.7.1 I have a Mac running Lion and Python 2.7.1. I am noticing something very strange from the re module. If I run the following line: print re.split(r'\s*,\s*', 'a, b,\nc, d, e, f, g, h, i, j, k,\nl, m, n, o, p, q, r') I get this result: ['a',...
Bug with re.split function and re.DOTALL flag in re module of Python 2.7.1
I have a Mac running Lion and Python 2.7.1. I am noticing something very strange from the re module. If I run the following line: print re.split(r'\s*,\s*', 'a, b,\nc, d, e, f, g, h, i, j, k,\nl, m, n, o, p, q, r') I get this result: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',...
[ ">>> s = 'a, b,\\nc, d, e, f, g, h, i, j, k,\\nl, m, n, o, p, q, r'\n>>> re.split(r'\\s*,\\s*', s)\n['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r']\n>>> re.split(r'\\s*,\\s*', s, maxsplit=16)\n['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',...
[ 13 ]
[]
[]
[ "python", "python_2.7", "regex" ]
stackoverflow_0008100767_python_python_2.7_regex.txt
Q: Mako: passing variables to base and child templates Goal: To access myargs in both base and child templates. Currently I can only access them in one or the other. Call: child.render(myargs={'a':2, b:'5'}) Base excerpt: <%page args="myargs=None, **kwargs"/> % if myargs['a']: a is: ${myargs['a']} % endif ${self...
Mako: passing variables to base and child templates
Goal: To access myargs in both base and child templates. Currently I can only access them in one or the other. Call: child.render(myargs={'a':2, b:'5'}) Base excerpt: <%page args="myargs=None, **kwargs"/> % if myargs['a']: a is: ${myargs['a']} % endif ${self.body(myargs=myargs)} Child excerpt version 1: <%page ar...
[ "Nice easy solution lol.\nIt turns out \"page args\" are not useful for this cause, in fact they were creating the problem by overwriting \"myargs\" with \"None\" on one of the pages. Keyword variables can be accessed directly from both files without using \"page args\".\n" ]
[ 3 ]
[]
[]
[ "mako", "python", "templates" ]
stackoverflow_0008089666_mako_python_templates.txt
Q: How to allow nosetests to pass the modified sys.path to the testing scripts in python? I want to do an automatic unittests for a bunch of files and subdirectories. I built a driver to setup sys.path for module importing followed by invoking nosetests. I need all my testing scripts below it will catch the sys.path ...
How to allow nosetests to pass the modified sys.path to the testing scripts in python?
I want to do an automatic unittests for a bunch of files and subdirectories. I built a driver to setup sys.path for module importing followed by invoking nosetests. I need all my testing scripts below it will catch the sys.path for module importing. However, it seems that nosetests will not pass the modified sys.path t...
[ "Have you tried using the PYTHONPATH environment variable? You can certainly modify sys.path directly, but PYTHONPATH has the advantage of being set at the OS level, and should be passed on to any child processes.\nRelevant documentation here: The Module Search Path\n" ]
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0008100898_python.txt
Q: python urllib2 utf-8 encoding okay, I have: # -*- coding: utf-8 -*- in my python file. the snippet: opener = urllib2.build_opener() opener.addheaders = [('User-agent', 'Mozilla/5.0')] opener.addheaders = [('Accept-Charset', 'utf-8')] f =opener.open(url) doc = f.read().decode('utf-8') The server response is: (via ...
python urllib2 utf-8 encoding
okay, I have: # -*- coding: utf-8 -*- in my python file. the snippet: opener = urllib2.build_opener() opener.addheaders = [('User-agent', 'Mozilla/5.0')] opener.addheaders = [('Accept-Charset', 'utf-8')] f =opener.open(url) doc = f.read().decode('utf-8') The server response is: (via f.info()) Content-Type: text/html; ...
[ "Try decoding the data using 'latin-1' to see what it looks like. What you're seeing indicates a UTF-8 decode error (see UnicodeDecodeError, invalid continuation byte ).\nIt would be helpful if you posted the result of list(f.read())[:100] so we can see the data.\nFYI, putting # -*- coding: utf-8 -*- is unrelated ...
[ 3, 1 ]
[]
[]
[ "encoding", "python", "urllib2", "utf_8" ]
stackoverflow_0008101036_encoding_python_urllib2_utf_8.txt
Q: YouTube Gdata No Average Rating in Python This works perfectly when finding the average rating and number of raters for a youtube video. #!/usr/bin/python import sys from gdata.youtube.service import YouTubeService yt = YouTubeService() entry = yt.GetYouTubeVideoEntry(video_id=sys.argv[1]) dir(entry.rating) ['Fi...
YouTube Gdata No Average Rating in Python
This works perfectly when finding the average rating and number of raters for a youtube video. #!/usr/bin/python import sys from gdata.youtube.service import YouTubeService yt = YouTubeService() entry = yt.GetYouTubeVideoEntry(video_id=sys.argv[1]) dir(entry.rating) ['FindExtensions', 'ToString', '_AddMembersToElemen...
[ "gd:rating is deprecated \nhttp://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_gd:rating\nAnyway you should check if raiting exists\nif entry.rating:\n print entry.rating.average\n print entry.rating.num_raters\nelse:\n print 'entry has no rating'\n\n" ]
[ 1 ]
[]
[]
[ "attributeerror", "python", "youtube", "youtube_api" ]
stackoverflow_0008100242_attributeerror_python_youtube_youtube_api.txt
Q: Can we pass a environment variable modified by python script to the outer shell? For the following python script: import os os.system('PYTHONPATH=\user\...') os.system('export PYTHONPATH') .... Is there anyway we can "export" the PYTHONPATH variable to the shell after executing this script? A: No, this is not p...
Can we pass a environment variable modified by python script to the outer shell?
For the following python script: import os os.system('PYTHONPATH=\user\...') os.system('export PYTHONPATH') .... Is there anyway we can "export" the PYTHONPATH variable to the shell after executing this script?
[ "No, this is not possible. When the Python process is launched, it gets its own copy of the environment, copied from the parent shell. The Python process can only modify the private copy, and changes are not propagated back to the parent process.\nIf you want to do something like this, the best you can get is to ...
[ 4, 0 ]
[]
[]
[ "python", "shell" ]
stackoverflow_0008101352_python_shell.txt
Q: 2D Lists in python I have a 2d list and a class to get users input for row and column and retrieve that object but if that row/column doesn't exist it says that list out of index but i want it return saying error this is my current code return self.object[row][column] A: try: return self.object[row][column] ...
2D Lists in python
I have a 2d list and a class to get users input for row and column and retrieve that object but if that row/column doesn't exist it says that list out of index but i want it return saying error this is my current code return self.object[row][column]
[ "try:\n return self.object[row][column]\nexcept IndexError:\n return \"error\"\n\n" ]
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0008101424_python.txt
Q: Scapy: Adding new protocol with complex field groupings I'm trying to specify a new packet format using scapy. In the packet there is a list of items, and items consist of "grouped fields". By "grouped fields" I mean a sub-sequence of fields of different types. The only way of making "grouped fields" that I know o...
Scapy: Adding new protocol with complex field groupings
I'm trying to specify a new packet format using scapy. In the packet there is a list of items, and items consist of "grouped fields". By "grouped fields" I mean a sub-sequence of fields of different types. The only way of making "grouped fields" that I know of in scapy is by using Packet class and using FieldLenField/P...
[ "Class RepeatingGroupedSequence needs to overwrite extract_padding method: \ndef extract_padding(self, s):\n return '', s\n\nBy default each sub packet treats everything as belonging to its own layer, ie:\ndef extract_padding(self, s):\n return s, None\n\nAnd this is not what is used for grouping purposes. Ca...
[ 9 ]
[]
[]
[ "python", "scapy" ]
stackoverflow_0008073508_python_scapy.txt
Q: For loops python problems Write a function that takes as an input parameter a string and a number n and returns a newly created string made of every nth letter. Can anyone help? A: This is quite simple in Python because of the way it handles indexing: def every_n(s, n): return s[::n] That third item betwee...
For loops python problems
Write a function that takes as an input parameter a string and a number n and returns a newly created string made of every nth letter. Can anyone help?
[ "This is quite simple in Python because of the way it handles indexing:\ndef every_n(s, n):\n return s[::n]\n\nThat third item between the colons says \"every n\".\nCheck out Explain Python's slice notation for a more in depth description of how to slice in Python.\n" ]
[ 2 ]
[]
[]
[ "for_loop", "loops", "python" ]
stackoverflow_0008102049_for_loop_loops_python.txt
Q: ValueError: Cannot convert argument type to rgba array? I am learning to draw scatter using matplotlib. However, there is a bug and it seems related with the color argument. Could anyone explain me the mistake? I googled but no answer found. Thanks in advance. xActA = range(10) yActA = np.random.randn(10) xActQ =...
ValueError: Cannot convert argument type to rgba array?
I am learning to draw scatter using matplotlib. However, there is a bug and it seems related with the color argument. Could anyone explain me the mistake? I googled but no answer found. Thanks in advance. xActA = range(10) yActA = np.random.randn(10) xActQ = range(10) yActQ = np.random.randn(10) xRa = np.random.randn(1...
[ "You are giving facecolors a boolean.\nThe parameter is defined as:\nfacecolor or facecolors: matplotlib color arg or sequence of rgba tuples \n\nJust make facecolor = None and it will work. You probably dont want this because you get the same color for the two plots. If you eliminate the parameter you will get au...
[ 1, 0 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0008102063_matplotlib_python.txt