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:
Set defaults at runtime
I manage a fairly large python-based quantum chemistry suite, PyQuante. I'm currently struggling with how to set various defaults so that users can choose among different options at runtime.
For example, I have three different methods for computing electron repulsion integrals. Let's call t... | Set defaults at runtime | I manage a fairly large python-based quantum chemistry suite, PyQuante. I'm currently struggling with how to set various defaults so that users can choose among different options at runtime.
For example, I have three different methods for computing electron repulsion integrals. Let's call them a,b,c. I used to simply p... | [
"With your current setup, the user can change the default functions in his scripts quite easily:\nimport Defaults\nDefaults.integral_method = somefunc\n\nIf the user adds this to his script, all your modules that use integral_method from Defaults will use somefunc to calculate integrals.\n",
"I might do this via ... | [
5,
3,
0
] | [] | [] | [
"python"
] | stackoverflow_0006140542_python.txt |
Q:
Python builds ok even with typos in the code?
(note: I'm new to Python)
I had a typo in a function call, and the project built, but crashed at runtime, when hitting the function call with the typo.
Is this normal?! Shouldn't the build have failed?! Am I setup correctly?!
I'm using Eclipse on Linux Centos.
Eclips... | Python builds ok even with typos in the code? | (note: I'm new to Python)
I had a typo in a function call, and the project built, but crashed at runtime, when hitting the function call with the typo.
Is this normal?! Shouldn't the build have failed?! Am I setup correctly?!
I'm using Eclipse on Linux Centos.
Eclipse does detect other errors (indentation, undefined ... | [
"Actually PyLint will detect that, so if you're using Eclipse with PyDev plug-in, it will mark line with foe() as error. \n\nPyDev can currently find:\n\nUndefined variables\nUndefined variable from import\nUnused variables\nUnused imports\nUnused wild imports\nDuplicated signatures\nImport redefinition\nUnresolved... | [
7,
2,
2,
0,
0
] | [] | [] | [
"eclipse",
"python"
] | stackoverflow_0006140789_eclipse_python.txt |
Q:
python multiprocessing can not control multiple long running console exe?
I am a newbie in Python. I recently tried to use Python script to call a console exe which is a process need long time. I will allow the exe being called as many times as the CPU can permit. And when the exe has finish its job. It should rel... | python multiprocessing can not control multiple long running console exe? | I am a newbie in Python. I recently tried to use Python script to call a console exe which is a process need long time. I will allow the exe being called as many times as the CPU can permit. And when the exe has finish its job. It should release the CPU to other new jobs. So I think I may need the multiple process cont... | [
"You're calling subprocessExec when you create the multiprocessing.Process object. You should instead do this:\np = multiprocessing.Process(target=subprocessExec, args=(exeFileName,))\n\nAnd then it should work.\n",
"There are number of things that are wrong in your test case. The following work for me:\nimport m... | [
2,
1
] | [] | [] | [
"console",
"exe",
"multiprocessing",
"python",
"subprocess"
] | stackoverflow_0006129754_console_exe_multiprocessing_python_subprocess.txt |
Q:
Getting the error text from `urllib2.urlopen`
I used Python's urllib2.urlopen and got a 500 error from the server. How do I find the text of the error? I'm hoping that it has useful information.
A:
from urllib2 import urlopen, HTTPError
try:
f = urlopen(url)
except HTTPError, e:
print(e.read())
| Getting the error text from `urllib2.urlopen` | I used Python's urllib2.urlopen and got a 500 error from the server. How do I find the text of the error? I'm hoping that it has useful information.
| [
"from urllib2 import urlopen, HTTPError\n\ntry:\n f = urlopen(url)\nexcept HTTPError, e:\n print(e.read())\n\n"
] | [
4
] | [] | [] | [
"http",
"python",
"urlopen"
] | stackoverflow_0006140923_http_python_urlopen.txt |
Q:
How do I iterate through all wx.CheckBox instances?
I have a wx frame where I have a quite a few checkboxes. Ever so often when the user changes the settings in a drop down menu (wx.ComboBox) I'd like to clear all the checkboxes. Currently, I've implemented a method that gets called when a change in the ComboBox... | How do I iterate through all wx.CheckBox instances? | I have a wx frame where I have a quite a few checkboxes. Ever so often when the user changes the settings in a drop down menu (wx.ComboBox) I'd like to clear all the checkboxes. Currently, I've implemented a method that gets called when a change in the ComboBox happens and it clears each check box manually, i.e.:
def... | [
"for control in self.GetChildren():\n if isinstance(control, wx.CheckBox):\n control.SetValue(False)\n\n",
"Have you tried something super ugly like:\n[checkbox.SetValue(0) for checkbox in dir(self) where type(checkbox) == type(wx.Checkbox)]\n\n"
] | [
5,
0
] | [] | [] | [
"python",
"wxpython",
"wxwidgets"
] | stackoverflow_0006140439_python_wxpython_wxwidgets.txt |
Q:
convert a dict of dict to json
I am trying to convert a dict of dict to json in order to read it with java (jsonLib java).
The problem here is that I have a big Json file (130 mb) and it seems that all the date is in only one line!
so I have a java out of memory exception when I try to read the file ( I read it wi... | convert a dict of dict to json | I am trying to convert a dict of dict to json in order to read it with java (jsonLib java).
The problem here is that I have a big Json file (130 mb) and it seems that all the date is in only one line!
so I have a java out of memory exception when I try to read the file ( I read it with BufferedReader from java.io)
here... | [
"You could break up the JSON payload into multiple files, perhaps one for each dict.\n",
"You should look into this http://jackson.codehaus.org/ and this http://outerthought.org/blog/415-ot.html\n"
] | [
0,
0
] | [] | [] | [
"dictionary",
"java",
"json",
"python"
] | stackoverflow_0006141111_dictionary_java_json_python.txt |
Q:
return value from listWidget in pyqt4
Whenever I attempt to store the selected value from a listWidget using
foo=self.listWidget.currentItem()
this is what I get as a value for foo:
<PyQt4.QtGui.QListWidgetItem object at 0x023BDD68>
This sort of makes sense, but is clearly not what I was asking it for. I'm aware... | return value from listWidget in pyqt4 | Whenever I attempt to store the selected value from a listWidget using
foo=self.listWidget.currentItem()
this is what I get as a value for foo:
<PyQt4.QtGui.QListWidgetItem object at 0x023BDD68>
This sort of makes sense, but is clearly not what I was asking it for. I'm aware of round about ways to get the actual item... | [
"From the PyQt4 QListWidgetItem docs, you could use:\nitem = self.listWidget.currentItem()\nvalue = item.text()\n\nOr on one line:\nvalue = self.listWidget.currentItem().text()\n\n"
] | [
5
] | [] | [] | [
"pyqt4",
"python",
"qlistwidget"
] | stackoverflow_0006141154_pyqt4_python_qlistwidget.txt |
Q:
Need help with Python delete old dirs script
This is function i am using to delete old dirs in python
def delete_olddirs(days,file_path):
numdays = 60*60*24*days
now = time.time()
for dir in os.listdir(file_path):
r = file_path
timestamp = os.path.getmtime(os.path.join(r... | Need help with Python delete old dirs script | This is function i am using to delete old dirs in python
def delete_olddirs(days,file_path):
numdays = 60*60*24*days
now = time.time()
for dir in os.listdir(file_path):
r = file_path
timestamp = os.path.getmtime(os.path.join(r,dir))
if now-numdays > timestamp:
... | [
"The else bit is run on success, you are misunderstanding its purpose.\nSee: http://docs.python.org/tutorial/errors.html\n",
"http://docs.python.org/reference/compound_stmts.html#the-try-statement\n\nThe optional else clause is executed\n if and when control flows off the end\n of the try clause. [2] Exceptions... | [
1,
1,
0,
0,
0
] | [] | [] | [
"linux",
"python"
] | stackoverflow_0006141264_linux_python.txt |
Q:
sqlalchemy: "Neither 'InstrumentedAttribute' object nor 'Comparator' object has an attribute" error
I've added a table to a database using sqlalchemy and sqlalchemy-migrate, and when I run unit tests on unrelated code that hits the database, I get the following error:
Traceback (most recent call last):
File "/U... | sqlalchemy: "Neither 'InstrumentedAttribute' object nor 'Comparator' object has an attribute" error | I've added a table to a database using sqlalchemy and sqlalchemy-migrate, and when I run unit tests on unrelated code that hits the database, I get the following error:
Traceback (most recent call last):
File "/Users/lorin/nova/instance_type_metadata/.nova-venv/lib/python2.6/site-packages/nose/suite.py", line 208, i... | [
"As you can see from traceback attribute metadata of mapped class is used internally by declarative extension for SQLAlchemy's MetaData instance, while you replaced it with your own relation (backref=\"metadata\") with different meaning. Renaming it to something else should solve the problem.\n"
] | [
4
] | [] | [] | [
"python",
"sqlalchemy",
"sqlalchemy_migrate"
] | stackoverflow_0006130902_python_sqlalchemy_sqlalchemy_migrate.txt |
Q:
Google App Engine Locking
just wondering if anyone of you has come across this. I'm playing around with the Python mail API on Google App Engine and I created an app that accepts a message body and address via POST, creates an entity in the datastore, then a cron job is run every minute, grabs 200 entities and sen... | Google App Engine Locking | just wondering if anyone of you has come across this. I'm playing around with the Python mail API on Google App Engine and I created an app that accepts a message body and address via POST, creates an entity in the datastore, then a cron job is run every minute, grabs 200 entities and sends out the emails, then deletes... | [
"Use tasks to send the email.\nCreate a task that takes a key as an argument, retrieves the stored entity for that key, then sends the email.\nWhen your handler receives the body and address, store that as you do now but then enqueue a task to do the send and pass the key of your datastore object to the task so it ... | [
3,
2
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0006109602_google_app_engine_python.txt |
Q:
Python + comet + web (chat) - I need working(!) library/server
I need working (cross-browser) project (library/server) to build web-chat in comet technology. There are: orbited, orbited2, hookbox, but it seems that are no longer developed (also projects sites are down) and have a lot of bugs.
Any ideas?
Thanks for... | Python + comet + web (chat) - I need working(!) library/server | I need working (cross-browser) project (library/server) to build web-chat in comet technology. There are: orbited, orbited2, hookbox, but it seems that are no longer developed (also projects sites are down) and have a lot of bugs.
Any ideas?
Thanks for help!
| [
"Have a look at Tornado a simple non-blocking webserver written in Python by the facebook team.\nThe comet behavior can be done with tornadio which makes possible to use socket.io javascript lib with tornado.\nThere is a chat example in tornadio that may look like what you are looking for. I 've tested it successfu... | [
1,
0
] | [] | [] | [
"comet",
"python"
] | stackoverflow_0006135781_comet_python.txt |
Q:
Replacing column values in an array using putmask and preserving order
I have a numpy array of floats and I wish to recalculate new values using a formula that depends on the column being recalculated.
I have initially tried to loop over the columns, masking the array except the column to be recalculated, and the... | Replacing column values in an array using putmask and preserving order | I have a numpy array of floats and I wish to recalculate new values using a formula that depends on the column being recalculated.
I have initially tried to loop over the columns, masking the array except the column to be recalculated, and the replacing the values with the new ones with numpy.putmask but this does not... | [
"putmask(x,mask,y) sets x.flat[n] = y[n] for each n where mask.flat[n] is True. \nIn [17]: list(x.flat)\nOut[17]: [21.0, 2.0, 22.0, 4.0, 23.0, 6.0, 24.0, 8.0, 25.0, 10.0]\n\nIn [18]: list(mask.flat)\nOut[18]: [True, False, True, False, True, False, True, False, True, False]\n\nSince mask.flat alternates between Tru... | [
2
] | [] | [] | [
"arrays",
"numpy",
"python"
] | stackoverflow_0006141493_arrays_numpy_python.txt |
Q:
How to control a command window opened from a .cmd file using Python
There's a file named startup.cmd that sets some environment variables, runs some preparation commands, then does:
start "startup" cmd /k
Which opens a command shell named startup. The manual process I'm trying to automate is to then enter the f... | How to control a command window opened from a .cmd file using Python | There's a file named startup.cmd that sets some environment variables, runs some preparation commands, then does:
start "startup" cmd /k
Which opens a command shell named startup. The manual process I'm trying to automate is to then enter the following command into this shell: get startup.xml. I thought the correct ... | [
"I found this warning in subprocess's document, \n\nWarning Use communicate() rather than .stdin.write, .stdout.read or .stderr.read to avoid deadlocks due to any of the other OS pipe buffers filling up and blocking the child process.\n\nSo my suggestion is to use communicate to send your command.\nimport subproces... | [
1,
-1
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0005998001_python_subprocess.txt |
Q:
numpy array of python objects
Since when did numpy allow you to define an array of python objects? Objects array with numpy.
Is there any fundamental difference between these arrays and a python list?
What is the difference between these arrays and say, a python tuple?
There are several handy numpy functions I wou... | numpy array of python objects | Since when did numpy allow you to define an array of python objects? Objects array with numpy.
Is there any fundamental difference between these arrays and a python list?
What is the difference between these arrays and say, a python tuple?
There are several handy numpy functions I would like to use, i.e. masks and elem... | [
"The \"fundamental\" difference is that a Numpy array is fixed-size, while a Python list is a dynamic array.\n>>> class Foo:\n... pass\n... \n>>> x = numpy.array([Foo(), Foo()])\n>>> x.append(Foo())\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nAttributeError: 'numpy.ndarray' object... | [
9
] | [] | [] | [
"arrays",
"numpy",
"object",
"python"
] | stackoverflow_0006141853_arrays_numpy_object_python.txt |
Q:
Adding/removing product fields to Product class in Cartridge?
Is there anyway to add fields to the default product class provided by Cartridge? I'm attempting to setup a parent-child relationship where the parent is the Product class and the child embellishes with custom product fields.
Is this at all possible? T... | Adding/removing product fields to Product class in Cartridge? | Is there anyway to add fields to the default product class provided by Cartridge? I'm attempting to setup a parent-child relationship where the parent is the Product class and the child embellishes with custom product fields.
Is this at all possible? Thanks.
Mark Anderson
| [
"The only way is to subclass the product class, and then use your subclass instead anywhere you need access to the extra fields. Just bear in mind that spots that require the parent class will accept the subclass but spots that require the subclass will not accept the parent class. It's like putting a round peg int... | [
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006141026_django_python.txt |
Q:
Creating a Legend Using ObjectListView
I am trying to create a legend of sorts using ObjectListView in Python.
I am able to accomplish this, using wx.PaintDC, DrawText, and DrawRectangle in wxPython, but it doesn't look very good because it is all free hand.
Is it possible to create a square image, say a 10x10 pi... | Creating a Legend Using ObjectListView | I am trying to create a legend of sorts using ObjectListView in Python.
I am able to accomplish this, using wx.PaintDC, DrawText, and DrawRectangle in wxPython, but it doesn't look very good because it is all free hand.
Is it possible to create a square image, say a 10x10 pixel square, using wxPython or another packag... | [
"You should be able to add different images to different rows with the ObjectListView widget, if I understand the question correctly. Alternatively, you might want to take a look at the UltimateListCtrl, which was written in pure Python and can have any widget put into it. I think there's a new list control widget ... | [
0
] | [] | [] | [
"objectlistview",
"python",
"wxpython"
] | stackoverflow_0006118139_objectlistview_python_wxpython.txt |
Q:
BadValueError: Property xxxx is required, even after the xxxx property has already been set? (google app engine)
Here's my model:
from google.appengine.ext import db
from google.appengine.ext.db import polymodel
class Item(polymodel.PolyModel):
title = db.StringProperty(required=True)
summary = db.StringP... | BadValueError: Property xxxx is required, even after the xxxx property has already been set? (google app engine) | Here's my model:
from google.appengine.ext import db
from google.appengine.ext.db import polymodel
class Item(polymodel.PolyModel):
title = db.StringProperty(required=True)
summary = db.StringProperty(required=True)
content = db.TextProperty(required=True)
createDate = db.DateTimeProperty(auto_now_add=... | [
"From the docs:\n\nBecause validation occurs when the\n instance is constructed, any property\n that is configured to be required must\n be initialized in the constructor.\n\nSo:\ntitle = \"Test title \" + str(i)\nauthor = \"wliao\"\nsummary = \"this is a test \" + str(i)\ncontent = \"this is the content of the ... | [
7
] | [] | [] | [
"google_app_engine",
"python",
"web_applications"
] | stackoverflow_0006142439_google_app_engine_python_web_applications.txt |
Q:
Tuple to string with a function to each element
There is a tuple (a, b, c).
I need to get foo(a) + "\n" + foo(b) + "\n" + foo(c)
How it can be done in a smart way, not manually?
A:
You could do it this way (if foo() returns a string):
tuple_ = (a,b,c)
"\n".join( foo(i) for i in tuple_ )
if foo() doesn't retur... | Tuple to string with a function to each element | There is a tuple (a, b, c).
I need to get foo(a) + "\n" + foo(b) + "\n" + foo(c)
How it can be done in a smart way, not manually?
| [
"You could do it this way (if foo() returns a string):\ntuple_ = (a,b,c)\n\"\\n\".join( foo(i) for i in tuple_ )\n\nif foo() doesn't return a string:\ntuple_ = (a,b,c)\n\"\\n\".join( str(foo(i)) for i in tuple_ )\n\nEdit\nIf writing for python < 2.4 use this since generator expressions were added in Python 2.4:\ntu... | [
8,
3
] | [] | [] | [
"python"
] | stackoverflow_0006142792_python.txt |
Q:
How to use bash variables inside a Python code?
I wanna do this:
import subprocess
subprocess.call(['var="foo_bar"'], shell=True)
subprocess.call(['echo $var'], shell=True)
But when i will use the $var in the second line your value is losted.
Somebody know some say to solve this problem?
This is a si... | How to use bash variables inside a Python code? | I wanna do this:
import subprocess
subprocess.call(['var="foo_bar"'], shell=True)
subprocess.call(['echo $var'], shell=True)
But when i will use the $var in the second line your value is losted.
Somebody know some say to solve this problem?
This is a simple example, but a need to do that in a much more co... | [
"Inject the value into the environment with os.environ.\nos.environ['var'] = \"foo_bar\"\nsubprocess.call(['echo $var'], shell=True)\n\n",
"You can't. You can use enviroment variables (os.environ), and you can of course use everything you get passed as command line args (sys.argv), but bash variables are bash var... | [
12,
0
] | [] | [] | [
"bash",
"python"
] | stackoverflow_0006142826_bash_python.txt |
Q:
Python data structure for a indexable list of string
I got a list of objects which look like strings, but are not real strings (think about mmap'ed files). Like this:
x = [ "abc", "defgh", "ij" ]
What i want is x to be directly indexable like it was a big string, i.e.:
(x[4] == "e") is True
(Of course I don't wa... | Python data structure for a indexable list of string | I got a list of objects which look like strings, but are not real strings (think about mmap'ed files). Like this:
x = [ "abc", "defgh", "ij" ]
What i want is x to be directly indexable like it was a big string, i.e.:
(x[4] == "e") is True
(Of course I don't want to do "".join(x) which would merge all strings, because... | [
"What you are describing is a special case of the rope data structure.\nUnfortunately, I am not aware of any Python implementations.\n",
"You have recreated the dictionary data type.\n",
"So do you still want to be able to address the n'th list element at all, like find that x.somemethod(2) == 'ij'?\nIf not, th... | [
9,
0,
0,
0,
0
] | [] | [] | [
"algorithm",
"data_structures",
"python"
] | stackoverflow_0006141354_algorithm_data_structures_python.txt |
Q:
In python is using a for loop a correct programming technique to create objects?
Ok so basically what I'm reading data from a file and with that data I want to create an object for each line.
So something like:
bar = [['a','b'],['c','d']]
for foo in bar:
foo = Class_name(list_of_arguments)
What would be th... | In python is using a for loop a correct programming technique to create objects? | Ok so basically what I'm reading data from a file and with that data I want to create an object for each line.
So something like:
bar = [['a','b'],['c','d']]
for foo in bar:
foo = Class_name(list_of_arguments)
What would be the best technique to 'unpack' the list? Would this best be done in the initializer meth... | [
"I ... think I understand your question. I'd probably approach it like so:\nclass myClass():\n def __init__(self, *args):\n # something here that actually uses the arguments.\n\ndata = [['a', 'b'], ['c', 'd']]\n\nobjects = [myClass(*vals) for vals in data]\n\nThat should instantiate myClass for each set of val... | [
6
] | [] | [] | [
"class",
"list",
"object",
"python"
] | stackoverflow_0006142941_class_list_object_python.txt |
Q:
remove unwanted space in between a string
I wanna know how to remove unwanted space in between a string. For example:
>>> a = "Hello world"
and i want to print it removing the extra middle spaces.
Hello world
A:
This will work:
" ".join(a.split())
Without any arguments, a.split() will automatically sp... | remove unwanted space in between a string | I wanna know how to remove unwanted space in between a string. For example:
>>> a = "Hello world"
and i want to print it removing the extra middle spaces.
Hello world
| [
"This will work: \n\" \".join(a.split())\n\nWithout any arguments, a.split() will automatically split on whitespace and discard duplicates, the \" \".join() joins the resulting list into one string.\n",
"Regular expressions also work\n>>> import re\n>>> re.sub(r'\\s+', ' ', 'Hello World')\n'Hello World'\n\... | [
43,
21
] | [] | [] | [
"python"
] | stackoverflow_0006142915_python.txt |
Q:
How to work with a datetime.datetime object returned from an Oracle query in Python
I have a query against an Oracle database using cx_Oracle. The results from the query come as
(datetime.datetime(2010, 11, 25, 14, 30, 47),)
I get this by using the below code:
#!/usr/bin/python
import obi
from datetime import dat... | How to work with a datetime.datetime object returned from an Oracle query in Python | I have a query against an Oracle database using cx_Oracle. The results from the query come as
(datetime.datetime(2010, 11, 25, 14, 30, 47),)
I get this by using the below code:
#!/usr/bin/python
import obi
from datetime import datetime
conn = obi.connect_obi()
query = obi.run_query(conn, "SELECT column FROM table_nam... | [
"x = (datetime.datetime(2010, 11, 25, 14, 30, 47),)\n\nis a tuple.\ndt = x[0]\n\nis the first element, which is your datetime.\ndt.year\n\nis the year of the datetime.\netc.\n",
"The returned value, (datetime.datetime(2010, 11, 25, 14, 30, 47),) is really a tuple. Note that it is enclosed in parenthesis and (most... | [
2,
0
] | [] | [] | [
"datetime",
"oracle",
"python"
] | stackoverflow_0006143531_datetime_oracle_python.txt |
Q:
Error: "x instance has no attribute y" when trying to inherit from class
I can't really understand what I'm doing wrong, since when I try it in "small scale" and it is working there.
I have a class named Play()
I goes like this:
class Play():
def __init__(self):
file = open("/home/trufa/Desktop/test", ... | Error: "x instance has no attribute y" when trying to inherit from class | I can't really understand what I'm doing wrong, since when I try it in "small scale" and it is working there.
I have a class named Play()
I goes like this:
class Play():
def __init__(self):
file = open("/home/trufa/Desktop/test", "r")
self.word = random.choice(file.readlines()).rstrip()
self... | [
"You overwrite the original __init__, which is then never called and doesn't initialize the members. You must call the parent's __init__ separately, usually with this snippet:\ndef __init__(self):\n super(Score, self).__init__()\n\nSee the docs for super() for details. However, super() only works for so-called n... | [
12,
4,
2
] | [] | [] | [
"attributes",
"inheritance",
"instance",
"python"
] | stackoverflow_0006143693_attributes_inheritance_instance_python.txt |
Q:
How to get the size of a single character in a (web) font?
I write a python script in order to generate a SVG file. This SVG file uses a web font ( imported from google webfonts via CSS ) to render my texts nicely. Everything is fine except I need to know the size (in pixel) of a sentence before putting it in my S... | How to get the size of a single character in a (web) font? | I write a python script in order to generate a SVG file. This SVG file uses a web font ( imported from google webfonts via CSS ) to render my texts nicely. Everything is fine except I need to know the size (in pixel) of a sentence before putting it in my SVG file.
As I started learning python few days ago, I don't kno... | [
"You can achieve it on the client side with javascript and the SVG DOM.\nFirst step : create a text element and compute its length with the getComputedTextLength() method ( http://www.w3.org/TR/SVG11/text.html#InterfaceSVGTextContentElement )\n<text id=\"foo\" xml:space=\"preserve\">foo </text>\n\nThen compute the ... | [
1,
0
] | [] | [] | [
"font_size",
"fonts",
"python",
"svg"
] | stackoverflow_0006138267_font_size_fonts_python_svg.txt |
Q:
Proportionality of parameter and mathematical expression
What is the best way to check if a parameter increase in a mathematical expression increases or decreases the expression as a whole (in Python, preferably SymPy)?
Assumptions: all parameters are positive (i.e. > 0).
Example A*B/(A+C): A should be found as pr... | Proportionality of parameter and mathematical expression | What is the best way to check if a parameter increase in a mathematical expression increases or decreases the expression as a whole (in Python, preferably SymPy)?
Assumptions: all parameters are positive (i.e. > 0).
Example A*B/(A+C): A should be found as proportional to the expression and C should be found as inverse ... | [
"I don't believe this can be solved in the general case. A simple counter-example is sin(A), which could be both proportional and inverse proportional, depending on what value of A you are evaluating it at. \nHowever, you could use an automatic differentiation tool, such as PyDX or Theano, to compute the derivat... | [
1
] | [] | [] | [
"mathematical_expressions",
"python",
"sympy"
] | stackoverflow_0006141500_mathematical_expressions_python_sympy.txt |
Q:
What is the appropriate way to parse a wiki dump into a format?
What is the best way to parse a wiki dump into a format which contains a self generated article id and the article content and nothing else?
The article id will be a reference id and the content to be a plain text no url no references.
A:
http://en... | What is the appropriate way to parse a wiki dump into a format? | What is the best way to parse a wiki dump into a format which contains a self generated article id and the article content and nothing else?
The article id will be a reference id and the content to be a plain text no url no references.
| [
"http://en.wikipedia.org/wiki/Wikipedia:Database_download#Database_schema\nSeems very clear.\nhttp://www.mediawiki.org/wiki/Manual:Importing_XML_dumps \nSeems very clear.\nhttp://www.mediawiki.org/wiki/Pywikipediabot\nSeems to be the code you want.\n"
] | [
1
] | [] | [] | [
"dump",
"java",
"parsing",
"python",
"wiki"
] | stackoverflow_0006142904_dump_java_parsing_python_wiki.txt |
Q:
Treemap visualisation view for Python profiler output?
Is there a profiler for Python that can render something like Kcachegrind's Callee map view?
A:
This looks like it might do what you want
http://www.vrplumber.com/programming/runsnakerun/
A:
If you are on Ubuntu (or have access to a host) you can convert ... | Treemap visualisation view for Python profiler output? | Is there a profiler for Python that can render something like Kcachegrind's Callee map view?
| [
"This looks like it might do what you want\nhttp://www.vrplumber.com/programming/runsnakerun/\n",
"If you are on Ubuntu (or have access to a host) you can convert the Python hotshot profiler's output into a form that KCachegrind can read. Check out the kcachegrind-converters package hotshot2calltree command.\nHe... | [
4,
2
] | [] | [] | [
"data_visualization",
"profiling",
"python",
"visualization"
] | stackoverflow_0006142744_data_visualization_profiling_python_visualization.txt |
Q:
How can I set the function environment for a Python function?
In Lua, there's a built-in function called setfenv(), which allows you to supply a table of variables as an environment for a function. Here's an example that uses it:
foo = 1
function f()
print(blech) --Note that no variable named blech has been d... | How can I set the function environment for a Python function? | In Lua, there's a built-in function called setfenv(), which allows you to supply a table of variables as an environment for a function. Here's an example that uses it:
foo = 1
function f()
print(blech) --Note that no variable named blech has been defined.
end
variableTable = {blech = foo}
setfenv(f, variableTable)... | [
"There's exec:\ndef foo():\n print bar\n\nexec foo.func_code in {\"bar\": \"baz\"}\n\nThis isn't particularly good style (I would even say that it is particularly bad). It makes the implementation of foo difficult to understand since it relies on knowing about the special way in which it will be called. Instea... | [
6,
2,
2,
0,
0
] | [] | [] | [
"lua",
"python"
] | stackoverflow_0006143994_lua_python.txt |
Q:
How can I override the HTTP methods for PUT and DELETE in a Flask Module?
I am having a hard time trying to modify the Flask request object before routing occurs.
My API Module (not my entire Flask app) depends on faking PUT and DELETE operations by sending a special header. I need to check out the contents of th... | How can I override the HTTP methods for PUT and DELETE in a Flask Module? | I am having a hard time trying to modify the Flask request object before routing occurs.
My API Module (not my entire Flask app) depends on faking PUT and DELETE operations by sending a special header. I need to check out the contents of the "-Method" header and modify the Flask Request object accordingly, before Flas... | [
"Werkzeug has the assumption that the request is only modified in a WSGI middleware or before Werkzeug has access to the data. The reason is that this way Werkzeug does not have to monitor the WSGI environment to see if it would have to invalidate caches or change behavior.\nIn this particular case you might be su... | [
8
] | [] | [] | [
"flask",
"python",
"werkzeug"
] | stackoverflow_0006144010_flask_python_werkzeug.txt |
Q:
What is behind python package namespaces: z3c, zc, collective?
So they all are somehow related to zope. Question is how?
I am not familiar with Zope. I guess that zc, z3c stand for Zope Component and Zope3 Component but I want to be sure. Also there is a collective namespace. What kind of packages goes under it?
W... | What is behind python package namespaces: z3c, zc, collective? | So they all are somehow related to zope. Question is how?
I am not familiar with Zope. I guess that zc, z3c stand for Zope Component and Zope3 Component but I want to be sure. Also there is a collective namespace. What kind of packages goes under it?
What are other well known python package namespaces?
Are there any co... | [
"\nzc is \"Zope Corporation\". \nz3c is \"Zope 3 community\", a namespace that long since has been \"deprecated\", ie no new packages are made with this namespace.\ncollective refers to the Plone Collective, a svn repository for Plone packages with a friendly attitude towards contributors. It's been the \"default\"... | [
8,
1
] | [] | [] | [
"python",
"zope"
] | stackoverflow_0005053174_python_zope.txt |
Q:
String replace utility conversion from Python to F#
I have a simple python utility code that modifies the string line by line. The code is as follows.
import re
res = ""
with open("tclscript.do","r") as f:
lines = f.readlines()
for l in lines:
l = l.rstrip()
l = l.replace("{","{{")
... | String replace utility conversion from Python to F# | I have a simple python utility code that modifies the string line by line. The code is as follows.
import re
res = ""
with open("tclscript.do","r") as f:
lines = f.readlines()
for l in lines:
l = l.rstrip()
l = l.replace("{","{{")
l = l.replace("}","}}")
l = re.sub(r'#(\d+)', r... | [
"I will not give you a complete example of the F# version, because I'm not sure what the regular expression in your Python version is supposed to do. However, the general structure of a nice F# solution would look something like this:\nlet lines = \n File.ReadAllLines(\"tclscript.do\")\n |> Seq.map (fun line ->\n... | [
4
] | [] | [] | [
".net",
"f#",
"python",
"utility"
] | stackoverflow_0006144274_.net_f#_python_utility.txt |
Q:
python threads that run in parallel?
I'm aware that Jython and IronPython can run threads in parallel(to take advantage Multicore or SMP machines) due to their VM implementation.
Is there an implementation or extension in CPython that does that ?
I'm not talking about multiprocessing as in http://docs.python.org/... | python threads that run in parallel? | I'm aware that Jython and IronPython can run threads in parallel(to take advantage Multicore or SMP machines) due to their VM implementation.
Is there an implementation or extension in CPython that does that ?
I'm not talking about multiprocessing as in http://docs.python.org/library/multiprocessing.html
How "heavy" a... | [
"The multiprocessing module uses full processes. That means it fork()s. So this are not threads like the usual POSIX threads you usually mean by talking about threads.\n"
] | [
6
] | [] | [] | [
"concurrency",
"multithreading",
"python"
] | stackoverflow_0006144710_concurrency_multithreading_python.txt |
Q:
How to draw a 2D graph in Python - horizontal bars
I would like to make graph like this in Python:
I have made the program in C that will give me combinations I need (here N=2n+|m| iirc), so could I integrate that here somehow?
I made something in Mathematica, but that's a pain in the butt... Any help is appreci... | How to draw a 2D graph in Python - horizontal bars | I would like to make graph like this in Python:
I have made the program in C that will give me combinations I need (here N=2n+|m| iirc), so could I integrate that here somehow?
I made something in Mathematica, but that's a pain in the butt... Any help is appreciated.
| [
"I would customize CairoPlot for doing that (http://linil.wordpress.com/2008/09/16/cairoplot-11/ ) --\nCairoplot is a simple and small project to use the powerfull Cairo library to make Graph's. \nIt does have few, although beauutiful, graphic options, but it is entirely made in Python - it should be possible to su... | [
1,
1
] | [] | [] | [
"graph",
"python"
] | stackoverflow_0004649651_graph_python.txt |
Q:
Regex to remove all punctuation and anything enclosed by brackets
I'm trying to remove all punctuation and anything inside brackets or parentheses from a string in python. The idea is to somewhat normalize song names to get better results when I query the MusicBrainz WebService.
Sample input: T.N.T. (live) [nyc]
E... | Regex to remove all punctuation and anything enclosed by brackets | I'm trying to remove all punctuation and anything inside brackets or parentheses from a string in python. The idea is to somewhat normalize song names to get better results when I query the MusicBrainz WebService.
Sample input: T.N.T. (live) [nyc]
Expected output: T N T
I can do it in two regexes, but I would like to s... | [
"You are correct that the \\W+ is eating the braces, remove the + and you should be set:\n>>> re.sub(r'\\[.*?\\]|\\(.*?\\)|\\W', ' ', 'T.N.T. (live) [nyc]')\n'T N T '\n\n",
"Here's a mini-parser that does the same thing I wrote as an exercise. If your effort to normalize gets much more complex, you may start ... | [
4,
1,
0,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006144326_python_regex.txt |
Q:
How can I call inlined machine code in Python on Linux?
I'm trying to call inlined machine code from pure Python code on Linux. To this end, I embed the code in a bytes literal
code = b"\x55\x89\xe5\x5d\xc3"
and then call mprotect() via ctypes to allow execution of the page containing the code. Finally, I try t... | How can I call inlined machine code in Python on Linux? | I'm trying to call inlined machine code from pure Python code on Linux. To this end, I embed the code in a bytes literal
code = b"\x55\x89\xe5\x5d\xc3"
and then call mprotect() via ctypes to allow execution of the page containing the code. Finally, I try to use ctypes to call the code. Here is my full code:
#!/usr/... | [
"I did a quick debug on this and it turns out the pointer to the code is\nnot being correctly constructed, and somewhere internally ctypes is munging \nthings up before passing the function pointer to ffi_call() which invokes the\ncode.\nHere is the line in ffi_call_unix64() (I'm on 64-bit) where the function point... | [
7,
3,
2
] | [] | [] | [
"ctypes",
"linux",
"mprotect",
"python"
] | stackoverflow_0006143042_ctypes_linux_mprotect_python.txt |
Q:
Why should CSS and JS not go through Django?
As per this answer to Can I gzip JavaScript and CSS files in Django?:
Your CSS and JS should not be going through Django on your production system. You need to configure Apache (or Nginx, or whatever) to serve these, and when you do so you'll be able to set up gzip com... | Why should CSS and JS not go through Django? | As per this answer to Can I gzip JavaScript and CSS files in Django?:
Your CSS and JS should not be going through Django on your production system. You need to configure Apache (or Nginx, or whatever) to serve these, and when you do so you'll be able to set up gzip compression there, rather than in Django.
The answer... | [
"Apache and Nginx are faster than Django (because they do much less and much simpler things). So serving CSS and JS with Django is a waste of resources.\nAlthough \"should\" is too strong here, IMO. \"Should, if you have high traffic\", rather.\n",
"The content served by a Web server can be broadly categorized in... | [
11,
3,
2
] | [] | [] | [
"css",
"django",
"javascript",
"optimization",
"python"
] | stackoverflow_0006135684_css_django_javascript_optimization_python.txt |
Q:
Python map vs list comprehension
When comparing these, which do you think is more intuitive / easier to read?
>>> [ord(i) for i in 'some string']
[115, 111, 109, 101, 32, 115, 116, 114, 105, 110, 103]
>>> map(ord,'some string')
[115, 111, 109, 101, 32, 115, 116, 114, 105, 110, 103]
Is there any benefit to the la... | Python map vs list comprehension | When comparing these, which do you think is more intuitive / easier to read?
>>> [ord(i) for i in 'some string']
[115, 111, 109, 101, 32, 115, 116, 114, 105, 110, 103]
>>> map(ord,'some string')
[115, 111, 109, 101, 32, 115, 116, 114, 105, 110, 103]
Is there any benefit to the lambda/map way?
| [
"I like the first one better and there's an advantage to it. You can instead of\n[ord(i) for i in 'some string']\n\nwrite \n(ord(i) for i in 'some string')\n\nand have a generator instead of making a list. Great in some siutations.\n",
"I prefer the first one, because I'm more used to it. Somebody doing a lot o... | [
5,
4,
0,
0
] | [] | [] | [
"lambda",
"loops",
"python"
] | stackoverflow_0006145347_lambda_loops_python.txt |
Q:
Editing Pickled Data
I need to save a complex piece of data:
list = ["Animals", {"Cats":4, "Dogs":5}, {"x":[], "y":[]}]
I was planning on saving several of these lists within the same file, and I was also planning on using the pickle module to save this data. I also want to be able to access the pickled data and ... | Editing Pickled Data | I need to save a complex piece of data:
list = ["Animals", {"Cats":4, "Dogs":5}, {"x":[], "y":[]}]
I was planning on saving several of these lists within the same file, and I was also planning on using the pickle module to save this data. I also want to be able to access the pickled data and add items to the lists in ... | [
"You could open the file for writing instead of appending -- then the changes would overwrite previous data. This is however a problem if there is more data stored in that file. If what you want really is to selectively replace data in a pickled file, I'm afraid this won't work with pickle. If this is a common oper... | [
3,
3
] | [] | [] | [
"pickle",
"python",
"storage"
] | stackoverflow_0006145334_pickle_python_storage.txt |
Q:
python matplotlib scatter
I am using matplotlib to scatter plot some data from an Oracle table. One of the fields is a DATE and when converting it to a to_char in the below query I get an error. I want to scatter plot by hours 00-23 not by date. So Y axis should show 00-23. See below code example along with error.... | python matplotlib scatter | I am using matplotlib to scatter plot some data from an Oracle table. One of the fields is a DATE and when converting it to a to_char in the below query I get an error. I want to scatter plot by hours 00-23 not by date. So Y axis should show 00-23. See below code example along with error.
Thanks for any help.
import ... | [
"You can just select the hour instead of the date.\nSELECT .. DATEPART(mm, end_date) AS end_hour\n\nhttp://www.bennadel.com/blog/172-Ask-Ben-Selecting-Parts-of-a-Date-Time-Stamp-In-SQL.htm\n"
] | [
1
] | [] | [] | [
"matplotlib",
"oracle",
"python"
] | stackoverflow_0006145552_matplotlib_oracle_python.txt |
Q:
Running Graph library with nodebox on windows + None Type Error
I have installed nodebox 2 for windows on my machine and have verified that all the examples are running as it is.
Now i want to use graph library Graph for the same.
I went and copied it as it is in my site-packages folder and then ran the examples i... | Running Graph library with nodebox on windows + None Type Error | I have installed nodebox 2 for windows on my machine and have verified that all the examples are running as it is.
Now i want to use graph library Graph for the same.
I went and copied it as it is in my site-packages folder and then ran the examples it had given along it in IDLE.
I recieved an error of ximport . So the... | [
"The Nodebox Graph docs mention that it supports Nodebox 1.9.5.6, which is a Nodebox 1 (Mac only) version number. To my knowledge the Graph library has not yet been ported to Nodebox 2, so can only currently run on the Mac.\n\nOne option is a project called Nodebox OpenGL which implements the Nodebox API and includ... | [
2
] | [] | [] | [
"nodebox",
"python"
] | stackoverflow_0006144968_nodebox_python.txt |
Q:
What is the optimal way to process a very large (over 30GB) text file and also show progress
[newbie question]
Hi,
I'm working on a huge text file which is well over 30GB.
I have to do some processing on each line and then write it to a db in JSON format. When I read the file and loop using "for" my computer cras... | What is the optimal way to process a very large (over 30GB) text file and also show progress | [newbie question]
Hi,
I'm working on a huge text file which is well over 30GB.
I have to do some processing on each line and then write it to a db in JSON format. When I read the file and loop using "for" my computer crashes and displays blue screen after about 10% of processing data.
Im currently using this:
f = open... | [
"File handles are iterable, and you should probably use a context manager. Try this:\nwith open(file_path, 'r') as fh:\n for line in fh:\n process(line)\n\nThat might be enough.\n",
"I use a function like this for a similiar problem. You can wrap up any iterable with it.\nChange this\nfor one_line in f.read... | [
4,
1,
0
] | [] | [] | [
"data_processing",
"python"
] | stackoverflow_0006145784_data_processing_python.txt |
Q:
Filtering two lists by comparing all items to eachother with numpy or tabular
i have two lists of tuples, where tuples in the each list are all unique.
lists have the following format:
[('col1', 'col2', 'col3', 'col4'), ...]
i'm using a nested loop to find the members from both lists that have the same values fo... | Filtering two lists by comparing all items to eachother with numpy or tabular | i have two lists of tuples, where tuples in the each list are all unique.
lists have the following format:
[('col1', 'col2', 'col3', 'col4'), ...]
i'm using a nested loop to find the members from both lists that have the same values for given cols, col2 and col3
temp1 = set([])
temp2 = set([])
for item1 in list1:
... | [
"Try this:\ntemp1 = set([])\ntemp2 = set([])\n\ndict1 = dict()\ndict2 = dict()\n\nfor key, value in zip([tuple(l[1:3]) for l in list1], list1):\n dict1.setdefault(key, list()).append(value)\n\nfor key, value in zip([tuple(l[1:3]) for l in list2], list2):\n dict2.setdefault(key, list()).append(value)\n\nfor ke... | [
1,
1,
0
] | [] | [] | [
"arrays",
"numpy",
"python"
] | stackoverflow_0006144058_arrays_numpy_python.txt |
Q:
Building/testing a Python project with C extensions
I have a project with a python package and a compiled component inside of it. Current directory layout is:
<project>
foo/
foo/__init__.py
foo/...
src/
src/c_foo.c
tests/
tests/test_foo.py
setup.py
When the project is built, distutils create a ... | Building/testing a Python project with C extensions | I have a project with a python package and a compiled component inside of it. Current directory layout is:
<project>
foo/
foo/__init__.py
foo/...
src/
src/c_foo.c
tests/
tests/test_foo.py
setup.py
When the project is built, distutils create a build/lib directory which I either add to PYTHONPATH or i... | [
"You may want to try the develop target in distribute (formerly setuptools). \nMake sure distribute is installed, then modify your setup.py like so:\n# the setuptools package name is still used\nfrom setuptools import setup, Extension\n...\n\nThen enter your virtualenv and run develop:\n% source ~/virt/bin/activat... | [
1
] | [] | [] | [
"compiled",
"distutils",
"python",
"testing"
] | stackoverflow_0006145637_compiled_distutils_python_testing.txt |
Q:
Delay a file update during a redirection url in a Python script
I use a python script (on a linux web server) to redirect a user on request. The redirection is based on a database (a python dictionary) and the database itself is builded from a remote CSV file.
For now, I have to manually update the database but t... | Delay a file update during a redirection url in a Python script | I use a python script (on a linux web server) to redirect a user on request. The redirection is based on a database (a python dictionary) and the database itself is builded from a remote CSV file.
For now, I have to manually update the database but the CSV file can change at any time.
I'm looking for a way to update t... | [
"You would be better served by updating a COPY in the background, and instantly switching them and making the updated copy into the live copy. Thus there would be no wait for the user, and you could do so at any time. You are probably best not doing so 10sec after each user request (imagine a flood of requests... i... | [
0
] | [] | [] | [
"database",
"delay",
"python",
"webserver"
] | stackoverflow_0006145987_database_delay_python_webserver.txt |
Q:
Can auto transfer data from memcached to mysql DB?
I'm building a real-time service so my real-time database need to storage in memcached before fetch to DB (Avoid to read/write mysql db too much). I want to fetch data to mysql DB when some events occur , etc : before data expire or have least-recently-used (LRU) ... | Can auto transfer data from memcached to mysql DB? | I'm building a real-time service so my real-time database need to storage in memcached before fetch to DB (Avoid to read/write mysql db too much). I want to fetch data to mysql DB when some events occur , etc : before data expire or have least-recently-used (LRU) data. What is solution for my problem ? My system used m... | [
"Memcached is not a persistent store, so if you need your data to be durable at all then you will need to store them in a persistent store immediately.\nSo you need to put them somewhere - possibly a MySQL table - as soon as the data arrive, and make sure they are fsync'd to disc. Storing them in memcached as well ... | [
1
] | [] | [] | [
"django",
"memcached",
"mysql",
"python"
] | stackoverflow_0006143748_django_memcached_mysql_python.txt |
Q:
Python 3.2 Debug Lib
I need to either download or build the python32_d.lib, unfortunately whenever I search for how to obtain said lib all I get is people asking the same question, but never the actual answer.
One answer was to #undef _DEBUG, but upon doing this I get an Iterator_Debug_Level linker error in the p... | Python 3.2 Debug Lib | I need to either download or build the python32_d.lib, unfortunately whenever I search for how to obtain said lib all I get is people asking the same question, but never the actual answer.
One answer was to #undef _DEBUG, but upon doing this I get an Iterator_Debug_Level linker error in the project.
So how do I actua... | [
"Are you building with MSVC? This should get you started.\n"
] | [
0
] | [] | [] | [
"linker_errors",
"python"
] | stackoverflow_0006145934_linker_errors_python.txt |
Q:
How to stop a WebView launched from SL4A from hiding the notification bar?
I'm building a UI for my little Python SL4A script that uses WebViews, but I find a little annoying that when I launch my WebView from the SL4A script (droid.webViewShow(...)) the Android notification bar gets hidden!
Here's some code:
impo... | How to stop a WebView launched from SL4A from hiding the notification bar? | I'm building a UI for my little Python SL4A script that uses WebViews, but I find a little annoying that when I launch my WebView from the SL4A script (droid.webViewShow(...)) the Android notification bar gets hidden!
Here's some code:
import android
droid = android.Android()
droid.webViewShow('file:///sdcard/sl4a/scr... | [
"It sounds like you need to re-architect your solution a bit. I would recommend you layout.xml file define the webview and the area of which it resides. In your manifest, you can define if the activity is a fullscreen activity or not, and lastly, you would instantiate it from your client code and render into the ... | [
0
] | [] | [] | [
"android",
"android_webview",
"python",
"sl4a"
] | stackoverflow_0005892717_android_android_webview_python_sl4a.txt |
Q:
Searching a data file: coding in python vs c++
First off , this isn't a homework assignment!!! :p What I want to do is this:
Given a data file(be it text or numbers) saved on the desktop i.e., I want to be able to search that file and pull out only the data I want and print it to the screen. I may want to do other... | Searching a data file: coding in python vs c++ | First off , this isn't a homework assignment!!! :p What I want to do is this:
Given a data file(be it text or numbers) saved on the desktop i.e., I want to be able to search that file and pull out only the data I want and print it to the screen. I may want to do other stuff with it but I have no idea what options there... | [
"This is a bit difficult to answer without knowing how you want to specify the data you want.\nIf you can specify the necessary data using regexes, Python will probably be about equally efficient, and a bit quicker to write -- but you may be able to do the job with something like grep even more easily.\nIf it'll ta... | [
3,
1
] | [
"Python will be much better for this task:\nfor line in file(\"path/to/file.txt\", \"rb\"):\n print line\n\nThe equivalent C++ is much more involved.\n"
] | [
-3
] | [
"c++",
"python",
"search"
] | stackoverflow_0006146359_c++_python_search.txt |
Q:
Python: Built-in Keyboard Signal/Interrupts
I currently need to provide multiple keyboard interrupts for a program. Is there an easy way to do this with the signal class? I currently use the SIGINT/Ctrl+C but I can't find any other keyboard mappings.
Would be nice to have more than 2 signals. How can I either def... | Python: Built-in Keyboard Signal/Interrupts | I currently need to provide multiple keyboard interrupts for a program. Is there an easy way to do this with the signal class? I currently use the SIGINT/Ctrl+C but I can't find any other keyboard mappings.
Would be nice to have more than 2 signals. How can I either define more signals or is there a better way to capt... | [
"The Ctrl+\\ that has been mentioned is interpreted by your terminal software, and the key binding is configured through stty. Unless you have some way of customizing your terminal software you'll only be able to use the few signals that are already built in.\nDepending on how much functionality you need or how far... | [
11,
7,
0
] | [] | [] | [
"linux",
"python",
"signals"
] | stackoverflow_0005475456_linux_python_signals.txt |
Q:
Writing from a text file to SQL using Python
Hey I was just wondering if anyone would be able to help with writing the contents of a series of text files (e.g. activities.txt, sports.txt) (each has has a number, a tab, and a value (e.g. 90 Badminton) in each row). I have already initialised the database connecti... | Writing from a text file to SQL using Python | Hey I was just wondering if anyone would be able to help with writing the contents of a series of text files (e.g. activities.txt, sports.txt) (each has has a number, a tab, and a value (e.g. 90 Badminton) in each row). I have already initialised the database connection and have the table in SQL made ready to go.
An... | [
"If I understand this correctly then the following snippet should get you started. I'm going to assume you already have access to a cursor...\ncategory = \"Sports\"\nwith open(\"sports.txt\", \"r\") as sports:\n lines = sports.readlines()\n\nfor line in lines:\n # Split the line on whitespace\n data = lin... | [
1
] | [] | [] | [
"mysql",
"python",
"python_idle",
"sql",
"text"
] | stackoverflow_0006146729_mysql_python_python_idle_sql_text.txt |
Q:
Using Spynner module in Python (need to select a Javascript element)
Trying to select a Javascript element using the Python module Spynner.
(NOTE: Username and Password not real)
Here's the list I am trying to pull it from:
<tr>
<td valign="middle" align="right">
<select onkeypress="javascript:if ( event.keyCode =... | Using Spynner module in Python (need to select a Javascript element) | Trying to select a Javascript element using the Python module Spynner.
(NOTE: Username and Password not real)
Here's the list I am trying to pull it from:
<tr>
<td valign="middle" align="right">
<select onkeypress="javascript:if ( event.keyCode == 13 ){valid();}" style="font-family:Tahoma; font-size:11px;FONT-WEIGHT :n... | [
"This is a bit of a guess, but it looks like select takes a css selector. Since IBESNA~US isn't a tag, it can't select it and throws an error. Try something like br.select('option[value=\"IBESNA~US\"]')\n"
] | [
1
] | [] | [] | [
"javascript",
"parsing",
"python",
"webkit"
] | stackoverflow_0006146472_javascript_parsing_python_webkit.txt |
Q:
Installing JDK and Python and setting the PATH variable on Windows 7
I recently installed Java's JDK and Python in my Windows 7 system. I wanted to access both programs from the command line (whether it be cmd or cygwin) so I used the PATH global variable and entered the path to my JDK. What can I do so that pytho... | Installing JDK and Python and setting the PATH variable on Windows 7 | I recently installed Java's JDK and Python in my Windows 7 system. I wanted to access both programs from the command line (whether it be cmd or cygwin) so I used the PATH global variable and entered the path to my JDK. What can I do so that python and JDK are accessed by PATH? What I am doing now is changing the PATH v... | [
"I'm confused. Are you switching out the paths between the JDK and Python? If that's the case, you can have both paths set in your system's PATH variable. Example: C:\\jdk-install\\;C:\\python-install\n",
"\nRight click on \"My Computer\"\nChoose \"Properties\"\nClick on \"Advanced System Settings\"\nClick on ... | [
2,
1
] | [] | [] | [
"installation",
"java",
"python",
"windows_7_x64"
] | stackoverflow_0006147101_installation_java_python_windows_7_x64.txt |
Q:
What clustering algorithm to use on 1-d data?
I have a list of numbers in an array. The index of each element is X and the value is Y. How do i go about partitioning/clustering this data?
If i had an array, i just want a set of values which mark the end of each partition. Since I'm working on Python, please do men... | What clustering algorithm to use on 1-d data? | I have a list of numbers in an array. The index of each element is X and the value is Y. How do i go about partitioning/clustering this data?
If i had an array, i just want a set of values which mark the end of each partition. Since I'm working on Python, please do mention if there are libraries to do the same.
Thanks.... | [
"K-Means is a very simple clustering algorithm, I would say the first to test before going for more complex things. \nThe K-Means algorithm http://en.wikipedia.org/wiki/K-means_clustering \nProper K-Means initialization is strongly advised http://en.wikipedia.org/wiki/K-means%2B%2B, as it.\nIf you're not happy with... | [
5
] | [] | [] | [
"cluster_analysis",
"python"
] | stackoverflow_0006147466_cluster_analysis_python.txt |
Q:
Need Help Understanding this Python Traceback
Amy idea what this means?
Traceback (most recent call last):
File "C:\Python27\Sample Programs\Spynner Basic.py", line 17, in <module>
br.select("#IBESNA~US")
File "C:\Python27\lib\site-packages\spynner\browser.py", line 862, in select
self._runjs_on_jquery... | Need Help Understanding this Python Traceback | Amy idea what this means?
Traceback (most recent call last):
File "C:\Python27\Sample Programs\Spynner Basic.py", line 17, in <module>
br.select("#IBESNA~US")
File "C:\Python27\lib\site-packages\spynner\browser.py", line 862, in select
self._runjs_on_jquery("select", jscode)
File "C:\Python27\lib\site-pac... | [
"This is just a guess, but I'm not sure if jQuery can modify an attribute that doesn't exist? That option tag has no 'selected' attribute.\nTry giving that option tag a selected='false' and see if that fixes it.\n",
"I am out of my depth here, but I believe recent versions of JQuery have stopped/changed support f... | [
1,
0
] | [] | [] | [
"javascript",
"python"
] | stackoverflow_0006147377_javascript_python.txt |
Q:
Django - Error socialregistration.middleware
Just now I clone my remote repo from my server to my computer with mercurial.
I changed settings.py for set sqlite3 as database engine and I tried to run Django built-in webserver:
$ python manage.py runserver
Validating models...
0 errors found
Django version 1.3, usi... | Django - Error socialregistration.middleware | Just now I clone my remote repo from my server to my computer with mercurial.
I changed settings.py for set sqlite3 as database engine and I tried to run Django built-in webserver:
$ python manage.py runserver
Validating models...
0 errors found
Django version 1.3, using settings 'myproj.settings'
Development server i... | [
"You forgot to install facebook on your server.\n"
] | [
2
] | [] | [] | [
"django",
"django_middleware",
"python"
] | stackoverflow_0006147534_django_django_middleware_python.txt |
Q:
How can I make my title-case regular expression match prefix titles?
I need to pull possible titles out of a chunk of text. So for instance, I want to match words like "Joe Smith", "The Firm", or "United States of America". I now need to modify it to match names that begin with a title of some kind (such as "Dr.... | How can I make my title-case regular expression match prefix titles? | I need to pull possible titles out of a chunk of text. So for instance, I want to match words like "Joe Smith", "The Firm", or "United States of America". I now need to modify it to match names that begin with a title of some kind (such as "Dr. Joe Smith"). Here's the regular expression I have:
NON_CAPPED_WORDS = (
... | [
"The problem seems to be that the first part of the expression, [A-Z0-9&][a-zA-Z0-9]*[\\s,:-]*, is gobbling up the initial characters in your \"prefix titles\", since they are title-cased until you get to the period. So, when the + is repeating the subexpression and encounters 'Dr.', that initial part of the expres... | [
2
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006146885_python_regex.txt |
Q:
How do I resolve difficulties with decoding and printing Greek characters using Python?
I am creating a simple game designed to prompt the user for the Greek translation of an English word. For example:
cow: # here, the gamer would answer with *η αγελάδα* in order to score one point.
I use a helper function to r... | How do I resolve difficulties with decoding and printing Greek characters using Python? | I am creating a simple game designed to prompt the user for the Greek translation of an English word. For example:
cow: # here, the gamer would answer with *η αγελάδα* in order to score one point.
I use a helper function to read and decode from a txt file. I do so using the following code in said function:
# The var... | [
"For part of your question, use:\nwords_text = codecs.open(filename, 'r', 'utf-8-sig')\n\nand it will handle processing the byte-order-mark of \\ufeff.\nTechnically, this:\nuser_reply = raw_input('%s: ' % (gr_en_dict[key])).decode(sys.stdout.encoding)\n\nshould be:\nuser_reply = raw_input('%s: ' % (gr_en_dict[key])... | [
4,
1
] | [] | [] | [
"printing",
"python",
"raw_input",
"unicode"
] | stackoverflow_0006146497_printing_python_raw_input_unicode.txt |
Q:
Migrating away from App Engine but still keeping tight Google Account integration
I've got an app currently running on Google App Engine that takes advantage of the close integration with Google Accounts to the extent that it was the only way users would sign in. The sign-in process was this:
User would click si... | Migrating away from App Engine but still keeping tight Google Account integration | I've got an app currently running on Google App Engine that takes advantage of the close integration with Google Accounts to the extent that it was the only way users would sign in. The sign-in process was this:
User would click sign-in w/ Google Account link, which would just be the output of `users.create_login_url... | [
"Since you can't use the App Engine API to do so (and you probably don't want to write this OpenID auth system by yourself), you better make use of a django app to do so. Have a look at Django packages. I personally have good experience with django-socialregistration, though they provide Facebook/Twitter auth as we... | [
0
] | [] | [] | [
"django",
"google_app_engine",
"hosting",
"python"
] | stackoverflow_0006146975_django_google_app_engine_hosting_python.txt |
Q:
How to "style" a text based hangman game
My question is simple, the hangman game looks like this:
I'm doing the indentation in a way I don't think is very good.
I just have var = "\t" and add it at the begging of every print, this seem impractical and hard to maintain.
Would you have it any other way? How is this... | How to "style" a text based hangman game | My question is simple, the hangman game looks like this:
I'm doing the indentation in a way I don't think is very good.
I just have var = "\t" and add it at the begging of every print, this seem impractical and hard to maintain.
Would you have it any other way? How is this generally managed?
Thanks in advance!
| [
"problem:\nprint('\\tthis')\nprint('\\tis')\nprint('\\tan')\nprint('\\texample')\n\nsolution = abstraction!:\ndef echo(string, indent=1): # name it whatever you want, e.g. p\n print('\\t'*indent + string)\n\necho('this')\necho('is')\necho('an')\necho('abstraction')\n\nbetter solution = templates:\ntemplate = \"... | [
1,
0,
0,
0
] | [] | [] | [
"python",
"terminal",
"text_based"
] | stackoverflow_0006147753_python_terminal_text_based.txt |
Q:
Python - Search for items in hundreds of large, gzipped files
Unfortunately, I'm working with an extremely large corpus which is spread into hundreds of .gz files -- 24 gigabytes (packed) worth, in fact. Python is really my native language (hah) but I was wondering if I haven't run up against a problem that will n... | Python - Search for items in hundreds of large, gzipped files | Unfortunately, I'm working with an extremely large corpus which is spread into hundreds of .gz files -- 24 gigabytes (packed) worth, in fact. Python is really my native language (hah) but I was wondering if I haven't run up against a problem that will necessitate learning a "faster" language?
Each .gz file contains a s... | [
"It would help to have an example of a few lines and expected output. But from what I understand, here are some ideas.\nYou certainly don't want to process all files every time you process a single file or, worse, a single 4-gram. Ideally you'd go through each file once. So my first suggestion is to maintain an int... | [
1
] | [] | [] | [
"corpus",
"gzip",
"large_data_volumes",
"large_files",
"python"
] | stackoverflow_0006147504_corpus_gzip_large_data_volumes_large_files_python.txt |
Q:
value of decoded json
I try to get item from dict, which was decoded by json:
data = [ { 'a':'A', 'b':(2, 4), 'c':3 } ]
data_string = json.dumps(data)
decoded = json.loads(data_string)
decoded['c']
So it shows the next:
Traceback (most recent call last):
File "", line 1, in
TypeError: list indices must be int... | value of decoded json | I try to get item from dict, which was decoded by json:
data = [ { 'a':'A', 'b':(2, 4), 'c':3 } ]
data_string = json.dumps(data)
decoded = json.loads(data_string)
decoded['c']
So it shows the next:
Traceback (most recent call last):
File "", line 1, in
TypeError: list indices must be integers, not str
I try to pr... | [
"your data is a list containing a dictionary\nyou can use decoded[0]['c'] since the dictionary is the first element of the list\nanother possibility is that you should use data = {u'a': u'A', u'c': 3, u'b': [2, 4]} (no square brackets)\nIt really depends on whether you mean for data to be a list of dictionaries or ... | [
5,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0006148096_python.txt |
Q:
Importing a Django model into a python cli script
I am just getting this django app (also an inexperienced python user) running and wanted to be able to access the models.
I have the following:
import sys, os
sys.path.append('/Users/jx/dev/arc/django/second/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.setting... | Importing a Django model into a python cli script | I am just getting this django app (also an inexperienced python user) running and wanted to be able to access the models.
I have the following:
import sys, os
sys.path.append('/Users/jx/dev/arc/django/second/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.db import models
from testproject.models... | [
"Django has support for creating custom django-admin commands (documentation).\nVery useful for creating command line scripts that access the model.\n",
"\nMake sure you have added the folder containing testproject folder to sys.path. \nFor example if you have the following structure /foo/bar/testproject/models.p... | [
6,
2,
1
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0006147526_django_django_models_python.txt |
Q:
Cant open file with associated app
I created an app. I have some files which I need to open with this app. So I made the association with the commands below:
assoc .bengi=BengiFile
ftype BengiFile="C:\Program Files (x86)\Bengi\CreateAS.exe" "%1" %*
After these, I can see that my file's icon has changed according... | Cant open file with associated app | I created an app. I have some files which I need to open with this app. So I made the association with the commands below:
assoc .bengi=BengiFile
ftype BengiFile="C:\Program Files (x86)\Bengi\CreateAS.exe" "%1" %*
After these, I can see that my file's icon has changed according to my app's icon. But when I double-cli... | [
"You need to add code in your application startup (main method) to parse the command line arguments and open the file.\nI suggest reading about this topic here.\nThis would normally look like:\nstatic void Main(string[] args)\n{\n // parse args, do something with them (like open the file specified)\n}\n\n"
] | [
1
] | [] | [] | [
"cmd",
"python",
"windows",
"wxpython"
] | stackoverflow_0006139184_cmd_python_windows_wxpython.txt |
Q:
How to read log files in python in django
I am trying to read the log files or any other file and display in web browser using django and python
I used this code
data_file = open('/var/log/samba', 'r') # note -- 'r' not r
data = data_file.readlines() # returns a list of lines
I get this error
[Errno 21] I... | How to read log files in python in django | I am trying to read the log files or any other file and display in web browser using django and python
I used this code
data_file = open('/var/log/samba', 'r') # note -- 'r' not r
data = data_file.readlines() # returns a list of lines
I get this error
[Errno 21] Is a directory: '/var/log/samba'
| [
"You're trying to open a directory. Don't do that. Open a file instead.\n"
] | [
2
] | [] | [] | [
"django",
"linux",
"python"
] | stackoverflow_0006148322_django_linux_python.txt |
Q:
Efficiently generate a lattice of points in python
Help make my code faster: My python code needs to generate a 2D lattice of points that fall inside a bounding rectangle. I kludged together some code (shown below) that generates this lattice. However, this function is called many many times and has become a serio... | Efficiently generate a lattice of points in python | Help make my code faster: My python code needs to generate a 2D lattice of points that fall inside a bounding rectangle. I kludged together some code (shown below) that generates this lattice. However, this function is called many many times and has become a serious bottleneck in my application.
I'm sure there's a fast... | [
"Since lower_bounds and upper_bounds are only 2-element arrays, numpy might not be the right choice here. Try to replace\nif all(lower_bounds < lp) and all(lp < upper_bounds):\n\nwith basic Python stuff:\nif lower1 < lp and lower2 < lp and lp < upper1 and lp < upper2:\n\nAccording to timeit, the second approach is ... | [
6,
5,
3,
1
] | [] | [] | [
"matplotlib",
"numpy",
"optimization",
"python",
"scipy"
] | stackoverflow_0006141955_matplotlib_numpy_optimization_python_scipy.txt |
Q:
How to use wordnet to find semantic relation between two web pages?
I want some way to determine whether two web pages are semantically related.I googled and found something called as the WordNet (a large lexical database). I want to know that how can I accomplish this using python and WordNet?
A:
The easiest a... | How to use wordnet to find semantic relation between two web pages? | I want some way to determine whether two web pages are semantically related.I googled and found something called as the WordNet (a large lexical database). I want to know that how can I accomplish this using python and WordNet?
| [
"The easiest and crudest way to do this would be:\n\nextract top N terms (keywords) from each page (could be as simple as top N terms by frequency, excluding stop words such as 'a, the, an' in English). This will give you a feature set for each page.\nCompare top terms between pages for overlaps. You could use Word... | [
4,
1
] | [] | [] | [
"nlp",
"python",
"wordnet"
] | stackoverflow_0006148817_nlp_python_wordnet.txt |
Q:
How to give path while saving images using PIL in Django
I'm having trouble figuring what path definition to give while saving my files - absolute system path or relative path to my static files directory
My minimized photo model -
class Photos(models.Model):
photo = models.ImageField(upload_to=get_photo_storag... | How to give path while saving images using PIL in Django | I'm having trouble figuring what path definition to give while saving my files - absolute system path or relative path to my static files directory
My minimized photo model -
class Photos(models.Model):
photo = models.ImageField(upload_to=get_photo_storage_path)
MY thumbnail model -
class PhotosThumbnails(models.... | [
"I always save with an absolute system path.\nim.save('/var/www/_uploads/myphoto.jpg', 'JPEG')\n\nSince you're in Django, you may also want to do this:\nim.save(settings.UPLOAD_DIRECTORY + 'myphoto.jpg', 'JPEG')\n\n"
] | [
7
] | [] | [] | [
"django",
"python",
"python_imaging_library"
] | stackoverflow_0006149054_django_python_python_imaging_library.txt |
Q:
Python string slice
How can i slice a string comparing with my list.
string = "how to dye my brunet hair to blonde? "
list = ['how', 'how to',...]
I want the code to remove "how to" and print the rest.
dye my brunet hair to blonde?
Any idea?
A:
In [1]: s = "how to dye my brunet hair to blonde? "
In [2]: prin... | Python string slice | How can i slice a string comparing with my list.
string = "how to dye my brunet hair to blonde? "
list = ['how', 'how to',...]
I want the code to remove "how to" and print the rest.
dye my brunet hair to blonde?
Any idea?
| [
"In [1]: s = \"how to dye my brunet hair to blonde? \"\n\nIn [2]: print s.replace(\"how to\", \"\")\n dye my brunet hair to blonde? \n\nWhen used this way, replace will replace all occurrences of its first argument with the second argument. It also takes an optional third argument, which would limit the number of r... | [
6,
3,
2,
1
] | [] | [] | [
"python",
"slice",
"string"
] | stackoverflow_0006149113_python_slice_string.txt |
Q:
Python: Using variables in Pylab Titles
I have variables N and W which change with each run. Is it possible to do something like the following?:
pylab.title('Minimal Energy Configuration of' N 'Charges on Disc' 'W = 'W)
A:
I think your talking about string interpolation like this :
pylab.title('Minimal Energy C... | Python: Using variables in Pylab Titles | I have variables N and W which change with each run. Is it possible to do something like the following?:
pylab.title('Minimal Energy Configuration of' N 'Charges on Disc' 'W = 'W)
| [
"I think your talking about string interpolation like this : \npylab.title('Minimal Energy Configuration of %s Charges on Disc W = %s'%(N, W))\n\n"
] | [
22
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0006147387_matplotlib_python.txt |
Q:
Queryset filtering using an array of GenericForeignKey objects
Here's the problem.
I have a table that contains records which associate a user with an object that is defined by a GenericForeignKey
I can obtain a list of these objects as such:
association_objects = Association.objects.filter(user = request.user)
T... | Queryset filtering using an array of GenericForeignKey objects | Here's the problem.
I have a table that contains records which associate a user with an object that is defined by a GenericForeignKey
I can obtain a list of these objects as such:
association_objects = Association.objects.filter(user = request.user)
This will return an array of objects, and I can access the associated... | [
"from django.contrib.contenttypes.models import ContentType\n\nct = ContentType.objects.get_for_model(Action)\naction_ids = association_objects.values_list(\"object_id\", flat=True)\\\n .filter(content_type=ct)\nactions = Action.objects.filter(pk__in=action_ids)\n\n(assuming your Gene... | [
2
] | [
"Try this:\n# I assume that association_objects is a QuerySet\nassociation_ids = association_objects.value_list(\"id\", flat=True)\ncontent_type = ContentType.objects.get_for_model(Association)\nactions = Action.objects.filter(content_type=content_type,\n object_id__in=association_ids... | [
-1
] | [
"django",
"orm",
"python"
] | stackoverflow_0006147152_django_orm_python.txt |
Q:
transforming the same character into different characters depending on position in word
I thank coffee-grinder very much for asking a question for me a few hours ago. Now that I am a member, I'd like to rephrase the question a bit.
What is the best way to state that a word-initial 's' transforms into a '$' and the... | transforming the same character into different characters depending on position in word | I thank coffee-grinder very much for asking a question for me a few hours ago. Now that I am a member, I'd like to rephrase the question a bit.
What is the best way to state that a word-initial 's' transforms into a '$' and the remainder of the 's' transforms into a '5' using regular expressions and python?
I attempted... | [
"You're just not being specific enough. You need a non-zero lookbehind assertion on the first one.\n>>> text = 'sassy'\n>>> for (regexp,subst) in [ (r'(?<=.)s', '5'),(r'^s', '$') ]:\n... text = re.sub(regexp,subst,text)\n... \n>>> text\n'$a55y'\n\nThat, or change the order.\nAll bets are out when one of your subs... | [
2
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006149464_python_regex.txt |
Q:
How to keep static resource in memory in python web app?
I implemented a python web app, which generates images dynamically using small pieces of images.
Each time when user visit the page, a script runs and all small images are loaded from disc to generate big image.
I think loading small images from disc is qui... | How to keep static resource in memory in python web app? | I implemented a python web app, which generates images dynamically using small pieces of images.
Each time when user visit the page, a script runs and all small images are loaded from disc to generate big image.
I think loading small images from disc is quite a big overhead. Is it possible to load all small images onc... | [
"The images will be most likely cached by the system virtual memory unless you are running out of memory.\nIn any case, it's common practice to always run webapps behind a fast webserver and let the webserver serve static images.\nThe webapp could simply send the img tags to the browser, than the browser would load... | [
2,
1
] | [] | [] | [
"image",
"python",
"resources",
"web_applications"
] | stackoverflow_0006149611_image_python_resources_web_applications.txt |
Q:
Can i access different database in django than other default database
I have the database backup script in python which inserts some data in mysql database .
Now my Django is in different database.
How can i access different database because i don't have any objects in Models.py.
i want to display some data in dj... | Can i access different database in django than other default database | I have the database backup script in python which inserts some data in mysql database .
Now my Django is in different database.
How can i access different database because i don't have any objects in Models.py.
i want to display some data in django interface
| [
"Yes, you can setup multiple database and access every one of them.\nyou can get the specified database connection cursor using this:\nfrom django.db import connections\ncursor = connections['my_db_alias'].cursor()\n\nwhere my_db_alias is your another db alias .\ncheck the doc:\nhttps://docs.djangoproject.com/en/1.... | [
9
] | [] | [] | [
"database",
"django",
"python"
] | stackoverflow_0006149853_database_django_python.txt |
Q:
Python C API: why doesn't PyRun_String evaluate simple conditional expressions?
PyRun_String("if True: 1\nelse: 0", Py_eval_input, globals, globals);
returns error with PyErr_Print() printing out:
File "<string>", line 1
if True: 1
^
What am I doing wrong?
Thank you.
A:
That isn't a conditional expression... | Python C API: why doesn't PyRun_String evaluate simple conditional expressions? | PyRun_String("if True: 1\nelse: 0", Py_eval_input, globals, globals);
returns error with PyErr_Print() printing out:
File "<string>", line 1
if True: 1
^
What am I doing wrong?
Thank you.
| [
"That isn't a conditional expression: it's a statement. Py_eval_input means to treat the string as a single expression. You probably want Py_single_input to treat the string as a statement.\nThis is the same as the distinction in Python code between eval (which is what you asked for) and exec.\nI am assuming of cou... | [
4,
0
] | [] | [] | [
"python",
"python_c_api"
] | stackoverflow_0006149807_python_python_c_api.txt |
Q:
Is it possible to use collective.alias in a 3.1.7 plone?
Is it possible? I would like to install it in a 3.1.7 Plone instance, but don't want to enter the buildout incompatible versions hell.
I tried in my machine, adding along with collective.alias
extends =
http://good-py.appspot.com/release/dexterity/1.0a2
... | Is it possible to use collective.alias in a 3.1.7 plone? | Is it possible? I would like to install it in a 3.1.7 Plone instance, but don't want to enter the buildout incompatible versions hell.
I tried in my machine, adding along with collective.alias
extends =
http://good-py.appspot.com/release/dexterity/1.0a2
and
[versions]
plone.recipe.plone = 3.1.7
plone.recipe.zope... | [
"collective.alias depends on dexterity. Dexterity is not fully supported on plone3. And I guess you will need to upgrade to 3.3. \nDexterity needs Plone4.1 to play well with archetypes content and have all plone feature (history, diff, lock, ...)\ntry this:\nextends=\nhttp://good-py.appspot.com/release/dexterity/1... | [
1
] | [] | [] | [
"buildout",
"plone",
"python"
] | stackoverflow_0006129074_buildout_plone_python.txt |
Q:
python number length validator
I am trying to write a python script that validates if an input number is the required length,
for example the input number has to be : 1234567890. The script should check that it is indeed 10 digits long. I could not find any examples of this.
The checked number is taken from a fi... | python number length validator | I am trying to write a python script that validates if an input number is the required length,
for example the input number has to be : 1234567890. The script should check that it is indeed 10 digits long. I could not find any examples of this.
The checked number is taken from a file.
| [
"If it's taken from a file then it's a string.\n>>> len('1234567890') == 10\nTrue\n\n",
"One way to do this is using regular expressions:\nIn [1]: import re\n\nIn [2]: s = '1234567890'\n\nIn [3]: re.match(r'^\\d{10}$', s)\nOut[3]: <_sre.SRE_Match object at 0x184f238>\n\nIn [4]: re.match(r'^\\d{10}$', '99999')\n\n... | [
3,
2,
1,
0
] | [] | [] | [
"python",
"string"
] | stackoverflow_0006149163_python_string.txt |
Q:
Python: How to plot a cdf function given an array of numbers
I am working on Windows. I just want to input an array and get the cdf of the array.
A:
First, you could implement the CDF like this:
from bisect import bisect_left
class discrete_cdf:
def __init__(self, data):
self._data = data # must be ... | Python: How to plot a cdf function given an array of numbers | I am working on Windows. I just want to input an array and get the cdf of the array.
| [
"First, you could implement the CDF like this:\nfrom bisect import bisect_left\n\nclass discrete_cdf:\n def __init__(self, data):\n self._data = data # must be sorted\n self._data_len = float(len(data))\n\n def __call__(self, point):\n return (len(self._data[:bisect_left(self._data, point... | [
5,
2
] | [] | [] | [
"python"
] | stackoverflow_0006149838_python.txt |
Q:
Django ManyToMany Inlines Ordering in 1.2.x
I'm using Django 1.2's new ManyToMany admin.TabularInline to display related objects in the admin app, and it works great except I can't figure out what to set the "ordering" property to so it can sort by one of the cross-referenced field names.
For instance:
class Foo(m... | Django ManyToMany Inlines Ordering in 1.2.x | I'm using Django 1.2's new ManyToMany admin.TabularInline to display related objects in the admin app, and it works great except I can't figure out what to set the "ordering" property to so it can sort by one of the cross-referenced field names.
For instance:
class Foo(models.Model):
name = models.CharField(max_len... | [
"The model ordering meta option designates the order of the inline elements. \nclass Foo(models.Model):\n name = models.CharField(max_length=100)\n\n class Meta:\n ordering = ('name',)\n\nIf you needed to have the ordering of the admin model different from your primary ordering, you could do something... | [
2,
0
] | [] | [] | [
"django",
"inlines",
"modeladmin",
"python"
] | stackoverflow_0004167195_django_inlines_modeladmin_python.txt |
Q:
Coming from C, how should I learn Python?
I've got a good grasp on C, my first programming language. I know a reasonable number of tricks and techniques and have written quite a few programs, mostly for scientific stuff. Now I'd like to branch out and understand OOP, and Python seems like a good direction to go.
I... | Coming from C, how should I learn Python? | I've got a good grasp on C, my first programming language. I know a reasonable number of tricks and techniques and have written quite a few programs, mostly for scientific stuff. Now I'd like to branch out and understand OOP, and Python seems like a good direction to go.
I've seen several questions on how to learn Pyth... | [
"I knew C before I knew Python. No offence intended, but I don't think that your C knowledge is that big a deal. Unless you read very, very slowly, just set out to learn Python. It won't take that long to skim through the material you're familiar with, and it's not as if a Python tutorial aimed at C programmers wil... | [
31,
15,
9,
4,
1,
1,
1
] | [] | [] | [
"c",
"python"
] | stackoverflow_0003516560_c_python.txt |
Q:
How to loading/show a picture in a Python CGI page
I have written a little survey using Python and CGI. I am trying to show a picture using the normal <img> tag, But even-though the picture is in the same directory as my cgi script, my script cannot show it. I also changed the header to this:
print "Content-type... | How to loading/show a picture in a Python CGI page | I have written a little survey using Python and CGI. I am trying to show a picture using the normal <img> tag, But even-though the picture is in the same directory as my cgi script, my script cannot show it. I also changed the header to this:
print "Content-type: text/html; image/jpeg"
print
print """<html>
<head>
<... | [
"print \"Content-type: text/html; image/jpeg\"\n\nDon't change the header to that. You can't have multiple content types for a single document (multipart documents excluded, but browsers don't support them and that isn't the right format).\nYou are delivering an HTML document with an reference to an image in it. Th... | [
2,
1
] | [] | [] | [
"cgi",
"html",
"python"
] | stackoverflow_0006149681_cgi_html_python.txt |
Q:
making HTTP authentication optional with mod-python
I've a web application that accesses multiple controller classes based on the parameters it is passed. For some of the controllers, I want users to authenticate themselves (by simple HTTP authentication), and for some I want public access.
Is there a way to make ... | making HTTP authentication optional with mod-python | I've a web application that accesses multiple controller classes based on the parameters it is passed. For some of the controllers, I want users to authenticate themselves (by simple HTTP authentication), and for some I want public access.
Is there a way to make this happen? In my .htaccess file, I now have
AddHandler ... | [
"There are a couple ways to specify authentication scope with Apache, the one most people are used to is gt;Directorylt; based - i.e. anything in or below a directory gets authenticated against htpasswd.\nThere's also gt;Locationlt;, which applies directives to content that live outside the filesystem such as mod_p... | [
1
] | [] | [] | [
"apache",
"authentication",
"mod_python",
"python"
] | stackoverflow_0001471602_apache_authentication_mod_python_python.txt |
Q:
Orbited launch problems: " ConfigParser.NoSectionError: No section: 'formatters' "
I'm trying to get Orbited started, but unfortunately I'm running into more than a few problems! First, problems with easy_install (solved). Then, proceeded on with instructions from http://mischneider.net/?p=125. But when using o... | Orbited launch problems: " ConfigParser.NoSectionError: No section: 'formatters' " | I'm trying to get Orbited started, but unfortunately I'm running into more than a few problems! First, problems with easy_install (solved). Then, proceeded on with instructions from http://mischneider.net/?p=125. But when using orbited -c orbited.cnf I get the following:
Traceback (most recent call last):
File "C:... | [
"There is a sample config file in the tar file.\nYou can find it online at https://bitbucket.org/desmaj/orbited/src/1a8a47861f1d/daemon/orbited.cfg.example\njust copy everything from the [loggers] section onwards.\nset relevant level=DEBUG wherever you want more debug information\n-- sid\n",
"Just in case anyone ... | [
7,
3
] | [] | [] | [
"comet",
"django",
"orbited",
"python",
"stomp"
] | stackoverflow_0006139342_comet_django_orbited_python_stomp.txt |
Q:
Python, working with list comprehensions
I have such code:
a = [[1, 1], [2, 1], [3, 0]]
I want to get two lists, the first contains elements of 'a', where a[][1] = 1, and the second - elements where a[][1] = 0. So
first_list = [[1, 1], [2, 1]]
second_list = [[3, 0]].
I can do such thing with two list compreh... | Python, working with list comprehensions | I have such code:
a = [[1, 1], [2, 1], [3, 0]]
I want to get two lists, the first contains elements of 'a', where a[][1] = 1, and the second - elements where a[][1] = 0. So
first_list = [[1, 1], [2, 1]]
second_list = [[3, 0]].
I can do such thing with two list comprehension:
first_list = [i for i in a if i[1] == ... | [
"List comprehension are very pythonic and the recommended way of doing this. Your code is fine.\n",
"If you want to have it in a single line you could do something like\nfirst_list, second_list = [i for i in a if i[1] == 1], [i for i in a if i[1] == 0]\n\nRemember that, \"Explicit is better than implicit.\"\nYour... | [
7,
3,
2,
0,
0,
0
] | [] | [] | [
"list",
"list_comprehension",
"python"
] | stackoverflow_0006149370_list_list_comprehension_python.txt |
Q:
Read numeric arrays from text file without delimiters
I am trying to read some numeric data from a text file but am struggling to read numbers stored without any deliminators. The file format itself is a fairly standard format used in numerous codes around the world and so cannot be changed. The following is a sni... | Read numeric arrays from text file without delimiters | I am trying to read some numeric data from a text file but am struggling to read numbers stored without any deliminators. The file format itself is a fairly standard format used in numerous codes around the world and so cannot be changed. The following is a snippet of the head of an example file:
SOME TEXT OF A FIXED L... | [
"\nThe arrays themselves are stored as a\n list of numbers of fixed width.\n\nSince each entry is exactly sixteen characters in width, the following will convert one line of your input file into an list of floats:\nIn [1]: line = '-5.487648393E-01-5.476736110E-01-5.447693831E-01-5.405765060E-01-5.353610408E-01'\n\... | [
3,
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0006150411_python.txt |
Q:
Python C API: How to get PyRun_String with Py_eval_input to use imported modules?
PyRun_String("random.randint(1,10)", Py_eval_input, globals, globals);
returns error with:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'random' is not defined
earlier in the code, I did... | Python C API: How to get PyRun_String with Py_eval_input to use imported modules? | PyRun_String("random.randint(1,10)", Py_eval_input, globals, globals);
returns error with:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'random' is not defined
earlier in the code, I did:
PyImport_ImportModule("random");
I guess this is not the way to get it work. What ... | [
"PyImport_ImportModule returns the imported value. You need to save it in globals under the name random. In summary:\nPyMapping_SetItemString(globals, \"random\", PyImport_ImportModule(\"random\"));\n\nbut don't forget to also check the result of the import in case it throws an exception.\n"
] | [
3
] | [] | [] | [
"python",
"python_c_api"
] | stackoverflow_0006150835_python_python_c_api.txt |
Q:
Grouping multiple variables and counting number of unique combinations
Using Python, I'm trying to print out a table, with collated information based on a set of data like this.
Data 1 - 'Car', 'Cadillac','Blue'
Data 2 - 'Car', 'Aston Martin','Black'
Data 3 - 'Car', 'Cadillac', 'Blue'
Now I need to find the numb... | Grouping multiple variables and counting number of unique combinations | Using Python, I'm trying to print out a table, with collated information based on a set of data like this.
Data 1 - 'Car', 'Cadillac','Blue'
Data 2 - 'Car', 'Aston Martin','Black'
Data 3 - 'Car', 'Cadillac', 'Blue'
Now I need to find the number of times the same combination occurs - i.e. I would like to print that th... | [
"First tuple the string and put it all in a list; then use count\n>>> list\n[('Car', 'Cadillac','Blue'), ('Car', 'Aston Martin','Black'), ('Car', 'Cadillac', 'Blue'), ...]\n>>> list.count(('Car', 'Cadillac', 'Blue'))\n1\n\n",
">>> from collections import Counter\n>>> Counter(['apple','red','apple','red','red','pe... | [
2,
1,
0,
0,
0
] | [] | [] | [
"python",
"string",
"variables"
] | stackoverflow_0006150983_python_string_variables.txt |
Q:
Python - Multiple frames with Grid manager
I'm trying to use the functionality from the Tkinter module (Python 2.7) to create a GUI that has eight widgets placed on a 7 row by 5 column grid (sorry that I did not include an image; the dialog box is not allowing me to browse and upload the saved image).
(Widget, st... | Python - Multiple frames with Grid manager | I'm trying to use the functionality from the Tkinter module (Python 2.7) to create a GUI that has eight widgets placed on a 7 row by 5 column grid (sorry that I did not include an image; the dialog box is not allowing me to browse and upload the saved image).
(Widget, start_row, start_col, row_span, column_span):
("B... | [
"After messing around with my code for a few hours, I was finally able to create the GUI that I intended to. The key was looping over rows and columns and setting their weights using rowconfigure and columnconfigure, respectively. Code is below:\nfrom tkinter import *\n\nclass Application(Frame):\n def __init_... | [
22,
4,
1
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0006129899_python_tkinter.txt |
Q:
Update in transaction SQLite3 and Python
I update rows in user table (sqlite3 and Python) with
def update_user_by_id(self,id,first_name,last_name,username,password,privilege,email):
'''Update user in table user based on id on passed parameters'''
try:
connection=sqlite3.connect(self.__path_users)
... | Update in transaction SQLite3 and Python | I update rows in user table (sqlite3 and Python) with
def update_user_by_id(self,id,first_name,last_name,username,password,privilege,email):
'''Update user in table user based on id on passed parameters'''
try:
connection=sqlite3.connect(self.__path_users)
cursor=connection.cursor()
cur... | [
"This is already a transaction. The transaction is commited when you call connection.commit(). If you would like to roll it back just remove that line.\n"
] | [
1
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0006151266_python_sqlite.txt |
Q:
Why pass string that represents an object instead passing the object?
Code below is from Django's settings.py. Since everything in Python is an object, why don't just pass installed apps as tuple of objects:
INSTALLED_APPS = (
django.contrib.auth,
django.contrib.contenttypes,
.....
Is there some strong reason... | Why pass string that represents an object instead passing the object? | Code below is from Django's settings.py. Since everything in Python is an object, why don't just pass installed apps as tuple of objects:
INSTALLED_APPS = (
django.contrib.auth,
django.contrib.contenttypes,
.....
Is there some strong reason why they do this:
INSTALLED_APPS = (
'django.contrib.auth',
'django.co... | [
"Passing module or class name as a string is typical solution to avoiding circular import error.\nFor example, if settings file contains import myapp.models and myapp.models contains from django.conf import settings this would lead to circular import.\n",
"You'd have to import django and so first to make it work,... | [
6,
1
] | [] | [] | [
"django",
"object",
"python"
] | stackoverflow_0006151400_django_object_python.txt |
Q:
Storing a string from a textbox to the Google App Engine Datastore
Is it possible to create a textbox in HTML, type a string into it, click a "save" button, store that information onto a GAE datastore model and have the text stay displayed in the textbox and saved in the datastore?
The HTML is on a separate file, ... | Storing a string from a textbox to the Google App Engine Datastore | Is it possible to create a textbox in HTML, type a string into it, click a "save" button, store that information onto a GAE datastore model and have the text stay displayed in the textbox and saved in the datastore?
The HTML is on a separate file, just rendered through my main.py file using
class MainPage(webapp.Reque... | [
"I think this will help, i have modified default guestbook app for you. Usual way of doing is having html files separately and using templates to render it. Here everything is just embedded into the controller itself \nimport cgi\n\nfrom google.appengine.api import users\nfrom google.appengine.ext import webapp\nf... | [
3,
2
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"python"
] | stackoverflow_0006133505_google_app_engine_google_cloud_datastore_python.txt |
Q:
How to use Google App Engine's Blobstore to save web images
UPDATE
This question was originally asked at a time when there was no support for programmatic file creation (via url for example). That has changed, see: http://code.google.com/appengine/docs/java/blobstore/overview.html#Writing_Files_to_the_Blobstore
I... | How to use Google App Engine's Blobstore to save web images | UPDATE
This question was originally asked at a time when there was no support for programmatic file creation (via url for example). That has changed, see: http://code.google.com/appengine/docs/java/blobstore/overview.html#Writing_Files_to_the_Blobstore
I'm accessing a couple different APIs to fetch images. My applica... | [
"HTTP POST to your own form works. I didn't try submitting a file, but here's how I submit a form. You can get the file from the internet, add it to the form submission and the file will store in your blobstore.\nimport urllib\ndata = urllib.urlencode({\"id\":str(id), \"password\" : self.request.POST['passwd'], \"e... | [
2,
2,
0
] | [] | [] | [
"blobstore",
"google_app_engine",
"python"
] | stackoverflow_0004564619_blobstore_google_app_engine_python.txt |
Q:
How to get last inserted id in Postgresql with OpenERP
I have a insert query and I want to get last inserted id in OpenERP. Here is the code:
query = "INSERT INTO foo SELECT * FROM bar"
cr.execute(query) # cr => cursor
How to get last inserted id(s)? What happened when insertion is empty?
A:
Look at the RETURNI... | How to get last inserted id in Postgresql with OpenERP | I have a insert query and I want to get last inserted id in OpenERP. Here is the code:
query = "INSERT INTO foo SELECT * FROM bar"
cr.execute(query) # cr => cursor
How to get last inserted id(s)? What happened when insertion is empty?
| [
"Look at the RETURNING clause.\nINSERT INTO table [ ( column [, ...] ) ]\n { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query }\n [ RETURNING * | output_expression [ AS output_name ] [, ...] ]\n\n\nInsert a single row into table distributors, returning the sequence number generated... | [
7,
1,
1,
0
] | [] | [] | [
"openerp",
"postgresql",
"python"
] | stackoverflow_0005853948_openerp_postgresql_python.txt |
Q:
How to draw non-transparent text on an icon (not bitmap) using wxpython?
Short question:
I know how to draw text on a wx.Bitmap, but how can I draw text on a wx.Icon in wxpython so that it does not appear transparent?
Long question:
I have a wxpython based GUI application, that has a taskbar icon, which I set usi... | How to draw non-transparent text on an icon (not bitmap) using wxpython? | Short question:
I know how to draw text on a wx.Bitmap, but how can I draw text on a wx.Icon in wxpython so that it does not appear transparent?
Long question:
I have a wxpython based GUI application, that has a taskbar icon, which I set using mytaskbaricon.SetIcon("myicon.ico").
Now I would like to dynamically put s... | [
"Short answer: It seems to me that there is a bug in this particular piece of wx code. I am going to report it and see what comes out of it.\nLong answer: You can hack your way around. Setup a color, which is not used in the image. Then draw using that color and when done, fix alpha values and color of those pixels... | [
1,
0
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0006108888_python_wxpython.txt |
Q:
Scrapy - no list page, but I know the url for each item page
I'm using Scrapy to scrape a website. The item page that I want to scrape looks like: http://www.somepage.com/itempage/&page=x. Where x is any number from 1 to 100. Thus, I have an SgmlLinkExractor Rule with a callback function specified for any page res... | Scrapy - no list page, but I know the url for each item page | I'm using Scrapy to scrape a website. The item page that I want to scrape looks like: http://www.somepage.com/itempage/&page=x. Where x is any number from 1 to 100. Thus, I have an SgmlLinkExractor Rule with a callback function specified for any page resembling this.
The website does not have a listpage with all the it... | [
"You could list all the known URLs in your Spider class' start_urls attribute:\nclass SomepageSpider(BaseSpider):\n name = 'somepage.com'\n allowed_domains = ['somepage.com']\n start_urls = ['http://www.somepage.com/itempage/&page=%s' % page for page in xrange(1, 101)]\n\n def parse(self, response):\n ... | [
6,
1
] | [] | [] | [
"python",
"scrapy"
] | stackoverflow_0006022450_python_scrapy.txt |
Q:
Model fields not updated
I wanted to add facebook feed to my website (only the first latest wall message). So I have created the model :
class FacebookFeed(models.Model):
checked = models.DateTimeField(name="Time Checked", auto_now_add=True)
message = models.TextField(name="Message", null=True)
author ... | Model fields not updated | I wanted to add facebook feed to my website (only the first latest wall message). So I have created the model :
class FacebookFeed(models.Model):
checked = models.DateTimeField(name="Time Checked", auto_now_add=True)
message = models.TextField(name="Message", null=True)
author = models.CharField(name="Autho... | [
"def save(self, *args, **kwargs):\n queryset = FacebookFeed.objects.all()\n if(queryset):\n return\n else:\n #super(FacebookFeed, self).save()\n super(FacebookFeed, self).save(*args, **kwargs)\n\ni think if(queryset) is always True if it contains records or not... | [
0
] | [] | [] | [
"django",
"django_models",
"facebook",
"json",
"python"
] | stackoverflow_0006152129_django_django_models_facebook_json_python.txt |
Q:
jquery autocomplete-ui not working with remote data
i spend two days on this plugin, and no success - works only on local data array :(
i have a code (django/python) that generate json string ( valid - tested on http://jsonlint.com/ ) something like this:
[{"id": 7626, "value": "Jaros\u0142aw", "label": "Adrianow... | jquery autocomplete-ui not working with remote data | i spend two days on this plugin, and no success - works only on local data array :(
i have a code (django/python) that generate json string ( valid - tested on http://jsonlint.com/ ) something like this:
[{"id": 7626, "value": "Jaros\u0142aw", "label": "Adrianowicz"}, {"id": 2702, "value": "Bo\u017cena", "label": "Bar... | [
"You can use any .ajax options inside autocomplete. Try this \n$('#query').autocomplete({\n source: \"/aut/\", //this generate json and working\n dataType: \"json\",\n minLength: 2\n });\n\n",
"For the value of source, you can use a callback rather than the url of the page, as in this example:\nhttp://jqueryui.... | [
0,
0
] | [] | [] | [
"django",
"jquery_ui_autocomplete",
"python"
] | stackoverflow_0006151236_django_jquery_ui_autocomplete_python.txt |
Q:
printing key presses to the screen instantly with python
I know this question is long but what I really want to know is in bold.
I would prefer to use python on Linux.
I'm trying to make a new keyboard layout kind of like devorak but the layout is set to either layout1 or layout2 depending on if you are holding a ... | printing key presses to the screen instantly with python | I know this question is long but what I really want to know is in bold.
I would prefer to use python on Linux.
I'm trying to make a new keyboard layout kind of like devorak but the layout is set to either layout1 or layout2 depending on if you are holding a hot key or not (the hot key should probably be ctrl?)
e.g. pre... | [
"If it's ok to depends on the X window system, you can use the python-xlib module or the xpyb module to access the X window system and use a XGrabKey call to grab the keyboard related events. Upon each KeyPress event you will be able to print the pressed key.\nNow, if you really want to write a keymap, this is tota... | [
3,
1
] | [] | [] | [
"keyboard",
"keypress",
"python"
] | stackoverflow_0006151966_keyboard_keypress_python.txt |
Q:
RestructuredText - Hyperlinks without leading and trailing spaces
Is it possible to create hyperlinks without leading and trailing spaces? The following doesn't work:
re`Structured`_Text
.. _`Structured`: http://docutils.sourceforge.net/docs/user/rst/quickstart.html
The reason I'm asking is I'm working with Chi... | RestructuredText - Hyperlinks without leading and trailing spaces | Is it possible to create hyperlinks without leading and trailing spaces? The following doesn't work:
re`Structured`_Text
.. _`Structured`: http://docutils.sourceforge.net/docs/user/rst/quickstart.html
The reason I'm asking is I'm working with Chinese text. Spaces are not used as word delimiters in Chinese. With the ... | [
"Eventually this is how I get away with this problem. Awkward, but works:\n没有\\ 空格_\\就对了。\n我觉得\\ `中文和 RST`_\\不够兼容。\n\n.. _空格: http://a-link-with-pure-zh-te.xt\n.. _`中文和 RST`: http://a-link-with-mixed-zh-and.en\n\nUpdate: Since docutils 0.13 we can enable character level inline markup. This way we can write like bel... | [
6
] | [] | [] | [
"python",
"restructuredtext",
"spacing"
] | stackoverflow_0006086756_python_restructuredtext_spacing.txt |
Q:
What did Apple do to the Python framework?
[tl;dr? see bottom]
Python on OS X has always been somewhat of an abomination in that it's split up and spread out all across the system. Some in /usr, some in /Library/Python, some /System/Library/Frameworks/Python.framework.
Now, as I understand it, the framework is sup... | What did Apple do to the Python framework? | [tl;dr? see bottom]
Python on OS X has always been somewhat of an abomination in that it's split up and spread out all across the system. Some in /usr, some in /Library/Python, some /System/Library/Frameworks/Python.framework.
Now, as I understand it, the framework is supposed to contain the Python distribution, i.e. t... | [
"Python.h and other headers are included with Xcode. On my system, it's located in both /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h and /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h. The latter appears to be ... | [
6,
3,
1
] | [] | [] | [
"macos",
"python"
] | stackoverflow_0006151548_macos_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.