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:
More pythonic way to iterate
I am using a module that is part of a commercial software API. The good news is there is a python module - the bad news is that its pretty unpythonic.
To iterate over rows, the follwoing syntax is used:
cursor = gp.getcursor(table)
row = cursor.next()
while row:
#do something w... | More pythonic way to iterate | I am using a module that is part of a commercial software API. The good news is there is a python module - the bad news is that its pretty unpythonic.
To iterate over rows, the follwoing syntax is used:
cursor = gp.getcursor(table)
row = cursor.next()
while row:
#do something with row
row = cursor.next()
W... | [
"Assuming that one of Next and next is a typo and they're both the same, you can use the not-so-well-known variant of the built-in iter function:\nfor row in iter(cursor.next, None):\n <do something>\n\n",
"You could create a custom wrapper like:\nclass Table(object):\n def __init__(self, gp, table):\n ... | [
11,
2,
1
] | [] | [] | [
"iterator",
"python",
"refactoring"
] | stackoverflow_0002980031_iterator_python_refactoring.txt |
Q:
Django: saving pickled object
i have a large dictionary I'd like to save. I have pickled it using cPickle.dumps and saved the result into a TextField. When trying to retrieve it (cPicle.loads) i get the following error:
loads() argument 1 must be string, not unicode
Does anybody have any experience in serializing... | Django: saving pickled object | i have a large dictionary I'd like to save. I have pickled it using cPickle.dumps and saved the result into a TextField. When trying to retrieve it (cPicle.loads) i get the following error:
loads() argument 1 must be string, not unicode
Does anybody have any experience in serializing python objects and storing them in... | [
"The best advice you're probably going to get is to use json rather than pickle not only for security reasons, but also because it's simply a string which can easily be read and modified if necessary.\nedit: in response to the actual problem you're having -\npickle.loads(str(textfield))\n\n"
] | [
8
] | [] | [] | [
"django",
"python"
] | stackoverflow_0002980092_django_python.txt |
Q:
Efficient way to access a mapping of identifiers in Python
I am writing an app to do a file conversion and part of that is replacing old account numbers with a new account numbers.
Right now I have a CSV file mapping the old and new account numbers with around 30K records. I read this in and store it as dict and w... | Efficient way to access a mapping of identifiers in Python | I am writing an app to do a file conversion and part of that is replacing old account numbers with a new account numbers.
Right now I have a CSV file mapping the old and new account numbers with around 30K records. I read this in and store it as dict and when writing the new file grab the new account from the dict by k... | [
"As long as they will all fit in memory, a dict will be the most efficient solution. It's also a lot easier to code. 100k records should be no problem on a modern computer.\nYou are right that switching to an SQLite database is a good choice when the number of records gets very large.\n"
] | [
1
] | [] | [] | [
"csv",
"database",
"dictionary",
"python",
"sqlite"
] | stackoverflow_0002980257_csv_database_dictionary_python_sqlite.txt |
Q:
Python dictionary key missing
I thought I'd put together a quick script to consolidate the CSS rules I have distributed across multiple CSS files, then I can minify it.
I'm new to Python but figured this would be a good exercise to try a new language. My main loop isn't parsing the CSS as I thought it would.
I pop... | Python dictionary key missing | I thought I'd put together a quick script to consolidate the CSS rules I have distributed across multiple CSS files, then I can minify it.
I'm new to Python but figured this would be a good exercise to try a new language. My main loop isn't parsing the CSS as I thought it would.
I populate a list with selectors parsed ... | [
"Change\ndef hasProperty(self, line):\n return True if re.search(\"^\\s?[a-z-]+:[^;]+;\", line) else False\n\nto\ndef hasProperty(self, line):\n return True if re.search(\"^\\s*[a-z-]+:[^;]+;\", line) else False\n\nThe hasProperty was not matching anything because \\s? matches only 0 or 1 whitespace character... | [
3
] | [] | [] | [
"dictionary",
"list",
"parsing",
"python"
] | stackoverflow_0002980375_dictionary_list_parsing_python.txt |
Q:
how to show all method and data when the object not has "__iter__" function in python
i find a way :
(1):the dir(object) is :
a="['__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__doc__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__metaclass__', '__module__', '... | how to show all method and data when the object not has "__iter__" function in python | i find a way :
(1):the dir(object) is :
a="['__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__doc__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__metaclass__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__... | [
"s += str(i)+':'+str(getattr(object, i))\n\n",
"s = ''.join('%s: %s' % (a, getattr(o, a)) for a in dir(o))\n\n\ndir lists all attributes\nthe for ... in creates a generator which returns each attribute name\nthe getattr retrieves the value of the attribute for the object\nthe % interpolates those values into a st... | [
2,
2
] | [] | [] | [
"dir",
"methods",
"python",
"show"
] | stackoverflow_0002979856_dir_methods_python_show.txt |
Q:
Change|Assign parent for the Model instance on Google App Engine Datastore
Is it possible to change or assign new parent to the Model instance that already in datastore? For example I need something like this
task = db.get(db.Key(task_key))
project = db.get(db.Key(project_key))
task.parent = project
task.put()
bu... | Change|Assign parent for the Model instance on Google App Engine Datastore | Is it possible to change or assign new parent to the Model instance that already in datastore? For example I need something like this
task = db.get(db.Key(task_key))
project = db.get(db.Key(project_key))
task.parent = project
task.put()
but it doesn't works this way because task.parent is built-in method. I was thinki... | [
"According to the docs, no:\n\nThe parent of an entity is defined\n when the entity is created, and cannot\n be changed later.\n...\nThe complete key of an entity,\n including the path, the kind and the\n name or numeric ID, is unique and\n specific to that entity. The complete\n key is assigned when the enti... | [
9
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"python",
"transactions"
] | stackoverflow_0002980196_google_app_engine_google_cloud_datastore_python_transactions.txt |
Q:
how to get all 'username' from my model 'MyUser' on google-app-engine
my model is :
class MyUser(db.Model):
username = db.StringProperty()
password = db.StringProperty(default=UNUSABLE_PASSWORD)
email = db.StringProperty()
nickname = db.StringProperty(indexed=False)
and my method which want ... | how to get all 'username' from my model 'MyUser' on google-app-engine | my model is :
class MyUser(db.Model):
username = db.StringProperty()
password = db.StringProperty(default=UNUSABLE_PASSWORD)
email = db.StringProperty()
nickname = db.StringProperty(indexed=False)
and my method which want to get all username is :
s=[]
a=MyUser.all()
for i in a:
s.append(i.user... | [
"Yes, there are many other ways to show all usernames. One is templates:\nusers = MyUser.all()\ntemplate.render('userlist.html', {'users': users})\n\n<ul>\n <% for user in users %>\n <li>{{ user.username }}</li>\n <% endfor %>\n</ul>\n\n"
] | [
0
] | [] | [] | [
"google_app_engine",
"model",
"python"
] | stackoverflow_0002979952_google_app_engine_model_python.txt |
Q:
from string of bytes to OpenCV's IplImage in Python?
I am streaming some data down from a webcam. When I get all of the bytes for a full image (in a string called byteString) I want to display the image using OpenCV. Done fast enough, this will "stream" video from the webcam to an OpenCV window.
Here's what I've d... | from string of bytes to OpenCV's IplImage in Python? | I am streaming some data down from a webcam. When I get all of the bytes for a full image (in a string called byteString) I want to display the image using OpenCV. Done fast enough, this will "stream" video from the webcam to an OpenCV window.
Here's what I've done to set up the window:
cvNamedWindow('name of window', ... | [
"I actually solved this problem and forgot to post the solution. Here's how I did it, though it may not be entirely robust:\nI analyzed the headers coming from the MJPEG of the network camera I was doing this to, then I just read from the stream 1 byte at a time, and, when I detected that the header of the next ima... | [
2,
0
] | [] | [] | [
"byte",
"image",
"opencv",
"python",
"string"
] | stackoverflow_0002970207_byte_image_opencv_python_string.txt |
Q:
python and overflowing byte?
I need to make a variable with similar behaviour like in C lanquage.
I need byte or unsigned char with range 0-255.
This variable should overflow, that means...
myVar = 255
myVar += 1
print myVar #!!myVar = 0!!
A:
I see lots of good answers here. However, if you want to create your ... | python and overflowing byte? | I need to make a variable with similar behaviour like in C lanquage.
I need byte or unsigned char with range 0-255.
This variable should overflow, that means...
myVar = 255
myVar += 1
print myVar #!!myVar = 0!!
| [
"I see lots of good answers here. However, if you want to create your own type as you mentioned, you could look at the Python Data model documentation. It explains how to make classes that have customized behaviours, for example emulating numeric types.\nWith this info, you could make a class like so:\nclass Num:\n... | [
9,
5,
5,
1,
1
] | [] | [] | [
"overflow",
"python",
"variables"
] | stackoverflow_0002980213_overflow_python_variables.txt |
Q:
Crossed import in django
On example, i have 2 apps: alpha and beta
in alpha/models.py import of model from beta.models
and in beta/models.py import of model from alpha.models
manage.py validate says that ImportError: cannot import name ModelName
how to solve this problem?
A:
I have had this issue in the past the... | Crossed import in django | On example, i have 2 apps: alpha and beta
in alpha/models.py import of model from beta.models
and in beta/models.py import of model from alpha.models
manage.py validate says that ImportError: cannot import name ModelName
how to solve this problem?
| [
"I have had this issue in the past there are two models that refer to one another, i.e. using a ForeignKey field. There is a simple way to deal with it, per the Django documentation:\n\nIf you need to create a relationship on a model that has not yet been defined, you can use the name of the model, rather than the ... | [
8
] | [] | [] | [
"django",
"django_models",
"import",
"python"
] | stackoverflow_0002958141_django_django_models_import_python.txt |
Q:
Python/Sqlite program, write as browser app or desktop app?
I am in the planning stages of rewriting an Access db I wrote several years ago in a full fledged program. I have very slight experience coding, but not enough to call myself a programmer by far. I'll definitely be learning as I go, so I'd like to keep ... | Python/Sqlite program, write as browser app or desktop app? | I am in the planning stages of rewriting an Access db I wrote several years ago in a full fledged program. I have very slight experience coding, but not enough to call myself a programmer by far. I'll definitely be learning as I go, so I'd like to keep everything as simple as possible. I've decided on Python and SQL... | [
"Writing a desktop application as a locally-hosted web application isn't typically a good idea. Although it's possible to create great user interfaces with HTML, CSS, and Javascript, it's far easier to create interfaces with conventional GUI frameworks.\nUsing web technologies to create your desktop GUI would intro... | [
5,
4,
3,
3,
1,
1,
1,
0
] | [] | [] | [
"browser",
"python",
"sqlite"
] | stackoverflow_0002924231_browser_python_sqlite.txt |
Q:
Launching browser within CherryPy
I have a html page displayed using...
cherrypy.quickstart(ShowHTML(htmlfile), config=configfile)
Once the page is loaded (eg. initiated via. the command 'python mypage.py'), I would like to automatically launch the browser to display the page (eg. via. http://localhost/8000). Is... | Launching browser within CherryPy | I have a html page displayed using...
cherrypy.quickstart(ShowHTML(htmlfile), config=configfile)
Once the page is loaded (eg. initiated via. the command 'python mypage.py'), I would like to automatically launch the browser to display the page (eg. via. http://localhost/8000). Is there any way I can achieve this (eg. ... | [
"You can either hook your webbrowser into the engine start/stop lifecycle:\ndef browse():\n webbrowser.open(\"http://127.0.0.1:8080\")\ncherrypy.engine.subscribe('start', browse, priority=90)\n\nOr, unpack quickstart:\nfrom cherrypy import config, engine, tree\n\nconfig.update(configfile)\ntree.mount(ShowHTML(ht... | [
4
] | [] | [] | [
"browser",
"cherrypy",
"python"
] | stackoverflow_0002978934_browser_cherrypy_python.txt |
Q:
Rails and Python hosting
I am trying to host some files/rails app in the port 8080 for external access. For Python I am using the SimpleHTTPServer module, and for Rails, webrick.
However, both of them does not work very well. I don't get the response back, and, sometimes, if I get it, it's VERY slow. Nevertheless... | Rails and Python hosting | I am trying to host some files/rails app in the port 8080 for external access. For Python I am using the SimpleHTTPServer module, and for Rails, webrick.
However, both of them does not work very well. I don't get the response back, and, sometimes, if I get it, it's VERY slow. Nevertheless, apache works very well on th... | [
"I can't speak for Python, but Webrick is not meant to be used for an in-production application—you didn't mention if this application was in production, though you did say 'external access'.\nFor Rails, have a look at Passenger.\n"
] | [
1
] | [] | [] | [
"apache",
"python",
"ruby_on_rails"
] | stackoverflow_0002981016_apache_python_ruby_on_rails.txt |
Q:
strange syntax error in python, version 2.6 and 3.1
this may not be an earth-shattering deficiency of python, but i still
wonder about the rationale behind the following behavior: when i
run
source = """
print( 'helo' )
if __name__ == '__main__':
print( 'yeah!' )
#"""
print( compile( source, '<whatever>', 'exe... | strange syntax error in python, version 2.6 and 3.1 | this may not be an earth-shattering deficiency of python, but i still
wonder about the rationale behind the following behavior: when i
run
source = """
print( 'helo' )
if __name__ == '__main__':
print( 'yeah!' )
#"""
print( compile( source, '<whatever>', 'exec' ) )
i get ::
File "<whatever>", line 6
#
^
... | [
"update\nturns out this is indeed a bug as pointed out by http://groups.google.com/group/comp.lang.python/msg/b4842cc7abd75fe9; the bug report is at http://bugs.python.org/issue1184112; it appears to be fixed in 2.7 and 3.2. \nsolution\nonce recognized, this bug is extremely simple to fix: since a valid python sour... | [
3
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0002976798_python_python_3.x.txt |
Q:
Best DataMining Database
I am an occasional Python programer who only have worked so far with MYSQL or SQLITE databases. I am the computer person for everything in a small company and I have been started a new project where I think it is about time to try new databases.
Sales department makes a CSV dump every wee... | Best DataMining Database | I am an occasional Python programer who only have worked so far with MYSQL or SQLITE databases. I am the computer person for everything in a small company and I have been started a new project where I think it is about time to try new databases.
Sales department makes a CSV dump every week and I need to make a small s... | [
"Quick Summary\n\nYou need enough memory(RAM) to solve your problem efficiently. I think you should upgrade memory?? When reading the excellent High Scalability Blog you will notice that for big sites to solve there problem efficiently they store the complete problem set in memory.\nYou do need a central database s... | [
16,
12,
1,
1,
1,
1,
1,
0,
0
] | [] | [] | [
"data_mining",
"database",
"nosql",
"python"
] | stackoverflow_0002577967_data_mining_database_nosql_python.txt |
Q:
Writing a program to scrape forums
I need to write a program to scrape forums.
Should I write the program in Python using the Scrapy framework or should I use Php cURL?
Also is there a Php equivalent to Scrapy?
Thanks
A:
I would choose Python due to superior libxml2 bindings, specifically things like lxml.html ... | Writing a program to scrape forums | I need to write a program to scrape forums.
Should I write the program in Python using the Scrapy framework or should I use Php cURL?
Also is there a Php equivalent to Scrapy?
Thanks
| [
"I would choose Python due to superior libxml2 bindings, specifically things like lxml.html and pyQuery. Scrapy has its own libxml2 bindings, I haven't looked at them to test them, though skimming the Scrapy documentation didn't leave me very impressed (I've done lots of scraping just using these parsers and manua... | [
4,
3
] | [] | [] | [
"information_retrieval",
"php",
"python",
"scrapy",
"web_scraping"
] | stackoverflow_0002980519_information_retrieval_php_python_scrapy_web_scraping.txt |
Q:
Google App Engine: TypeError problem with Models
I'm running Google App Engine on the dev server.
Here is my models file:
from google.appengine.ext import db
import pickle
import re
re_dept_code = re.compile(r'[A-Z]{2,}')
re_course_number = re.compile(r'[0-9]{4}')
class DependencyArcHead(db.Model):
sink = ... | Google App Engine: TypeError problem with Models | I'm running Google App Engine on the dev server.
Here is my models file:
from google.appengine.ext import db
import pickle
import re
re_dept_code = re.compile(r'[A-Z]{2,}')
re_course_number = re.compile(r'[0-9]{4}')
class DependencyArcHead(db.Model):
sink = db.ReferenceProperty()
tails = db.ListProperty()
... | [
"Possible solution: I was missing the type_name argument in the listProperty() constructor. Oops.\n"
] | [
2
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0002981548_google_app_engine_python.txt |
Q:
syntax difference between ruby and python?
i wonder if there are tutorials that go through the syntax differences for ruby and python?
i have seen a comparison between ruby and php but not between ruby and python.
i have looked at both ruby and python but it would be very useful with this side-by-side comparison f... | syntax difference between ruby and python? | i wonder if there are tutorials that go through the syntax differences for ruby and python?
i have seen a comparison between ruby and php but not between ruby and python.
i have looked at both ruby and python but it would be very useful with this side-by-side comparison for deciding which one to choose.
thanks
| [
"Here's the link from ruby language site: http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-python/\n",
"Check out http://c2.com/cgi/wiki?PythonVsRuby.\n"
] | [
5,
3
] | [] | [] | [
"python",
"ruby"
] | stackoverflow_0002981611_python_ruby.txt |
Q:
Google App Engine: get_or_create()?
Does Google App Engine have an equivalent of Django's get_or_create()?
A:
There is no full equivalent, but get_or_insert is something similar. The main differences is that get_or_insert accepts key_name as lookup against filters set in get_or_create.
A:
Haven't tested this, ... | Google App Engine: get_or_create()? | Does Google App Engine have an equivalent of Django's get_or_create()?
| [
"There is no full equivalent, but get_or_insert is something similar. The main differences is that get_or_insert accepts key_name as lookup against filters set in get_or_create.\n",
"Haven't tested this, but it should be something like the following:\nclass BaseModel(db.Model):\n @classmethod\n def get_or_creat... | [
8,
2
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0002981630_django_google_app_engine_python.txt |
Q:
How do I get contents of a Google Wave given the wave id and wavelet id?
I am using the robots api. I have a wave id and wavelet id, and my app's email is added to the wave. How can I simply get the wave (or wavelet's) contents using the python api?
A:
Based on the example here:
def OnWaveletSelfAdded(event, wav... | How do I get contents of a Google Wave given the wave id and wavelet id? | I am using the robots api. I have a wave id and wavelet id, and my app's email is added to the wave. How can I simply get the wave (or wavelet's) contents using the python api?
| [
"Based on the example here:\ndef OnWaveletSelfAdded(event, wavelet):\n for id in wavelet.blips:\n blip = wavelet.blips[id]\n logging.debug(blip.text)\n\n"
] | [
0
] | [] | [] | [
"google_app_engine",
"google_wave",
"python"
] | stackoverflow_0002981672_google_app_engine_google_wave_python.txt |
Q:
I need to change a zip code into a series of dots and dashes (a barcode), but I can't figure out how
Here's what I've got so far:
def encodeFive(zip):
zero = "||:::"
one = ":::||"
two = "::|:|"
three = "::||:"
four = ":|::|"
five = ":|:|:"
six = ":||::"
seven = "|::... | I need to change a zip code into a series of dots and dashes (a barcode), but I can't figure out how | Here's what I've got so far:
def encodeFive(zip):
zero = "||:::"
one = ":::||"
two = "::|:|"
three = "::||:"
four = ":|::|"
five = ":|:|:"
six = ":||::"
seven = "|:::|"
eight = "|::|:"
nine = "|:|::"
codeList = [zero,one,two,three,four,five,six,seven,eigh... | [
"codeList = [\"||:::\", \":::||\", \"::|:|\", \"::||:\", \":|::|\",\n \":|:|:\", \":||::\", \"|:::|\", \"|::|:\", \"|:|::\" ]\nbarcode = \"\".join(codeList[int(digit)] for digit in str(zipcode))\n\n",
"Perhaps use a dictionary:\nbarcode = {'0':\"||:::\",\n '1':\":::||\",\n '2':\"::|:|\",\n ... | [
4,
2,
1,
1,
0,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0002798766_python.txt |
Q:
Python: combine logging and wx so that logging stream is redirectet to stdout/stderr frame
Here's the thing:
I'm trying to combine the logging module with wx.App()'s redirect feature. My intention is to log to a file AND to stderr. But I want stderr/stdout redirected to a separate frame as is the feature of wx.App... | Python: combine logging and wx so that logging stream is redirectet to stdout/stderr frame | Here's the thing:
I'm trying to combine the logging module with wx.App()'s redirect feature. My intention is to log to a file AND to stderr. But I want stderr/stdout redirected to a separate frame as is the feature of wx.App.
My test code:
import logging
import wx
class MyFrame(wx.Frame):
def __init__(self):
... | [
"When wx.App says it will redirect stdout/stderr to a popup window, what it means really is that it will redirect sys.stdout and sys.stderr, so if you directly write to sys.stdout or sys.stderr it will be redirected to a popup window e.g. try this \nprint \"this will go to wx msg frame\"\nsys.stdout.write(\"yes it ... | [
1,
1
] | [] | [] | [
"logging",
"python",
"wxpython"
] | stackoverflow_0002689441_logging_python_wxpython.txt |
Q:
Python - Blackjack
def showCards():
#SUM
sum = playerCards[0] + playerCards[1]
#Print cards
print "Player's Hand: " + str(playerCards) + " : " + "sum"
print "Dealer's Hand: " + str(compCards[0]) + " : " + "sum"
compCards = [Deal(),Deal()]
playerCards = [Deal(),Deal()]
How can i ad... | Python - Blackjack | def showCards():
#SUM
sum = playerCards[0] + playerCards[1]
#Print cards
print "Player's Hand: " + str(playerCards) + " : " + "sum"
print "Dealer's Hand: " + str(compCards[0]) + " : " + "sum"
compCards = [Deal(),Deal()]
playerCards = [Deal(),Deal()]
How can i add up the integer elemen... | [
"To find the value of a hand here you can just do something like\ncompSum = sum(compCards)\n\nBut it looks like you might have tried that from the second part of your post mentioning #SUM, I don't know what you were trying to say. This will only work if Deal() returns integers.\n",
"Aside from the comments mentio... | [
1,
1
] | [] | [] | [
"blackjack",
"python"
] | stackoverflow_0002982133_blackjack_python.txt |
Q:
Output being printed in the same line, Py3k
In Python 2.x, I'd write...
for i in range(5):
print i,
...to get integers from 0 to 4 printed in the same row. How to do that in Python 3.x, since print is a function now?
A:
Use print(x, end = ' '):
From the release notes:
Old: print x, # Trailing comm... | Output being printed in the same line, Py3k | In Python 2.x, I'd write...
for i in range(5):
print i,
...to get integers from 0 to 4 printed in the same row. How to do that in Python 3.x, since print is a function now?
| [
"Use print(x, end = ' '):\nFrom the release notes:\nOld: print x, # Trailing comma suppresses newline \nNew: print(x, end=\" \") # Appends a space instead of a newline\n\n"
] | [
7
] | [] | [] | [
"python",
"python_2.7",
"python_3.x"
] | stackoverflow_0002982295_python_python_2.7_python_3.x.txt |
Q:
'NoneType' object has no attribute 'data'
I am sending a SOAP request to my server and getting the response back. sample of the response string is shown below:
<?xml version = '1.0' ?>
<env:Envelope xmlns:env=http:////www.w3.org/2003/05/soap-envelop
.
..
..
<env:Body>
<epas:get-all-config-resp xmlns:epas="urn... | 'NoneType' object has no attribute 'data' | I am sending a SOAP request to my server and getting the response back. sample of the response string is shown below:
<?xml version = '1.0' ?>
<env:Envelope xmlns:env=http:////www.w3.org/2003/05/soap-envelop
.
..
..
<env:Body>
<epas:get-all-config-resp xmlns:epas="urn:organization:epas:soap"> ^M
...
...
<epas:prop... | [
"[Edited to make clearer, and to suggest looking for an empty element]\nApparently, some of the elements returned by getElementsByTagName don't have a firstChild. This happens when the element is empty, as in\n<epas:property name=\"Empty\"></epas:property>\n\nWhen minidom encounters that situation, it'll set \"elem... | [
3,
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0002976838_python.txt |
Q:
Specifying formatting for csv.writer in Python
I am using csv.DictWriter to output csv files from a set of dictionaries. I use the following function:
def dictlist2file(dictrows, filename, fieldnames, delimiter='\t',
lineterminator='\n'):
out_f = open(filename, 'w')
# Write out header
heade... | Specifying formatting for csv.writer in Python | I am using csv.DictWriter to output csv files from a set of dictionaries. I use the following function:
def dictlist2file(dictrows, filename, fieldnames, delimiter='\t',
lineterminator='\n'):
out_f = open(filename, 'w')
# Write out header
header = delimiter.join(fieldnames) + lineterminator
... | [
"class TypedWriter:\n \"\"\"\n A CSV writer which will write rows to CSV file \"f\",\n which uses \"fieldformats\" to format fields.\n \"\"\"\n\n def __init__(self, f, fieldnames, fieldformats, **kwds):\n self.writer = csv.DictWriter(f, fieldnames, **kwds)\n self.formats = fieldformats\... | [
5
] | [] | [] | [
"csv",
"parsing",
"python"
] | stackoverflow_0002982642_csv_parsing_python.txt |
Q:
Django admin add page, how to, autofill with latest data(0002)+1=0003
When adding a new data, can we automatically add a dynamic default data where the value is previous recorded data(0002)+1=0003
A:
Not reliably. What will happen if multiple people access it at the same time is that data will be overwritten. Le... | Django admin add page, how to, autofill with latest data(0002)+1=0003 | When adding a new data, can we automatically add a dynamic default data where the value is previous recorded data(0002)+1=0003
| [
"Not reliably. What will happen if multiple people access it at the same time is that data will be overwritten. Let the PK serve its purpose, behind the scenes.\n"
] | [
1
] | [] | [] | [
"admin",
"django",
"python"
] | stackoverflow_0002982708_admin_django_python.txt |
Q:
Python program for NIST randomness equation
There is a recurrence equation on page 1789 of this paper and I need some help making a python program to calculate pi_i. I have no idea what is going on here.
Other references:original paper, pages (according to adobe, not the physical pages) 43 and 86
edit and i had a... | Python program for NIST randomness equation | There is a recurrence equation on page 1789 of this paper and I need some help making a python program to calculate pi_i. I have no idea what is going on here.
Other references:original paper, pages (according to adobe, not the physical pages) 43 and 86
edit and i had already deleted what i wrote because all the answe... | [
"Here's a pseudocode/VBAish answer:\nFunction T(i as Integer, n as Integer, m as Integer) As Double\n\nDim j As Integer, temp As Double\n\nSelect Case i\n Case 0\n If n < 1 Then\n n = 1\n Else\n If n < m Then\n T = 2 * T(0,n-1)\n Else\n ... | [
1,
0
] | [] | [] | [
"equation",
"math",
"python"
] | stackoverflow_0002982604_equation_math_python.txt |
Q:
How to control Microsoft Speech Recognition app?
I want to know if it's possible to control "Microsoft Speech Recognition" using c#.
(source: yfrog.com)
Is it possible, for instance, to simulate the click on "On: Listen to everything I say" programmatically using c# or python?
A:
JRobert had the right idea.
... | How to control Microsoft Speech Recognition app? | I want to know if it's possible to control "Microsoft Speech Recognition" using c#.
(source: yfrog.com)
Is it possible, for instance, to simulate the click on "On: Listen to everything I say" programmatically using c# or python?
| [
"JRobert had the right idea. \nIf you were using C++, then you would call ISpRecognizer::SetRecoState(SPRST_ACTIVE), and then, if you're running on Windows 7, QI the ISpRecognizer for ISpRecognizer3 and call ISpRecognizer3::SetActiveCategory(NULL) to force the recognizer into the ON state.\nBut, since you're using... | [
0
] | [
"Here's Microsoft's Speech API documentation, and an \nexample in Python.\n"
] | [
-1
] | [
"c#",
"python",
"speech_recognition"
] | stackoverflow_0002972889_c#_python_speech_recognition.txt |
Q:
Python - excel - xlwt: colouring every second row
i just finish some MYSQL to excel script with xlwt and I need to colour every second row for easy reading.
I have tried this:
row = easyxf('pattern: pattern solid, fore_colour blue')
for i in range(0,10,2):
ws0.row(i).set_style(row)
Alone this colouring is fine,... | Python - excel - xlwt: colouring every second row | i just finish some MYSQL to excel script with xlwt and I need to colour every second row for easy reading.
I have tried this:
row = easyxf('pattern: pattern solid, fore_colour blue')
for i in range(0,10,2):
ws0.row(i).set_style(row)
Alone this colouring is fine, but when when I write my data rows are again white.
Ca... | [
"I've only ever applied color to rows using the write() method.\nDoes something like this work for you? (adapted from this excellent example):\nmystyle = easyxf('pattern: pattern solid, fore_colour blue')\n\nfor row in data:\n rowx += 1\n for colx, value in enumerate(row):\n if rowx % 2 == 0:\n ... | [
4,
1
] | [] | [] | [
"excel",
"python",
"xlwt"
] | stackoverflow_0002981293_excel_python_xlwt.txt |
Q:
How to query an input in Python without outputting a new line
The title describes the question pretty much.
A:
The input function, which does the query, does not emit a newline:
>>> input('tell me: ')
tell me: what?
'what?'
>>>
as you see, the prompt is output without any newline, and what the user types after... | How to query an input in Python without outputting a new line | The title describes the question pretty much.
| [
"The input function, which does the query, does not emit a newline:\n>>> input('tell me: ')\ntell me: what?\n'what?'\n>>> \n\nas you see, the prompt is output without any newline, and what the user types after that appears on the same line as the prompt. Of course, the user is also typing a newline, and (like ever... | [
3,
1
] | [] | [] | [
"input",
"newline",
"python",
"python_3.x"
] | stackoverflow_0002982964_input_newline_python_python_3.x.txt |
Q:
How to query an input in Python without outputting a new line (cont.)
I already posted this, but here is the exact code:
x1 = input("")
x2 = input("-")
x3 = input("-")
x4 = input("-")
So, how would I do it so that there are no spaces between the first input and the next "-"?
Example:
1234-5678-9101-1121
A:
U... | How to query an input in Python without outputting a new line (cont.) | I already posted this, but here is the exact code:
x1 = input("")
x2 = input("-")
x3 = input("-")
x4 = input("-")
So, how would I do it so that there are no spaces between the first input and the next "-"?
Example:
1234-5678-9101-1121
| [
"Ugly, but you could use terminal escape sequences to delete the newline created by the user ending input between each successive call of input().\nThe appropriate sequences of escapes would be <Esc>[2K to erase the current line, and then possibly <Esc>[nC to move forwards n characters where n is calculated by retr... | [
1,
0,
0
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0002983090_python_python_3.x.txt |
Q:
How do I process a nested list?
Suppose I have a bulleted list like this:
* list item 1
* list item 2 (a parent)
** list item 3 (a child of list item 2)
** list item 4 (a child of list item 2 as well)
*** list item 5 (a child of list item 4 and a grand-child of list item 2)
* list item 6
I'd like to parse that in... | How do I process a nested list? | Suppose I have a bulleted list like this:
* list item 1
* list item 2 (a parent)
** list item 3 (a child of list item 2)
** list item 4 (a child of list item 2 as well)
*** list item 5 (a child of list item 4 and a grand-child of list item 2)
* list item 6
I'd like to parse that into a nested list or some other data s... | [
"In the view of search algorithm, the bullet you give is actually a sequence generated by Depth-First-Search. So my strategy is just to rebuild the tree structure with the dfs-sequence. \nFollowing is the python code:\nfrom collections import deque\ndef dfsBullet(bullet,depth):\n \"\"\"\n parse the subtree... | [
5,
2,
1
] | [] | [] | [
"list",
"parsing",
"python"
] | stackoverflow_0002982992_list_parsing_python.txt |
Q:
python simple function error?
I have a simple function to do simple math operations. If I call this from another script using import, I get no output. If I remove def function, everything is working fine. What's the problem with defining this function? I'm new to Python.
def calci(a, op, b):
if op == '+':
... | python simple function error? | I have a simple function to do simple math operations. If I call this from another script using import, I get no output. If I remove def function, everything is working fine. What's the problem with defining this function? I'm new to Python.
def calci(a, op, b):
if op == '+':
c = a + b
elif op == '-':
... | [
"Do you want to return the result to the calling function or print it? The only path through your program that results in a return is division, and when you do this you'll never reach the print statement.\nIf you want to do both, you should dedent the part:\nprint('value is',c)\nreturn c\n\n...to the level of the i... | [
3,
3,
1,
1
] | [] | [] | [
"function",
"python"
] | stackoverflow_0002983215_function_python.txt |
Q:
QWebView: is it possible to highlight terms and do keyboard navigation?
I am using QWebView from PyQT4. I'd like to
highlight terms of a webpage.
do a keyboard navigation inside a webpage (for example Ctrl-N move to next link)
is it possible?
A:
Have a look to Qwebview findText() method.
bool QWebView::find... | QWebView: is it possible to highlight terms and do keyboard navigation? | I am using QWebView from PyQT4. I'd like to
highlight terms of a webpage.
do a keyboard navigation inside a webpage (for example Ctrl-N move to next link)
is it possible?
| [
"Have a look to Qwebview findText() method.\n bool QWebView::findText ( const QString & subString,QWebPage::FindFlags options = 0 )\n\n\nFinds the specified string, subString,\n in the page, using the given options.\nIf the HighlightAllOccurrences flag is\n passed, the function will highlight\n all occurrences ... | [
3,
2
] | [] | [] | [
"pyqt",
"python",
"qt"
] | stackoverflow_0002940232_pyqt_python_qt.txt |
Q:
How do you iterate through each email in your inbox using python?
I'm completely new to programming and I'm trying to build an autorespoder to send a msg to a specific email address.
Using an if statement, I can check if there is an email from a certain address in the inbox and I can send an email, but if there ... | How do you iterate through each email in your inbox using python? | I'm completely new to programming and I'm trying to build an autorespoder to send a msg to a specific email address.
Using an if statement, I can check if there is an email from a certain address in the inbox and I can send an email, but if there are multiple emails from that address, how can I make a for loop to sen... | [
"As you claim to be new to programming, my best advice is: Always read the documentation.\nAnd maybe you should read a tutorial first.\n\nThe documentation provides an example:\nimport getpass, imaplib\n\nM = imaplib.IMAP4()\nM.login(getpass.getuser(), getpass.getpass())\nM.select()\ntyp, data = M.search(None, 'ALL... | [
7
] | [] | [] | [
"email",
"imaplib",
"iterator",
"python"
] | stackoverflow_0002983647_email_imaplib_iterator_python.txt |
Q:
ctypes for static libraries?
I'm attempting to write a Python wrapper for poker-eval, a c static library. All the documentation I can find on ctypes indicates that it works on shared/dynamic libraries. Is there a ctypes for static libraries?
I know about cython, but should I use that or recompile the poker-eval in... | ctypes for static libraries? | I'm attempting to write a Python wrapper for poker-eval, a c static library. All the documentation I can find on ctypes indicates that it works on shared/dynamic libraries. Is there a ctypes for static libraries?
I know about cython, but should I use that or recompile the poker-eval into a dynamic library so that I can... | [
"The choice is really up to you. If you have the ability to recompile the library as a shared object, I would suggest that, because it will minimize the non-python code you have to maintain. Otherwise, you'll want to build a python extension module that links to the static library and wraps the functions it expos... | [
9,
1
] | [] | [] | [
"ctypes",
"python",
"static_libraries"
] | stackoverflow_0002983649_ctypes_python_static_libraries.txt |
Q:
How to limit requests per minute per user?
I Have several forms in my website and I have several pages with intense database activity. I want to set a cap on requests per user. For example, I don't want people to make over 10 requests in less than 10 seconds.
Is there way to do this in Django?
A:
You can likel... | How to limit requests per minute per user? | I Have several forms in my website and I have several pages with intense database activity. I want to set a cap on requests per user. For example, I don't want people to make over 10 requests in less than 10 seconds.
Is there way to do this in Django?
| [
"You can likely do this with custom middleware. You'll need to keep the data somewhere (db?). See the docs for how to write your own middleware. Here's what's available to you in the request object.\nI'd recommend doing this on apache/nginx/whatever you're using, though.\n",
"Have a look at Simon Willison's ratel... | [
3,
2
] | [] | [] | [
"django",
"python",
"web_applications"
] | stackoverflow_0002983121_django_python_web_applications.txt |
Q:
In-document schema declarations and lxml
As per the official documentation of lxml, if one wants to validate a xml document against a xml schema document, one has to
construct the XMLSchema object (basically, parse the schema document)
construct the XMLParser, passing the XMLSchema object as its schema argument
p... | In-document schema declarations and lxml | As per the official documentation of lxml, if one wants to validate a xml document against a xml schema document, one has to
construct the XMLSchema object (basically, parse the schema document)
construct the XMLParser, passing the XMLSchema object as its schema argument
parse the actual xml document (instance documen... | [
"Caution: this is not the full answer to this, because I don't know all that much about lxml in particular.\nIn can just tell you that:\n\nIgnoring schemalocations in documents and instead managing a namespace -> schema file mapping in an application is almost always better, unless you can guarantee that the schema... | [
3
] | [] | [] | [
"lxml",
"python",
"xml",
"xsd"
] | stackoverflow_0002979824_lxml_python_xml_xsd.txt |
Q:
Splitting a list in python
I'm writing a parser in Python. I've converted an input string into a list of tokens, such as:
['(', '2', '.', 'x', '.', '(', '3', '-', '1', ')', '+', '4', ')', '/', '3', '.', 'x', '^', '2']
I want to be able to split the list into multiple lists, like the str.split('+') function. But th... | Splitting a list in python | I'm writing a parser in Python. I've converted an input string into a list of tokens, such as:
['(', '2', '.', 'x', '.', '(', '3', '-', '1', ')', '+', '4', ')', '/', '3', '.', 'x', '^', '2']
I want to be able to split the list into multiple lists, like the str.split('+') function. But there doesn't seem to be a way to ... | [
"You can write your own split function for lists quite easily by using yield:\ndef split_list(l, sep):\n current = []\n for x in l:\n if x == sep:\n yield current\n current = []\n else:\n current.append(x)\n yield current\n\nAn alternative way is to use list.i... | [
8,
1
] | [] | [] | [
"list",
"parsing",
"python"
] | stackoverflow_0002983959_list_parsing_python.txt |
Q:
Problem with a Python function
Well I have a little problem. I want to get the sum of all numbers below to 1000000, and who has 4 divisors...
I try, but i have a problem because the GetTheSum(n) function always returns the number "6"...
This is my Code :
http://pastebin.com/bhiDb5fe
A:
The problem seems to b... | Problem with a Python function | Well I have a little problem. I want to get the sum of all numbers below to 1000000, and who has 4 divisors...
I try, but i have a problem because the GetTheSum(n) function always returns the number "6"...
This is my Code :
http://pastebin.com/bhiDb5fe
| [
"The problem seems to be that you return as soon as you find the first number (which is 6).\nYou have this:\ndef GetTheSum(n):\n k = 0\n for d in range(1,n):\n if NumberOfDivisors(d) == 4:\n k += d\n return k\n\nBut you have probably meant this:\ndef GetTheSum(n):\n k = 0\n ... | [
2
] | [] | [] | [
"python"
] | stackoverflow_0002984305_python.txt |
Q:
Google Application Engine slow in case of Python
I am reading a "table" in Python in GAE that has 1000 rows and the program stops because the time limit is reached. (So it takes at least 20 seconds.)(
Is that possible that GAE is that slow? Is there a way to fix that?
Is this because I use free service and I do no... | Google Application Engine slow in case of Python | I am reading a "table" in Python in GAE that has 1000 rows and the program stops because the time limit is reached. (So it takes at least 20 seconds.)(
Is that possible that GAE is that slow? Is there a way to fix that?
Is this because I use free service and I do not pay for it?
Thank you.
The code itself is this:
lis... | [
"GAE is slow when used inefficiently. Like any framework, sometimes you have to know a little bit about how it works in order to efficiently use it. Luckily, I think there is an easy improvement that will help your code a lot.\nIt is faster to use fetch() explicitly instead of using the iterator. The iterator cau... | [
8
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0002984444_google_app_engine_python.txt |
Q:
How to output an index while iterating over an array in python
I am iterating over an array in python:
for g in [ games[0:4] ]:
g.output()
Can I also initialise and increment an index in that for loop and pass it to g.output()?
such that g.output(2) results in:
Game 2 - ... stuff relating to the object `g` he... | How to output an index while iterating over an array in python | I am iterating over an array in python:
for g in [ games[0:4] ]:
g.output()
Can I also initialise and increment an index in that for loop and pass it to g.output()?
such that g.output(2) results in:
Game 2 - ... stuff relating to the object `g` here.
| [
"Like this:\nfor index, g in enumerate(games[0:4]):\n g.output(index)\n\n",
"Use the built-in enumerate method:\nfor i,a in enumerate(['cat', 'dog']):\n print '%s is %d' % (a, i)\n\n# output:\n# cat is 0\n# dog is 1\n\n"
] | [
37,
15
] | [] | [] | [
"python"
] | stackoverflow_0002984566_python.txt |
Q:
How Can I Populate Default Form Data with a ManyToMany Field?
Ok, I've been crawling google and Django documentation for over 2 hours now (as well as the IRC channel on freenode), and haven't been able to figure this one out.
Basically, I have a model called Room, which is displayed below:
class Room(models.Model)... | How Can I Populate Default Form Data with a ManyToMany Field? | Ok, I've been crawling google and Django documentation for over 2 hours now (as well as the IRC channel on freenode), and haven't been able to figure this one out.
Basically, I have a model called Room, which is displayed below:
class Room(models.Model):
"""
A `Partyline` room. Rooms on the `Partyline`s are lik... | [
"You probably need to use \"initial\": Django set default form values\n"
] | [
0
] | [] | [] | [
"django",
"django_forms",
"python"
] | stackoverflow_0002983183_django_django_forms_python.txt |
Q:
How to print an Objectified Element?
I have xml of the format:
<channel>
<games>
<game slot='1'>
<id>Bric A Bloc</id>
<title-text>BricABloc Hoorah</title-text>
<link>Fruit Splat</link>
</game>
</games>
</channel>
I've parsed this xml using lxml.objectify... | How to print an Objectified Element? | I have xml of the format:
<channel>
<games>
<game slot='1'>
<id>Bric A Bloc</id>
<title-text>BricABloc Hoorah</title-text>
<link>Fruit Splat</link>
</game>
</games>
</channel>
I've parsed this xml using lxml.objectify, via:
tree = objectify.parse(file)
There... | [
"Perhaps use \nfor game in tree.games[0].game[0:4]:\n print(lxml.objectify.dump(game))\n\nwhich yields\ngame = None [ObjectifiedElement]\n * slot = '1'\n id = 'Bric A Bloc' [StringElement]\n title-text = 'BricABloc Hoorah' [StringElement]\n link = 'Fruit Splat' [StringElement]\n\nprint(game) shows that... | [
4
] | [] | [] | [
"lxml",
"python"
] | stackoverflow_0002984665_lxml_python.txt |
Q:
python+gae compatible web ui toolkit with ajax but degrades gracefully when there is no js?
I am searching for a web toolkit that is
Python compatible
social/db/wiki like
google-appengine compatible
has built in pagination
handles 'relationships' between entities
uses ajax
modal dialogs
but degrades very gr... | python+gae compatible web ui toolkit with ajax but degrades gracefully when there is no js? | I am searching for a web toolkit that is
Python compatible
social/db/wiki like
google-appengine compatible
has built in pagination
handles 'relationships' between entities
uses ajax
modal dialogs
but degrades very gracefully on browsers that dont have js
good ui decisions that make it gracefully degrade even... | [
"Django and JQuery.\nThey aren't exactly a unified framework, but I don't really know of any frameworks comprised of Python and JS together that fit your description.\nThere are also gigantic communities behind both Django and JQuery, which will help you immensely should you ever encounter any problems.\nDjango is ... | [
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0002984590_google_app_engine_python.txt |
Q:
Decorators vs. classes in python web development
I've noticed three main ways Python web frameworks deal request handing: decorators, controller classes with methods for individual requests, and request classes with methods for GET/POST.
I'm curious about the virtues of these three approaches. Are there major ad... | Decorators vs. classes in python web development | I've noticed three main ways Python web frameworks deal request handing: decorators, controller classes with methods for individual requests, and request classes with methods for GET/POST.
I'm curious about the virtues of these three approaches. Are there major advantages or disadvantages to any of these approaches? ... | [
"There's actually a reason for each of the three methods you listed, specific to each project.\n\nBottle tries to keep things as\nsimple/straightforward as possible\nfor the programmer. With decorators\nfor routes you don't have to worry\nabout the developer understanding OOP.\nPylons development goal is to make\n... | [
10,
1
] | [] | [] | [
"bottle",
"django",
"pylons",
"python",
"tornado"
] | stackoverflow_0002985014_bottle_django_pylons_python_tornado.txt |
Q:
Python Code Introspection and Analysis
I am trying to write a Python code analyzer, and I am trying to avoid having to parse bare Python text files. I was hoping that once the Python compiler/interpreter parses the code there's a way to get to the object code or parse tree from within a running Python program.
Is... | Python Code Introspection and Analysis | I am trying to write a Python code analyzer, and I am trying to avoid having to parse bare Python text files. I was hoping that once the Python compiler/interpreter parses the code there's a way to get to the object code or parse tree from within a running Python program.
Is there anyway to do this?
Thank you
| [
"A combination of ast and tokenize should provide the necessary framework for what you want to do.\n",
"You can take a look at Python's abstract syntax trees.\n"
] | [
4,
3
] | [] | [] | [
"compiler_construction",
"interpreter",
"introspection",
"python"
] | stackoverflow_0002985176_compiler_construction_interpreter_introspection_python.txt |
Q:
Do you use Python mostly for its functional or object-oriented features?
I see what seems like a majority of Python developers on StackOverflow endorsing the use of concise functional tools like lambdas, maps, filters, etc., while others say their code is clearer and more maintainable by not using them. What is y... | Do you use Python mostly for its functional or object-oriented features? | I see what seems like a majority of Python developers on StackOverflow endorsing the use of concise functional tools like lambdas, maps, filters, etc., while others say their code is clearer and more maintainable by not using them. What is your preference?
Also, if you are a die-hard functional programmer or hardcore ... | [
"I mostly use Python using object-oriented and procedural styles. Python is actually not particularly well-suited to functional programming.\nA lot of people think they are writing functional Python code by using lots of lambda, map, filter, and reduce, but this is a bit over-simplified. The hallmark feature of fun... | [
70,
27,
10,
6,
5,
1
] | [] | [] | [
"functional_programming",
"oop",
"python"
] | stackoverflow_0002984460_functional_programming_oop_python.txt |
Q:
module "random" not found when building .exe from IronPython 2.6 script
I am using SharpDevelop to build an executable from my IronPython script. The only hitch is that my script has the line
import random
which works fine when I run the script through ipy.exe, but when I attempt to build and run an exe from the s... | module "random" not found when building .exe from IronPython 2.6 script | I am using SharpDevelop to build an executable from my IronPython script. The only hitch is that my script has the line
import random
which works fine when I run the script through ipy.exe, but when I attempt to build and run an exe from the script in SharpDevelop, I always get the message:
IronPython.Runtime.Exceptio... | [
"When you run an IronPython script with ipy.exe the path to the Python Standard Library is typically determined from one of the following:\n\nThe IRONPYTHONPATH environment variable.\nCode in the lib\\site.py, next to ipy.exe, that adds the location of the Python Standard Library to the path.\n\nAn IronPython execu... | [
3
] | [] | [] | [
"ironpython",
"python",
"random",
"sharpdevelop"
] | stackoverflow_0002984561_ironpython_python_random_sharpdevelop.txt |
Q:
Which os is better for development : Debian or Ubuntu?
Are there any real differences between them?
I want to program in java and python. And of corse be a normal user: internet, etc
Which one will give me less headaches/more satisfaction ?
And which is better for a server machine ?
Thank you
A:
Since Ubuntu is... | Which os is better for development : Debian or Ubuntu? | Are there any real differences between them?
I want to program in java and python. And of corse be a normal user: internet, etc
Which one will give me less headaches/more satisfaction ?
And which is better for a server machine ?
Thank you
| [
"Since Ubuntu is based on Debian, development is almost exactly the same for both. They're both quite suitable for server machines. The fundamental difference is that Debian follows a Free software ideology, while Ubuntu sacrifices that purity for practicality when no Free equivalent exists for important propriet... | [
14,
4,
2,
2,
1,
1
] | [] | [] | [
"debian",
"java",
"operating_system",
"python",
"ubuntu"
] | stackoverflow_0002985426_debian_java_operating_system_python_ubuntu.txt |
Q:
DeprecationWarning when pushing to Mercurial repo
I'm trying to serve a merurial repository with apache, and when I try to push to the repo I see this in the apache error.log. On the client side I get a 500 error.
How do I get this to go away????
[Sun Jun 06 14:43:25 2010] [error] [client 192.168.1.8] /var/lib/py... | DeprecationWarning when pushing to Mercurial repo | I'm trying to serve a merurial repository with apache, and when I try to push to the repo I see this in the apache error.log. On the client side I get a 500 error.
How do I get this to go away????
[Sun Jun 06 14:43:25 2010] [error] [client 192.168.1.8] /var/lib/python-support/python2.6/mercurial/hgweb/common.py:24: De... | [
"The deprecation warning is a red herring. It's just letting you know that the server code accessed a python exception in a way that will eventually be unsupported. What you really want to find out is what exception was raised in the first place. (Was there an error message along with that 500 error?)\n"
] | [
0
] | [] | [] | [
"apache",
"mercurial",
"python"
] | stackoverflow_0002985577_apache_mercurial_python.txt |
Q:
Database query optimization
Ok my Giant friends once again I seek a little space in your shoulders :P
Here is the issue, I have a python script that is fixing some database issues but it is taking way too long, the main update statement is this:
cursor.execute("UPDATE jiveuser SET username = '%s' WHERE userid = %... | Database query optimization | Ok my Giant friends once again I seek a little space in your shoulders :P
Here is the issue, I have a python script that is fixing some database issues but it is taking way too long, the main update statement is this:
cursor.execute("UPDATE jiveuser SET username = '%s' WHERE userid = %d" % (newName,userId))
That is g... | [
"Insert all the data into another empty table (called userchanges, say) then UPDATE in a single batch:\nUPDATE jiveuser\nSET username = userchanges.username\nFROM userchanges\nWHERE userchanges.userid = jiveuser.userid\n AND userchanges.username <> jiveuser.username\n\nSee this documentation on the COPY command ... | [
4,
3,
3,
2,
1,
1,
0,
0
] | [] | [] | [
"database",
"postgresql",
"python",
"query_optimization"
] | stackoverflow_0002968451_database_postgresql_python_query_optimization.txt |
Q:
Moving to an arbitrary position in a file in Python
Let's say that I routinely have to work with files with an unknown, but large, number of lines. Each line contains a set of integers (space, comma, semicolon, or some non-numeric character is the delimiter) in the closed interval [0, R], where R can be arbitraril... | Moving to an arbitrary position in a file in Python | Let's say that I routinely have to work with files with an unknown, but large, number of lines. Each line contains a set of integers (space, comma, semicolon, or some non-numeric character is the delimiter) in the closed interval [0, R], where R can be arbitrarily large. The number of integers on each line can be varia... | [
"Python's seek goes to a byte offset in a file, not to a line offset, simply because that's the way modern operating systems and their filesystems work -- the OS/FS just don't record or remember \"line offsets\" in any way whatsoever, and there's no way for Python (or any other language) to just magically guess the... | [
17,
4,
0
] | [] | [] | [
"file",
"python",
"python_3.x"
] | stackoverflow_0002985725_file_python_python_3.x.txt |
Q:
High level audio crossfading library for python
I am looking for a high level audio library that supports crossfading for python (and that works in linux). In fact crossfading a song and saving it is about the only thing I need.
I tried pyechonest but I find it really slow. Working with multiple songs at the same... | High level audio crossfading library for python | I am looking for a high level audio library that supports crossfading for python (and that works in linux). In fact crossfading a song and saving it is about the only thing I need.
I tried pyechonest but I find it really slow. Working with multiple songs at the same time is hard on memory too (I tried to crossfade abo... | [
"A list of Python sound libraries.\nPlay a Sound with Python\nPyGame or Snack would work, but for this, I'd use something like audioop.\n— basic first steps here : merge background audio file\n",
"A scriptable solution using external tools AviSynth and avs2wav or WAVI:\nCreate an AviSynth script file:\ntest.avs\n... | [
1,
0
] | [] | [] | [
"audio",
"python"
] | stackoverflow_0002984390_audio_python.txt |
Q:
Python: why does this code take forever (infinite loop?)
I'm developing an app in Google App Engine. One of my methods is taking never completing, which makes me think it's caught in an infinite loop. I've stared at it, but can't figure it out.
Disclaimer: I'm using http://code.google.com/p/gaeunitlink text to run... | Python: why does this code take forever (infinite loop?) | I'm developing an app in Google App Engine. One of my methods is taking never completing, which makes me think it's caught in an infinite loop. I've stared at it, but can't figure it out.
Disclaimer: I'm using http://code.google.com/p/gaeunitlink text to run my tests. Perhaps it's acting oddly?
This is the problematic ... | [
"Ignoring the commented out recursion, I don't think this should be an infinite loop - you are just doing some for-loops over finite results sets.\nHowever, it does seem like this would be really slow. You're looping over entire tables and then doing more datastore queries in every nested loop. It seems unlikely ... | [
3
] | [] | [] | [
"google_app_engine",
"infinite_loop",
"python",
"recursion"
] | stackoverflow_0002986098_google_app_engine_infinite_loop_python_recursion.txt |
Q:
How do I convert a regex with pack and hex from Perl to Python?
I am a newcomer to Python and am converting a Perl script. What is the Python equivalent to...
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
Any help is greatly appreciated.
A:
You should likely just use urllib.unquote (python 2) / ... | How do I convert a regex with pack and hex from Perl to Python? | I am a newcomer to Python and am converting a Perl script. What is the Python equivalent to...
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
Any help is greatly appreciated.
| [
"You should likely just use urllib.unquote (python 2) / urllib.parse.unquote (python 3), since it looks like that's what the code you provided is trying to accomplish.\n",
"value = value.decode('hex')\n\n"
] | [
1,
0
] | [] | [] | [
"perl",
"python"
] | stackoverflow_0002986299_perl_python.txt |
Q:
What is the best way to open a URL and get up to X bytes in Python?
I want to have a robot fetch a URL every hour, but if the site's operator is malicious he could have his server send me a 1 GB file. Is there a good way to limit downloading to, say, 100 KB and stop after that limit?
I can imagine writing my own c... | What is the best way to open a URL and get up to X bytes in Python? | I want to have a robot fetch a URL every hour, but if the site's operator is malicious he could have his server send me a 1 GB file. Is there a good way to limit downloading to, say, 100 KB and stop after that limit?
I can imagine writing my own connection handler from scratch, but I'd like to use urllib2 if at all pos... | [
"This is probably what you're looking for:\nimport urllib\n\ndef download(url, bytes = 1024):\n \"\"\"Copy the contents of a file from a given URL\n to a local file.\n \"\"\"\n webFile = urllib.urlopen(url)\n localFile = open(url.split('/')[-1], 'w')\n localFile.write(webFile.read(bytes))\n web... | [
7
] | [] | [] | [
"http",
"python",
"sockets",
"url"
] | stackoverflow_0002986392_http_python_sockets_url.txt |
Q:
Python: what modules have been imported in my process?
How can I get a list of the modules that have been imported into my process?
A:
sys.modules.values() ... if you really need the names of the modules, use sys.modules.keys()
dir() is not what you want.
>>> import re
>>> def foo():
... import csv
... f... | Python: what modules have been imported in my process? | How can I get a list of the modules that have been imported into my process?
| [
"sys.modules.values() ... if you really need the names of the modules, use sys.modules.keys()\ndir() is not what you want.\n>>> import re\n>>> def foo():\n... import csv\n... fubar = 0\n... print dir()\n...\n>>> foo()\n['csv', 'fubar'] # 're' is not in the current scope\n>>>\n\n",
"You can also run th... | [
11,
4
] | [] | [] | [
"python",
"python_module"
] | stackoverflow_0002986419_python_python_module.txt |
Q:
Best practice for installing python modules from an arbitrary VCS repository
I'm newish to the python ecosystem, and have a question about module editing.
I use a bunch of third-party modules, distributed on PyPi. Coming from a C and Java background, I love the ease of easy_install <whatever>. This is a new, wo... | Best practice for installing python modules from an arbitrary VCS repository | I'm newish to the python ecosystem, and have a question about module editing.
I use a bunch of third-party modules, distributed on PyPi. Coming from a C and Java background, I love the ease of easy_install <whatever>. This is a new, wonderful world, but the model breaks down when I want to edit the newly installed m... | [
"Pip lets you install files gives a URL to the Subversion, git, Mercurial or bzr repository.\npip install -e svn+http://path_to_some_svn/repo#egg=package_name\n\nExample:\n pip install -e hg+https://rwilcox@bitbucket.org/ianb/cmdutils#egg=cmdutils\nIf I wanted to download the latest version of cmdutils. (Random ... | [
3,
2,
1,
1
] | [] | [] | [
"easy_install",
"module",
"python",
"version_control"
] | stackoverflow_0002986357_easy_install_module_python_version_control.txt |
Q:
How do i read EXIF data from an image without the use of external scripts in python?
How do i read EXIF data from an image without the use of external scripts in python? I don't want to use any prewritten scripts.
Thanks!
A:
You can use exif.py. If you don't want it to be an external module (it wouldn't necessa... | How do i read EXIF data from an image without the use of external scripts in python? | How do i read EXIF data from an image without the use of external scripts in python? I don't want to use any prewritten scripts.
Thanks!
| [
"You can use exif.py. If you don't want it to be an external module (it wouldn't necessarily be used as a script anyway), you can just copy all 1767 lines right inside your own module. If your objection is to \"prewritten\", you can study and then rewrite the 1767 lines in question, if you have a few days to wast... | [
4,
2
] | [] | [] | [
"exif",
"python"
] | stackoverflow_0002985218_exif_python.txt |
Q:
Very simple python functions takes spends long time in function and not subfunctions
I have spent many hours trying to figure what is going on here.
The function 'grad_logp' in the code below is called many times in my program, and cProfile and runsnakerun the visualize the results reveals that the function grad_l... | Very simple python functions takes spends long time in function and not subfunctions | I have spent many hours trying to figure what is going on here.
The function 'grad_logp' in the code below is called many times in my program, and cProfile and runsnakerun the visualize the results reveals that the function grad_logp spends about .00004s 'locally' every call not in any functions it calls and the functi... | [
"Functions coded in C are not instrumented by profiling; so, for example, any time spent in sum (which you're spelling __builtin__.sum) will be charged to its caller. Not sure what np.reshape is, but if it's numpy.reshape, the same applies there.\n",
"Your \"many hours\" might be better spent making your code le... | [
3,
1
] | [] | [] | [
"performance",
"python"
] | stackoverflow_0002986372_performance_python.txt |
Q:
Python C API from C++ app - know when to lock
I am trying to write a C++ class that calls Python methods of a class that does some I/O operations (file, stdout) at once. The problem I have ran into is that my class is called from different threads: sometimes main thread, sometimes different others. Obviously I tri... | Python C API from C++ app - know when to lock | I am trying to write a C++ class that calls Python methods of a class that does some I/O operations (file, stdout) at once. The problem I have ran into is that my class is called from different threads: sometimes main thread, sometimes different others. Obviously I tried to apply the approach for Python calls in multi-... | [
"Unless you have wrapped your C++ code quite peculiarly, when any Python thread calls into your C++ code, the GIL is held. You may release it in your C++ code (if you want to do some consuming task that doesn't require any Python interaction), and then will have to acquire it again when you want to do any Python i... | [
2
] | [] | [] | [
"c++",
"multithreading",
"python",
"python_2.4"
] | stackoverflow_0002986547_c++_multithreading_python_python_2.4.txt |
Q:
python code to retrieve url from mozilla
is it any possibilities to retrieve currently open url in Mozilla firefox using python
A:
You could write an extension in python and access the browser that way.
| python code to retrieve url from mozilla | is it any possibilities to retrieve currently open url in Mozilla firefox using python
| [
"You could write an extension in python and access the browser that way.\n"
] | [
0
] | [] | [] | [
"firefox",
"python",
"url"
] | stackoverflow_0002986710_firefox_python_url.txt |
Q:
Need some help converting a MAC address to binary data for use in an ethernet frame
I've been looking over various internet postings and a lot of the code I've seen looks similar to this:
def mactobinar(mac):
addr = ''
temp = mac.replace(':', '')
for i in range(0, len(temp), 2):
addr = ''.join... | Need some help converting a MAC address to binary data for use in an ethernet frame | I've been looking over various internet postings and a lot of the code I've seen looks similar to this:
def mactobinar(mac):
addr = ''
temp = mac.replace(':', '')
for i in range(0, len(temp), 2):
addr = ''.join([addr, struct.pack('B', int(temp[i: i + 2], 16)))])
return addr
Can someone explai... | [
"Why do people insist on writing all that?\ndef mactobinar(mac):\n return binascii.unhexlify(mac.replace(':', ''))\n\n",
"7.3. struct — Interpret strings as packed binary data. That'd be a good place to start.\n",
"Ok im not really the best at pythen but ill give it a shot.\nwhen the mac address is passed into... | [
4,
1,
0
] | [] | [] | [
"ethernet",
"networking",
"python"
] | stackoverflow_0002986702_ethernet_networking_python.txt |
Q:
Directory ignored by "setup.py"
The Selenium setup.py can be found at http://code.google.com/p/selenium/source/browse/trunk/setup.py.
When running "python setup.py sdist" the "firefox/test/py" directory
is ignored for some reason though it's
mentioned in the "package_dir" and in "packages".
Any ideas why it's i... | Directory ignored by "setup.py" | The Selenium setup.py can be found at http://code.google.com/p/selenium/source/browse/trunk/setup.py.
When running "python setup.py sdist" the "firefox/test/py" directory
is ignored for some reason though it's
mentioned in the "package_dir" and in "packages".
Any ideas why it's ignored?
| [
"That directory is ignored because it is not in the MANIFEST.\nMore info - http://docs.python.org/distutils/sourcedist.html\n"
] | [
1
] | [] | [] | [
"distutils",
"python"
] | stackoverflow_0002984481_distutils_python.txt |
Q:
Counting entries in a list of dictionaries: for loop vs. list comprehension with map(itemgetter)
In a Python program I'm writing I've compared using a for loop and increment variables versus list comprehension with map(itemgetter) and len() when counting entries in dictionaries which are in a list. It takes the sa... | Counting entries in a list of dictionaries: for loop vs. list comprehension with map(itemgetter) | In a Python program I'm writing I've compared using a for loop and increment variables versus list comprehension with map(itemgetter) and len() when counting entries in dictionaries which are in a list. It takes the same time using a each method. Am I doing something wrong or is there a better approach?
Here is a great... | [
"I think you're measuring incorrectly by swamping the code to be measured in a lot of overhead (running at top module level instead of in a function, doing output). Putting the two snippets into functions named forloop and withmap, and adding a * 100 to the list's definition (after the closing ]) to make the measu... | [
12
] | [] | [] | [
"dictionary",
"list_comprehension",
"loops",
"map",
"python"
] | stackoverflow_0002986929_dictionary_list_comprehension_loops_map_python.txt |
Q:
need help in site classification
I have to crawl the contents of several blogs. The problem is that I need to classify whether the blogs the authors are from a specific school and is talking about the school's stuff. May i know what's the best approach in doing the crawling or how should i go about the classificat... | need help in site classification | I have to crawl the contents of several blogs. The problem is that I need to classify whether the blogs the authors are from a specific school and is talking about the school's stuff. May i know what's the best approach in doing the crawling or how should i go about the classification?
| [
"If you're looking for a good Python web scraper, this question seems to have all the information you're looking for.\nAs for classifying whether the blog is discussing the school's stuff, that's a much trickier problem. I doubt you'll get away from having to have the results reviewed by humans. A really sophisti... | [
1,
1
] | [] | [] | [
"python",
"web_crawler"
] | stackoverflow_0002986963_python_web_crawler.txt |
Q:
In Python, how to use a C++ function which returns an allocated array of structs via a ** parameter?
I'd like to use some existing C++ code, NvTriStrip, in a Python tool.
SWIG easily handles the functions with simple parameters, but the main function, GenerateStrips, is much more complicated.
What do I need to put... | In Python, how to use a C++ function which returns an allocated array of structs via a ** parameter? | I'd like to use some existing C++ code, NvTriStrip, in a Python tool.
SWIG easily handles the functions with simple parameters, but the main function, GenerateStrips, is much more complicated.
What do I need to put in the SWIG interface file to indicate that primGroups is really an output parameter and that it must be ... | [
"Have you looked at the documentation of SWIG regarding their \"cpointer.i\" and \"carray.i\" libraries? They're found here. That's how you have to manipulate things unless you want to create your own utility libraries to accompany the wrapped code. Here's the link to the Python handling of pointers with SWIG.\n... | [
2,
2,
1
] | [] | [] | [
"python",
"swig"
] | stackoverflow_0002897717_python_swig.txt |
Q:
Is it possible to post binaries to usenet with Python?
I'm trying to use the nntplib that comes with python to make some posts to usenet. However I can't figure out how to post binary files using the .post method.
I can post plain text files just fine, but not binary files. any ideas?
-- EDIT--
So thanks to Adrian... | Is it possible to post binaries to usenet with Python? | I'm trying to use the nntplib that comes with python to make some posts to usenet. However I can't figure out how to post binary files using the .post method.
I can post plain text files just fine, but not binary files. any ideas?
-- EDIT--
So thanks to Adrian's comment below I've managed to make one step towards my go... | [
"you have to MIME-encode your post: a binary post in an NNTP newsgroup is like a mail with an attachment.\nthe file has to be encoded in ASCII, generally using the base64 encoding, then the encoded file is packaged iton a multipart MIME message and posted...\nhave a look at the email module: it implements all that ... | [
3
] | [] | [] | [
"nntp",
"python"
] | stackoverflow_0002987255_nntp_python.txt |
Q:
Trouble with copying dictionaries and using deepcopy on an SQLAlchemy ORM object
I'm doing a Simulated Annealing algorithm to optimise a given allocation of students and projects.
This is language-agnostic pseudocode from Wikipedia:
s ← s0; e ← E(s) // Initial state, energy.
sbest ←... | Trouble with copying dictionaries and using deepcopy on an SQLAlchemy ORM object | I'm doing a Simulated Annealing algorithm to optimise a given allocation of students and projects.
This is language-agnostic pseudocode from Wikipedia:
s ← s0; e ← E(s) // Initial state, energy.
sbest ← s; ebest ← e // Initial "best" solution
k ← 0 ... | [
"I have another possible solution: use transactions. This probably still isn't the best solution but implementing it should be faster.\nFirstly create your session like this:\n# transactional session\nSession = sessionmaker(transactional=True)\nsess = Session()\n\nThat way it will be transactional. The way transact... | [
2,
0
] | [] | [] | [
"deep_copy",
"python",
"simulated_annealing",
"sqlalchemy"
] | stackoverflow_0002970456_deep_copy_python_simulated_annealing_sqlalchemy.txt |
Q:
Dealing with wacky encodings in Python
I have a Python script that pulls in data from many sources (databases, files, etc.). Supposedly, all the strings are unicode, but what I end up getting is any variation on the following theme (as returned by repr()):
u'D\\xc3\\xa9cor'
u'D\xc3\xa9cor'
'D\\xc3\\xa9cor'
'D\xc3\... | Dealing with wacky encodings in Python | I have a Python script that pulls in data from many sources (databases, files, etc.). Supposedly, all the strings are unicode, but what I end up getting is any variation on the following theme (as returned by repr()):
u'D\\xc3\\xa9cor'
u'D\xc3\xa9cor'
'D\\xc3\\xa9cor'
'D\xc3\xa9cor'
Is there a reliable way to take any... | [
"That's just UTF-8 data. Use .decode to convert it into unicode.\n>>> 'D\\xc3\\xa9cor'.decode('utf-8')\nu'D\\xe9cor'\n\nYou can perform an additional string-escape decode for the 'D\\\\xc3\\\\xa9cor' case.\n>>> 'D\\xc3\\xa9cor'.decode('string-escape').decode('utf-8')\nu'D\\xe9cor'\n>>> 'D\\\\xc3\\\\xa9cor'.decode('... | [
4,
2,
1
] | [] | [] | [
"character_encoding",
"encoding",
"python",
"unicode"
] | stackoverflow_0002987305_character_encoding_encoding_python_unicode.txt |
Q:
Will this SQL cause any problems?
I'm sure everyone knows the joys of concurrency when it comes to threading.
Imagine the following scenario on every page-load on a noobily set up MySQL db:
UPDATE stats SET visits = (visits+1)
If a thousand users load the page at same time, will the count cause any issues? is th... | Will this SQL cause any problems? | I'm sure everyone knows the joys of concurrency when it comes to threading.
Imagine the following scenario on every page-load on a noobily set up MySQL db:
UPDATE stats SET visits = (visits+1)
If a thousand users load the page at same time, will the count cause any issues? is this that table locking/row locking mecha... | [
"No this won't screw up. This is perfectly acceptable in any ACID compliant DB. The I stands for Isolation. Each one of these queries will lock all rows in the visit table. The A (in ACID) stands for Atomicity and means the transaction must run in full or not at all.\n",
"You have two potential problems:\n\nWill ... | [
3,
3,
2,
2,
1,
1,
0
] | [
"It's fine.\nall that \"table locking/row locking\" is the crap databases were invented to take care for. \nThere can be other issues when \"thousand users load the page at same time\", like index updating. But that's another story and noobily MySQL setup isn't a case anyway.\n"
] | [
-1
] | [
"c++",
"java",
"mysql",
"php",
"python"
] | stackoverflow_0002983264_c++_java_mysql_php_python.txt |
Q:
Mimic C preprocessor with Python/Ruby?
I need to mimic the preprocessor feature of C with Python.
If I want to run the debug release, I use as follows with C
#ifdef DEBUG
printf(...)
#endif
I just use -DDEBUG or similar to trigger it on or off.
What method can I use for Python/Ruby?
I mean, what should I do to c... | Mimic C preprocessor with Python/Ruby? | I need to mimic the preprocessor feature of C with Python.
If I want to run the debug release, I use as follows with C
#ifdef DEBUG
printf(...)
#endif
I just use -DDEBUG or similar to trigger it on or off.
What method can I use for Python/Ruby?
I mean, what should I do to control the behavior of python/ruby scripts i... | [
"You usually use the python logging functionality in this use-case. That is configured in configuration files, and you can set the output levels. Very close in usage to java log4j, if you're familiar with that.\n",
"You can almost use the actual C preprocessor. If you rename your file to end in .c, you can then d... | [
5,
2,
2
] | [] | [] | [
"preprocessor",
"python",
"ruby",
"user_controls"
] | stackoverflow_0002684712_preprocessor_python_ruby_user_controls.txt |
Q:
Any high-level languages that can use c libraries?
I know this question could be in vain, but it's just out of curiosity, and I'm still much a newb^^ Anyways I've been loving python for some time while learning it. My problem is obviously speed issues. I'd like to get into indie game creation, and for the short fu... | Any high-level languages that can use c libraries? | I know this question could be in vain, but it's just out of curiosity, and I'm still much a newb^^ Anyways I've been loving python for some time while learning it. My problem is obviously speed issues. I'd like to get into indie game creation, and for the short future, 2d and pygame will work.
But I'd eventually like ... | [
"Python can call functions in dynamically loaded C libraries (.so in unix, .dll in Windows) using the ctypes module.\nThere is also cython - a variation of python that compiles to C and can call C libraries directly. You can mix modules written in pure Python and cython.\nYou may also want to look at the numerous ... | [
9,
3,
3,
1,
1,
1,
1,
0,
0,
0
] | [] | [] | [
"c",
"c++",
"python"
] | stackoverflow_0002987524_c_c++_python.txt |
Q:
python return class
I new to python and I read from someone else of the example code below:
class A:
def current(self):
data = Data(a=a,b=b,c=c)
return data
class B(A):
#something here
#print data a b c
How do I print out the data a, b, and c?
A:
It's not really clear what you exactly want, but h... | python return class | I new to python and I read from someone else of the example code below:
class A:
def current(self):
data = Data(a=a,b=b,c=c)
return data
class B(A):
#something here
#print data a b c
How do I print out the data a, b, and c?
| [
"It's not really clear what you exactly want, but here is a try:\nclass A:\n def current(self):\n data = Data(a=a,b=b,c=c)\n return data\n\nclass B(A):\n def print(self):\n data = self.current()\n print \"Data A:%s B:%s C:%s\" % (data.a, data.b, data.c) \n\n"
] | [
1
] | [] | [] | [
"python"
] | stackoverflow_0002988059_python.txt |
Q:
which file stored os.environ,and store where , disk c: or disk d:
my code is :
os.environ['ss']='ssss'
print os.environ
and it show :
{'TMP': 'C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp', 'COMPUTERNAME': 'PC-200908062210', 'USERDOMAIN': 'PC-200908062210', 'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files', 'PROC... | which file stored os.environ,and store where , disk c: or disk d: | my code is :
os.environ['ss']='ssss'
print os.environ
and it show :
{'TMP': 'C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp', 'COMPUTERNAME': 'PC-200908062210', 'USERDOMAIN': 'PC-200908062210', 'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files', 'PROCESSOR_IDENTIFIER': 'x86 Family 6 Model 15 Stepping 2, GenuineIntel', 'P... | [
"I am not sure I understand your question correctly. Do you ask where the file os.environ is located on disk? If yes, the answer is:\nThere is no such file.\nos.environ is a collection of environment variables and informations about the host system, provided by the python interpreter.\n"
] | [
4
] | [] | [] | [
"environment_variables",
"google_app_engine",
"python"
] | stackoverflow_0002988019_environment_variables_google_app_engine_python.txt |
Q:
How to prevent BeautifulSoup from stripping lines
I'm trying to translate an online html page into text.
I have a problem with this structure:
<div align="justify"><b>Available in
<a href="http://www.example.com.be/book.php?number=1">
French</a> and
<a href="http://www.example.com.be/book.php?number=5">
English... | How to prevent BeautifulSoup from stripping lines | I'm trying to translate an online html page into text.
I have a problem with this structure:
<div align="justify"><b>Available in
<a href="http://www.example.com.be/book.php?number=1">
French</a> and
<a href="http://www.example.com.be/book.php?number=5">
English</a>.
</div>
Here is its representation as a python st... | [
"I finally got a good solution:\ndef clean_line(line):\n return re.sub(r'[ ]{2,}', ' ', re.sub(r'[\\r\\n]', '', line))\n\nhtml_content = get_html_div_from_above()\npara = BeautifulSoup(html_content)\n''.join([clean_line(line) for line in para.findAll(text=True)])\n\nWhich outputs:\nu'Available in French and Engl... | [
2,
1
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0002988229_beautifulsoup_python.txt |
Q:
Where can I find good ajax support in Java/Python?
I want a framework (or anything) that helps me make rich client guis. I know my server-side, but I don't like programming in ajax, javascript, css etc.
Something that wraps the ajax code in some objects/methods with clean syntax, would do the trick. I want to wri... | Where can I find good ajax support in Java/Python? | I want a framework (or anything) that helps me make rich client guis. I know my server-side, but I don't like programming in ajax, javascript, css etc.
Something that wraps the ajax code in some objects/methods with clean syntax, would do the trick. I want to write code in java instead of defining css and html tags.
D... | [
"Look into Google Web Toolkit (aka GWT). It's a Java framework that \"is a development toolkit for building and optimizing complex browser-based applications. GWT is used by many products at Google, including Google Wave and Google AdWords.\"\nI think GWT aims to do exactly what you're looking for, though I have n... | [
4,
3,
0,
0
] | [] | [] | [
"ajax",
"css",
"java",
"python",
"spring"
] | stackoverflow_0002969054_ajax_css_java_python_spring.txt |
Q:
OverflowError: math range error
>>> import math
>>> math.pow(2, 3000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: math range error
How can I fix it?
A:
Use the built-in operator.
2**3000
| OverflowError: math range error | >>> import math
>>> math.pow(2, 3000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: math range error
How can I fix it?
| [
"Use the built-in operator.\n2**3000\n\n"
] | [
18
] | [] | [] | [
"math",
"python"
] | stackoverflow_0002988634_math_python.txt |
Q:
what should i do after openid (or twitter ,facebook) user login my site ,on gae
how to integration local user and openid(or facebook twitter) user ,
did you know some framework have already done this ,
updated
my mean is : how to deal with 'local user' and 'openid user',
and how to mix them in one model .
please g... | what should i do after openid (or twitter ,facebook) user login my site ,on gae | how to integration local user and openid(or facebook twitter) user ,
did you know some framework have already done this ,
updated
my mean is : how to deal with 'local user' and 'openid user',
and how to mix them in one model .
please give me a framework that realize 'local user' and 'openid user'
| [
"I understand your question.\nYou wish to be able to maintain a list of users that have signed up with your service, and also want to record users using OpenID to authenticate.\nIn order to solve this I would do either of the following:\n\nCreate a new user in your users table for each new user logged in under Open... | [
1
] | [] | [] | [
"google_app_engine",
"integration",
"openid",
"python"
] | stackoverflow_0002986766_google_app_engine_integration_openid_python.txt |
Q:
How to show why "try" failed in python
is there anyway to show why a "try" failed, and skipped to "except", without writing out all the possible errors by hand, and without ending the program?
example:
try:
1/0
except:
someway to show
"Traceback (most recent call last):
File "<pyshell#0>", line... | How to show why "try" failed in python | is there anyway to show why a "try" failed, and skipped to "except", without writing out all the possible errors by hand, and without ending the program?
example:
try:
1/0
except:
someway to show
"Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
1/0
ZeroDivisio... | [
"Try:\n>>> try:\n... 1/0\n... except Exception, e:\n... print e\n... \ninteger division or modulo by zero\n\nThere are other syntactical variants, e.g.:\n>>> try:\n... 1/0\n... except Exception as e:\n... print e\n... \ninteger division or modulo by zero\n\nMore information can be found in the errors ... | [
10,
8
] | [] | [] | [
"error_handling",
"python"
] | stackoverflow_0002988751_error_handling_python.txt |
Q:
manyToManyField question
Hay guys, I'm writing a simple app which logs recipes.
I'm working out my models and have stumbled across a problem
My Dish models needs to have many Ingredients. This is no problem because i would do something like this
ingredients = models.ManyToManyfield(Ingredient)
No problems, my dis... | manyToManyField question | Hay guys, I'm writing a simple app which logs recipes.
I'm working out my models and have stumbled across a problem
My Dish models needs to have many Ingredients. This is no problem because i would do something like this
ingredients = models.ManyToManyfield(Ingredient)
No problems, my dish now can have many ingrendien... | [
"I think you got the right answer with a \"through\" table ( http://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany )\nModel\nclass Recipe(models.Model):\n name = models.TextField(blank=False)\n ingredients = models.ManyToManyField(Ingredient, through='Components')\n\nclass Ingredient(... | [
2
] | [] | [] | [
"django",
"manytomanyfield",
"python"
] | stackoverflow_0002988471_django_manytomanyfield_python.txt |
Q:
Open/Close database connection in django
I am using Django and Postgresql as my DBMS.
I wish to set a setting that enables to enable/disable database connection. When the connection is set to closed (in settings.py) the site will display a message such as "meintanence mode" or something like that. Django will not ... | Open/Close database connection in django | I am using Django and Postgresql as my DBMS.
I wish to set a setting that enables to enable/disable database connection. When the connection is set to closed (in settings.py) the site will display a message such as "meintanence mode" or something like that. Django will not show any db connection error message (or mail ... | [
"Maybe creating a middleware solves your problem. Put your new middleware \"maintenancemiddleware\" as the FIRST item of your settings.middleware tuple.\n# code not tested, only for demonstration.\n# maintenancemiddleware.py\nfrom django.conf.settings import MAINTENANCE\n\nclass MaintenanceMiddleware(object):\n ... | [
3
] | [] | [] | [
"database_connection",
"django",
"python"
] | stackoverflow_0002989066_database_connection_django_python.txt |
Q:
Facebook authentication with extended permission request
I'm wondering which authentication method to use if i need extended permissions (e.g. if i want to use the users photos in my application). The methods are either the single-sign on using JavaScript SDK or by using the OAuth 2.0 protocol. Both methods are ex... | Facebook authentication with extended permission request | I'm wondering which authentication method to use if i need extended permissions (e.g. if i want to use the users photos in my application). The methods are either the single-sign on using JavaScript SDK or by using the OAuth 2.0 protocol. Both methods are explained here: Authentication - Facebook developers. The JS SDK... | [
"At the moment the entire Facebook API is undergoing changes.\nI would suggest you use the OAuth API - it appears as this is the direction they will adopt. \nA word of caution - the \"official\" documentation in the page you mentioned are not complete at best and some of the options are still buggy (try setting di... | [
1
] | [] | [] | [
"django",
"facebook",
"google_app_engine",
"javascript",
"python"
] | stackoverflow_0002988981_django_facebook_google_app_engine_javascript_python.txt |
Q:
Pure python implementation of greenlet API
The greenlet package is used by gevent and eventlet for asynchronous IO. It is written as a C-extension and therefore doesn't work with Jython or IronPython. If performance is of no concern, what is the easiest approach to implementing the greenlet API in pure Python.
A... | Pure python implementation of greenlet API | The greenlet package is used by gevent and eventlet for asynchronous IO. It is written as a C-extension and therefore doesn't work with Jython or IronPython. If performance is of no concern, what is the easiest approach to implementing the greenlet API in pure Python.
A simple example:
def test1():
print 12
g... | [
"This kind of thing can be achieved with co-routines which have been built-in to the standard Python distribution since version 2.5. If IronPython and co are fully compliant with all Python 2.5 features (I believe they are) you should be able to use this idiom.\nSee this post for more information on how they can b... | [
12,
10
] | [] | [] | [
"ironpython",
"jython",
"python"
] | stackoverflow_0002939678_ironpython_jython_python.txt |
Q:
cherrypy when to know that the server has started
I am trying to write some unit tests for a small web service written with Cherrypy and I am wondering what's the best way to figure out that the server has started, so i don't get connection refused if I try to connect too early to the service ?
A:
I got it figur... | cherrypy when to know that the server has started | I am trying to write some unit tests for a small web service written with Cherrypy and I am wondering what's the best way to figure out that the server has started, so i don't get connection refused if I try to connect too early to the service ?
| [
"I got it figured out:\ncherrypy.engine.start(); cherrypy.server.wait()\nit's the way to go.\nOtherwise, I think you can get away with some tricks with\ncherrypy.server.bus.states\n"
] | [
4
] | [] | [] | [
"cherrypy",
"python"
] | stackoverflow_0002988636_cherrypy_python.txt |
Q:
File copy completion?
In Linux, how can we know if a file has completed copying before reading it? In Windows, an OSError is raised.
A:
In Linux, you can open a file while another process is writing to it without Python throwing an OSError, so in general, you cannot know for sure whether the other side has finis... | File copy completion? | In Linux, how can we know if a file has completed copying before reading it? In Windows, an OSError is raised.
| [
"In Linux, you can open a file while another process is writing to it without Python throwing an OSError, so in general, you cannot know for sure whether the other side has finished writing into that file. You can try some hacks, though:\n\nYou can check the file size regularly to see whether it increased since the... | [
1,
1
] | [] | [] | [
"file_io",
"python"
] | stackoverflow_0002989388_file_io_python.txt |
Q:
stdout and stderr anomalies
from the interactive prompt:
>>> import sys
>>> sys.stdout.write('is the')
is the6
what is '6' doing there?
another example:
>>> for i in range(3):
... sys.stderr.write('new black')
...
9
9
9
new blacknew blacknew black
where are the numbers coming from?
A:
In 3.x the write met... | stdout and stderr anomalies | from the interactive prompt:
>>> import sys
>>> sys.stdout.write('is the')
is the6
what is '6' doing there?
another example:
>>> for i in range(3):
... sys.stderr.write('new black')
...
9
9
9
new blacknew blacknew black
where are the numbers coming from?
| [
"In 3.x the write method of a file object returns the number of bytes written, and the interactive prompt prints out the return value of whatever you are running. So you print out 'is the' (6 bytes), and the interpreter then prints out 6 (the return from write). See the relevant docs for 3.1.\nThis does not happen ... | [
2,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0002989591_python.txt |
Q:
How to make string from regex and value of group
I have regexp for twitter profile url and someone's twitter profile url. I can easily extract username from url.
>>> twitter_re = re.compile('twitter.com/(?P<username>\w+)/')
>>> twitter_url = 'twitter.com/dir01/'
>>> username = twitter_re.search(twitter_url).groups... | How to make string from regex and value of group | I have regexp for twitter profile url and someone's twitter profile url. I can easily extract username from url.
>>> twitter_re = re.compile('twitter.com/(?P<username>\w+)/')
>>> twitter_url = 'twitter.com/dir01/'
>>> username = twitter_re.search(twitter_url).groups()[0]
>>> _
'dir01'
But if I have regexp and username... | [
"Regexen are no two-way street. You can use them for parsing strings, but not for generating strings back from the result. You should probably look into another way of getting the URLs back, like basic string interpolation, or URI templates (see http://code.google.com/p/uri-templates/)\n",
"If you are not looking... | [
1,
0
] | [
"Why do you need the regex for that - just append the strings.\nbase_url = \"twitter.com/\"\ntwt_handle = \"dir01\"\ntwit_url = base_url + twt_handle\n\n"
] | [
-1
] | [
"python",
"regex",
"replace"
] | stackoverflow_0002989715_python_regex_replace.txt |
Q:
Django: How to write the reverse function for the following
The urlconf and view is as follows:
url(r'^register/$',
register,
{ 'backend': 'registration.backends.default.DefaultBackend' },
name='registration_register'),
def register(request, backend, success_url=None, form_class=None,
dis... | Django: How to write the reverse function for the following | The urlconf and view is as follows:
url(r'^register/$',
register,
{ 'backend': 'registration.backends.default.DefaultBackend' },
name='registration_register'),
def register(request, backend, success_url=None, form_class=None,
disallowed_url='registration_disallowed',
template_na... | [
"If you want to be able to specify reverse() with parameters, those parameters have to be defined in the URL configuration itself (regexp). Something like:\nurl(r'^register/(?P<success_url>[\\w\\/]+)/$',\n register,\n { 'backend': 'registration.backends.default.DefaultBackend' },\n name='registration_regis... | [
1,
0
] | [] | [] | [
"django",
"keyword_argument",
"python",
"reverse",
"url"
] | stackoverflow_0002988978_django_keyword_argument_python_reverse_url.txt |
Q:
How can I find all the possible combinations of a list of lists (in Python)?
I have the following structure in Python:
letters = [['a', 'b', 'c'], ['p', 'q', 'r', 's'], ['j', 'k', 'l']]
I would like to find all the possible combinations of letters in the order that they currently exist. For the example above this... | How can I find all the possible combinations of a list of lists (in Python)? | I have the following structure in Python:
letters = [['a', 'b', 'c'], ['p', 'q', 'r', 's'], ['j', 'k', 'l']]
I would like to find all the possible combinations of letters in the order that they currently exist. For the example above this would be:
apj
apk
apl
aqj
aqk
aql
...
csk
csl
This seems like it should be a ver... | [
"In Python 2.6 or newer you can use itertools.product:\n>>> import itertools\n>>> map(''.join, itertools.product(*letters))\napj\napk\napl\naqj\naqk\naql\n...etc...\ncsk\ncsl\n\n"
] | [
14
] | [] | [] | [
"python"
] | stackoverflow_0002990003_python.txt |
Q:
Problems with sys.stdout.write() with time.sleep() in a function
What I wanted is printing out 5 dots that a dot printed per a second using time.sleep(), but the result was 5 dots were printed at once after 5 seconds delay.
Tried both print and sys.stdout.write, same result.
Thanks for any advices.
import time
i... | Problems with sys.stdout.write() with time.sleep() in a function | What I wanted is printing out 5 dots that a dot printed per a second using time.sleep(), but the result was 5 dots were printed at once after 5 seconds delay.
Tried both print and sys.stdout.write, same result.
Thanks for any advices.
import time
import sys
def wait_for(n):
"""Wait for {n} seconds. {n} should be... | [
"You need to flush after writing.\nsys.stdout.write('foo')\nsys.stdout.flush()\nwastetime()\nsys.stdout.write('bar')\nsys.stdout.flush()\n\n",
"You should use sys.stderr.write for progress bars; stderr has the (not at all coincidental) advantage of not being buffered, so no sys.stderr.flush calls are needed.\nSee... | [
9,
4
] | [] | [] | [
"buffering",
"python"
] | stackoverflow_0002808832_buffering_python.txt |
Q:
python on the web, does it compile down to bytecode or is it more like php?
Does python compile down to some byte code or is it rendered on the fly each time like php/asp?
From my readings I read it has its own byte code format, so i figured it was like java/.net where it compiles into a intermediate language/byte... | python on the web, does it compile down to bytecode or is it more like php? | Does python compile down to some byte code or is it rendered on the fly each time like php/asp?
From my readings I read it has its own byte code format, so i figured it was like java/.net where it compiles into a intermediate language/byte code.
so it is more effecient in that respect that php right?
| [
"Given a language X, and a way the server can be aware of it (a module or whatever) or a proper \"intermediate\" CGI program mX, this mX can be programmed so that it indeed interprets directly plain text script in X (like php), or bytecode compiled code (originally written in X). So, provided the existance of the p... | [
1,
1,
0,
0,
0
] | [] | [] | [
"fastcgi",
"python"
] | stackoverflow_0002990301_fastcgi_python.txt |
Q:
Is there a recommended command for "hg bisect --command"?
I have an emergent bug that I've got to track down tomorrow. I know a previous hg revision which was good so I'm thinking about using hg bisect.
However, I'm on Windows and don't want to get into DOS scripting.
Ideally, I'd be able to write a Python unit te... | Is there a recommended command for "hg bisect --command"? | I have an emergent bug that I've got to track down tomorrow. I know a previous hg revision which was good so I'm thinking about using hg bisect.
However, I'm on Windows and don't want to get into DOS scripting.
Ideally, I'd be able to write a Python unit test and have hg bisect use that. This is my first attempt.
bisec... | [
"Thanks to all, especially to Will McCutchen.\nThe solution that worked best is below.\nbisector.py\n#!/usr/bin/env python\n\nimport unittest\n\nclass TestCase(unittest.TestCase):\n\n def test(self):\n # Raise an assertion error to mark the revision as bad\n pass\n\n\nif '__main__' == __name__:\n ... | [
10,
4,
1
] | [] | [] | [
"mercurial",
"python"
] | stackoverflow_0002511704_mercurial_python.txt |
Q:
Python - Polymorphism in wxPython, What's wrong?
I am trying to write a simple custom button in wx.Python. My code is as follows, an error is thrown on line 19 of my "Custom_Button.py" - What is going on? I can find no help online for this error and have a suspicion that it has to do with the Polymorphism. (As a s... | Python - Polymorphism in wxPython, What's wrong? | I am trying to write a simple custom button in wx.Python. My code is as follows, an error is thrown on line 19 of my "Custom_Button.py" - What is going on? I can find no help online for this error and have a suspicion that it has to do with the Polymorphism. (As a side note: I am relatively new to python having come fr... | [
"In function definitions, arguments with default values need to be listed after arguments without defaults, but before *args and **kwargs expansions\nBefore:\ndef __init__(self, parent, id=-1, NORM_BMP, PUSH_BMP, MOUSE_OVER_BMP, text=\"\", \n pos, size, **kwargs)\n\nCorrected:\ndef __init__(self, par... | [
3
] | [] | [] | [
"polymorphism",
"pydev",
"python",
"wxpython"
] | stackoverflow_0002990446_polymorphism_pydev_python_wxpython.txt |
Q:
Many-to-one relationship in SQLAlchemy
This is a beginner-level question.
I have a catalog of mtypes:
mtype_id name
1 'mtype1'
2 'mtype2'
[etc]
and a catalog of Objects, which must have an associated mtype:
obj_id mtype_id name
1 1 'obj1'
2 1 'obj2'
3 2 'obj3'
[et... | Many-to-one relationship in SQLAlchemy | This is a beginner-level question.
I have a catalog of mtypes:
mtype_id name
1 'mtype1'
2 'mtype2'
[etc]
and a catalog of Objects, which must have an associated mtype:
obj_id mtype_id name
1 1 'obj1'
2 1 'obj2'
3 2 'obj3'
[etc]
I am trying to do this in SQLAlchemy by ... | [
"Have you tried:\nColumn('mtype_id', ForeignKey('mtypes.mtype_id')),\n\ninstead of:\nColumn('mtype_id', None, ForeignKey('mtypes.mtype_id')),\n\nSee also: https://docs.sqlalchemy.org/en/13/core/constraints.html\n",
"I was able to run the code you have shown above so I guess the problem was removed when you simpli... | [
2,
0
] | [] | [] | [
"database_design",
"many_to_one",
"python",
"sqlalchemy"
] | stackoverflow_0002952010_database_design_many_to_one_python_sqlalchemy.txt |
Q:
How do I loop through a list by twos?
I want to loop through a Python list and process 2 list items at a time. Something like this in another language:
for(int i = 0; i < list.length(); i+=2)
{
// do something with list[i] and list[i + 1]
}
What's the best way to accomplish this?
A:
You can use a range with ... | How do I loop through a list by twos? | I want to loop through a Python list and process 2 list items at a time. Something like this in another language:
for(int i = 0; i < list.length(); i+=2)
{
// do something with list[i] and list[i + 1]
}
What's the best way to accomplish this?
| [
"You can use a range with a step size of 2:\nPython 2\nfor i in xrange(0,10,2):\n print(i)\n\nPython 3\nfor i in range(0,10,2):\n print(i)\n\nNote: Use xrange in Python 2 instead of range because it is more efficient as it generates an iterable object, and not the whole list.\n",
"You can also use this syntax (... | [
478,
134,
75,
43,
7,
3
] | [
"If you have control over the structure of the list, the most pythonic thing to do would probably be to change it from:\nl=[1,2,3,4]\n\nto:\nl=[(1,2),(3,4)]\n\nThen, your loop would be:\nfor i,j in l:\n print i, j\n\n"
] | [
-2
] | [
"for_loop",
"iteration",
"list",
"loops",
"python"
] | stackoverflow_0002990121_for_loop_iteration_list_loops_python.txt |
Q:
How to save big "database-like" class in python
I'm doing a project with reasonalby big DataBase. It's not a probper DB file, but a class with format as follows:
DataBase.Nodes.Data=[[] for i in range(1,1000)] f.e. this DataBase is all together something like few thousands rows. Fisrt question - is the way I'm doi... | How to save big "database-like" class in python | I'm doing a project with reasonalby big DataBase. It's not a probper DB file, but a class with format as follows:
DataBase.Nodes.Data=[[] for i in range(1,1000)] f.e. this DataBase is all together something like few thousands rows. Fisrt question - is the way I'm doing efficient, or is it better to use SQL, or any othe... | [
"Pickle (cPickle) can handle any (picklable) Python object. So as long, as you're not trying to pickle thread or filehandle or something like that, you're ok.\n",
"Pickle should be able to serialise the data for you so that you can save it to file.\nAlternatively if you don't need the features of a full featured ... | [
3,
2,
1
] | [] | [] | [
"object_persistence",
"pickle",
"python",
"serialization"
] | stackoverflow_0002990995_object_persistence_pickle_python_serialization.txt |
Q:
Is there a way to use a substring function on variables in .vimrc?
I have gVim and portable python stored in a DropBox folder on several machines. The location of the DropBox folder is different on each computer. However, I'd like to be able to setup the .vimrc so that it automatically references the correct pyt... | Is there a way to use a substring function on variables in .vimrc? | I have gVim and portable python stored in a DropBox folder on several machines. The location of the DropBox folder is different on each computer. However, I'd like to be able to setup the .vimrc so that it automatically references the correct python folder no matter what computer it's on.
For example, I have gVim in ... | [
"I was able to do what I needed using the strpart and strlen functions.\nlet s:pp = strpart($VIMRUNTIME, 0, strlen($VIMRUNTIME)-strridx($VIMRUNTIME, \"DropBox\")+1) . \"\\\\Apps\\\\PortablePython_1.1_py2.5.4\\\\App\"\nif (has('win32') || has('win64')) && isdirectory(s:pp) \n let $PATH .= ';' . s:pp \nendif \n\nT... | [
2
] | [] | [] | [
"python",
"substring",
"vim"
] | stackoverflow_0002978911_python_substring_vim.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.