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:
Tornado with jQuery Webcam Plugin Problem
I'm using Tornado Webserver and the jQuery Webcam Plugin.
Everything is going fine except that I don't think i'm getting the raw data properly. I'm getting "FFD8FFE000104A46494600010100000100010000FFDB0084000503040404030504040405050506070C08070707070F0B0B090C110F1212110F11... | Tornado with jQuery Webcam Plugin Problem | I'm using Tornado Webserver and the jQuery Webcam Plugin.
Everything is going fine except that I don't think i'm getting the raw data properly. I'm getting "FFD8FFE000104A46494600010100000100010000FFDB0084000503040404030504040405050506070C08070707070F0B0B090C110F1212110F111113161C1713141A1511111821181A1D1D1F1F1F1317222... | [
"Using your data as x, notice the JFIF in the output from unhexlify:\nIn [88]: binascii.unhexlify(x[:-1])\nOut[88]: '\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF...'\n\nSo it appears the data is a JPEG that needs to be unhexlified. Therefore try:\nimport binascii\nfilecontent = self.request.body \nwith open('static/studentph... | [
0
] | [] | [] | [
"jquery_plugins",
"python",
"tornado"
] | stackoverflow_0007139963_jquery_plugins_python_tornado.txt |
Q:
Google App Engine: Reverse Proxy + OpenID, users being redirected to appspot domain after login
I am using a reverse proxy to enable ssl on a custom domain. The proxy works fine on the public pages, however when the user attempts to access a login_required directory the login url shifts them over to my appspot do... | Google App Engine: Reverse Proxy + OpenID, users being redirected to appspot domain after login | I am using a reverse proxy to enable ssl on a custom domain. The proxy works fine on the public pages, however when the user attempts to access a login_required directory the login url shifts them over to my appspot domain after sign-in.
Is there a way to keep users on the custom domain?
Here is my login handler:
clas... | [
"I'm not sure this is an option for you, but the next release of app engine claims to have support for ssl on custom domains (http://code.google.com/appengine/business/). If your application won't be in production for a while maybe it would just be easier to wait until they officially add support. They appear to be... | [
1,
0
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0005845489_google_app_engine_python.txt |
Q:
Draggable window with pyqt4
just a simple question: I'm using pyqt4 to render a simple window. Here's the code, I post the whole thing so it easier to explain.
from PyQt4 import QtGui, QtCore, Qt
import time
import math
class FenixGui(QtGui.QWidget):
def __init__(self):
super(FenixGui, self).__in... | Draggable window with pyqt4 | just a simple question: I'm using pyqt4 to render a simple window. Here's the code, I post the whole thing so it easier to explain.
from PyQt4 import QtGui, QtCore, Qt
import time
import math
class FenixGui(QtGui.QWidget):
def __init__(self):
super(FenixGui, self).__init__()
# setting layout ... | [
"You can override mousePressEvent() and mouseMoveEvent() to get the location of the mouse cursor and move your widget to that location. mousePressEvent will give you the offset from the cursor position to the top left corner of your widget, and then you can calculate what the new position of the top left corner sh... | [
5
] | [] | [] | [
"drag",
"draggable",
"pyqt",
"pyqt4",
"python"
] | stackoverflow_0007138773_drag_draggable_pyqt_pyqt4_python.txt |
Q:
Python - Informix - Character to numeric conversion error (-1213)
While trying to update an Informix table via a Python script I am getting the error:
Character to numeric conversion error (-1213)
The db request:
cursor.execute("update sales set pid = ? where sid = '1'", price)
Table sales:
sid | oid... | Python - Informix - Character to numeric conversion error (-1213) | While trying to update an Informix table via a Python script I am getting the error:
Character to numeric conversion error (-1213)
The db request:
cursor.execute("update sales set pid = ? where sid = '1'", price)
Table sales:
sid | oid | price | pid
The column I want to update has the data type money(10,... | [
"Your DB driver is converting your code to SQL. You can use the Informix debugger to see what SQL it produces. I know Informix doesn't like thousand separators in its SQL.\n",
"There are two possible string-to-numeric conversions in the SQL you show.\n\nConverting '1' to the same type as sid.\nConverting the val... | [
1,
0
] | [] | [] | [
"casting",
"informix",
"python"
] | stackoverflow_0007138900_casting_informix_python.txt |
Q:
How to structure a python projects with shared sub apps using git and buidout without symbolic links
I have multiple projects that shares child apps with other projects.
When working within the project directory I want to be able to make changes to the app, update it, and pull those updates into the second project... | How to structure a python projects with shared sub apps using git and buidout without symbolic links | I have multiple projects that shares child apps with other projects.
When working within the project directory I want to be able to make changes to the app, update it, and pull those updates into the second project.
Requirement:
No use of symbolic links (my IDE's debugger doesn't work well with them)
No compiling/reru... | [
"mr.developer. When a mr.developer source is checked out and activated, it becomes a setuptools/distribute develop egg in the buildout and so the checkout will be what is used by any scripts (such as a zc.recipe.egg generated python interpreter) in the buildout.\n"
] | [
3
] | [] | [] | [
"buildout",
"git",
"git_submodules",
"git_subtree",
"python"
] | stackoverflow_0007140321_buildout_git_git_submodules_git_subtree_python.txt |
Q:
Unicode Hell in Pyramid: MySQL -> SQLAlchemy -> Pyramid -> JSON
Background
I'm in a real mess with unicode and Python. It seems to be a common angst and I've tried using other solutions out there but I just can't get my head around it.
Setup
MySQL Database Setup
collation_database: utf8_general_ci
character_set_d... | Unicode Hell in Pyramid: MySQL -> SQLAlchemy -> Pyramid -> JSON | Background
I'm in a real mess with unicode and Python. It seems to be a common angst and I've tried using other solutions out there but I just can't get my head around it.
Setup
MySQL Database Setup
collation_database: utf8_general_ci
character_set_database: utf8
SQLAlchemy Model
class Product(Base):
id = Column(... | [
"The above comment is right, but more specifially, you can replace 'label': prod.name with 'label': prod.name.decode(\"cp1252\"). You should probably also do this for all of the strings in your json_prod dictionary since it's likely you'll see cp1252 encoded characters elsewhere in the real-world use of your appli... | [
6
] | [] | [] | [
"json",
"pyramid",
"python",
"sqlalchemy"
] | stackoverflow_0007139116_json_pyramid_python_sqlalchemy.txt |
Q:
Buggy Text Replace code:
I cant seem to figure out why I keep getting this buggy output.
Input file:
ff1
ff2
ff3
ff10
ff11
ff20
ff21
ff23
gb20
gb10
gh23
Output File:
FF01
FF02
FF03
FF010
FF011
FF020
FF021
FF023
GB020
GB010
GH023
Code:
import os
import sys
#directory is the directory we will work from
directory ... | Buggy Text Replace code: | I cant seem to figure out why I keep getting this buggy output.
Input file:
ff1
ff2
ff3
ff10
ff11
ff20
ff21
ff23
gb20
gb10
gh23
Output File:
FF01
FF02
FF03
FF010
FF011
FF020
FF021
FF023
GB020
GB010
GH023
Code:
import os
import sys
#directory is the directory we will work from
directory = "C:\\Users\\user\\Desktop"
o... | [
"The reason your original solution doesn't work is that it isn't checking that it's matching a whole line/word/number. So for instance after replacing ff1 with FF01 your buffer is now:\nFF01\nff2\nff3\nFF010\nFF011\nff20\nff21\nff23\ngb20\ngb10\ngh23\n\n",
"Here is a simple solution:\nwith open(\"New Text Documen... | [
3,
2,
1,
0
] | [] | [] | [
"python",
"replace",
"string"
] | stackoverflow_0007140504_python_replace_string.txt |
Q:
Setting Pixels Quickly
I have searched and searched for a good answer and I am about to cry from frustration. I am a hobbyist programmer, I don't do things because they make sense, or they are the right way to do them; I do them to learn how, and right now I am stumped.
I want to set individual pixels on the scree... | Setting Pixels Quickly | I have searched and searched for a good answer and I am about to cry from frustration. I am a hobbyist programmer, I don't do things because they make sense, or they are the right way to do them; I do them to learn how, and right now I am stumped.
I want to set individual pixels on the screen. This may sound easy, but ... | [
"If you want to make your own \"for each pixel\" math (as opposed to just moving circles and bitmaps around), you will have to do it in C (or C++) to get anywhere close to machine speed.\nOn the other hand, if you want to make a full game, it will not be fun to write it all in a low-level language like C. You will ... | [
4,
3,
1,
0,
0
] | [] | [] | [
"graphics",
"performance",
"python"
] | stackoverflow_0007117143_graphics_performance_python.txt |
Q:
Is del called on an object that doesn't complete init?
Will __del__ be called if an object's __init__ does not complete (such as by throwing an exception)?
A:
class test():
def __init__(self):
raise
def __del__(self):
print "__del__ called"
try:
test()
except:
pass
Yes.
Explana... | Is del called on an object that doesn't complete init? | Will __del__ be called if an object's __init__ does not complete (such as by throwing an exception)?
| [
"class test():\n def __init__(self):\n raise\n\n def __del__(self):\n print \"__del__ called\"\n\ntry:\n test()\nexcept:\n pass\n\nYes.\nExplanation: __del__ is called when the last reference to the object is removed. But if you do not catch the exception, __del__ will not be called becaus... | [
27,
14,
2,
1
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0006409644_python_python_3.x.txt |
Q:
Python-Like "Classes" in Javascript
I was wondering how one would go about making "classes" similar to those in Python in Javascript. Take the Python classes and functions listed here:
class one:
def foo(bar):
# some code
The function "foo" would be called with one.foo(bar).
What would the JS equivale... | Python-Like "Classes" in Javascript | I was wondering how one would go about making "classes" similar to those in Python in Javascript. Take the Python classes and functions listed here:
class one:
def foo(bar):
# some code
The function "foo" would be called with one.foo(bar).
What would the JS equivalent be? I suspect it would be something li... | [
"The native way to create classes in Javascript is to first define the constructor:\nfunction MyClass() {\n}\n\nand a prototype:\nMyClass.prototype = {\n property: 1,\n foo: function(bar) {\n }\n};\n\nThen you can create instance of MyClass:\nvar object = new MyClass;\nobject.foo();\n\nAdd static methods:\... | [
10,
6,
6,
2
] | [] | [] | [
"class",
"javascript",
"python"
] | stackoverflow_0007140980_class_javascript_python.txt |
Q:
app_index.html => app is in adminsite to see
i have a small problem... i want to bind my app to adminsite. my app doesnot use models.py so the only way to make my app visible in adminsite is to override the app_index.html from django's admin/templates directory. my problem is that i dont know how to override this ... | app_index.html => app is in adminsite to see | i have a small problem... i want to bind my app to adminsite. my app doesnot use models.py so the only way to make my app visible in adminsite is to override the app_index.html from django's admin/templates directory. my problem is that i dont know how to override this sothat my app is in admin. i v read all the docs, ... | [
"you don't need models.py, just register a \"Model\" with the admin site.\nadmin.site.register(class MyMenuThing(models.Model): pass)\n"
] | [
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0007132900_django_python.txt |
Q:
pySVG css links
I'm trying to figure out pySVG, having trouble understanding how to link to an external CSS file, does pySVG handle this? Looking over the documentation, the style seems to be hard coded in most of the examples.
Further, I'd love to add an 'onclick' to change the CSS reference, so, a heat map (fo... | pySVG css links | I'm trying to figure out pySVG, having trouble understanding how to link to an external CSS file, does pySVG handle this? Looking over the documentation, the style seems to be hard coded in most of the examples.
Further, I'd love to add an 'onclick' to change the CSS reference, so, a heat map (for example) could link... | [
"I'm not quite sure how pySVG does things, but you can add an external CSS to an SVG you've created by adding:\n<?xml-stylesheet type=\"text/css\" href=\"CSS_filename.css\" ?>\n\nIt should be the very first line of the file, i.e. before the DOCTYPE declaration.\nAs for the onclick changes, you can have an element l... | [
1
] | [] | [] | [
"python",
"svg"
] | stackoverflow_0007140656_python_svg.txt |
Q:
SQLAlchemy versioning cares about class import order
I was following the guide here:
http://www.sqlalchemy.org/docs/orm/examples.html?highlight=versioning#versioned-objects
and have come across an issue. I have defined my relationships like:
generic_ticker = relation('MyClass', backref=backref("stuffs"))
with str... | SQLAlchemy versioning cares about class import order | I was following the guide here:
http://www.sqlalchemy.org/docs/orm/examples.html?highlight=versioning#versioned-objects
and have come across an issue. I have defined my relationships like:
generic_ticker = relation('MyClass', backref=backref("stuffs"))
with strings so it doesn't care about the import order of my model... | [
"\nI fixed the problem by putting the try: except stuff in a lambda and\n running them all after all the imports have happened. \n\nGreat!\n"
] | [
2
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0005733113_python_sqlalchemy.txt |
Q:
python: unpack IBM 32-bit float point
I was reading a binary file in python like this:
from struct import unpack
ns = 1000
f = open("binary_file", 'rb')
while True:
data = f.read(ns * 4)
if data == '':
break
unpacked = unpack(">%sf" % ns, data)
print str(unpacked)
when I realized unpack(... | python: unpack IBM 32-bit float point | I was reading a binary file in python like this:
from struct import unpack
ns = 1000
f = open("binary_file", 'rb')
while True:
data = f.read(ns * 4)
if data == '':
break
unpacked = unpack(">%sf" % ns, data)
print str(unpacked)
when I realized unpack(">f", str) is for unpacking IEEE floating p... | [
"I think I understood it:\nfirst unpack the string to unsigned 4 byte integer, and then use this function:\ndef ibm2ieee(ibm):\n \"\"\"\n Converts an IBM floating point number into IEEE format.\n :param: ibm - 32 bit unsigned integer: unpack('>L', f.read(4))\n \"\"\"\n if ibm == 0:\n return 0.... | [
5
] | [] | [] | [
"binary",
"floating_point",
"ieee_754",
"python"
] | stackoverflow_0007125890_binary_floating_point_ieee_754_python.txt |
Q:
Any prefab stuff for organising a tournament?
Does anyone know if there are premade open source webapps not from 2005 (preferably PHP, but Rails/pYthon are fine) for an esports (specifically, counter-strike: source) tournament?
I've googled a fair bit and can't find anything serious.
Thanks in advance!
A:
While ... | Any prefab stuff for organising a tournament? | Does anyone know if there are premade open source webapps not from 2005 (preferably PHP, but Rails/pYthon are fine) for an esports (specifically, counter-strike: source) tournament?
I've googled a fair bit and can't find anything serious.
Thanks in advance!
| [
"While this isnt open source per se I still think it can satisfy your needs.\nBoth Binary Beast and Challonge serves an API from which you can create and manage tournaments.\nBinary Beast even provides libraries to interact with the API.\nYou will have to do some front end programming yourself or host it entirely o... | [
2
] | [] | [] | [
"php",
"python",
"ruby_on_rails",
"web_applications"
] | stackoverflow_0007141306_php_python_ruby_on_rails_web_applications.txt |
Q:
importing imports from your imports in python
Question: In python, Is it wise to use the imports from your sub classes, or does it matter?
Info:
So, I have a program split up over 6 files. in almost every one of the .py files i import threading, socket, and pickle. What I'm wondering is this, is there an efficien... | importing imports from your imports in python | Question: In python, Is it wise to use the imports from your sub classes, or does it matter?
Info:
So, I have a program split up over 6 files. in almost every one of the .py files i import threading, socket, and pickle. What I'm wondering is this, is there an efficiency difference between:
File1.py:
import socket
Fil... | [
"Don't use from File1 import socket. It doesn't make a performance difference, but it gives headaches to other people having to look in the other file to see that File1.socket is actually socket, and it might get messy if you decide you don't need socket in File1.\nAlso, this is against the python principles becaus... | [
3,
2,
1
] | [] | [] | [
"import",
"python"
] | stackoverflow_0007141414_import_python.txt |
Q:
Finding Top Level Tags With BeautifulSoup
I have some BeautifulSoup I'm looking at. In this case, my tree looks like this:
soup = "<table class="myTable"><tr>...</tr></table>"
When I call the following:
soup.findAll(attrs={'class':'myTable'})
I don't have anything returned, when I would expect that top level tag... | Finding Top Level Tags With BeautifulSoup | I have some BeautifulSoup I'm looking at. In this case, my tree looks like this:
soup = "<table class="myTable"><tr>...</tr></table>"
When I call the following:
soup.findAll(attrs={'class':'myTable'})
I don't have anything returned, when I would expect that top level tag to be returned. But if the tag I'm searching f... | [
"I can't reproduce the problem. I think finding the top-level tags should work:\nIn [92]: import BeautifulSoup\nIn [94]: soup=BeautifulSoup.BeautifulSoup('<table class=\"myTable\"><tr>...</tr></table>')\n\nIn [95]: soup.findAll(attrs={'class':'myTable'})\nOut[95]: [<table class=\"myTable\"><tr>...</tr></table>]\n\n... | [
1
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0007141350_beautifulsoup_python.txt |
Q:
Working implementation of daemon in Python
Does anyone know of a working and well documented implementation of a daemon using python? Please post a link here if you know of a project that fits these two requirements.
A:
Three options I can think of-
Make a cron job that calls your script. Cron is a common name... | Working implementation of daemon in Python | Does anyone know of a working and well documented implementation of a daemon using python? Please post a link here if you know of a project that fits these two requirements.
| [
"Three options I can think of-\n\nMake a cron job that calls your script. Cron is a common name for a GNU/Linux daemon that periodically launches scripts according to a schedule you set. You add your script into a crontab or place a symlink to it into a special directory and the daemon handles the job of launching ... | [
4,
4,
1
] | [] | [] | [
"daemon",
"python"
] | stackoverflow_0004000042_daemon_python.txt |
Q:
Adding """ at the beginning and end of a string?
Whenever I feed a string like "Muhammed went to the store and said "Can I have some pickles please"" It seems to screw up how the string is handled since a Can I have some pickles please becomes invalid. So I thought adding """ at both sides of it would surely fix i... | Adding """ at the beginning and end of a string? | Whenever I feed a string like "Muhammed went to the store and said "Can I have some pickles please"" It seems to screw up how the string is handled since a Can I have some pickles please becomes invalid. So I thought adding """ at both sides of it would surely fix it, if there are any better solutions to this, I'm open... | [
"You can just escape the inner quotes:\n\"Muhammed went to the store and said \\\"Can I have some pickles please\\\"\"\n\nor use single quotes\n'Muhammed went to the store and said \"Can I have some pickles please\"'\n\n",
"Pick one:\n'Muhammed went to the store and said \"Can I have some pickles please\"'\n\"Muh... | [
4,
4,
1
] | [] | [] | [
"formatting",
"python",
"string"
] | stackoverflow_0007139361_formatting_python_string.txt |
Q:
repeated items in a list python
I have a huge dictionary (like a database) where I want to find some specific information. Let's call the huge database A.
If one specific number of a new list is inside A I want to print some info. This is what I am doing (oversimplified):
A = {info1:34, info2:4, info3:-34, in... | repeated items in a list python | I have a huge dictionary (like a database) where I want to find some specific information. Let's call the huge database A.
If one specific number of a new list is inside A I want to print some info. This is what I am doing (oversimplified):
A = {info1:34, info2:4, info3:-34, info4:2,.......}
b = [1, 2, 3, 4, 5... | [
"From what I understand what you are trying is overkill. This is a solution that makes use of the fact that dict is actually a hash:\nfor item in b:\n if item in A:\n print A[item]\n\nEDIT: from your edit it seems that the keys and values are interchanged. Why are you doing this? Maybe it's a better idea ... | [
0,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0007141501_list_python.txt |
Q:
How to install the pygame Python module easily on a mac
Please help me! I have been looking for a while and I am really frustrated. I can't find a tutorial that I can understand that will help me install pygame. Please post a really easy to understand tutorial as I am fairly new to Python. I am running Mac OSX 10.... | How to install the pygame Python module easily on a mac | Please help me! I have been looking for a while and I am really frustrated. I can't find a tutorial that I can understand that will help me install pygame. Please post a really easy to understand tutorial as I am fairly new to Python. I am running Mac OSX 10.6 if that helps. Thanks!
| [
"I installed pygame recently on 10.6 using the installer linked from the pygame download page:\n\nhttp://f0o.com/~rene/stuff/pygame-1.9.2pre-py2.6-macosx10.6.mpkg.zip\n\n"
] | [
1
] | [] | [] | [
"pygame",
"python"
] | stackoverflow_0007141801_pygame_python.txt |
Q:
How to run a script for more than 10 minutes in Google App Engine
I know that Task Queues can only run for 10 minutes, and I have a script that cannot finish in that time limit. Is there a way to exceed this time constraint? I looked into backends, as I know those have no limits, but I couldn't find the documentat... | How to run a script for more than 10 minutes in Google App Engine | I know that Task Queues can only run for 10 minutes, and I have a script that cannot finish in that time limit. Is there a way to exceed this time constraint? I looked into backends, as I know those have no limits, but I couldn't find the documentation on how to make one
| [
"Use a backend. They're documented here.\nIf your script won't finish in time because it's processing too much data, though, you probably want to consider rewriting it if you want it to scale. Breaking it up into chunks and running them on the task queue is a common approach, and means your task won't run slower an... | [
3
] | [] | [] | [
"google_app_engine",
"python",
"queue",
"task",
"task_queue"
] | stackoverflow_0007141497_google_app_engine_python_queue_task_task_queue.txt |
Q:
c# ip address generator to SQL
I have the following python code I found on the internet, I would like to make a table in a SQL database with every ipv4 address that there is. I dont code in python but its what I found.
My question is
1: Is there T-SQL code I can use to generate the table ? (one column ie 0.0.0.0-... | c# ip address generator to SQL | I have the following python code I found on the internet, I would like to make a table in a SQL database with every ipv4 address that there is. I dont code in python but its what I found.
My question is
1: Is there T-SQL code I can use to generate the table ? (one column ie 0.0.0.0-255.255.255.255)
2: Is how would I ... | [
"Would this work?\nDECLARE @a INTEGER\nDECLARE @b INTEGER\nDECLARE @c INTEGER\nDECLARE @d INTEGER\nDECLARE @IPADDRESS nvarchar(50)\n\nset @a = 0\n\nWHILE @a < 256\nBEGIN\n SET @b = 0\n WHILE @b < 256\n BEGIN\n SET @c = 0\n WHILE @c < 256\n BEGIN\n SET @d = 0\n WHI... | [
0,
0,
0
] | [] | [] | [
"c#",
"python",
"sql",
"tsql"
] | stackoverflow_0007141873_c#_python_sql_tsql.txt |
Q:
rpy2 plot problem
I use rpy2-2.0.8, R-2.11.1, Python-2.6.2 on Windows XP.
When I run this script, output image is filled with text message.
I suppose this message is function definition of clusplot.
[test.py]
#!/usr/bin/env python
# -*- mode: python -*- -*- coding: utf-8 -*-
import rpy2.robjects as ro
r = ro.r
#... | rpy2 plot problem | I use rpy2-2.0.8, R-2.11.1, Python-2.6.2 on Windows XP.
When I run this script, output image is filled with text message.
I suppose this message is function definition of clusplot.
[test.py]
#!/usr/bin/env python
# -*- mode: python -*- -*- coding: utf-8 -*-
import rpy2.robjects as ro
r = ro.r
# read from csv file
dat... | [
"I have solved this problem by myself.\nR plot command completes the plot title automatically when it is not given.\nR command with console and via rpy2 have different behavior for this complement.\n(I think it is a kind of bug for rpy2)\nSo set the title with \"main\" argument explicitly like this.\n# plot\nr.jpeg... | [
1
] | [] | [] | [
"python",
"rpy2"
] | stackoverflow_0007087450_python_rpy2.txt |
Q:
What does the `s` in `%s` mean in string formatting?
I have just started reading learn python the hard way and I have a question.
for example the code will be
name = input("Name?")
print "your name is %s" % name
why do we use d or what ever, does it make a difference?
A:
The d in %d stands for decimal. %d is f... | What does the `s` in `%s` mean in string formatting? | I have just started reading learn python the hard way and I have a question.
for example the code will be
name = input("Name?")
print "your name is %s" % name
why do we use d or what ever, does it make a difference?
| [
"The d in %d stands for decimal. %d is for formatting numbers. %s is for formatting strings. (thus, the example you gave actually doesn't work) Yes, it matters. You need to tell Python where to place the thing after the % operator into the string.\n",
"%d indicates that the value is an integer. %s would be used ... | [
4,
3,
3,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0007142299_python.txt |
Q:
Parse FB Graph API date string into python datetime
Here's an example of how the Facebook Graph API is returning date strings for me:
2011-03-06T03:36:45+0000
how would I parse this into a python datetime class? I'm aware of the datetime.strptime function, which takes in a second parameter that contains some goog... | Parse FB Graph API date string into python datetime | Here's an example of how the Facebook Graph API is returning date strings for me:
2011-03-06T03:36:45+0000
how would I parse this into a python datetime class? I'm aware of the datetime.strptime function, which takes in a second parameter that contains some googly-eyed format string, but don't know which letters and d... | [
"Here it is with time & strptime:\n>>> time.strptime('2011-03-06T03:36:45+0000', '%Y-%m-%dT%H:%M:%S+0000')\ntime.struct_time(tm_year=2011, tm_mon=3, tm_mday=6, tm_hour=3, tm_min=36, tm_sec=45, tm_wday=6, tm_yday=65, tm_isdst=-1)\n\nor with datetime:\n>>> datetime.datetime.strptime('2011-03-06T03:36:45+0000','%Y-%m-... | [
16,
1
] | [] | [] | [
"facebook_graph_api",
"python"
] | stackoverflow_0007142618_facebook_graph_api_python.txt |
Q:
How to get bandwidth quota usage with Google app engine api?
I want to know if Google App Engine support using google.appengine.api.quota package to get bandwidth usage, not cpu usage?
If so, how to get with Python or Java and print in webpage?
A:
No, but you can get a very close estimate of this by adding up th... | How to get bandwidth quota usage with Google app engine api? | I want to know if Google App Engine support using google.appengine.api.quota package to get bandwidth usage, not cpu usage?
If so, how to get with Python or Java and print in webpage?
| [
"No, but you can get a very close estimate of this by adding up the length of the request headers and body for incoming requests, and the response body and headers for responses.\n"
] | [
1
] | [
"Reading the javadoc gives the answer: no.\nAnd no, I won't mail you this answer. You write here, you read here.\n"
] | [
-1
] | [
"api",
"google_app_engine",
"java",
"python"
] | stackoverflow_0007131834_api_google_app_engine_java_python.txt |
Q:
How can I send raw post data with python?
I'm trying to post data to a web page using python.
There is a game on facebook, and the invite codes are combinations of 5 letters.
I wrote a script that wrote all the combinations of letters to a txt file.
Here is the data I need to post.
http://pastie.org/2409481
This c... | How can I send raw post data with python? | I'm trying to post data to a web page using python.
There is a game on facebook, and the invite codes are combinations of 5 letters.
I wrote a script that wrote all the combinations of letters to a txt file.
Here is the data I need to post.
http://pastie.org/2409481
This cookie 'bbbbb' will end up being a variable and ... | [
"Take a look at Requests, a wrapper for urllib2 (I believe). Ripping one of the examples off that page:\n# This example cooked up by me!\n\nimport requests\npost_data = {\"amount\":10000, \"service\":\"writing blog posts\"}\n\nr = requests.post('http://example.com/api', post_data, auth=('user', 'pass'))\n\nprint r.... | [
0
] | [] | [] | [
"brute_force",
"http_headers",
"http_post",
"python",
"variables"
] | stackoverflow_0007142829_brute_force_http_headers_http_post_python_variables.txt |
Q:
how to print the mysql shell output table
in mysql shell print a table like this
[code][1]
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| PROXY |
| bbs_bj |
| bbs_bj_copy |
| mysql |
| octopus ... | how to print the mysql shell output table | in mysql shell print a table like this
[code][1]
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| PROXY |
| bbs_bj |
| bbs_bj_copy |
| mysql |
| octopus |
| octopus_cp |
| spider ... | [
"Just get the result of \"show databases\" query, and format the result what ever you want.To output as pdf, you may use some lib like pyPdf.\n"
] | [
0
] | [] | [] | [
"python"
] | stackoverflow_0007142952_python.txt |
Q:
Python : Not able to get the list of the options that have been added via 'add_option'?
My code portion looks like:
parser.add_option("-h", "--help","-?",
action = "help",
help= """Print the help of the scipt"""
)
When I am trying to print the options availa... | Python : Not able to get the list of the options that have been added via 'add_option'? | My code portion looks like:
parser.add_option("-h", "--help","-?",
action = "help",
help= """Print the help of the scipt"""
)
When I am trying to print the options available for the script, it returns an empty array.
optlist = [x.get_opt_string() for x in parse... | [
"In python 2.6.5 optparse objects have undocumented attributes _short_opts and _long_opts. For a bumpy list\n[x._short_opts + x._long_opts for x in parser._get_all_options()]\n\nUsing join list of lists in python to flatten the list\nsum([x._short_opts + x._long_opts for x in parser._get_all_options()],[])\n\n"
] | [
1
] | [] | [] | [
"python",
"python_2.x"
] | stackoverflow_0007142902_python_python_2.x.txt |
Q:
Communication between Python and Jython(JAVA) App over nework
I am going to develop a Saas ( Software as a Service ) based application , which uses a python app which will run on the server and a client GUI which will be running as a jython app. Initially my plan is that the client will be developed in Jython for... | Communication between Python and Jython(JAVA) App over nework | I am going to develop a Saas ( Software as a Service ) based application , which uses a python app which will run on the server and a client GUI which will be running as a jython app. Initially my plan is that the client will be developed in Jython for prototyping purposes, but later if the application complexity incr... | [
"I recommend to use RPC, instead of pure TCP/IP communication via sockets.\nIf there's few clients, and you don't want to engage with complicated technologies, use something like JsonRPC or XMLRPC. (Note that Pyro can only be used when both server and client written in Python. If you plan to move to Java later, you... | [
2,
0
] | [] | [] | [
"java",
"jython",
"python"
] | stackoverflow_0007142995_java_jython_python.txt |
Q:
PIL's Image.frombuffer expected data length when using ctypes array
I am using Python, PIL and ctypes to do image manipulation. As I hacked stuff together, I used PIL's fromstring function to get the pixel buffer from ctypes into a PIL object. I simply iterated over the array, building the python string.
This ... | PIL's Image.frombuffer expected data length when using ctypes array | I am using Python, PIL and ctypes to do image manipulation. As I hacked stuff together, I used PIL's fromstring function to get the pixel buffer from ctypes into a PIL object. I simply iterated over the array, building the python string.
This works
tx = foo.tx
tx.restype = POINTER(c_ubyte)
result = tx(...args...)
... | [
"try the following code:\nimport Image\nfrom ctypes import c_ubyte, cast, POINTER\n\nbuf = (c_ubyte * 400)()\npbuf = cast(buf, POINTER(c_ubyte))\npbuf2 = cast(pbuf, POINTER(c_ubyte*400))\n\nimg1 = Image.frombuffer(\"RGBA\", (10,10), buf, \"raw\", \"RGBA\", 0, 1)\nimg2 = Image.frombuffer(\"RGBA\", (10,10), pbuf2.con... | [
3,
3
] | [] | [] | [
"ctypes",
"python",
"python_imaging_library"
] | stackoverflow_0007142169_ctypes_python_python_imaging_library.txt |
Q:
Advanced python string search
I was wondering if anyone can point me to a library that can search a string using google-ish syntax. Examples:
Google advanced search syntax
Craigslist advanced search syntax
So if the query were
food -pizza
and the search subject was
Ray's Pizza, best food in town!
It would not ... | Advanced python string search | I was wondering if anyone can point me to a library that can search a string using google-ish syntax. Examples:
Google advanced search syntax
Craigslist advanced search syntax
So if the query were
food -pizza
and the search subject was
Ray's Pizza, best food in town!
It would not result in a match. Etc etc.
| [
"Whoosh is really great fast, full-text search engine written in Python, it has a nice API and nice documentation.\n",
"Does it has to be Python? Because Lucene would be perfect otherwise.\n"
] | [
3,
0
] | [] | [] | [
"python",
"search"
] | stackoverflow_0007143418_python_search.txt |
Q:
how to create scripting languages
I'd really like to know what knowledge do I have to pursue in order to create scripting languages from the ground up, probably using C++, maybe python, for those are the languages I know.
I've searched through SO similar questions, but nothing comes close of what I'm asking. I int... | how to create scripting languages | I'd really like to know what knowledge do I have to pursue in order to create scripting languages from the ground up, probably using C++, maybe python, for those are the languages I know.
I've searched through SO similar questions, but nothing comes close of what I'm asking. I intend to understand language processing, ... | [
"\"From the ground up\" is a quite relative term, especially if you consider Python as the implementation language. I think what you are looking for is the implementation of a domain specific language (DSL). Good starting points might be this book or this one. DSLs are a wide topic, so if you provide more details, ... | [
3
] | [] | [] | [
"algorithm",
"c++",
"data_mining",
"python",
"scripting_language"
] | stackoverflow_0007143716_algorithm_c++_data_mining_python_scripting_language.txt |
Q:
is there any way to converts Python scripts into executable Windows programs on linux
is there any way to converts Python scripts into executable Windows programs on linux
i know py2exe and pyinstall will work well on windows
but i only has linux Environment
A:
Why would you want to convert it to a windows exec... | is there any way to converts Python scripts into executable Windows programs on linux | is there any way to converts Python scripts into executable Windows programs on linux
i know py2exe and pyinstall will work well on windows
but i only has linux Environment
| [
"Why would you want to convert it to a windows executable on a linux platform? Anyway, I'd say you have two options: \n\nUse py2exe with wine (a Windows emulator). I've done this, and it works\nIf that is not possible, you could try pyinstaller. I haven't tried it, but it seems to be sort of the same, but multi-pla... | [
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0007143749_python.txt |
Q:
Django: show useful database data in admin interface?
So I've set up my django site with the following admin.py:
import models
from django.contrib import admin
admin.site.register(models.Comment)
which uses this models.py:
from django.db import models
class Comment(models.Model):
text = models.CharField(max_l... | Django: show useful database data in admin interface? | So I've set up my django site with the following admin.py:
import models
from django.contrib import admin
admin.site.register(models.Comment)
which uses this models.py:
from django.db import models
class Comment(models.Model):
text = models.CharField(max_length=400)
name = models.CharField(max_length=100)
... | [
"The admin turns your object into a string so just put a def __str__ or def __unicode__\n(As @Mandax has reminded me the docs recommend to define __unicode__ only.)\ndef __unicode__(self);\n return u\"%s (%s): %s\" % (self.article, self.date, self.name)\n\n",
"Just as it says in the documentation, your model's... | [
5,
4
] | [] | [] | [
"database",
"django",
"model",
"python"
] | stackoverflow_0007143679_database_django_model_python.txt |
Q:
Difference between memcache and python dictionary
In my current project, I am using Memcache to store key-value pairs, but since the communication happens over the socket between my process and the Memcache causing the huge latencies. We went with memcache because we had a requirement of storing large amount of ke... | Difference between memcache and python dictionary | In my current project, I am using Memcache to store key-value pairs, but since the communication happens over the socket between my process and the Memcache causing the huge latencies. We went with memcache because we had a requirement of storing large amount of key-value pairs. But now I want to store the dictionary a... | [
"The usual reason to use memcached is that you would like to distribute the cache among multiple machines, with the goal of both having data available on all the machines, while also utilizing the storage of all the machines. If those requirements don't apply to you, and you only need the cached data on a single ma... | [
10,
6,
1
] | [] | [] | [
"memcached",
"python"
] | stackoverflow_0007143746_memcached_python.txt |
Q:
Java Calling Python Script stuck on sudo password prompt
I am developing a Java application that calls a python script behind the scene.
This is the way i call my python script:
Runtime r = Runtime.getRuntime();
Process p = r.exe("/path/to/Python/script.py");
I can see that my python script running in the backgro... | Java Calling Python Script stuck on sudo password prompt | I am developing a Java application that calls a python script behind the scene.
This is the way i call my python script:
Runtime r = Runtime.getRuntime();
Process p = r.exe("/path/to/Python/script.py");
I can see that my python script running in the background using ps.
The script requires root privileges so sudo prom... | [
"Use gksudo in place of sudo. It automatically pops up a window asking for the password. \n"
] | [
0
] | [] | [] | [
"java",
"jython",
"python",
"sudo"
] | stackoverflow_0007143888_java_jython_python_sudo.txt |
Q:
Set digits on float field in xml
I need a set digits on float field in xml. In python we can set digits like this
'data': fields.float('Data', digits=(16,4))
How to set digits on float field in xml in openerp 6?
A:
From an OpenERP XML file :
<group colspan="2" col="2" groups="base.group_extended">
... | Set digits on float field in xml | I need a set digits on float field in xml. In python we can set digits like this
'data': fields.float('Data', digits=(16,4))
How to set digits on float field in xml in openerp 6?
| [
"From an OpenERP XML file : \n<group colspan=\"2\" col=\"2\" groups=\"base.group_extended\">\n <separator string=\"Weights\" colspan=\"2\"/>\n <field digits=\"(14, 3)\" name=\"volume\" attrs=\"{'readonly':[('type','=','service')]}\"/>\n ... | [
5
] | [] | [] | [
"openerp",
"python"
] | stackoverflow_0007142432_openerp_python.txt |
Q:
Django error: AttributeError: 'NoneType' object has no attribute 'db'
Has anyone seen this error before? It comes whenever I try to execute a query on a particular model of mine. Querying the db directly works fine and it doesn't happen with other models.
For example, it's triggered by something like:
MyModel.... | Django error: AttributeError: 'NoneType' object has no attribute 'db' | Has anyone seen this error before? It comes whenever I try to execute a query on a particular model of mine. Querying the db directly works fine and it doesn't happen with other models.
For example, it's triggered by something like:
MyModel.objects.get(name__iexact = 'an existent name')
I believe this started imme... | [
"Kicking myself for this one, especially given how obvious the error message makes it in retrospect.\nMy migration had added a new field named \"_state\" to the model. This field collided with the _state attribute of the object referenced in line 289 of query.pyc above.\nSo new lesson: no field can be named \"_sta... | [
0
] | [] | [] | [
"django",
"django_south",
"python"
] | stackoverflow_0007141621_django_django_south_python.txt |
Q:
how to count the number of online users
Possible Duplicate:
Who's Online in Pylons
We have a project on the pylons. And now the task is to count all users are on the site. Do this with a session does not work, because the lifetime of the session for about a day. How can I do?
A:
In my project (but in django), ... | how to count the number of online users |
Possible Duplicate:
Who's Online in Pylons
We have a project on the pylons. And now the task is to count all users are on the site. Do this with a session does not work, because the lifetime of the session for about a day. How can I do?
| [
"In my project (but in django), I'm store user id in database with time of last request and show all users for last 5 minute.\n"
] | [
1
] | [] | [] | [
"pylons",
"python"
] | stackoverflow_0007144437_pylons_python.txt |
Q:
Delete all visible cookies raises an exception
I am using selenium with a python client. When doing selenium.delete_all_visible_cookies I get the exception:
ERROR: Command execution failure.
Please search the forum at
http://clearspace.openqa.org for error
details from the log window. The
error message ... | Delete all visible cookies raises an exception | I am using selenium with a python client. When doing selenium.delete_all_visible_cookies I get the exception:
ERROR: Command execution failure.
Please search the forum at
http://clearspace.openqa.org for error
details from the log window. The
error message is: malformed URI
sequence
The log window's error... | [
"This is a bug, see here: \nhttp://clearspace.openqa.org/message/68779\n",
"To see the bug: http://jira.openqa.org/browse/SEL-712\n"
] | [
1,
1
] | [] | [] | [
"cookies",
"exception",
"python",
"selenium"
] | stackoverflow_0001506315_cookies_exception_python_selenium.txt |
Q:
apache server with mod_wsgi + python as backend, how can i be able to notified my connection status?
i'm trying to build a web server using apache as the http server, mod_wsgi + python as the logic handler, the server was supposed to handler long request without returning, meaning i want to keep writing stuff into... | apache server with mod_wsgi + python as backend, how can i be able to notified my connection status? | i'm trying to build a web server using apache as the http server, mod_wsgi + python as the logic handler, the server was supposed to handler long request without returning, meaning i want to keep writing stuff into this request.
the problem is, when the link is broken, the socket is in a CLOSE_WAIT status, apache will ... | [
"You cant. It is a limitation of the API defined by the WSGI specification. So, nothing to do with Apache or mod_wsgi really as you will have the same issue with any WSGI server if you follow the WSGI specification.\nIf you search through the mod_wsgi mailing list on Google Groups you will find a number of discussi... | [
1
] | [] | [] | [
"apache",
"mod_wsgi",
"python",
"webserver"
] | stackoverflow_0007144011_apache_mod_wsgi_python_webserver.txt |
Q:
Problems with mousepressevent
I just asked a similar question but (sorry!) I think I'll need more help. I have a problem with signals in pyqt. Let me post the whole code, it isn't long and it is easier for me to explain...
from PyQt4 import QtGui, QtCore, Qt
import time
import math
class FenixGui(QtGui.QWidget):
... | Problems with mousepressevent | I just asked a similar question but (sorry!) I think I'll need more help. I have a problem with signals in pyqt. Let me post the whole code, it isn't long and it is easier for me to explain...
from PyQt4 import QtGui, QtCore, Qt
import time
import math
class FenixGui(QtGui.QWidget):
def backgroundmousepressevent(... | [
"In Qt, events are different from signals and slots. Events are represented by QEvent objects that are passed to the event() method of QObjects, where they are typically dispatched to specialized methods such as mousePressEvent and mouseMoveEvent. Since they are not signals, you cannot connect them to slots.\nIns... | [
5,
1
] | [] | [] | [
"mouseevent",
"mousepress",
"pyqt",
"python",
"signals"
] | stackoverflow_0007144705_mouseevent_mousepress_pyqt_python_signals.txt |
Q:
No Newlines in the CSV when the field of the Dict is empty [Python, CSV]
I'm a python beginner, (I actually use the 2.7 version)
My code is actually working well (it's a simple one)
but it insert new lines between the reslut in my output file. I've noticed that they mentionned it in the documentation (see further... | No Newlines in the CSV when the field of the Dict is empty [Python, CSV] | I'm a python beginner, (I actually use the 2.7 version)
My code is actually working well (it's a simple one)
but it insert new lines between the reslut in my output file. I've noticed that they mentionned it in the documentation (see further) but no the way to avoid inserting automatically a newline when a field is em... | [
"If you want the ; to be the field delimiter, you have to specify that:\nnew = csv.reader(ifile, delimiter=';')\noutput = csv.writer(ofile,dialect='excel',delimiter=\"\\t\")\nfor item in new:\n output.writerow(item)\n\nThis works just as well with a DictReader to separate the fields.\nWrites the fields tab delim... | [
1
] | [] | [] | [
"csv",
"dictionary",
"python"
] | stackoverflow_0007145224_csv_dictionary_python.txt |
Q:
How to run cron-like scripts on Django?
To give you a little brief about what I'm tying to do ->
I'm building a timed-contest app which expires at a set datetime.
So basically I want a script which queries my model and changes some values according to busines logic periodically
How would you do this in django ?
... | How to run cron-like scripts on Django? | To give you a little brief about what I'm tying to do ->
I'm building a timed-contest app which expires at a set datetime.
So basically I want a script which queries my model and changes some values according to busines logic periodically
How would you do this in django ?
| [
"You use celery.\nhttp://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html\n",
"You wouldn't. You'd use cron to run a standalone script or management command.\n",
"You could take a look at django-cron\nhttp://code.google.com/p/django-cron/\nIt takes advantage of Django being a long-run process and ... | [
7,
6,
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0007145018_django_python.txt |
Q:
Python unittest sudden quit
Is there a way to make python unittest (I am using 2.6, I have unittest2 available) as soon as an error or fail occured without waiting all tests to finish?
And a bonus question :) Is there a way to order tests. For example, pulling tests that are likely to fail on front?
A:
Run unitt... | Python unittest sudden quit | Is there a way to make python unittest (I am using 2.6, I have unittest2 available) as soon as an error or fail occured without waiting all tests to finish?
And a bonus question :) Is there a way to order tests. For example, pulling tests that are likely to fail on front?
| [
"Run unittest it with the -f option.\nOptions:\n -f, --failfast Stop on first failure\n\nExample: ./auth_test.py -f\nWhere at the end of auth_test.py you have\nif __name__ == '__main__':\n unittest.main()\n\n\nFor ordering - I don't think so. At least not out of the box. You can, however, run only a single ... | [
5
] | [] | [] | [
"python",
"unit_testing"
] | stackoverflow_0007145977_python_unit_testing.txt |
Q:
Why am I getting a UnicodeDecodeError in Python's JSON encoding?
I am using Solr 3.3 to index stuff from my database. I compose the JSON content in Python. I manage to upload 2126 records which add up to 523246 chars (approx 511kb). But when I try 2027 records, Python gives me the error:
Traceback (most recent cal... | Why am I getting a UnicodeDecodeError in Python's JSON encoding? | I am using Solr 3.3 to index stuff from my database. I compose the JSON content in Python. I manage to upload 2126 records which add up to 523246 chars (approx 511kb). But when I try 2027 records, Python gives me the error:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "D:\Technovia\... | [
"Simple, just don't use utf-8 encoding if your data is not in utf-8\n>>> json.loads('[\"\\x96\"]')\n....\nUnicodeDecodeError: 'utf8' codec can't decode byte 0x96 in position 0: invalid start byte\n\n>>> json.loads('[\"\\x96\"]', encoding=\"latin-1\")\n[u'\\x96']\n\n\njson.loads\nIf s is a str instance and is encode... | [
14
] | [] | [] | [
"json",
"python"
] | stackoverflow_0007146000_json_python.txt |
Q:
Streaming webcam data to a webpage
My intention:
Stream webcam feed to a webpage.
Have buttons that talk to a Python program.
I'm planning on using OpenTLD (AKA Predator) to get information about a moving speaker via webcam. Then I will send the coordinates to Python, which will do calculations, and send it via... | Streaming webcam data to a webpage | My intention:
Stream webcam feed to a webpage.
Have buttons that talk to a Python program.
I'm planning on using OpenTLD (AKA Predator) to get information about a moving speaker via webcam. Then I will send the coordinates to Python, which will do calculations, and send it via the serial connection (using pyserial) ... | [
"I would suggest the following: \n\nCapture and write to file:\nRead file and calculate coordinates\nUse Python or any other language to send the signals over serial.\n\nYou might need to incorporate some feedback aspect for proper control. For capturing and writing to files, there should be range of programs. Many... | [
2
] | [] | [] | [
"arduino",
"python",
"stream",
"ubuntu",
"web"
] | stackoverflow_0007140125_arduino_python_stream_ubuntu_web.txt |
Q:
use of python super function in django model
Here's some code in a django tutorial that I'm going through. I've never come across the super function in python before and the way it's used here is different from the examples I've seen online. I.e., usually when you use super, don't you have multiple classes? It'... | use of python super function in django model | Here's some code in a django tutorial that I'm going through. I've never come across the super function in python before and the way it's used here is different from the examples I've seen online. I.e., usually when you use super, don't you have multiple classes? It's in the last line: super(Snippet, self).save(for... | [
"super(Snippet, self) causes Python to look in the MRO of the class of self (i.e. self.__class__.mro() for the next class listed after Snippet. It returns a super object which acts as a proxy for that class. That is, calling a method on the super object acts like calling that method on the class.\nsuper(Snippet, se... | [
41,
4
] | [] | [] | [
"django",
"python",
"super"
] | stackoverflow_0007141820_django_python_super.txt |
Q:
Python2.6 run error failing to import md5
i downloaded python2.6 and installed it on Solaris10 operating system which ships with python2.4 already installed however when tried importing the md5 module i was getting this error
import md5
__main__:1: DeprecationWarning: the md5 module is deprecated; use hashlib in... | Python2.6 run error failing to import md5 | i downloaded python2.6 and installed it on Solaris10 operating system which ships with python2.4 already installed however when tried importing the md5 module i was getting this error
import md5
__main__:1: DeprecationWarning: the md5 module is deprecated; use hashlib instead
Traceback (most recent call last):
File... | [
"See http://docs.python.org/library/md5.html:\n\nDeprecated since version 2.5: Use the hashlib module instead.\n\nNot much changes for you - you should import the haslib module and call hashlib.md5() instead of md5.new().\nEdit: Then again, I just verified that module md5 normally imports correctly in Python 2.6 de... | [
2
] | [] | [] | [
"python",
"unix"
] | stackoverflow_0007146412_python_unix.txt |
Q:
pycurl with Google app engine
Possible Duplicate:
curl on app engine
Does GAE support pycurl ?
I have downloaded the pycurl setup (pycurl-ssl-7.18.2.win32-py2.5.exe) from this link :http://pycurl.sourceforge.net/download/ . And setup was installed in C:\Python25\Lib\site-packages\curl
Now how can in integrate py... | pycurl with Google app engine |
Possible Duplicate:
curl on app engine
Does GAE support pycurl ?
I have downloaded the pycurl setup (pycurl-ssl-7.18.2.win32-py2.5.exe) from this link :http://pycurl.sourceforge.net/download/ . And setup was installed in C:\Python25\Lib\site-packages\curl
Now how can in integrate pycurl with Google app engine proje... | [
"http://pycurl.sourceforge.net/:\n\nPycURL is a Python interface to libcurl [...]\n\nYou can't use PycURL on GAE since it requires this C library. \nAs the commenters said, use the native URL Fetch API for similar functionality.\n"
] | [
3
] | [] | [] | [
"google_app_engine",
"pycurl",
"python",
"windows"
] | stackoverflow_0007143797_google_app_engine_pycurl_python_windows.txt |
Q:
Ruby HAML with Django?
Ok, so I really love HAML. Particularly, I love the integration with RedCloth and BlueCloth, so I can use Markdown and Textile intermixed with my HAML.
I also love Python and Django.
So, I would like to use HAML with Django. Now, I already understand that there are some attempts at cloning... | Ruby HAML with Django? | Ok, so I really love HAML. Particularly, I love the integration with RedCloth and BlueCloth, so I can use Markdown and Textile intermixed with my HAML.
I also love Python and Django.
So, I would like to use HAML with Django. Now, I already understand that there are some attempts at cloning HAML-like syntax in Python ... | [
"Question 1: static HTML files should work finely (unless you plan to use HAML's ruby evaluation feature to dynamically content). I use a similar way on a php website with SASS stylesheets. Just make sure you start HAML in directory watch mode before starting to hack ;)\nQuestion 2: while forking a ruby process to ... | [
8,
2,
1,
0
] | [] | [] | [
"django",
"haml",
"python",
"ruby"
] | stackoverflow_0003079368_django_haml_python_ruby.txt |
Q:
Multithreading with Pygame
I'm having some trouble writing a simple Pygame application that uses threads. Please keep in mind that this is the first multithreaded code I've ever written.
Here's the situation. I'm writing a simple app that will draw some funky lines to the screen. My problem is that while I'm drawi... | Multithreading with Pygame | I'm having some trouble writing a simple Pygame application that uses threads. Please keep in mind that this is the first multithreaded code I've ever written.
Here's the situation. I'm writing a simple app that will draw some funky lines to the screen. My problem is that while I'm drawing the lines, the app can't hand... | [
"Although I have never used pygame, I doubt that you can (or should) call its API from different threads. All your drawing should be done in the main event loop.\nI guess you have to change the way you are thinking for game development. Instead of using time.sleep() to pause the drawing, create an object that can... | [
10
] | [] | [] | [
"multithreading",
"pygame",
"python"
] | stackoverflow_0007141665_multithreading_pygame_python.txt |
Q:
initializing module on django+mod_wsgi+apache
My django application is running on apache+wsgi. One of the module in my django app needs to load a Java library via jpype and this Java library takes long time to initialize due to its application nature.
The problem is that, for each http request handled by django i... | initializing module on django+mod_wsgi+apache | My django application is running on apache+wsgi. One of the module in my django app needs to load a Java library via jpype and this Java library takes long time to initialize due to its application nature.
The problem is that, for each http request handled by django in apache+wsgi setup, this Java library is re-loaded... | [
"You are possibly just getting confused and are actually using as poor Apache/mod_wsgi configuration. Specifically, you are likely using embedded mode with Apache prefork MPM. That is bad because Apache will use lots of single thread processes and so the code has to be loaded in all of them. That is why you probabl... | [
2
] | [] | [] | [
"apache",
"django",
"django_wsgi",
"python",
"wsgi"
] | stackoverflow_0007142284_apache_django_django_wsgi_python_wsgi.txt |
Q:
How to make binary to hex converter using for loop - Python
Yes, this is homework.
I have the basic idea. I know that basically I need to introduce a for loop and set if's saying if the value is above 9 then it's a, b, c, and so forth. But what I need is to get the for loop to grab the integer and its index numbe... | How to make binary to hex converter using for loop - Python | Yes, this is homework.
I have the basic idea. I know that basically I need to introduce a for loop and set if's saying if the value is above 9 then it's a, b, c, and so forth. But what I need is to get the for loop to grab the integer and its index number to calculate and go back and forth and then print out the hex. ... | [
"I'm assuming that you have a string containing the binary data.\nIn Python, you can iterate over all sorts of things, strings included. It becomes as simple as this:\nfor char in mystring:\n pass\n\nAnd replace pass with your suite (a term meaning a \"block\" of code). At this point, char will be a single-chara... | [
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0007147702_python.txt |
Q:
How to use re to find consecutive, repeated chars
I want to find all consecutive, repeated character blocks in a string. For example, consider the following:
s = r'http://www.google.com/search=ooo-jjj'
What I want to find this: www, ooo and jjj.
I tried to do it like this:
m = re.search(r'(\w)\1\1', s)
But it d... | How to use re to find consecutive, repeated chars | I want to find all consecutive, repeated character blocks in a string. For example, consider the following:
s = r'http://www.google.com/search=ooo-jjj'
What I want to find this: www, ooo and jjj.
I tried to do it like this:
m = re.search(r'(\w)\1\1', s)
But it doesn't seem to work as I expect. Any ideas?
Also, how c... | [
"((\\w)\\2{2,}) matches 3 or more consecutive characters:\nIn [71]: import re\nIn [72]: s = r'http://www.google.com/search=ooo-jjjj'\nIn [73]: re.findall(r'((\\w)\\2{2,})', s)\nOut[73]: [('www', 'w'), ('ooo', 'o'), ('jjjj', 'j')]\n\nIn [78]: [match[0] for match in re.findall(r'((\\w)\\2{2,})', s)]\nOut[78]: ['www',... | [
22,
3,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0007147796_python_regex.txt |
Q:
Django upload file url problem
I've got this media root:MEDIA_ROOT = '/var/www/hosted/myapp/static/' and this media urlMEDIA_URL = '/static/res/' and I am trying to upload a file using a callable: def get_uploadto(instance, filename):
''' Dummy callable to silence the upload_to field of FileFields '''
retu... | Django upload file url problem | I've got this media root:MEDIA_ROOT = '/var/www/hosted/myapp/static/' and this media urlMEDIA_URL = '/static/res/' and I am trying to upload a file using a callable: def get_uploadto(instance, filename):
''' Dummy callable to silence the upload_to field of FileFields '''
return os.path.join('uploads', filename)... | [
"This is the expected behaviour. The files are in\nMEDIA_ROOT + 'uploads' + filename\nor\n/var/www/hosted/myapp/static/uploads/filename\n\nthe URL's that point to those files are:\nMEDIA_URL + 'uploads' + filename\nor\n/static/res/uploads/filename\n\nYou then need to make sure that your application or hosting envi... | [
3
] | [] | [] | [
"django",
"file_upload",
"python"
] | stackoverflow_0007147188_django_file_upload_python.txt |
Q:
python - A problem happen when I'm trying to fetch documents from a website
I tried to download documents from this page
Securities Class Action Filings
I tried to download the 25 documents on the page.
I thought it was simple, and here's my code:
from BeautifulSoup import BeautifulSoup
import re
import urllib2
i... | python - A problem happen when I'm trying to fetch documents from a website | I tried to download documents from this page
Securities Class Action Filings
I tried to download the 25 documents on the page.
I thought it was simple, and here's my code:
from BeautifulSoup import BeautifulSoup
import re
import urllib2
import os
if __name__ == "__main__":
pre_url = "http://securities.stanford.edu"... | [
"The sample page is encoded in UTF-16 without properly providing that factoid in the header. \n>>> page = urllib2.urlopen( \"http://securities.stanford.edu/1046/BWEN00_01\" )\n>>> page.info().headers\n['Date: Mon, 22 Aug 2011 13:13:56 GMT\\r\\n', 'Server: Apache/1.3.33 (Darwin) mod_jk/1.2.2 DAV/1.0.3\\r\\n', 'Cache... | [
2,
0
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0007145715_beautifulsoup_python.txt |
Q:
Find the cursor position on a GtkSourceView window
I want to display a popup window with an auto-complete combo, how do I identify the current cursor screen position to setup the auto-complete popup window ?
A:
Found the solution looking into the gtk source completion code:
def get_iter_pos(text_view, iter):
... | Find the cursor position on a GtkSourceView window | I want to display a popup window with an auto-complete combo, how do I identify the current cursor screen position to setup the auto-complete popup window ?
| [
"Found the solution looking into the gtk source completion code:\ndef get_iter_pos(text_view, iter):\n iter_location = text_view.get_iter_location(iter)\n win_location = text_view.buffer_to_window_coords(\n Gtk.TextWindowType.WIDGET, iter_location.x, iter_location.y) \n\n ... | [
2
] | [] | [] | [
"pygtk",
"python"
] | stackoverflow_0007139645_pygtk_python.txt |
Q:
Python: string is escaped when creating a tuple
I have the following code:
string = "ad\23e\4x{\s"
data = (string,)
When I print the data my string in the tuple has an extra slash for each slash a total of 6 back slashes.
How can I avoid the extra back slashes?
A:
The object data is a tuple. When you print a tu... | Python: string is escaped when creating a tuple | I have the following code:
string = "ad\23e\4x{\s"
data = (string,)
When I print the data my string in the tuple has an extra slash for each slash a total of 6 back slashes.
How can I avoid the extra back slashes?
| [
"The object data is a tuple. When you print a tuple, Python call repr for each element. If you want to format it another way, you have to do the conversion yourself.\n>>> s = \"ad\\23e\\4x{\\s\"\n>>> d = (s,)\n>>> print d\n('ad\\x13e\\x04{\\\\s',)\n>>> print '(%s,)' % (', '.join('\"%s\"' % _ for _ in d))\n(\"adex{\... | [
4,
1,
0
] | [] | [] | [
"python",
"tuples"
] | stackoverflow_0007145934_python_tuples.txt |
Q:
Adding arrows to rising edges of pulse plots in matplotlib
Need help in matplotlib to figure out the answers for,
How do you make an arrow pointing up and an arrow pointing down along a curve/line on the plot?
How do you adjust the range/limits of the plot so that the edges of it are visible clearly on the graph?... | Adding arrows to rising edges of pulse plots in matplotlib | Need help in matplotlib to figure out the answers for,
How do you make an arrow pointing up and an arrow pointing down along a curve/line on the plot?
How do you adjust the range/limits of the plot so that the edges of it are visible clearly on the graph?
I wanted to add arrows on the rising edge of a pulsing wave, (... | [
"To make an arrow, you can use the arrow routine:\n #x,y, dx, dy,\narrow(0,0, 0,1.0,\n 'lw':2,\n 'color':'black',\n 'head_width':baseFreqTimePeriod/4,\n 'head_length':0.05\n\nto make a downward pointing arrow, set a negative dy.: \narrow(baseFreqTimePeriod,0, 0,-1.0,\n 'lw':2,\n 'color':'bla... | [
2
] | [] | [] | [
"graphics",
"matplotlib",
"plot",
"python"
] | stackoverflow_0007139271_graphics_matplotlib_plot_python.txt |
Q:
How do you set up multiple multithreaded QWebViews in PyQt?
I am trying to make an application in Python using PyQt that can fetch the generated content of a list of URLs and process the fetched source with the help of multiple threads. I need to run about ten QWebViews at once. As ridiculous as that might sound, ... | How do you set up multiple multithreaded QWebViews in PyQt? | I am trying to make an application in Python using PyQt that can fetch the generated content of a list of URLs and process the fetched source with the help of multiple threads. I need to run about ten QWebViews at once. As ridiculous as that might sound, when it comes to hundreds of URLs, using threaded QWebViews gets ... | [
"There are multiple issues with your question and code:\n\nYou are talking about QWebFrame, but are actually passing a QWebView to your worker(s). Since this is a QWidget, it belongs to the main (GUI) thread and should not be modified by other threads.\nOne QWebView / QWebFrame can only load one URL at a time, so ... | [
4
] | [] | [] | [
"multithreading",
"pyqt",
"python",
"qt",
"qwebview"
] | stackoverflow_0007143088_multithreading_pyqt_python_qt_qwebview.txt |
Q:
compiled python library works on one computer but not on another
I have written a python interface to c++ code.I have two different computers running ubuntu 11.04 with the same packages (python 2.7.1, numpy 1.5.1, gcc 4.5.2). Let's call them A and B.
The code compiles and links without errors on both computers. H... | compiled python library works on one computer but not on another | I have written a python interface to c++ code.I have two different computers running ubuntu 11.04 with the same packages (python 2.7.1, numpy 1.5.1, gcc 4.5.2). Let's call them A and B.
The code compiles and links without errors on both computers. However, on A, the code seems to enter an infinite loop somewhere in th... | [
"Which compiler was used to build python on your machine ? This is a crucial point for Python extensions. If you use a different compiler anything bad can happen.\n",
"Even if you are not multithreading (as in defining multiple threads) there may be a SMP problem: if a memory location is volatile, context switche... | [
0,
0,
0
] | [] | [] | [
"c++",
"python",
"ubuntu"
] | stackoverflow_0007148014_c++_python_ubuntu.txt |
Q:
Python Shipping Rates Calculator
Do you have any experience about open source/commercial python project/ api shipping rates calculator ?
I would like to add one to my Django based project I have no clue where to start from. The most important area United States however world-wide calculator would be awesome.
A:... | Python Shipping Rates Calculator | Do you have any experience about open source/commercial python project/ api shipping rates calculator ?
I would like to add one to my Django based project I have no clue where to start from. The most important area United States however world-wide calculator would be awesome.
| [
"Shipping rates will depend entirely on the carrier. In basically every case, you will have to have an account with the carrier, and then use the development tools or api's they provide. \n\nUPS: https://www.ups.com/upsdeveloperkit\nFedEX: http://fedex.com/us/developer/index.html\nDHL (USA): http://www.dhl-usa.co... | [
2,
2
] | [] | [] | [
"python",
"shipping"
] | stackoverflow_0007031256_python_shipping.txt |
Q:
implementation of dequeue in python using linkedlist
I implemented a Dequeue using a simple list in python. However i need to implement a separate class for linked list and implement dequeue with that. For this pointer reference is needed at left and right ends. I don't know how to do this. Can some body provide s... | implementation of dequeue in python using linkedlist | I implemented a Dequeue using a simple list in python. However i need to implement a separate class for linked list and implement dequeue with that. For this pointer reference is needed at left and right ends. I don't know how to do this. Can some body provide some references or implementations..
| [
"Any reason you're not just using the one from the library? http://docs.python.org/library/collections.html\n"
] | [
2
] | [] | [] | [
"deque",
"linked_list",
"python"
] | stackoverflow_0007149283_deque_linked_list_python.txt |
Q:
metaclass conflict with ctypes Structure
I'm trying to create a metaclass for the class I created here: ctypes variable length structures
I want to simplify the Points class so it looks like this (Python 3.2):
class Points(c.Structure, metaclass=VariableMeta):
_fields_ = [
('num_points', c.c_uint32),
... | metaclass conflict with ctypes Structure | I'm trying to create a metaclass for the class I created here: ctypes variable length structures
I want to simplify the Points class so it looks like this (Python 3.2):
class Points(c.Structure, metaclass=VariableMeta):
_fields_ = [
('num_points', c.c_uint32),
('points', 'Point*self.num_points')
... | [
"The problem is that ctypes.Structure uses its own custom metaclass: _ctypes.StructType. Since you inherit the metaclass from Structure, Python does not know which metaclass to use when constructing your class.\nYou can fix this by inheriting your metaclass from _ctypes.StructType. Since the name of the metaclass... | [
5
] | [] | [] | [
"metaclass",
"python"
] | stackoverflow_0007149488_metaclass_python.txt |
Q:
How to avoid making a webserver a bottleneck with cassandra?
Im new to Cassandra, so bear with me.
So, I am building a search engine using Cassandra as the db. I am interacting with it through Pycassa.
Now, I want to output Cassandra's response to a webpage, having the user submitted a query.
I am aware of tools s... | How to avoid making a webserver a bottleneck with cassandra? | Im new to Cassandra, so bear with me.
So, I am building a search engine using Cassandra as the db. I am interacting with it through Pycassa.
Now, I want to output Cassandra's response to a webpage, having the user submitted a query.
I am aware of tools such as django, fastCGI, SCGI, etc to allow python to web interacti... | [
"I've seen this problem before - sometimes people need much more CPU power and bandwidth to generate and serve some server generated HTML and images than they do to run the actual query in Cassandra. For one customer, this was many 10's times the number of servers serving the front end of the website than in their... | [
3,
0
] | [] | [] | [
"python",
"web_applications"
] | stackoverflow_0007140661_python_web_applications.txt |
Q:
Regex to match letters, numbers and some specific characters?
I'm trying to match a Django URL bit that can contain:
_, %, &, +, 0-9, a-z, A-Z, (space)
How can I do it so it is picked up by Django's URL matcher, in form of a parameter?
(r'^(?P<chararg>\w+)/IT_NEEDS_TO_BE_HERE/(?P<intarg>\d+)', 'dest')
A:
I am no... | Regex to match letters, numbers and some specific characters? | I'm trying to match a Django URL bit that can contain:
_, %, &, +, 0-9, a-z, A-Z, (space)
How can I do it so it is picked up by Django's URL matcher, in form of a parameter?
(r'^(?P<chararg>\w+)/IT_NEEDS_TO_BE_HERE/(?P<intarg>\d+)', 'dest')
| [
"I am not so sure about % char, but regex would be [_%&+0-9a-zA-Z ]+\n",
"As \\w means [a-zA-Z0-9_], you could use :\n[%&+ \\w]+\n\n",
"I played a bit and got this - [\\w\\+%_& ]+.\nSo (r'^(?P<chararg>\\w+)/IT_NEEDS_TO_BE_HERE/(?P<intarg>\\d+)', 'dest') would become \n(r'^(?P<chararg>\\w+)/(?P<arg>[\\w\\+%_& ]+... | [
10,
6,
5
] | [] | [] | [
"django",
"python",
"regex"
] | stackoverflow_0007148860_django_python_regex.txt |
Q:
Cross-platform background silent process execution in python
Within a python program I need to run a command in background, without displaying its output. Therefore I'm doing os.system("nohup " + command + " &") for now.
Edit : command shouldn't be killed/closed when python program exits.
However that will only wo... | Cross-platform background silent process execution in python | Within a python program I need to run a command in background, without displaying its output. Therefore I'm doing os.system("nohup " + command + " &") for now.
Edit : command shouldn't be killed/closed when python program exits.
However that will only work on Linux, and the content of the file will end up in nohup.out ... | [
"You are looking for a daemon process. Look at How do you create a daemon in Python? or http://blog.ianbicking.org/daemon-best-practices.html\n",
"Look into the subprocess module.\nfrom subprocess import Popen, PIPE\nprocess = Popen(['command', 'arg'], stdout=PIPE)\n\n"
] | [
3,
2
] | [] | [] | [
"background",
"process",
"python"
] | stackoverflow_0007149137_background_process_python.txt |
Q:
Python Regex Optional Second Word Within a Group
I wrote the following Regular Expression
m = re.match('.+SPELL_DAMAGE,.+,"([A-Z][a-z]+)",.+"([A-Z][a-z]+\s[A-Z][a-z]+!?)",\d+x\d+,(\d+)',line)
I want the second group to basically say "Look for one word or two words that sometimes end in an exclamation point.
([A-... | Python Regex Optional Second Word Within a Group | I wrote the following Regular Expression
m = re.match('.+SPELL_DAMAGE,.+,"([A-Z][a-z]+)",.+"([A-Z][a-z]+\s[A-Z][a-z]+!?)",\d+x\d+,(\d+)',line)
I want the second group to basically say "Look for one word or two words that sometimes end in an exclamation point.
([A-Z][a-z]+\s[A-Z][a-z]+!?)
Right now the regular expres... | [
"([A-Z][a-z](+\\s[A-Z][a-z]+!?)?) has the first + on the wrong side of the parens.\nTry ([A-Z][a-z]+(\\s[A-Z][a-z]+!?)?)\n>>> re.match(r\"([A-Z][a-z]+(\\s[A-Z][a-z]+!?)?)\", \"White House\").groups()\n('White House', ' House')\n\nAside: to get rid of the pointless \"extra words\" group, you can use non-grouping par... | [
4
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0007149837_python_regex.txt |
Q:
How can I register a function to be called only on *successful* exit of my Python program?
I want to run a task when my Python program finishes, but only if it finishes successfully. As far as I know, using the atexit module means that my registered function will always be run at program termination, regardless of... | How can I register a function to be called only on *successful* exit of my Python program? | I want to run a task when my Python program finishes, but only if it finishes successfully. As far as I know, using the atexit module means that my registered function will always be run at program termination, regardless of success. Is there a similar functionality to register a function so that it runs only on succes... | [
"Out of the box, atexit is not quite suited for what you want to do: it's primarily used for resource cleanup at the very last moment, as things are shutting down and exiting. By analogy, it's the \"finally\" of a try/except, whereas what you want is the \"else\" of a try/except. \nThe simplest way I can think of i... | [
6,
4
] | [] | [] | [
"atexit",
"python"
] | stackoverflow_0007149337_atexit_python.txt |
Q:
Python Network devices.. General query:
This WORKS:
I used to write device drivers for Cisco vendor..
Where I login to there device using putty via Telnet device IP and it enters into device and use some commands in my script to get information .. like show version command in my script n get I read all info into ... | Python Network devices.. General query: | This WORKS:
I used to write device drivers for Cisco vendor..
Where I login to there device using putty via Telnet device IP and it enters into device and use some commands in my script to get information .. like show version command in my script n get I read all info into CSV file.
Solution for below problem
Now we g... | [
"Use pexpect. It's a python module designed for interaction with local or remote processes. Here's an example from its website showing how you can use it to connect to a keyboard-driven FTP subprocess.\n import pexpect\n child = pexpect.spawn ('ftp ftp.openbsd.org')\n child.expect ('Name .*: ')\n child.send... | [
3
] | [] | [] | [
"cisco_ios",
"network_programming",
"networking",
"python"
] | stackoverflow_0007150285_cisco_ios_network_programming_networking_python.txt |
Q:
Hiding buttons via Javascript
I have a small problem that I am hoping you guys can help me with. I have two buttons that I use to approve, or disable rates. Basically, makes the boolean flag True or False. Now I'm having some trouble wrapping my head around this idea but, I would like to have only the Approve b... | Hiding buttons via Javascript | I have a small problem that I am hoping you guys can help me with. I have two buttons that I use to approve, or disable rates. Basically, makes the boolean flag True or False. Now I'm having some trouble wrapping my head around this idea but, I would like to have only the Approve button show if rates are disabled, a... | [
"your question is really not enough specific. If you want to hide button via css you add property \n display: hidden;\n\nif you want to toggle buttons after clicking one, you can write jquery code as following:\n $('#approveButton').click(function(){\n $('#disableButton').show();\n $(this).hide();\n)};\n $('#disp... | [
1,
0,
0,
0
] | [] | [] | [
"django",
"javascript",
"jquery",
"python"
] | stackoverflow_0007150336_django_javascript_jquery_python.txt |
Q:
os.execv without args argument
I want to replace the current process with a new one using os.execv, this works fine unless you don't have any arguments.
How can I call this even if I don't have an arguments to pass to the process I want to launch ?
# Works fine, unless the arguments tuple wouldn't exist or be empt... | os.execv without args argument | I want to replace the current process with a new one using os.execv, this works fine unless you don't have any arguments.
How can I call this even if I don't have an arguments to pass to the process I want to launch ?
# Works fine, unless the arguments tuple wouldn't exist or be empty
os.execv('process.exe', ('arg1', '... | [
"These three variants can resolve the problem:\ncmd = '/usr/bin/vi'\nos.execv(cmd, (' ',))\nos.execv(cmd, [' '])\nos.execl(cmd, '')\n\nUsually, the first parameter of an argument list (sys.argv) is the command which had been used to invoke the application.\nSo it is better to use one of those:\ncmd = '/usr/bin/vi'\... | [
14,
7,
1
] | [] | [] | [
"python"
] | stackoverflow_0003384007_python.txt |
Q:
Unusual problem with multiple return in Python
When I call the function "G()" which returns two values: p_T and q_T twice (see below) but using the same style, that's, P_T, neg = G(); U, Ign = G() and print sums of P_T and U, I get two different answers! Another thing is that both answers are incorrect!
I have onl... | Unusual problem with multiple return in Python | When I call the function "G()" which returns two values: p_T and q_T twice (see below) but using the same style, that's, P_T, neg = G(); U, Ign = G() and print sums of P_T and U, I get two different answers! Another thing is that both answers are incorrect!
I have only included part of the code which can simply aid in ... | [
"You have global state. You mutate global state. Then you mutate it again, starting where you left off. So P_T is a result after N operations, and U is a result after 2N operations.\nDon't use global state.\n",
"Because p_T and q_T are globals, their scope is not local to the function. So it's no surprise that yo... | [
4,
2
] | [] | [] | [
"python"
] | stackoverflow_0007150513_python.txt |
Q:
Python Decorator Scoping Issues
I have a static class that has a method hello. I want to run the decorator method bar before hello. However, using the following code I always get a "name 'bar' is not defined" error. Does anyone know what's going on? Thanks!
class foo():
@staticmethod
@bar
def hello():
... | Python Decorator Scoping Issues | I have a static class that has a method hello. I want to run the decorator method bar before hello. However, using the following code I always get a "name 'bar' is not defined" error. Does anyone know what's going on? Thanks!
class foo():
@staticmethod
@bar
def hello():
print "hello"
def bar(fn... | [
"Because it's not defined yet. Besides, that decorator shouldn't be a method at all.\ndef bar(fn):\n # ...\n\nclass foo(object):\n @staticmethod\n @bar\n def hello():\n # ...\n\n# ...\n\nAlso, don't use static methods, unless you really know what you're doing. Make it a free function instead.\n",... | [
2,
2
] | [] | [] | [
"class",
"decorator",
"python",
"static"
] | stackoverflow_0007150667_class_decorator_python_static.txt |
Q:
Removing attributes from HTML tags
Possible Duplicates:
php: how can I remove attributes from an html tag?
How do I iterate over the HTML attributes of a Beautiful Soup element?
I have some HTML like the following:
<div class="foo">
<p id="first">Hello, world!</p>
<p id="second">Stack Overflow</p>
</div>
An... | Removing attributes from HTML tags |
Possible Duplicates:
php: how can I remove attributes from an html tag?
How do I iterate over the HTML attributes of a Beautiful Soup element?
I have some HTML like the following:
<div class="foo">
<p id="first">Hello, world!</p>
<p id="second">Stack Overflow</p>
</div>
And it needs to come back as this:
<div>
... | [
"this works also with sed,\n<([a-zA-Z!]+)[^>]+>\nthen just replace by the first group like,\n<\\1>\n",
"This is easily possible in Python by using Lxml.\nFirst install Lxml and try the following code:\nfrom lxml.html import tostring, fromstring\n\nhtml = '''\n<div class=\"foo\">\n <p id=\"first\">Hello, world!</... | [
0,
0
] | [] | [] | [
"beautifulsoup",
"html",
"php",
"python",
"regex"
] | stackoverflow_0007150021_beautifulsoup_html_php_python_regex.txt |
Q:
How to show column headers in a GtkTreeView inside a gtk.ScrolledWindow?
I have a problem with Gtk.Treeview indide a Gtk.ScrolledWindow. I have a large amount of data, which doesnt fit inside my normal window geometrics, so i put my Treeview inside a ScrolledWindow, which seems to be the normal way. The problem wi... | How to show column headers in a GtkTreeView inside a gtk.ScrolledWindow? | I have a problem with Gtk.Treeview indide a Gtk.ScrolledWindow. I have a large amount of data, which doesnt fit inside my normal window geometrics, so i put my Treeview inside a ScrolledWindow, which seems to be the normal way. The problem with this solution is, that my Column Headers disapear, when I scroll. This beha... | [
"Change self.scrolledwindow.add_with_viewport to self.scrolledwindow.add and it will work. From the documentation:\n\nThe add_with_viewport() method is used to add a widget (specified by child) without native scrolling capabilities to the scrolled window. This is a convenience function that is equivalent to adding ... | [
14
] | [] | [] | [
"gtk",
"gtktreeview",
"pygtk",
"python",
"scrolledwindow"
] | stackoverflow_0007147489_gtk_gtktreeview_pygtk_python_scrolledwindow.txt |
Q:
program timeout in windows for python
Hi I've seen a bunch of questions here on SE that deal with similar issues but I find much of the answers to be unclear and confusing. My question is very simple. How on a Windows platform can I kill a running function after a certain amount of time using Python v2.6? If I hav... | program timeout in windows for python | Hi I've seen a bunch of questions here on SE that deal with similar issues but I find much of the answers to be unclear and confusing. My question is very simple. How on a Windows platform can I kill a running function after a certain amount of time using Python v2.6? If I have:
def my_function(start):
x=start
... | [
"If you just want to run a normal function with a timeout, try:\nfrom datetime import timedelta, datetime\nfrom time import sleep\n\nendtime = datetime.utcnow() + timedelta(seconds = 2)\n\nwhile True:\n sleep(1) # just an example\n if datetime.utcnow() > endtime: # if more than two seconds has elapsed\n ... | [
4,
1,
1
] | [] | [] | [
"multithreading",
"python",
"timeout"
] | stackoverflow_0007150840_multithreading_python_timeout.txt |
Q:
How to set an SQLAlchemy relationship up to access a field value instead of the related instance
The following totally incomplete snippet defines a basic SQLAlchemy relationship using declarative syntax...
Base = declarative_base()
class Movie(Base):
__tablename__ = 'movies'
id = Column(Integer, primary_ke... | How to set an SQLAlchemy relationship up to access a field value instead of the related instance | The following totally incomplete snippet defines a basic SQLAlchemy relationship using declarative syntax...
Base = declarative_base()
class Movie(Base):
__tablename__ = 'movies'
id = Column(Integer, primary_key=True)
name = Column(String)
director = relationship("People", uselist = False)
class People... | [
"The association proxy is used for all kinds of \"object reference-> attribute reference\" styles of transformation on the Python side. Docs have been newly updated and rewritten:\nhttp://www.sqlalchemy.org/docs/orm/extensions/associationproxy.html\n",
"What if you use property?\nclass Movie(Base):\n __tablen... | [
2,
2
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0007150851_python_sqlalchemy.txt |
Q:
IndexError: list index out of range
I'm new to selenium python. right now i'm trying to run python code that already converted from selenium Ide. when i'm ran the code i got this error. i'm using eclipse to run the code
ERROR: test_isnin2 (__main__.Isnin2)
=========================================================... | IndexError: list index out of range | I'm new to selenium python. right now i'm trying to run python code that already converted from selenium Ide. when i'm ran the code i got this error. i'm using eclipse to run the code
ERROR: test_isnin2 (__main__.Isnin2)
======================================================================
ERROR: test_isnin2 (__main_... | [
"It seems like you do not supply your base_url to the driver. Maybe you should replace this line:\ndriver.get(\"/search?q=google&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a\")\n\nwith something like this:\ndriver.get(self.base_url + \"/search?q=google&ie=utf-8&oe=utf-8&aq=t&rls=org.mozill... | [
1,
1
] | [] | [] | [
"eclipse",
"python",
"selenium"
] | stackoverflow_0007144571_eclipse_python_selenium.txt |
Q:
Django with HAML, SASS, CoffeeScript and related compressors
I would like to use HAML-like templates together with SASS and CoffeeScript in a Django site. Currently I am looking into DMSL for HAML templates, and recompiling SASS (Compass) and CoffeeScript files to CSS and JS (and compressing) every time I change t... | Django with HAML, SASS, CoffeeScript and related compressors | I would like to use HAML-like templates together with SASS and CoffeeScript in a Django site. Currently I am looking into DMSL for HAML templates, and recompiling SASS (Compass) and CoffeeScript files to CSS and JS (and compressing) every time I change them. For inline code, I could add some DMSL filters, however, this... | [
"I recommend django_compressor for sass and coffeescript (I actually contributed to part of it supporting the precompilers :)\nFor HAML I was using HamlPy + Djaml which provides a generic usable template loader\n"
] | [
3
] | [] | [] | [
"coffeescript",
"django",
"haml",
"python",
"sass"
] | stackoverflow_0007151112_coffeescript_django_haml_python_sass.txt |
Q:
Python: Plotting a power law function with exponential cutoff
I have a graph between 2 functions f and g.
I know it follows a power law function with exponential cutoff.
f(x) = x**(-alpha)*e**(-lambda*x)
How do I find the value of exponent alpha?
A:
If you have sufficiently close x points (for example one every... | Python: Plotting a power law function with exponential cutoff | I have a graph between 2 functions f and g.
I know it follows a power law function with exponential cutoff.
f(x) = x**(-alpha)*e**(-lambda*x)
How do I find the value of exponent alpha?
| [
"If you have sufficiently close x points (for example one every 0.1), you can try the following:\n\nln(f(x)) = -alpha ln(x) - lambda x\nln(f(x))' = - alpha / x - lambda\n\nSo depending on where you have your points:\nIf you have a lot of points near 0, you can try:\n\nh(x) = x ln(f(x))' = -alpha - lambda x\n\nSo th... | [
3,
2,
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0002250385_python.txt |
Q:
Java type conversion to Python through JPype and numpy
I'm currently porting a program written in Python to Java and have run into some problems. I'm porting a part of the program at the time and for testing purposes I'm using JPype to make it compatible with the new java classes.
EDIT: Just to makes things more c... | Java type conversion to Python through JPype and numpy | I'm currently porting a program written in Python to Java and have run into some problems. I'm porting a part of the program at the time and for testing purposes I'm using JPype to make it compatible with the new java classes.
EDIT: Just to makes things more clear, the class I'm currently working on provides data to th... | [
"I tried JPype some time ago and had some issues with type conversions too. Maybe you can speedup your code using http://cython.org/, there are some methods to speed up access to numpy data structures: http://docs.cython.org/src/tutorial/numpy.html\nOne further comment: vstack and hstack can copy with arbitrary lis... | [
0
] | [] | [] | [
"java",
"numpy",
"python",
"type_conversion"
] | stackoverflow_0006532911_java_numpy_python_type_conversion.txt |
Q:
python 2.5.2 multiprocessing pool behavior
When attempting to divide a DB insertion up between cores using the python multiprocessing module on 2.5.2, CentOS 5.5, the entire pool of 16 processes aborts as soon as the first one finishes. I thought that using pool.close/pool.join was supposed to prevent this very t... | python 2.5.2 multiprocessing pool behavior | When attempting to divide a DB insertion up between cores using the python multiprocessing module on 2.5.2, CentOS 5.5, the entire pool of 16 processes aborts as soon as the first one finishes. I thought that using pool.close/pool.join was supposed to prevent this very thing from occurring.
def insert():
blocksize... | [
"I'm not sure if this has anything to do with your issue, but you're creating a new multiprocessing.Lock object in every process you create.\n...so acquiring this lock around your connection commits isn't going to do anything.\n[EDIT] In order to share this lock between processes, you need a manager object:\nmanage... | [
0
] | [] | [] | [
"module",
"multiprocessing",
"pool",
"python"
] | stackoverflow_0007151023_module_multiprocessing_pool_python.txt |
Q:
Python hash_ring not distributing uniformly, what are consistent hashing alternatives?
I'm using hash_ring package for distributing objects among servers. I've assumed that distribution would be uniform, as it's based on MD5 hashes. Unfortunately it's not the case.
I'm using random keys which are generated using u... | Python hash_ring not distributing uniformly, what are consistent hashing alternatives? | I'm using hash_ring package for distributing objects among servers. I've assumed that distribution would be uniform, as it's based on MD5 hashes. Unfortunately it's not the case.
I'm using random keys which are generated using uuid.uuid4(). I've verified, that MD5 itself in fact does give uniform distribution. However,... | [
"the hash ring sacrifices the \"eveness\" of your md5 test code to maintain mappings when the number of entries changes. see http://www.lexemetech.com/2007/11/consistent-hashing.html. so the differences you see are not because of uuid4, or because of an error, but because the library uses a different algorithm fr... | [
9
] | [] | [] | [
"consistent_hashing",
"hashtable",
"python"
] | stackoverflow_0007150159_consistent_hashing_hashtable_python.txt |
Q:
How can I extract email addresses from between '<' and '>'?
I've got a list of emails and names from Outlook, semicolon delimited, like this:
fname lname <email>; fname2 lname2 <email2>; ... ; fnameN lnameN <emailN>
And I'd like to extract the emails and semicolon delimit them like this:
email1; email2; ... ; ema... | How can I extract email addresses from between '<' and '>'? | I've got a list of emails and names from Outlook, semicolon delimited, like this:
fname lname <email>; fname2 lname2 <email2>; ... ; fnameN lnameN <emailN>
And I'd like to extract the emails and semicolon delimit them like this:
email1; email2; ... ; emailN
How can I do this in Python?
| [
"Using regex:\nimport re\n# matches everything which is between < and > (excluding them)\nptrn = re.compile(\"<([^>]+)>\")\n# findall returns ['email','email2']. Join concats them.\nprint '; '.join(ptrn.findall(\"fname lname <email>; fname2 lname2 <email2>;\"))\n# email; email2\n\n",
"Using list comprehension:\ne... | [
6,
3,
0
] | [] | [] | [
"email",
"python",
"string_formatting",
"text_processing"
] | stackoverflow_0007151637_email_python_string_formatting_text_processing.txt |
Q:
Convert Back Latitude from Hex data GREENTEL
Currently I am doing a GPS Tracking project based on Django and GREENTEL
It uses this protocol
http://www.m2msolution.eu/doc/Fejlesztoi_dokumentaciok/GT03/GPRS%20Communication%20Protocol_GT03.pdf
It says how to convert Latitude/ Longitude to Hex.. but I want to convert ... | Convert Back Latitude from Hex data GREENTEL | Currently I am doing a GPS Tracking project based on Django and GREENTEL
It uses this protocol
http://www.m2msolution.eu/doc/Fejlesztoi_dokumentaciok/GT03/GPRS%20Communication%20Protocol_GT03.pdf
It says how to convert Latitude/ Longitude to Hex.. but I want to convert latitude hex data to the normal form
Conversion m... | [
"First you get the hex, convert it back to base 10 and divide it by 30000.\nGet the result and divide it by 60, the integer part will be the degrees, the rest will be the minutes.\nIn python:\na = 0x026B3F3E\nb = a/30000.0\ndegrees = b//60\nminutes = b%60\n\nprint degrees, ' degrees and ', minutes, 'minutes'\n>>> ... | [
4
] | [] | [] | [
"gps",
"network_protocols",
"python"
] | stackoverflow_0007151896_gps_network_protocols_python.txt |
Q:
How to control gdb within C or Python code without the GDB Python API?
I am trying to write a program in python or c that can debug c code by using gdb.
I've read the solution of Tom and Invoke and control GDB from Python. But they are more or less a solution for scripting gdb in python. Since I am going to use an... | How to control gdb within C or Python code without the GDB Python API? | I am trying to write a program in python or c that can debug c code by using gdb.
I've read the solution of Tom and Invoke and control GDB from Python. But they are more or less a solution for scripting gdb in python. Since I am going to use an arm-gdb to debug embedded program, I cannot enable python scripting in my g... | [
"As promised in the comments above, I have published my (early, incomplete, almost certainly buggy) ruby work to http://github.com/mcarpenter/rubug.\nHere's an example (you can find this in\nexamples/breakpoint). Function check_for_crash is a callback that may be invoked\nafter the program called factorial is set r... | [
5,
2,
0
] | [] | [] | [
"arm",
"c",
"gdb",
"python"
] | stackoverflow_0006822584_arm_c_gdb_python.txt |
Q:
License question related to bsddb
I plan to use bsddb/pybsddb in a commercial product written in python for windows and linux. I also plan to use py2exe.
Yet I am not sure about the legal implications. I have read that commercial products don't have to pay royalties as long as it is written in python. Is it true?... | License question related to bsddb | I plan to use bsddb/pybsddb in a commercial product written in python for windows and linux. I also plan to use py2exe.
Yet I am not sure about the legal implications. I have read that commercial products don't have to pay royalties as long as it is written in python. Is it true?
| [
"Python is released under the Python License. It's permissive, so you can use it with closed source commercial software.\nThe Oracle Berkeley DB is licensed under the Sleepycat License, which requires you to distribute the source of your code. You can't use it with closed source commercial software unless you buy a... | [
3
] | [] | [] | [
"bsddb",
"linux",
"py2exe",
"python",
"windows"
] | stackoverflow_0007152191_bsddb_linux_py2exe_python_windows.txt |
Q:
Input and output arguments for ctypes
I am having a problem with formatting my input and output arguments using ctypes in python to access a fortran function in a dll. I can access the library and the function, but am struggling in how to format the arguments.
The f90 code starts as:
subroutine DataSub (Data_input... | Input and output arguments for ctypes | I am having a problem with formatting my input and output arguments using ctypes in python to access a fortran function in a dll. I can access the library and the function, but am struggling in how to format the arguments.
The f90 code starts as:
subroutine DataSub (Data_input,da,db,dy)
double precision, intent(in... | [
"Most likely these would be c_double, however you shouldn't use \"double precision\" anymore.\nUse real with a kind attribute instead, better yet use the ISO_C_Binding in Fortran to provide a C-like interface.\nThe ISO_C_Binding would also allow you to pass arguments by value instead of by reference.\nWithout it yo... | [
2,
2
] | [] | [] | [
"ctypes",
"fortran",
"python"
] | stackoverflow_0007151925_ctypes_fortran_python.txt |
Q:
Decoding html content and HTMLParser
I'm creating a sub-class based on 'HTMLParser' to pull out html content. Whenever I have character refs such as
' ' '&' '–' '…'
I'd like to replace them with their English counterparts of
' ' (space), '&', '-', '...', and so on.
What's the best way to ... | Decoding html content and HTMLParser | I'm creating a sub-class based on 'HTMLParser' to pull out html content. Whenever I have character refs such as
' ' '&' '–' '…'
I'd like to replace them with their English counterparts of
' ' (space), '&', '-', '...', and so on.
What's the best way to convert some of the simple character refs ... | [
"Your question has two parts. The easy part is decoding the HTML entities. The easiest way to do that is to grab this undocumented but long-stable method from the HTMLParser module:\n>>> HTMLParser.HTMLParser().unescape('a < é – …')\nu'a < é – …'\n\nThe second part, converting Unicode charact... | [
9
] | [] | [] | [
"python"
] | stackoverflow_0007152111_python.txt |
Q:
python extracting HTML tag attributes without regular expressions
Is there any way using urlib, urllib2 or BeautifulSoup to extract HTML tag attributes?
for example:
<a href="xyz" title="xyz">xyz</a>
gets href=xyz, title=xyz
There is another thread talking about using regular expressions
Thanks
A:
You c... | python extracting HTML tag attributes without regular expressions | Is there any way using urlib, urllib2 or BeautifulSoup to extract HTML tag attributes?
for example:
<a href="xyz" title="xyz">xyz</a>
gets href=xyz, title=xyz
There is another thread talking about using regular expressions
Thanks
| [
"You could use BeautifulSoup to parse the HTML, and for each <a> tag, use tag.attrs to read the attributes:\nIn [111]: soup = BeautifulSoup.BeautifulSoup('<a href=\"xyz\" title=\"xyz\">xyz</a>')\n\nIn [112]: [tag.attrs for tag in soup.findAll('a')]\nOut[112]: [[(u'href', u'xyz'), (u'title', u'xyz')]]\n\n",
"why d... | [
8,
6
] | [] | [] | [
"beautifulsoup",
"html_parsing",
"python"
] | stackoverflow_0007141431_beautifulsoup_html_parsing_python.txt |
Q:
How to match search strings to content in python
Usually when we search, we have a list of stories, we provide a search string, and expect back a list of results where the given search strings matches the story.
What I am looking to do, is the opposite. Give a list of search strings, and one story and find out whi... | How to match search strings to content in python | Usually when we search, we have a list of stories, we provide a search string, and expect back a list of results where the given search strings matches the story.
What I am looking to do, is the opposite. Give a list of search strings, and one story and find out which search strings match to that story.
Now this could ... | [
"After extensive googling, i realized what i am looking to do is a Boolean search.\nFound the code that makes regex boolean aware : http://code.activestate.com/recipes/252526/\nIssue looks solved for now.\n",
"Probably slow, but easy solution:\nMake a query on the story plus each string to the search engine. If i... | [
2,
0,
0,
0,
0,
0
] | [] | [] | [
"lucene",
"python",
"search",
"solr"
] | stackoverflow_0001103685_lucene_python_search_solr.txt |
Q:
Friendly URLs in Google App Engine
I'm trying to build a Friendly URL lookup method in GAE and Python. Have anyone done this?
I've got it working but it feels VERY shaky. How it works is that it takes the path (let's say /foo/bar/) and splits it to a list. Takes the last element in the list and query the database ... | Friendly URLs in Google App Engine | I'm trying to build a Friendly URL lookup method in GAE and Python. Have anyone done this?
I've got it working but it feels VERY shaky. How it works is that it takes the path (let's say /foo/bar/) and splits it to a list. Takes the last element in the list and query the database for a match. Now comes some headaches.
... | [
"http://code.google.com/appengine/docs/python/tools/webapp/running.html#URL_Mappings\nCheck out the section that says url mappings\nthis is complete code but I hope you get the idea\nthis is my request handler parama = my first param, paramb = my second param\nclass testPath(webapp.RequestHandler):\n def get(sel... | [
1,
1
] | [] | [] | [
"friendly_url",
"google_app_engine",
"python"
] | stackoverflow_0002916624_friendly_url_google_app_engine_python.txt |
Q:
Match alternating digits and characters
I have read the Google python regex tutorial about regular expression and tried to test one of the patterns I need.
String must be 10 characters long.
1,3,5,7,9 chars must be digits (1 - 5) and should not be repeated
other symbols are letters (a, b or c) and the can be repe... | Match alternating digits and characters | I have read the Google python regex tutorial about regular expression and tried to test one of the patterns I need.
String must be 10 characters long.
1,3,5,7,9 chars must be digits (1 - 5) and should not be repeated
other symbols are letters (a, b or c) and the can be repeated
For example:
1a2b4a3c5b # is valid
1a5... | [
"You're trying to include a previous match in a negated character class, which is not possible.\nThe only way to do this is to do something like this:\n^([1-5])[abc](?!\\1)([1-5])[abc](?!\\1|\\2)([1-5])[abc](?!\\1|\\2|\\3)([1-5])[abc](?!\\1|\\2|\\3|\\4)[1-5][abc]$\n\nNeedless to say, this is not something regex sho... | [
4,
4,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0007152576_python_regex.txt |
Q:
send code from vim to an external application for execution
I am regularly using stata at work. My text editor of choice is (g)vim.
I have been using the scripts provided here or here to send code from vim to stata. This functionality is immensely practical and virtually the only thing the keeps me from switching ... | send code from vim to an external application for execution | I am regularly using stata at work. My text editor of choice is (g)vim.
I have been using the scripts provided here or here to send code from vim to stata. This functionality is immensely practical and virtually the only thing the keeps me from switching to linux completely. The scripts are written in AutoIT, so I cann... | [
"IronAHK is a Linux/Mono rewrite of the AutoHotKey scripting language, which is similar to AutoIt (a GUI automation / keyboard remapping tool). I haven't used IronAHK, but AutoHotkey can run AutoIt v2 scripts.\nYou can also look @Project Sikuli: \"Sikuli is a visual technology to automate and test graphical user in... | [
3,
1,
0
] | [] | [] | [
"autoit",
"bash",
"python",
"stata",
"vim"
] | stackoverflow_0007038701_autoit_bash_python_stata_vim.txt |
Q:
changing size of a plot in a subplot figure
i create a figure with 4 subplots (2 x 2), where 3 of them are of the type imshow and the other is errorbar. Each imshow plots have in addition a colorbar at the right side of them. I would like to resize my 3rd plot, that the area of the graph would be exactly under the... | changing size of a plot in a subplot figure | i create a figure with 4 subplots (2 x 2), where 3 of them are of the type imshow and the other is errorbar. Each imshow plots have in addition a colorbar at the right side of them. I would like to resize my 3rd plot, that the area of the graph would be exactly under the one above it (with out colorbar)
as example (thi... | [
"To adjust the dimensions of an axes instance, you need to use the set_position() method. This applies to subplotAxes as well. To get the current position/dimensions of the axis, use the get_position() method, which returns a Bbox instance. For me, it's conceptually easier to just interact with the position, ie [le... | [
5
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0007147210_matplotlib_python.txt |
Q:
undefined _PyUnicodeUCS4_IsWhitespace in compiled cython+numpy
i work on ubuntu 10.04 and used cython to compile my python code.
i then tried to copy 2 of my binaries (one with numpy, and one without) to another distribution with supported kernel and etc... the only thing i did which is not so cool is that i used ... | undefined _PyUnicodeUCS4_IsWhitespace in compiled cython+numpy | i work on ubuntu 10.04 and used cython to compile my python code.
i then tried to copy 2 of my binaries (one with numpy, and one without) to another distribution with supported kernel and etc... the only thing i did which is not so cool is that i used the python that comes with that distribution (2.6), and copy from my... | [
"well, it goes like this:\nwhen running python interpreter and imports the numpy library it tries to load from libpython.so the symbol Python is compiled with (i guess so). this is why it works with the interpreter. so the request for that unicode function doesn't come from numpy - but from Python - so it uses the ... | [
0
] | [] | [] | [
"cython",
"numpy",
"python"
] | stackoverflow_0007137275_cython_numpy_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.