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:
How to aggregate timeseries in Python?
I have two different timeseries with partially overlapping timestamps:
import scikits.timeseries as ts
from datetime import datetime
a = ts.time_series([1,2,3], dates=[datetime(2010,10,20), datetime(2010,10,21), datetime(2010,10,23)], freq='D')
b = ts.time_series([4,5,6], da... | How to aggregate timeseries in Python? | I have two different timeseries with partially overlapping timestamps:
import scikits.timeseries as ts
from datetime import datetime
a = ts.time_series([1,2,3], dates=[datetime(2010,10,20), datetime(2010,10,21), datetime(2010,10,23)], freq='D')
b = ts.time_series([4,5,6], dates=[datetime(2010,10,20), datetime(2010,10,... | [
"I have tried and found this:\naWgt = 0.3\nbWgt = 0.7\n\nprint (np.where(a1.mask, 0., a1.data * aWgt) +\n np.where(b1.mask, 0., b1.data * bWgt)) / (np.where(a1.mask, 0., aWgt) +\n np.where(b1.mask, 0., bWgt))\n\n# array([ 3.1, 2. , 5. , 5.1])\n\nThis is appli... | [
3
] | [] | [] | [
"datetime",
"python",
"scikits",
"time_series",
"weighted_average"
] | stackoverflow_0003977535_datetime_python_scikits_time_series_weighted_average.txt |
Q:
python location of the running program on windows
I have an python application that need to know in which directory it founded when it run,
how can i know the running application path on windows for example when i change the directory path is changed to the new directory .
is there a way to know where is the pytho... | python location of the running program on windows | I have an python application that need to know in which directory it founded when it run,
how can i know the running application path on windows for example when i change the directory path is changed to the new directory .
is there a way to know where is the python application run withour saving it on the beginning by... | [
"it is contained in the __file__ variable.\nBut if you want to know the current working directory then you should use os.getcw.\n>>> os.getcwd()\n'C:\\\\Program Files\\\\Python31'\n>>> os.chdir(r'C:\\\\')\n>>> os.getcwd()\n'C:\\\\'\n\n",
"import os\nprint os.path.abspath(os.path.dirname(__file__))\n\nedit : littl... | [
1,
0
] | [] | [] | [
"command_line",
"path",
"python"
] | stackoverflow_0003978079_command_line_path_python.txt |
Q:
pyinotify asyncnotifier thread question
I'm confused about how asyncnotifier works. What exactly is threaded in the notifier? Is the just the watcher threaded? Or does each of the callbacks to the handler functions run on its own thread?
The documentation says essentially nothing about the specifics of the class.
... | pyinotify asyncnotifier thread question | I'm confused about how asyncnotifier works. What exactly is threaded in the notifier? Is the just the watcher threaded? Or does each of the callbacks to the handler functions run on its own thread?
The documentation says essentially nothing about the specifics of the class.
| [
"The AsyncNotifier doesn't use threading, it uses the asynchronous socket handler loop.\nIf you're talking about the ThreadedNotifier, then each callback seems to be called in the same thread per notifier.\nThis means that even if you have several EventHandlers registered with some WatchManager, they will all issue... | [
3
] | [] | [] | [
"multithreading",
"pyinotify",
"python"
] | stackoverflow_0003955544_multithreading_pyinotify_python.txt |
Q:
MapReduce on more than one datastore kind in Google App Engine
I just watched Batch data processing with App Engine session of Google I/O 2010, read some parts of MapReduce article from Google Research and now I am thinking to use MapReduce on Google App Engine to implement a recommender system in Python.
I prefer... | MapReduce on more than one datastore kind in Google App Engine | I just watched Batch data processing with App Engine session of Google I/O 2010, read some parts of MapReduce article from Google Research and now I am thinking to use MapReduce on Google App Engine to implement a recommender system in Python.
I prefer using appengine-mapreduce instead of Task Queue API because the for... | [
"Following Nick Johnson suggestion, I wrote my own InputReader. This reader fetch entities from two different kinds. It yields tuples with all combinations of these entities. Here it is:\nclass TwoKindsInputReader(InputReader):\n _APP_PARAM = \"_app\"\n _KIND1_PARAM = \"kind1\"\n _KIND2_PARAM = \"kind2\"\n... | [
3,
2
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"mapreduce",
"python",
"task_queue"
] | stackoverflow_0003766154_google_app_engine_google_cloud_datastore_mapreduce_python_task_queue.txt |
Q:
How to convert a special float into a fraction object
I have this function inside another function:
def _sum(k):
return sum([(-1) ** v * fractions.Fraction(str(bin_coeff(k, v))) * fractions.Fraction((n + v) ** m, k + 1) for v in xrange(k + 1)])
When i call fractions.Fraction on bin_coeff it reports me thi... | How to convert a special float into a fraction object | I have this function inside another function:
def _sum(k):
return sum([(-1) ** v * fractions.Fraction(str(bin_coeff(k, v))) * fractions.Fraction((n + v) ** m, k + 1) for v in xrange(k + 1)])
When i call fractions.Fraction on bin_coeff it reports me this error:
ValueError: Invalid literal for Fraction: '1.05204... | [
"I cannot reproduce your error in py3k, but you could pass your float straight to from_float class method:\n>>> fractions.Fraction.from_float(1.05204948186e+12)\nFraction(1052049481860, 1)\n\n",
"If you're curious, this is due (as you might expect) to the Fraction regex in fractions.py:\n_RATIONAL_FORMAT = re.com... | [
1,
1
] | [] | [] | [
"floating_point",
"fractions",
"python"
] | stackoverflow_0003978130_floating_point_fractions_python.txt |
Q:
Since Python doesn't have a switch statement, what should I use?
Possible Duplicate:
Replacements for switch statement in python?
I'm making a little console based application in Python and I wanted to use a Switch statement to handle the users choice of a menu selection.
What do you vets suggest I use. Thanks!
... | Since Python doesn't have a switch statement, what should I use? |
Possible Duplicate:
Replacements for switch statement in python?
I'm making a little console based application in Python and I wanted to use a Switch statement to handle the users choice of a menu selection.
What do you vets suggest I use. Thanks!
| [
"There are two choices, first is the standard if ... elif ... chain. The other is a dictionary mapping selections to callables (of functions are a subset). Depends on exactly what you're doing which one is the better idea.\nelif chain\n selection = get_input()\n if selection == 'option1':\n handle_option1()\... | [
12,
9,
8
] | [] | [] | [
"python",
"switch_statement"
] | stackoverflow_0003978624_python_switch_statement.txt |
Q:
Finding a strings in a text using regular expressions with Python
I have a text, in which only <b> and </b> has been used.for example<b>abcd efg-123</b> . Can can I extract the string between these tags? also I need to extract 3 words before and after this chunk of <b>abcd efg-123</b> string.
How can I do that? wh... | Finding a strings in a text using regular expressions with Python | I have a text, in which only <b> and </b> has been used.for example<b>abcd efg-123</b> . Can can I extract the string between these tags? also I need to extract 3 words before and after this chunk of <b>abcd efg-123</b> string.
How can I do that? what would be the suitable regular expression for this?
| [
"this will get what's in between the tags,\n>>> s=\"1 2 3<b>abcd efg-123</b>one two three\"\n>>> for i in s.split(\"</b>\"):\n... if \"<b>\" in i:\n... print i.split(\"<b>\")[-1]\n...\nabcd efg-123\n\n",
"This is actually a very dumb version and doesn't allow nested tags.\nre.search(r\"(\\w+)\\s+(\\w+)\\s+... | [
3,
1,
1,
0
] | [] | [] | [
"parsing",
"python",
"regex"
] | stackoverflow_0003978480_parsing_python_regex.txt |
Q:
Name isn't found in my Python application
keepProgramRunning = True
while keepProgramRunning:
print "Welcome to the Calculator!"
print "Please choose what you'd like to do:"
print "0: Addition"
print "1: Subtraction"
print "2: Multiplication"
print "3: Division"
#Capture the menu... | Name isn't found in my Python application | keepProgramRunning = True
while keepProgramRunning:
print "Welcome to the Calculator!"
print "Please choose what you'd like to do:"
print "0: Addition"
print "1: Subtraction"
print "2: Multiplication"
print "3: Division"
#Capture the menu choice.
choice = raw_input()
#Captur... | [
"You need to define your functions before calling them. \nWhen the interpreter reads the line where Addition() is called it hasn't yet reached the line where Addition() will be defined. It therefore throws an Exception.\n",
"Reorder your code, so that the functions will be defined before they're used:\ndef Additi... | [
8,
4,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0003978787_python.txt |
Q:
python serval variables combine into a dict?
All,
A class:
class foo():
def __init__(self):
self.avar1 = 0
self.bvar2 = 1
self.cvar3 = 3
def debug_info(self):
print "avar1:" avar1
print "bvar2:" bvar2
print "cvar3:" cvar3
my question, it is too complex to wr... | python serval variables combine into a dict? | All,
A class:
class foo():
def __init__(self):
self.avar1 = 0
self.bvar2 = 1
self.cvar3 = 3
def debug_info(self):
print "avar1:" avar1
print "bvar2:" bvar2
print "cvar3:" cvar3
my question, it is too complex to write the debug_info() if I got a lot of self.vars
,... | [
"def debug_info ( self ):\n for ( key, value ) in self.__dict__.items():\n print( key, '=', value )\n\n",
"Every Python object already has such a dictionary it is the self.__dict__ This prints reasonably well like and other Python dict, but you could control the format using the Data pretty printer in t... | [
3,
2,
1,
1,
1
] | [] | [] | [
"dictionary",
"python",
"variables"
] | stackoverflow_0003977408_dictionary_python_variables.txt |
Q:
SQLite equivalent of Python's "'%s %s' % (first_string, second_string)"
As the title says, what is the equivalent of Python's '%s %s' % (first_string, second_string) in SQLite? I know I can do concatenation like first_string || " " || second_string, but it looks very ugly.
A:
I can understand not liking first_st... | SQLite equivalent of Python's "'%s %s' % (first_string, second_string)" | As the title says, what is the equivalent of Python's '%s %s' % (first_string, second_string) in SQLite? I know I can do concatenation like first_string || " " || second_string, but it looks very ugly.
| [
"I can understand not liking first_string || ' ' || second_string, but that's the equivalent. Standard SQL (which SQLite speaks in this area) just isn't the world's prettiest string manipulation language. You could try getting the results of the query back into some other language (e.g., Python which you appear to ... | [
2,
2,
1,
0,
0
] | [] | [] | [
"python",
"sqlite",
"string"
] | stackoverflow_0003976313_python_sqlite_string.txt |
Q:
Regular Expressions - testing if a String contains another String
Suppose you have some this String (one line)
10.254.254.28 - - [06/Aug/2007:00:12:20 -0700] "GET
/keyser/22300/ HTTP/1.0" 302 528 "-"
"Mozilla/5.0 (X11; U; Linux i686
(x86_64); en-US; rv:1.8.1.4)
Gecko/20070515 Firefox/2.0.0.4"
and you wan... | Regular Expressions - testing if a String contains another String | Suppose you have some this String (one line)
10.254.254.28 - - [06/Aug/2007:00:12:20 -0700] "GET
/keyser/22300/ HTTP/1.0" 302 528 "-"
"Mozilla/5.0 (X11; U; Linux i686
(x86_64); en-US; rv:1.8.1.4)
Gecko/20070515 Firefox/2.0.0.4"
and you want to extract the part between the GET and HTTP (i.e., some url) but onl... | [
"No need regex\n>>> s\n'10.254.254.28 - - [06/Aug/2007:00:12:20 -0700] \"GET /keyser/22300/ HTTP/1.0\" 302 528 \"-\" \"Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4\"'\n\n>>> s.split(\"HTTP\")[0]\n'10.254.254.28 - - [06/Aug/2007:00:12:20 -0700] \"GET /keyser/22300/ '\n\... | [
5,
2,
1
] | [] | [] | [
"python",
"regex",
"string"
] | stackoverflow_0003978549_python_regex_string.txt |
Q:
How to schedule an event in python without multithreading?
Is it possible to schedule an event in python without multithreading?
I am trying to obtain something like scheduling a function to execute every x seconds.
A:
Maybe sched?
A:
You could use a combination of signal.alarm and a signal handler for SIGALRM... | How to schedule an event in python without multithreading? | Is it possible to schedule an event in python without multithreading?
I am trying to obtain something like scheduling a function to execute every x seconds.
| [
"Maybe sched?\n",
"You could use a combination of signal.alarm and a signal handler for SIGALRM like so to repeat the function every 5 seconds.\nimport signal\n\ndef handler(sig, frame):\n print (\"I am done this time\")\n signal.alarm(5) #Schedule this to happen again.\n\nsignal.signal(signal.SIGALRM, handle... | [
4,
3,
2,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0003978974_python.txt |
Q:
How to break out of double while loop in python?
Newbie python here. How can I break out of the second while loop if a user selects "Q" for "Quit?"
If I hit "m," it goes to the main menu and there I can quit hitting the "Q" key.
while loop == 1:
choice = main_menu()
if choice == "1":
os.system("cl... | How to break out of double while loop in python? | Newbie python here. How can I break out of the second while loop if a user selects "Q" for "Quit?"
If I hit "m," it goes to the main menu and there I can quit hitting the "Q" key.
while loop == 1:
choice = main_menu()
if choice == "1":
os.system("clear")
while loop == 1:
choice = a... | [
"You nearly have it; you just need to swap these two lines. \nelif choice.lower() == \"m\":\n break\n loop = 0\n\nelif choice.lower() == \"m\":\n loop = 0\n break\n\nYou break out of the nested loop before setting loop. :)\n",
"Change\nbreak\nloop = 0\n\nto\nloop = 0\nbreak\n\nin your elif blocks.\n... | [
5,
2,
2,
1,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0003978890_python.txt |
Q:
How to use python in windows to open javascript, have it interpreted by WScript, and pass it the command line arguments
I have a format holding paths to files and command line arguments to pass to those files when they are opened in Windows.
For example I might have a path to a javascript file and a list of comma... | How to use python in windows to open javascript, have it interpreted by WScript, and pass it the command line arguments | I have a format holding paths to files and command line arguments to pass to those files when they are opened in Windows.
For example I might have a path to a javascript file and a list of command line arguments to pass it, in such a case I want to open the javascript file in the same way you might with os.startfile a... | [
"If windows has registered the .js extension to open with wscript, you can do this, by leaving that decision up to the windows shell.\nYou can just use os.system() to do the same thing as you would do when you type it at the command prompt, for example:\nimport os\nos.system('example.js arg1 arg2')\n\nYou can also ... | [
2
] | [] | [] | [
"popen",
"process",
"python",
"windows"
] | stackoverflow_0003978542_popen_process_python_windows.txt |
Q:
How should I comment partial Python functions?
say I have the following code:
def func(x, y = 1, z = 2):
""" A comment about this function """
return x + y + z
another_func = partial(func, z = 4)
What would be the correct or Pythonic way of documenting the another_func function?
A:
See partial() descri... | How should I comment partial Python functions? | say I have the following code:
def func(x, y = 1, z = 2):
""" A comment about this function """
return x + y + z
another_func = partial(func, z = 4)
What would be the correct or Pythonic way of documenting the another_func function?
| [
"See partial() description on http://docs.python.org/library/functools.html#functools.partial\nLike this:\nanother_func.__doc__ = \"My documentation\"\n\n"
] | [
6
] | [] | [] | [
"comments",
"function",
"partial",
"python"
] | stackoverflow_0003979417_comments_function_partial_python.txt |
Q:
What's wrong with my Python SOAPpy webservice call?
I am playing around trying to call a simple SOAP webservice using the following code in the Python interpreter:
from SOAPpy import WSDL
wsdl = "http://www.webservicex.net/whois.asmx?wsdl"
proxy = WSDL.Proxy(wsdl)
proxy.soapproxy.config.dumpSOAPOut=1
proxy.soappro... | What's wrong with my Python SOAPpy webservice call? | I am playing around trying to call a simple SOAP webservice using the following code in the Python interpreter:
from SOAPpy import WSDL
wsdl = "http://www.webservicex.net/whois.asmx?wsdl"
proxy = WSDL.Proxy(wsdl)
proxy.soapproxy.config.dumpSOAPOut=1
proxy.soapproxy.config.dumpSOAPIn=1
proxy.GetWhoIS(HostName="google.co... | [
"Your call seems all right to me, i think this could be a soappy problem or misconfigured server (although i have not checked this thoroughly).\nThis document also suggests incompatibilities between soappy and webservicex.net:\nhttp://users.jyu.fi/~mweber/teaching/ITKS545/exercises/ex5.pdf\nHow i would work around ... | [
3,
2,
1,
0
] | [] | [] | [
"python",
"soappy",
"wsdl"
] | stackoverflow_0000679302_python_soappy_wsdl.txt |
Q:
How can I use Python to get the contents inside of this span tag?
I'm trying to scrape the information from Google Translate as a learning exercise and I can't figure out how to reach the content of this span tag.
<span title="Hello" onmouseover="this.style.backgroundColor='#ebeff9'" ... | How can I use Python to get the contents inside of this span tag? | I'm trying to scrape the information from Google Translate as a learning exercise and I can't figure out how to reach the content of this span tag.
<span title="Hello" onmouseover="this.style.backgroundColor='#ebeff9'"
onmouseout="this.style.backgroundColor='#fff'">
Hallo
</s... | [
"Checkout BeautifulSoup\n",
"# -*- coding: utf-8 -*-\ndef gettext(html):\n for sp in myhtml.split(\"</span>\"):\n if \"<span\" in sp:\n return sp.rsplit(\">\")[-1].strip()\n\nmyhtml=\"\"\"\n<span title=\"Hello\" onmouseover=\"this.style.backgroundColor='#ebeff9'\"\n onmouseout=\"this.style.... | [
3,
0,
0
] | [] | [] | [
"html_parsing",
"python"
] | stackoverflow_0003979962_html_parsing_python.txt |
Q:
Widgets disappear after tkMessageBox in Tkinter
Every time I use this code in my applications:
tkMessageBox.showinfo("Test", "Info goes here!")
a message box pops up (like it is supposed to), but after I click OK, the box disappears along with most of the other widgets on the window. How do I prevent the other wi... | Widgets disappear after tkMessageBox in Tkinter | Every time I use this code in my applications:
tkMessageBox.showinfo("Test", "Info goes here!")
a message box pops up (like it is supposed to), but after I click OK, the box disappears along with most of the other widgets on the window. How do I prevent the other widgets from disappearing?
Here Is My Code:
from Tkint... | [
"Ok, there are a few things going wrong here. First, your label has no string or image associated with it. Therefore, it's width and height will be very small. Because you use pack, the containing widget (the root window) will \"shrink to fit\" around this widget and any other widgets you pack in the root window.\n... | [
1
] | [] | [] | [
"python",
"tkinter",
"tkmessagebox",
"widget",
"windows"
] | stackoverflow_0003974512_python_tkinter_tkmessagebox_widget_windows.txt |
Q:
Negative lookbehind in Python regular expressions
I am trying to parse a list of data out of a file using python - however I don't want to extract any data that is commented out. An example of the way the data is structured is:
#commented out block
uncommented block
# commented block
I am trying to only retriev... | Negative lookbehind in Python regular expressions | I am trying to parse a list of data out of a file using python - however I don't want to extract any data that is commented out. An example of the way the data is structured is:
#commented out block
uncommented block
# commented block
I am trying to only retrieve the middle item, so am trying to exclude the items wi... | [
"Why using regex? String methods would do just fine:\n>>> s = \"\"\"#commented out block\nuncommented block\n# commented block\n\"\"\".splitlines()\n>>> for line in s:\n not line.lstrip().startswith('#')\n\n\nFalse\nTrue\nFalse\n\n",
"As SilentGhost indicated, a regular expression isn't the best solution to ... | [
6,
4,
0
] | [] | [] | [
"python",
"regex",
"string"
] | stackoverflow_0003980213_python_regex_string.txt |
Q:
higher level Python GUI toolkit, e.g. pass dict for TreeView/Grid
Started my first Python pet project using PyGTK. Though it is a really powerful GUI toolkit and looks excellent, I have some pet peeves. So I thought about transitioning to something else, as it's not yet too extensive. Had a look around on SO and p... | higher level Python GUI toolkit, e.g. pass dict for TreeView/Grid | Started my first Python pet project using PyGTK. Though it is a really powerful GUI toolkit and looks excellent, I have some pet peeves. So I thought about transitioning to something else, as it's not yet too extensive. Had a look around on SO and python documentation, but didn't get a good overview.
What's nice about ... | [
"Try Kiwi, maybe? Especially with its ObjectList.\nUpdate: I think Kiwi development has moved to PyGTKHelpers.\n",
"I hadn't come across Kiwi before. Thanks, Johannes Sasongko.\nHere are some more tooklits that I keep bookmarked. Some of these are wrappers around other toolkits (GTK, wxWidgets) while others sta... | [
5,
4,
3,
1
] | [] | [] | [
"gtk",
"pygtk",
"python",
"user_interface"
] | stackoverflow_0003136128_gtk_pygtk_python_user_interface.txt |
Q:
How to check the values in a instance with Python?
I have a python class/object as follows.
class Hello:
def __init__(self):
self.x = None
self.y = None
self.z = None
h = Hello()
h.x = 10
h.y = 20
# h.z is not set
I need to check if all the member variables are set (not None). How can... | How to check the values in a instance with Python? | I have a python class/object as follows.
class Hello:
def __init__(self):
self.x = None
self.y = None
self.z = None
h = Hello()
h.x = 10
h.y = 20
# h.z is not set
I need to check if all the member variables are set (not None). How can I do that automatically?
for value in ??memeber varia... | [
"class Hello(object):\n def __init__(self):\n self.x = None\n self.y = None\n self.z = None\n def is_all_set(self):\n return all(getattr(self, attr) is not None for attr in self.__dict__)\n\nthough, as @delnan said, you should prefer to make it impossible for the class to always be... | [
3,
0
] | [] | [] | [
"member",
"python"
] | stackoverflow_0003980374_member_python.txt |
Q:
How can my desktop application be notified of a state change on a remote server?
I'm creating a desktop application that requires authorization from a remote server before performing certain actions locally.
What's the best way to have my desktop application notified when the server approves the request for autho... | How can my desktop application be notified of a state change on a remote server? | I'm creating a desktop application that requires authorization from a remote server before performing certain actions locally.
What's the best way to have my desktop application notified when the server approves the request for authorization? Authorization takes 20 seconds average on, 5 seconds minimum, with a 120 sec... | [
"Does the remote end block while it does the authentication? If so, you can use a simple select to block till it returns.\nAnother way I can think of is to pass a callback URL to the authentication server asking it to call it when it's done so that your client app can proceed. Something like a webhook.\n",
"You n... | [
0,
0
] | [] | [] | [
"authentication",
"authorization",
"polling",
"python",
"web.py"
] | stackoverflow_0003978739_authentication_authorization_polling_python_web.py.txt |
Q:
rotating tire rims of car opengl transformations
Here is the draw function which draws the parts of the car, in this function car rims is checked and flag is checked, and i need to rotate the tire rim as i move the car. Something is not working since the rims are rotated but taken out from the car model, when i pr... | rotating tire rims of car opengl transformations | Here is the draw function which draws the parts of the car, in this function car rims is checked and flag is checked, and i need to rotate the tire rim as i move the car. Something is not working since the rims are rotated but taken out from the car model, when i press up arrow key, but the car does move.
I also initia... | [
"I would highly suggest posting this to the class forum. I don't think TJ would really like to see this, and its very easy to find.\n",
"You're almost certainly applying the rotation and transformation in the wrong order, so that the rim is rotated about some point other than the center of the tire.\nYou might tr... | [
2,
1,
1
] | [] | [] | [
"opengl",
"python"
] | stackoverflow_0003950829_opengl_python.txt |
Q:
Extract all
Could someone tell me how I can extract and remove all the <script> tags in a HTML document and add them to the end of the document, right before the </body></html>? I'd like to try and avoid using lxml please.
Thanks.
A:
The answer is simple and may miss many nuances. How ever, this should give you... | Extract all | Could someone tell me how I can extract and remove all the <script> tags in a HTML document and add them to the end of the document, right before the </body></html>? I'd like to try and avoid using lxml please.
Thanks.
| [
"The answer is simple and may miss many nuances. How ever, this should give you an idea of how to go about doing it, improving it in general. I am sure this can be improved but you should be able to do that quickly with help of the documentation.\nReference doc: http://www.crummy.com/software/BeautifulSoup/document... | [
6
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0003980740_beautifulsoup_python.txt |
Q:
Pickling an enum exposed by Boost.Python
Is it possible to pickle (using cPickle) an enum that has been exposed with Boost.Python? I have successfully pickled other objects using the first method described here, but none of that seems to apply for an enum type, and the objects don't seem to be pickleable by defaul... | Pickling an enum exposed by Boost.Python | Is it possible to pickle (using cPickle) an enum that has been exposed with Boost.Python? I have successfully pickled other objects using the first method described here, but none of that seems to apply for an enum type, and the objects don't seem to be pickleable by default.
| [
"Not as they are in the module. I am given to understand that this is SUPPOSED to be possible, but the way the enum_ statement works prevents this. \nYou can work around this on the python side. Somewhere (probably in a __init__.py file) do something like this:\nimport yourmodule\n\ndef isEnumType(o):\n return i... | [
6
] | [] | [] | [
"boost_python",
"pickle",
"python"
] | stackoverflow_0003214969_boost_python_pickle_python.txt |
Q:
Reference encoding error byte in Python
Suppose I type line = line.decode('gb18030;) and get the error
UnicodeDecodeError: 'gb18030' codec can't decode bytes in position 142-143: illegal multibyte sequence
Is there a nice way to automatically get the error bytes? That is, is there a way to get 142 & 143 or line[1... | Reference encoding error byte in Python | Suppose I type line = line.decode('gb18030;) and get the error
UnicodeDecodeError: 'gb18030' codec can't decode bytes in position 142-143: illegal multibyte sequence
Is there a nice way to automatically get the error bytes? That is, is there a way to get 142 & 143 or line[142:144] from a built-in command or module? Si... | [
"try:\n line = line.decode('gb18030')\nexcept UnicodeDecodeError, e:\n print \"Error in bytes %d through %d\" % (e.start, e.end)\n\n",
"Access the start and end attributes of the caught exception object.\nu = u'áiuê©'\ntry:\n l = u.encode('latin-1')\n print repr(l)\n l.decode('utf-8')\nexcept UnicodeDeco... | [
2,
1
] | [] | [] | [
"encoding",
"python"
] | stackoverflow_0003980972_encoding_python.txt |
Q:
Yet another python import issue of mine
Looks like I am having a real tough day with python imports.I am using Flask and am trying to organise my app structure.I am using it on GAE and thus have to put python packages in my app itself. It looks something like this below:-
-MyFolder
-flask
-werkzeug
-Myapp
... | Yet another python import issue of mine | Looks like I am having a real tough day with python imports.I am using Flask and am trying to organise my app structure.I am using it on GAE and thus have to put python packages in my app itself. It looks something like this below:-
-MyFolder
-flask
-werkzeug
-Myapp
- __init__.py
-templates
-static
... | [
"sys.path.append could also fit your purpose.\n",
"Smells like you want to be using a relative import.\nfrom .base import ...\n\n"
] | [
1,
0
] | [] | [] | [
"import",
"python"
] | stackoverflow_0003980717_import_python.txt |
Q:
Dynamic filenames
So I'm working on a program where I store data into multiple .txt files. The naming convention I want to use is file"xx" where the Xs are numbers, so file00, file01, ... all the way up to file20, and I want the variables assigned to them to be fxx (f00, f01, ...).
How would I access these files i... | Dynamic filenames | So I'm working on a program where I store data into multiple .txt files. The naming convention I want to use is file"xx" where the Xs are numbers, so file00, file01, ... all the way up to file20, and I want the variables assigned to them to be fxx (f00, f01, ...).
How would I access these files in Python using a for lo... | [
"The names are regular. You can create the list of filenames with a simple list comprehension.\n[\"f%02d\"%x for x in range(1,21)]\n\n",
"Look into python's glob module. \nIt uses the usual shell wildcard syntax, so ?? would match any two characters, while * would match anything. You could use either f??.txt or ... | [
5,
1,
1,
1,
0
] | [] | [] | [
"filenames",
"python"
] | stackoverflow_0003484348_filenames_python.txt |
Q:
How to check if MAX has finished loading
I am trying to instantiate a program via a python script as follows
os.startfile( '"C:/Program Files/Autodesk/3ds Max 2010/3dsmax.exe"' )
since 3dsMax takes a bit of time to load, I wanna wait till it has finished loading completely. I check the task manager to see if 3dsm... | How to check if MAX has finished loading | I am trying to instantiate a program via a python script as follows
os.startfile( '"C:/Program Files/Autodesk/3ds Max 2010/3dsmax.exe"' )
since 3dsMax takes a bit of time to load, I wanna wait till it has finished loading completely. I check the task manager to see if 3dsmax10.exe is in the list, but it's in the list ... | [
"Here is a bit of a hackish (not robust) solution. Starti 3ds Max with a MAXScript script on the command-line. For example\nc:\\3dsmax\\3dsmax -U MAXScript myscript.ms\n\nAs Parceval suggests, this script can create a new file using the MAXScript command:\ncreateFile c:\\tmp\\myfile.txt\n\nNext in Python wait until... | [
2,
1,
1
] | [] | [] | [
"3dsmax",
"python"
] | stackoverflow_0002927049_3dsmax_python.txt |
Q:
Python metaprogramming for XML parsing
I'm trying to create a simple XML parser where each different XML schema has it's own parser class but I can't figure out what the best way is. What I in effect would like to do is something like this:
in = sys.stdin
xmldoc = minidom.parse(in).documentElement
xmlParser = xml... | Python metaprogramming for XML parsing | I'm trying to create a simple XML parser where each different XML schema has it's own parser class but I can't figure out what the best way is. What I in effect would like to do is something like this:
in = sys.stdin
xmldoc = minidom.parse(in).documentElement
xmlParser = xmldoc.nodeName
parser = xmlParser()
out = pars... | [
"I think most python programmers would just use lxml to parse their xml. If you still want to wrap that in classes you could, but as delnan said in his comment, it's a bit unclear what you really mean.\nfrom lxml import etree\n\ntree = etree.parse('my_doc.xml')\nfor element in tree.getroot():\n ...\n\nA couple ... | [
1,
1
] | [] | [] | [
"metaprogramming",
"python",
"xml"
] | stackoverflow_0003618246_metaprogramming_python_xml.txt |
Q:
how to input python code in run time and execute it?
Well i want to input a python function as an input in run time and execute that part of code 'n' no of times. For example using tkinter i create a textbox where the user writes the function and submits it , also mentioning how many times it wants to be executed... | how to input python code in run time and execute it? | Well i want to input a python function as an input in run time and execute that part of code 'n' no of times. For example using tkinter i create a textbox where the user writes the function and submits it , also mentioning how many times it wants to be executed. My program should be able to run that function as many t... | [
"Python provides number of ways to do this using function calls:\n- eval()\n- exec()\nFor your needs you should read about exec.\n",
"That's what execfile() is for.\nhttp://docs.python.org/library/functions.html#execfile\n\nCreate a temporary file.\nWrite the content of the textbox into the file.\nClose.\nExecfil... | [
2,
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0003981357_python.txt |
Q:
PySide or PyQT SQLite support in Ubuntu
I am running Ubuntu 10.04 Lucid and am developing a application in QT using Python. Today I tried to create a database binding to a SQLite database via QtSQL.QAddDatabase and got the following error:
QSqlDatabase: QSQLITE driver not loaded
QSqlDatabase: available drivers: QM... | PySide or PyQT SQLite support in Ubuntu | I am running Ubuntu 10.04 Lucid and am developing a application in QT using Python. Today I tried to create a database binding to a SQLite database via QtSQL.QAddDatabase and got the following error:
QSqlDatabase: QSQLITE driver not loaded
QSqlDatabase: available drivers: QMYSQL3 QMYSQL
So obviously I don't have the S... | [
"Does this help?\n$> apt-cache search qt mysql\nlibqt3-mt-mysql - MySQL database driver for Qt3 (Threaded)\nqtstalker - commodity and stock market charting and technical analysis\ntora - A graphical toolkit for database developers and administrators\nlibqt4-sql-mysql - Qt 4 MySQL database driver\n\nSounds like the ... | [
3,
1
] | [] | [] | [
"pyqt",
"pyside",
"python",
"sqlite",
"ubuntu"
] | stackoverflow_0003980974_pyqt_pyside_python_sqlite_ubuntu.txt |
Q:
Serving static files with apache and mod_wsgi without changing apache's configuration?
I have a Django application, and I'm using a shared server hosting, so I cannot change apache's config files. The only thing that I can change is the .htaccess file in my application. I also have a standard django.wsgi python fi... | Serving static files with apache and mod_wsgi without changing apache's configuration? | I have a Django application, and I'm using a shared server hosting, so I cannot change apache's config files. The only thing that I can change is the .htaccess file in my application. I also have a standard django.wsgi python file, as an entry point.
In dev environment, I'm using Django to serve the static files, but i... | [
"The first step is to add just\nAddHandler wsgi-script .wsgi\n\nto your .htaccess file with nothing else to establish wsgi as the handler. This will make requests to django.wsgi and django.wsgi/whatever go to your django app.\nTo make the django.wsgi part of the URL go away, you will need to use mod_rewrite. Hopefu... | [
2,
1
] | [] | [] | [
".htaccess",
"apache",
"django",
"mod_wsgi",
"python"
] | stackoverflow_0003981267_.htaccess_apache_django_mod_wsgi_python.txt |
Q:
How do I use an external .py file?
I downloaded beautifulsoup.py for use on a little project I'm making. Do I need to import this .py file in my project?
Do I just copy and paste the code somewhere inside my current python script?
Thank you for the help.
I found this but it doesn't say anything regarding Windows.... | How do I use an external .py file? | I downloaded beautifulsoup.py for use on a little project I'm making. Do I need to import this .py file in my project?
Do I just copy and paste the code somewhere inside my current python script?
Thank you for the help.
I found this but it doesn't say anything regarding Windows.
http://mail.python.org/pipermail/tutor... | [
"If it's in the same directory as your little project, all you should need to do is:\nimport BeautifulSoup\n\nIf you are keeping it in some other directory, the easiest way to do it is:\nfrom sys import path\npath.append(path_to_Beautiful_Soup)\n\nimport BeautifulSoup\n\nPython keeps track of where it is currently,... | [
11,
5,
2,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0003980059_python.txt |
Q:
Parser generation
i am doing a project on SOFWARE PLAGIARISM DETECTION..i am intended to do it with language C..for that i am supposed to create a token generator, and a parser..but i dont know where to start..any one can help me out with this..
i created a database of tokens and i separated the tokens from my pro... | Parser generation | i am doing a project on SOFWARE PLAGIARISM DETECTION..i am intended to do it with language C..for that i am supposed to create a token generator, and a parser..but i dont know where to start..any one can help me out with this..
i created a database of tokens and i separated the tokens from my program.Next thing i wanna... | [
"If you want to create a parser in Python you can look at these libraries:\nPLY\npyparsing\nand Lepl - new but very powerful\n",
"Building a real C parser by yourself is a really big task.\nI suggest you either find one that is already done, eg. pycparser or you define a really simple subset of C that is easily p... | [
3,
1,
0
] | [] | [] | [
"parsing",
"plagiarism_detection",
"python"
] | stackoverflow_0003976665_parsing_plagiarism_detection_python.txt |
Q:
How can I deal with accented letters, german letters and other characters?
My python script is working now, but I'm having a little trouble:
Here is the output:
from BeautifulSoup import BeautifulSoup
import urllib
langCode={
"arabic":"ar", "bulgarian":"bg", "chinese":"zh-CN",
"croatian":"hr", "czech":"cs... | How can I deal with accented letters, german letters and other characters? | My python script is working now, but I'm having a little trouble:
Here is the output:
from BeautifulSoup import BeautifulSoup
import urllib
langCode={
"arabic":"ar", "bulgarian":"bg", "chinese":"zh-CN",
"croatian":"hr", "czech":"cs", "danish":"da", "dutch":"nl",
"english":"en", "finnish":"fi", "french":"fr... | [
"Don't parse http://translate.google.com/translate_t since Google provides an AJAX service for this purpose. The translatedText in the json data returned by ajax.googleapis.com is already a unicode string. \nimport urllib2\nimport urllib\nimport sys\nimport json\n\nLANG={\n \"arabic\":\"ar\", \"bulgarian\":\"bg\... | [
1,
0
] | [] | [] | [
"python",
"unicode"
] | stackoverflow_0003981732_python_unicode.txt |
Q:
Question regarding python profiling
I'm trying to do profiling of my application in python. I'm using the cProfile library. I need to profile the onFrame function of my application, but this is called by an outside application. I've tried loads of things, but at the moment I have the following in my onFrame method... | Question regarding python profiling | I'm trying to do profiling of my application in python. I'm using the cProfile library. I need to profile the onFrame function of my application, but this is called by an outside application. I've tried loads of things, but at the moment I have the following in my onFrame method:
runProfiler(self)
and then outside of ... | [
"In that case, you should pass the necessary context to cProfile.runctx:\ncProfile.runctx(\"doProfile()\", globals(), locals(), \"profile.log\")\n\n",
"An alternative is to use the runcall method of a Profile object.\nprofiler = cProfile.Profile()\nprofiler.runcall(doProfile)\nprofiler.dump_stats(\"profile.log\")... | [
1,
0
] | [] | [] | [
"profiling",
"python"
] | stackoverflow_0003981569_profiling_python.txt |
Q:
performance of modules in Python
Which is the best: create the modules and put them in a separate file and import them or put them all together in the same file?
Is there any significant difference?
A:
Same as disscussion on .py and .pyc. Having modules allows you to load them faster through precompiled module... | performance of modules in Python | Which is the best: create the modules and put them in a separate file and import them or put them all together in the same file?
Is there any significant difference?
| [
"Same as disscussion on .py and .pyc. Having modules allows you to load them faster through precompiled modules. How ever negligible, this adds to performance. Though execution speed remains the same.\nPlease look at the following for a detailed answer. Repeating it is not useful.\n\nWhat is the difference between ... | [
3
] | [] | [] | [
"performance",
"python"
] | stackoverflow_0003982021_performance_python.txt |
Q:
How can i extract files using custom names with zipfile module from python?
I want to add suffix to names of my files, for example uuid. How can i extract files using zipfile and pass custom names?
A:
Use ZipFile.open() to open a read-only file-like to the file data, then copy it to a write-only file with the co... | How can i extract files using custom names with zipfile module from python? | I want to add suffix to names of my files, for example uuid. How can i extract files using zipfile and pass custom names?
| [
"Use ZipFile.open() to open a read-only file-like to the file data, then copy it to a write-only file with the correct name using shutil.copyfileobj().\n",
"Step 1: Extract the files.\nStep 2: Rename them.\n"
] | [
4,
0
] | [] | [] | [
"python",
"python_zipfile"
] | stackoverflow_0003982034_python_python_zipfile.txt |
Q:
cron-like recurring task scheduler design
Say you want to schedule recurring tasks, such as:
Send email every wednesday at 10am
Create summary on the first day of every month
And you want to do this for a reasonable number of users in a web app - ie. 100k users each user can decide what they want scheduled when.... | cron-like recurring task scheduler design | Say you want to schedule recurring tasks, such as:
Send email every wednesday at 10am
Create summary on the first day of every month
And you want to do this for a reasonable number of users in a web app - ie. 100k users each user can decide what they want scheduled when.
And you want to ensure that the scheduled item... | [
"There's 2 designs, basically.\nOne runs regularly and compares the current time to the scheduling spec (i.e. \"Does this run now?\"), and executes those that qualify.\nThe other technique takes the current scheduling spec and finds the NEXT time that the item should fire. Then, it compares the current time to all ... | [
7,
4,
2
] | [] | [] | [
"cron",
"python",
"scheduling"
] | stackoverflow_0003980782_cron_python_scheduling.txt |
Q:
Django ImageField: files dont get uploaded
I implemented some ImageFields in my model and installed PIL (not the cleanest install). Things seem to work as I get an upload button in the admin and when I call the .url property in the view I get the string with the filename + its upload property.
The problem is that ... | Django ImageField: files dont get uploaded | I implemented some ImageFields in my model and installed PIL (not the cleanest install). Things seem to work as I get an upload button in the admin and when I call the .url property in the view I get the string with the filename + its upload property.
The problem is that the file is not there, apparently it doesnt get ... | [
"Make sure that you're binding request.FILES to the form when POSTing, and that the form is declared as multi-part in the template\nHere's the view from one of my applications:\n@login_required\ndef submit(request):\n if request.method == 'POST':\n (Photo.objects.count()+1, request.FILES['photo'].name.spl... | [
1
] | [] | [] | [
"django",
"django_admin",
"django_models",
"python",
"python_imaging_library"
] | stackoverflow_0003981451_django_django_admin_django_models_python_python_imaging_library.txt |
Q:
Getting The Most Recent Data Item - Google App Engine - Python
I need to retrieve the most recent item added to a collection. Here is how I'm doing it:
class Box(db.Model):
ID = db.IntegerProperty()
class Item(db.Model):
box = db.ReferenceProperty(Action, collection_name='items')
date = db.DateTimePro... | Getting The Most Recent Data Item - Google App Engine - Python | I need to retrieve the most recent item added to a collection. Here is how I'm doing it:
class Box(db.Model):
ID = db.IntegerProperty()
class Item(db.Model):
box = db.ReferenceProperty(Action, collection_name='items')
date = db.DateTimeProperty(auto_now_add=True)
#get most recent item
lastItem = box.items... | [
"If you are going to iterate over a list of boxes, that is a very bad way to do it. You will run an additional query for every box. You can easily see what is going on with Appstats.\nIf you are doing one of those per request, it may be ok. But it is not ideal. you might also want to use: lastItem = box.items.... | [
4
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"gql",
"python"
] | stackoverflow_0003981997_google_app_engine_google_cloud_datastore_gql_python.txt |
Q:
Python: How do I redirect this output?
I'm calling rtmpdump via subprocess and trying to redirect its output to a file. The problem is that I simply can't redirect it.
I tried first setting up the sys.stdout to the opened file. This works for, say, ls, but not for rtmpdump. I also tried setting the sys.stderr just... | Python: How do I redirect this output? | I'm calling rtmpdump via subprocess and trying to redirect its output to a file. The problem is that I simply can't redirect it.
I tried first setting up the sys.stdout to the opened file. This works for, say, ls, but not for rtmpdump. I also tried setting the sys.stderr just to make sure and it also didn't work.
I tri... | [
"sys.stdout is the python's idea of the parent's output stream.\nIn any case you want to change the child's output stream.\nsubprocess.call and subprocess.Popen take named parameters for the output streams.\nSo open the file you want to output to and then pass that as the appropriate argument to subprocess.\nf = op... | [
21,
1
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0003982577_python_subprocess.txt |
Q:
Consequences of changing __type__
I'm attempting to create what a believe (in my ignorance) is known as a class factory. Essentially, I've got a parent class that I'd like to take an __init__ argument and become one of several child classes. I found an example of this recommended on StackOverflow here, and it look... | Consequences of changing __type__ | I'm attempting to create what a believe (in my ignorance) is known as a class factory. Essentially, I've got a parent class that I'd like to take an __init__ argument and become one of several child classes. I found an example of this recommended on StackOverflow here, and it looks like this:
class Vehicle(object):
d... | [
"I think a class factory is defined as a callable that returns a class (not an instance):\ndef vehicle_factory(vtype):\n if vtype == 'c':\n return Car\n if vtype == 't':\n return Truck\n\nVehicleClass = vehicle_factory(c)\nvehicle_instance_1 = VehicleClass(*args, **kwargs)\nVehicleClass = vehicl... | [
1
] | [
"Don't do it this way. Override __new__() instead.\n"
] | [
-1
] | [
"factory",
"python",
"types"
] | stackoverflow_0003982566_factory_python_types.txt |
Q:
How to create QString in PyQt4?
>>> from PyQt4 import QtCore
>>> str = QtCore.QString('Hello')
AttributeError: 'module' object has no attribute 'QString'
>>> QtCore.QString._init_(self)
AttributeError: 'module' object has no attribute 'QString'
Yes, I've read QString Class Reference
Why can't I import QString ... | How to create QString in PyQt4? | >>> from PyQt4 import QtCore
>>> str = QtCore.QString('Hello')
AttributeError: 'module' object has no attribute 'QString'
>>> QtCore.QString._init_(self)
AttributeError: 'module' object has no attribute 'QString'
Yes, I've read QString Class Reference
Why can't I import QString from QtCore, as specified in the docs... | [
"In Python 3, QString is automatically mapped to the native Python string by default:\n\nThe QString class is implemented as a mapped type that is automatically converted to and from a Python string. In addition a None is converted to a null QString. However, a null QString is converted to an empty Python string (a... | [
19,
18,
9,
2
] | [] | [] | [
"pyqt",
"python",
"user_interface"
] | stackoverflow_0001400858_pyqt_python_user_interface.txt |
Q:
Structuring Django Many-to-Many Relation
In writing an application for my school's yearbook committee, I've hit a bit of a dead end with modeling a specific relation. Currently I have a photo class
class Photo(models.Model):
photo = models.ImageField(upload_to="user_photos/")
name = models.CharField(blank=True, ... | Structuring Django Many-to-Many Relation | In writing an application for my school's yearbook committee, I've hit a bit of a dead end with modeling a specific relation. Currently I have a photo class
class Photo(models.Model):
photo = models.ImageField(upload_to="user_photos/")
name = models.CharField(blank=True, max_length=50)
rating = models.IntegerField(... | [
"You want a through table.\n",
"you want to have a many-to-many field, but custom defined.\n\nclass Rating(models.Model):\n photo = models.ForeignKey(Photo)\n user = models.ForeignKey(User)\n rating = models.IntegerField(default=1500)\n\nclass Photo(models.Model):\n photo = models.ImageField(upload_to... | [
2,
1,
0,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0003982260_django_django_models_python.txt |
Q:
python on xp: errno 13 permission denied - limits to number of files in folder?
I'm running Python 2.6.2 on XP. I have a large number of text files (100k+) spread across several folders that I would like to consolidate in a single folder on an external drive.
I've tried using shutil.copy() and shutil.copytree() an... | python on xp: errno 13 permission denied - limits to number of files in folder? | I'm running Python 2.6.2 on XP. I have a large number of text files (100k+) spread across several folders that I would like to consolidate in a single folder on an external drive.
I've tried using shutil.copy() and shutil.copytree() and distutils.file_util.copy_file() to copy files from source to destination. None of t... | [
"Are you using FAT32? The maximum number of directory entries in a FAT32 folder is is 65.534. If a filename is longer than 8.3, it will take more than one directory entry. If you are conking out at 13,106, this indicates that each filename is long enough to require five directory entries.\nSolution: Use an NTFS vo... | [
2,
0,
0
] | [] | [] | [
"python",
"windows_xp"
] | stackoverflow_0003982881_python_windows_xp.txt |
Q:
How to add xml header to dom object
I'm using Python's xml.dom.minidom but I think the question is valid for any DOM parser.
My original file has a line like this at the beginning:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
This doesn't seem to be part of the dom, so when I do something like dom.toxm... | How to add xml header to dom object | I'm using Python's xml.dom.minidom but I think the question is valid for any DOM parser.
My original file has a line like this at the beginning:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
This doesn't seem to be part of the dom, so when I do something like dom.toxml() the resulting string have not line a... | [
"\nThis doesn't seem to be part of the dom\n\nThe XML Declaration doesn't get a node of its own, no, but the properties declared in it are visible on the Document object:\n>>> doc= minidom.parseString('<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><a/>')\n>>> doc.encoding\n'utf-8'\n>>> doc.standalone... | [
2
] | [] | [] | [
"dom",
"python",
"xml"
] | stackoverflow_0003982887_dom_python_xml.txt |
Q:
Always return proper URL no matter what the user enters?
I have the following python code
from urlparse import urlparse
def clean_url(url):
new_url = urlparse(url)
if new_url.netloc == '':
return new_url.path.strip().decode()
else:
return new_url.netloc.strip().decode()
print clean_url(... | Always return proper URL no matter what the user enters? | I have the following python code
from urlparse import urlparse
def clean_url(url):
new_url = urlparse(url)
if new_url.netloc == '':
return new_url.path.strip().decode()
else:
return new_url.netloc.strip().decode()
print clean_url("http://www.facebook.com/john.doe")
print clean_url("http://fa... | [
"I know this answer is a little late to the party, but if this is exactly what you're trying to do, I recommend a slightly different approach. Rather than reinventing the wheel for canonicalizing facebook urls, consider using the work that Google has already done for use with their Social Graph API.\nThey've alread... | [
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0003938674_python.txt |
Q:
rename files with python - regex
I am wanting to rename 1k files using python. they are all in the format somejunkDATE.doc
basically, I would like to delete all the junk, and only leave the date. I am unsure how to match this for all files in a directory.
thanks
A:
If your date format is the same throughout, jus... | rename files with python - regex | I am wanting to rename 1k files using python. they are all in the format somejunkDATE.doc
basically, I would like to delete all the junk, and only leave the date. I am unsure how to match this for all files in a directory.
thanks
| [
"If your date format is the same throughout, just use slicing\n>>> file=\"someJunk20101022.doc\"\n>>> file[-12:]\n'20101022.doc'\n>>> import os\n>>> os.rename(file, file[-12:]\n\nIf you want to check if the numbers are valid dates, pass file[-12:-3] to time or datetime module to check.\nSay your files are all in a ... | [
8
] | [] | [] | [
"file",
"python",
"regex",
"rename"
] | stackoverflow_0003983309_file_python_regex_rename.txt |
Q:
Check facebook object type
In my app, I have a form where user should submit a facebook page URL.
How to check that it's correct?
Presently, I'm just checking that it begins with 'http://www.facebook.com'
How can I check that it is a page (where you can become a fan) and not a profile, event or whatever?
I'm using... | Check facebook object type | In my app, I have a form where user should submit a facebook page URL.
How to check that it's correct?
Presently, I'm just checking that it begins with 'http://www.facebook.com'
How can I check that it is a page (where you can become a fan) and not a profile, event or whatever?
I'm using the python api and appengine.
T... | [
"You could hit up the graph api with the id and see what you get back.\nhttps://graph.facebook.com/{OBJECTID}\n"
] | [
0
] | [] | [] | [
"facebook",
"python"
] | stackoverflow_0003983168_facebook_python.txt |
Q:
Python Class Decorator
I am trying to decorate an actual class, using this code:
def my_decorator(cls):
def wrap(*args, **kw):
return object.__new__(cls)
return wrap
@my_decorator
class TestClass(object):
def __init__(self):
print "__init__ should run if object.__new__ correctly return... | Python Class Decorator | I am trying to decorate an actual class, using this code:
def my_decorator(cls):
def wrap(*args, **kw):
return object.__new__(cls)
return wrap
@my_decorator
class TestClass(object):
def __init__(self):
print "__init__ should run if object.__new__ correctly returns an instance of cls"
test... | [
"__init__ isn't running because object.__new__ doesn't know to call it. If you change it to \ncls.__call__(*args, **kwargs), or better, cls(*args, **kwargs), it should work. Remember that a class is a callable: calling it produces a new instance. Just calling __new__ returns an instance but doesn't go through the i... | [
10,
0
] | [] | [] | [
"decorator",
"python"
] | stackoverflow_0003983378_decorator_python.txt |
Q:
CSRF error in Django; How can I add CSRF to my login view?
I have a simple form I want users to be able to log into; here is the template code with the CSRF tag in it:
<html>
<head><title>My Site</title></head>
<body>
<form action="" method="post">{% csrf_token %}
<label for="username">User name:</lab... | CSRF error in Django; How can I add CSRF to my login view? | I have a simple form I want users to be able to log into; here is the template code with the CSRF tag in it:
<html>
<head><title>My Site</title></head>
<body>
<form action="" method="post">{% csrf_token %}
<label for="username">User name:</label>
<input type="text" name="username" value="" id="user... | [
"You have to add the RequestContext to the view that renders the page with the {% csrf_token %} line in it. Here is the example from the tutorial:\n# The {% csrf_token %} tag requires information from the request object, which is \n# not normally accessible from within the template context. To fix this, \n# a smal... | [
5
] | [] | [] | [
"csrf",
"django",
"django_csrf",
"python"
] | stackoverflow_0003983474_csrf_django_django_csrf_python.txt |
Q:
How do you generate xml from non string data types using minidom?
How do you generate xml from non string data types using minidom? I have a feeling someone is going to tell me to generate strings before hand, but this is not what I'm after.
from datetime import datetime
from xml.dom.minidom import Document
num =... | How do you generate xml from non string data types using minidom? | How do you generate xml from non string data types using minidom? I have a feeling someone is going to tell me to generate strings before hand, but this is not what I'm after.
from datetime import datetime
from xml.dom.minidom import Document
num = "1109"
bool = "false"
time = "2010-06-24T14:44:46.000"
doc = Document... | [
"The bound method setAttribute expects its second argument, the value, to be a string. You can help the process along by converting the data to strings:\nbool = str(False)\n\nor, converting to strings when you call setAttribute:\nSubmission.setAttribute(\"bool\",str(bool))\n\n(and of course, the same must be done ... | [
3
] | [] | [] | [
"minidom",
"python",
"xml"
] | stackoverflow_0003983890_minidom_python_xml.txt |
Q:
Django template: Why block in included template can't be overwritten by child template?
To illustrate my question more clearly, let's suppose I have a include.html template with content:
{% block test_block %}This is include{% endblock %}
I have another template called parent.html with content like this:
This is ... | Django template: Why block in included template can't be overwritten by child template? | To illustrate my question more clearly, let's suppose I have a include.html template with content:
{% block test_block %}This is include{% endblock %}
I have another template called parent.html with content like this:
This is parent
{% include "include.html" %}
Now I create a templated called child.html that extends... | [
"When you include a template, it renders the template, then includes the rendered content.\nFrom the django docs:\n\nThe include tag should be considered as an implementation of \"render this subtemplate and include the HTML\", not as \"parse this subtemplate and include its contents as if it were part of the paren... | [
13
] | [] | [] | [
"django",
"extend",
"include",
"python",
"templates"
] | stackoverflow_0003983872_django_extend_include_python_templates.txt |
Q:
Is there any reason for using classes in Python if there is only one class in the program?
I've seen some people writing Python code by creating one class and then an object to call all the methods. Is there any advantage of using classes if we don't make use of inheritance, encapsulation etc? Such code seems to m... | Is there any reason for using classes in Python if there is only one class in the program? | I've seen some people writing Python code by creating one class and then an object to call all the methods. Is there any advantage of using classes if we don't make use of inheritance, encapsulation etc? Such code seems to me less clean with all these 'self' arguments, which we could avoid. Is this practice an influenc... | [
"One advantage, though not always applicable, is that it makes it easy to extend the program by subclassing the one class. For example I can subclass it and override the method that reads from, say, a csv file to reading an xml file and then instantiate the subclass or original class based on run-time information. ... | [
8,
5,
3,
2,
1
] | [] | [] | [
"class",
"oop",
"python"
] | stackoverflow_0003983520_class_oop_python.txt |
Q:
DJango Dev Server strange output ppcfinder.net/judge.php
I wonder if anyone has seen this. I am developing a web app and the dev server just output the following when I was doing some testing.
logging on
[21/Oct/2010 13:42:56] "POST /members/logon/ HTTP/1.1" 302 0
[21/Oct/2010 13:42:57] "GET / HTTP/1.1" 200 20572
... | DJango Dev Server strange output ppcfinder.net/judge.php | I wonder if anyone has seen this. I am developing a web app and the dev server just output the following when I was doing some testing.
logging on
[21/Oct/2010 13:42:56] "POST /members/logon/ HTTP/1.1" 302 0
[21/Oct/2010 13:42:57] "GET / HTTP/1.1" 200 20572
[21/Oct/2010 13:42:59] "GET http://ppcfinder.net/judge.php HTT... | [
"Seems like a bot in another host hit yours searching for known vulnerabilities to exploit.\n"
] | [
2
] | [] | [] | [
"django",
"malware",
"python"
] | stackoverflow_0003984008_django_malware_python.txt |
Q:
Kindly review the python code to boost its performance
I'm doing an Information Retrieval task. I built a simple searchengine. The InvertedIndex is a python dictionary object which is serialized (pickled in python terminology) to a file. Size of this file is InvertedIndex is just 6.5MB.
So, my Code just unpickles ... | Kindly review the python code to boost its performance | I'm doing an Information Retrieval task. I built a simple searchengine. The InvertedIndex is a python dictionary object which is serialized (pickled in python terminology) to a file. Size of this file is InvertedIndex is just 6.5MB.
So, my Code just unpickles it and searches it for query & ranks the matching documents ... | [
"It's definitely your code, but since you choose to hide it from us it's impossible for us to help any further. All I can tell you based on the very scarce info you choose to supply is that unpickling a dict (in the right way) is much faster, and indexing into it (assuming that's what you mean by \"searches it for... | [
18,
5,
4,
2,
1
] | [] | [] | [
"information_retrieval",
"performance",
"python"
] | stackoverflow_0003801072_information_retrieval_performance_python.txt |
Q:
Java framework for social network
Is there a Java analogue to Pinax/Django? (Perhaps an extension to Jboss Seam and/or functionality already built into Seam?)
Please analyse and compare Pinax/Django, Seam, and any other good Java/Python frameworks in the following criteria (ranked in order of importance):
Securit... | Java framework for social network | Is there a Java analogue to Pinax/Django? (Perhaps an extension to Jboss Seam and/or functionality already built into Seam?)
Please analyse and compare Pinax/Django, Seam, and any other good Java/Python frameworks in the following criteria (ranked in order of importance):
Security (sensitive financial information)
Abi... | [
"you might want to try Apache Shinding\nhttp://incubator.apache.org/projects/shindig.html\nAnd if you want a youtube demostration try\nhttp://www.youtube.com/watch?v=ZcWszaReqXI\ntaken from this thread\n"
] | [
2
] | [] | [] | [
"django",
"java",
"pinax",
"python",
"seam"
] | stackoverflow_0003984166_django_java_pinax_python_seam.txt |
Q:
How can I better structure this code?
I have an lxml.objectify data structure I get from a RESTful web service. I need to change a setting if it exists and create it if it doesn't. Right now I have something along the lines of the following, but I feel like it's ugly. The structure I'm looking in has a list of sub... | How can I better structure this code? | I have an lxml.objectify data structure I get from a RESTful web service. I need to change a setting if it exists and create it if it doesn't. Right now I have something along the lines of the following, but I feel like it's ugly. The structure I'm looking in has a list of subelements which all have the same structure,... | [
"Overall, the structure isn't too bad (assuming you need to call modify on 1+ items in the settings -- if \"just one\", i.e., if the is_what_I_want flag is going to be set for one setting at most, that's of course different, as you could and should use a break from the for loop -- but that's not the impression of y... | [
2,
0
] | [] | [] | [
"code_cleanup",
"python"
] | stackoverflow_0003824179_code_cleanup_python.txt |
Q:
using python to encapsulate part of a string after 3 commas
I am trying to create a python script that adds quotations around part of a string, after 3 commas
So if the input data looks like this:
1234,1,1/1/2010,This is a test. One, two, three.
I want python to convert the string to:
1234,1,1/1/2010,"This is a t... | using python to encapsulate part of a string after 3 commas | I am trying to create a python script that adds quotations around part of a string, after 3 commas
So if the input data looks like this:
1234,1,1/1/2010,This is a test. One, two, three.
I want python to convert the string to:
1234,1,1/1/2010,"This is a test. One, two, three."
The quotes will always need to be added a... | [
"Having addressed the two issues mentioned in my comment above I've just tested that the code below (edit: ALMOST works; see very short code sample below for a fully tested and working version) for your test input.\ni_file=open(\"input.csv\",\"r\")\no_file=open(\"output.csv\",\"w\")\n\nfor line in i_file:\n toke... | [
2,
2,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0003984200_python.txt |
Q:
C# bindings for MEEP (Photonic Simulation Package)
Does anyone know of a way to call MIT's Meep simulation package from C# (probably Mono, god help me).
We're stuck with the #$@%#$^ CTL front-end, which is a productivity killer. Some other apps that we're integrating into our sim pipeline are in C# (.NET). I've s... | C# bindings for MEEP (Photonic Simulation Package) | Does anyone know of a way to call MIT's Meep simulation package from C# (probably Mono, god help me).
We're stuck with the #$@%#$^ CTL front-end, which is a productivity killer. Some other apps that we're integrating into our sim pipeline are in C# (.NET). I've seen a Python interface to Meep (light years ahead of CTL... | [
"The straightforward and portable solution is to write a C++ wrapper for libmeep that exposes a C ABI (via extern \"C\" { ... }), then write a C# wrapper around this API using P/Invoke. This would be roughly equivalent to the Python Meep wrapper, AFAICT.\nOf course, mapping C++ classes to C# classes via a flat C AP... | [
0
] | [] | [] | [
"c#",
"c++",
"meep",
"mono",
"python"
] | stackoverflow_0003982717_c#_c++_meep_mono_python.txt |
Q:
How do I send single character ASCII data to a serial port with python
I'v looked at pyserial but I can't seem to figure out how to do it. I only need to send one at a time? Please help?
A:
Using pySerial:
Python 2.x:
import serial
byte = 42
out = serial.Serial("/dev/ttyS0") # "COM1" on Windows
out.write(chr(by... | How do I send single character ASCII data to a serial port with python | I'v looked at pyserial but I can't seem to figure out how to do it. I only need to send one at a time? Please help?
| [
"Using pySerial:\nPython 2.x:\nimport serial\nbyte = 42\nout = serial.Serial(\"/dev/ttyS0\") # \"COM1\" on Windows\nout.write(chr(byte))\n\nPython 3.x:\nimport serial\nbyte = 42\nout = serial.Serial(\"/dev/ttyS0\") # \"COM1\" on Windows\nout.write(bytes(byte))\n\n",
"Google says:\n\nhttp://pyserial.sourceforge.... | [
7,
1
] | [] | [] | [
"arduino",
"python"
] | stackoverflow_0003984602_arduino_python.txt |
Q:
Python 2.7, sqlite3, ValueError: could not convert BLOB to buffer
I am trying to save a BLOB created from an integer array (that is, a packed array of integers) in an SQLite DB. The script shown below gives the following traceback. As far as I can see from the Python 2.7 sqlite3 documentation, it should be possibl... | Python 2.7, sqlite3, ValueError: could not convert BLOB to buffer | I am trying to save a BLOB created from an integer array (that is, a packed array of integers) in an SQLite DB. The script shown below gives the following traceback. As far as I can see from the Python 2.7 sqlite3 documentation, it should be possible to insert a buffer object into a table, where it is supposed to be sa... | [
"Cristian Ciupitu's note about the bug is correct, but bytes(ar) will give you the __str__ representation instead of a serialized output. Therefore, use ar.tostring().\nUse array.fromstring to unserialize the array again - you have to create an array object with the same type and then call .fromstring(...).\n"
] | [
2
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0003983587_python_sqlite.txt |
Q:
Python sample programs for FusionCharts to integrate with MySQL
I want to integrate Python with FusionCharts and MySQL.
I have python programs to create/access MySQL DB.
The same data which resides in the MySQL DB has to be projected to the user in the FusionCharts using Python scripts.
Please help me out on this... | Python sample programs for FusionCharts to integrate with MySQL | I want to integrate Python with FusionCharts and MySQL.
I have python programs to create/access MySQL DB.
The same data which resides in the MySQL DB has to be projected to the user in the FusionCharts using Python scripts.
Please help me out on this.
| [
"There are quite a few examples out there\n\nhttp://bitbucket.org/schmichael/python-fusioncharts/src/tip/snippets/\n\n"
] | [
0
] | [] | [] | [
"fusioncharts",
"python"
] | stackoverflow_0003984849_fusioncharts_python.txt |
Q:
Caching static files in Django
I was profiling the performance of my web application using Google's Page Speed plugin for Firebug and one of the things it says is that I should 'leverage caching' — "The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the fu... | Caching static files in Django | I was profiling the performance of my web application using Google's Page Speed plugin for Firebug and one of the things it says is that I should 'leverage caching' — "The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources". W... | [
"Any static files you may have for your page should be served by your web server, e.g. Apache. Django should never be involved unless you have to prevent access of some files to certain people.\nHere, I found an example of how to do it:\n# our production setup includes a caching load balancer in front.\n# we tell t... | [
7
] | [] | [] | [
"caching",
"django",
"python"
] | stackoverflow_0003984984_caching_django_python.txt |
Q:
I have a text file of a paragraph of writing, and want to iterate through each word in Python
How would I do this? I want to iterate through each word and see if it fits certain parameters (for example is it longer than 4 letters..etc. not really important though).
The text file is literally a rambling of text wi... | I have a text file of a paragraph of writing, and want to iterate through each word in Python | How would I do this? I want to iterate through each word and see if it fits certain parameters (for example is it longer than 4 letters..etc. not really important though).
The text file is literally a rambling of text with punctuation and white spaces, much like this posting.
| [
"Try split()ing the string.\nf = open('your_file')\nfor line in f:\n for word in line.split():\n # do something\n\nIf you want it without punctuation:\nf = open('your_file')\nfor line in f:\n for word in line.split():\n word = word.strip('.,?!')\n # do something\n\n",
"You can simply co... | [
2,
0,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0003984910_python.txt |
Q:
Documentation for python-gnomeapplet and friends
I'm attempting to write a Gnome applet using Python and pygtk. Sadly all sources of information that I have been able to find are from 2004 or older, and while the general structures presented are still valid, most of the particulars are out-of-date. Even the exampl... | Documentation for python-gnomeapplet and friends | I'm attempting to write a Gnome applet using Python and pygtk. Sadly all sources of information that I have been able to find are from 2004 or older, and while the general structures presented are still valid, most of the particulars are out-of-date. Even the example applets I've found through web searches no longer wo... | [
"There is a step-by-step tutorial, which might be the most up-to-date:\nhttp://www.znasibov.info/blog/post/gnome-applet-with-python-part-1.html\nAlso check out the various applets listed in Gnome projects.\n"
] | [
4
] | [] | [] | [
"gnome",
"pygtk",
"python"
] | stackoverflow_0003977736_gnome_pygtk_python.txt |
Q:
Why does Python disables MSCRT assertions when built with debug mode?
Python disables MSCRT assertions for debug mode during the initialization of exceptions module when it is built in debug mode. At least from the source code, I can see Python 2.6.5 doing this for _MSC_VER >= 1400 i.e. Visual C++ 2005. Does anyon... | Why does Python disables MSCRT assertions when built with debug mode? | Python disables MSCRT assertions for debug mode during the initialization of exceptions module when it is built in debug mode. At least from the source code, I can see Python 2.6.5 doing this for _MSC_VER >= 1400 i.e. Visual C++ 2005. Does anyone know why?
| [
"See this thread on the bug tracker.\n"
] | [
2
] | [] | [] | [
"assertion",
"crt",
"python"
] | stackoverflow_0003985059_assertion_crt_python.txt |
Q:
Dictionary based switch-like statement with actions
I'm relatively new to Python and would like to know if I'm reinventing a wheel or do things in a non-pythonic way - read wrong.
I'm rewriting some parser originally written in Lua. There is one function which accepts a field name from imported table and its value... | Dictionary based switch-like statement with actions | I'm relatively new to Python and would like to know if I'm reinventing a wheel or do things in a non-pythonic way - read wrong.
I'm rewriting some parser originally written in Lua. There is one function which accepts a field name from imported table and its value, does some actions on value and stores it in target dict... | [
"If by any means possible, you could name your member functions based on the field names and just do something like this:\ngetattr(self, \"fn_\" + fieldname)(value)\n\nEdit: And you can use hasattr to check if the function exists, instead of expecting a KeyError. Or expect an AttributeError. At any rate, you should... | [
1,
0
] | [] | [] | [
"design_patterns",
"lua",
"python"
] | stackoverflow_0003982533_design_patterns_lua_python.txt |
Q:
Python: pattern matching for a string
Im trying to check a file line by line for any_string=any_string. It must be that format, no spaces or anything else. The line must contain a string then a "=" and then another string and nothing else. Could someone help me with the syntax in python to find this please? =]
pat... | Python: pattern matching for a string | Im trying to check a file line by line for any_string=any_string. It must be that format, no spaces or anything else. The line must contain a string then a "=" and then another string and nothing else. Could someone help me with the syntax in python to find this please? =]
pattern='*\S\=\S*'
I have this, but im pretty... | [
"Don't know if you are looking for lines with the same value on both = sides. If so then use:\nthe_same_re = re.compile(r'^(\\S+)=(\\1)$')\n\nif values can differ then use\nthe_same_re = re.compile(r'^(\\S+)=(\\S+)$')\n\nIn this regexpes:\n\n^ is the beginning of line\n$ is the end of line\n\\S+ is one or more non ... | [
4,
1,
1,
1,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0003984930_python_regex.txt |
Q:
Parsing a list into a url string
I have a list of tags that I would like to add to a url string, separated by commas ('%2C'). How can I do this ? I was trying :
>>> tags_list
['tag1', ' tag2']
>>> parse_string = "http://www.google.pl/search?q=%s&restofurl" % (lambda x: "%s," %x for x in tags_list)
but received a ... | Parsing a list into a url string | I have a list of tags that I would like to add to a url string, separated by commas ('%2C'). How can I do this ? I was trying :
>>> tags_list
['tag1', ' tag2']
>>> parse_string = "http://www.google.pl/search?q=%s&restofurl" % (lambda x: "%s," %x for x in tags_list)
but received a generator :
>>> parse_string
'http://<... | [
"parse_string = (\"http://www.google.pl/search?q=%s&restofurl\" % \n '%2C'.join(tag.strip() for tag in tags_list))\n\nResults in:\n>>> parse_string = (\"http://www.google.pl/search?q=%s&restofurl\" %\n... '%2C'.join(tag.strip() for tag in tags_list))\n>>> parse_string\n'http://www.googl... | [
4,
1
] | [] | [] | [
"lambda",
"parsing",
"python",
"url",
"url_parsing"
] | stackoverflow_0003984422_lambda_parsing_python_url_url_parsing.txt |
Q:
Slicing a result list by time value
I got a result list and want to keep the elements that are newer than timeline and older than bookmark. Is there a more convenient method than iterating the whole list and removing the elements if they match the conditition? Can you introduce me to how specically how? The way I ... | Slicing a result list by time value | I got a result list and want to keep the elements that are newer than timeline and older than bookmark. Is there a more convenient method than iterating the whole list and removing the elements if they match the conditition? Can you introduce me to how specically how? The way I fetch data and then sort it
results = A.a... | [
"If you're using the SearchableModel and doing a search query (which it would appear you are, from the snippet), you can't apply sort orders or inequality filters without requiring exploding indexes, as established in your previous question on the topic. Thus, you can't apply these filters as part of the query - so... | [
1,
0
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0003983093_google_app_engine_python.txt |
Q:
Matching a datetime against a date in django
I have a django model with a DateTimeField called when which I want to match against a Date object. Is there a way to do that in django's queryset language better than
Samples.objects.filter( when__gte = mydate, when__lt = mydate + datetime.timedelta(1) )
A:
Same lik... | Matching a datetime against a date in django | I have a django model with a DateTimeField called when which I want to match against a Date object. Is there a way to do that in django's queryset language better than
Samples.objects.filter( when__gte = mydate, when__lt = mydate + datetime.timedelta(1) )
| [
"Same like W_P, off the top of my head:\nSamples.objects.filter(when__year = mydate.year, when__month = mydate.month, when__day = mydate.day)\n\nYou can round that up to year, month, day. This is the way I create posts archive in my code. I have three options: yearly archive, monthly archive and daily archive. The ... | [
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0003983535_django_python.txt |
Q:
How to Append data to a combobox
I need to insert data to a combobox so i do an append as defined in this lines :
fd = open(files,'rb')
data=fd.readlines()
for i in data[]:
item=i.strip()
if item is not None:
combobox.Append(item)
fd.close
Even data insert the selection still void
please can you t... | How to Append data to a combobox | I need to insert data to a combobox so i do an append as defined in this lines :
fd = open(files,'rb')
data=fd.readlines()
for i in data[]:
item=i.strip()
if item is not None:
combobox.Append(item)
fd.close
Even data insert the selection still void
please can you tell me how to set a selection a value ... | [
"combobox.SetSelection(0) # select first item\n\n",
"I know this probably doesn't answer your question, but I recommend you close the file connection once you're done using it.\nfd = open(files,'rb')\ndata=fd.readlines()\n\n#Close the connection, you're done using it!\nfd.close\n\n#Now do what you want with data... | [
1,
0
] | [] | [] | [
"python",
"wxpython",
"wxwidgets"
] | stackoverflow_0003983583_python_wxpython_wxwidgets.txt |
Q:
Fix depth tree in Python
I want to implement a tree structure which has fixed depth, i.e. when adding children to the leef nodes, the whole tree structure should "move up". This also means that several roots can exist simultaneously. See example beneath:
In this example, the green nodes are added in iteration 1, ... | Fix depth tree in Python | I want to implement a tree structure which has fixed depth, i.e. when adding children to the leef nodes, the whole tree structure should "move up". This also means that several roots can exist simultaneously. See example beneath:
In this example, the green nodes are added in iteration 1, deleting the top node (grey) a... | [
"Store each node with a reference to its parent. When you add a node to it as a child, walk up the parents (from the node being added to) and delete the third one after you set the parent reference in all of its children to None. Then add the children of the deleted node to your list of trees.\nclass Node(object):\... | [
2
] | [] | [] | [
"data_structures",
"python",
"tree"
] | stackoverflow_0003985453_data_structures_python_tree.txt |
Q:
Slim down Python wxPython OS X app built with py2app?
I have just made a small little app of a Python wxPython script with py2app. Everything worked as advertised, but the app is pretty big in size. Is there any way to optimize py2app to make the app smaller in size?
A:
This is a workaround.
It will depend on wh... | Slim down Python wxPython OS X app built with py2app? | I have just made a small little app of a Python wxPython script with py2app. Everything worked as advertised, but the app is pretty big in size. Is there any way to optimize py2app to make the app smaller in size?
| [
"This is a workaround.\nIt will depend on which OS you want to target. Python and wxPython are bundled with every Mac OS X installation (at least starting with Leopard, if I recall correctly)\nWhat you might try, is to add the --alias compilation option. According to the py2app doc:\n\nAlias mode (the -A or --alias... | [
2,
1
] | [] | [] | [
"optimization",
"py2app",
"python",
"wxpython"
] | stackoverflow_0003979658_optimization_py2app_python_wxpython.txt |
Q:
Python - go to two lines above match
In a text file like this:
First Name last name #
secone name
Address Line 1
Address Line 2
Work Phone:
Home Phone:
Status:
First Name last name #
....same as above...
I need to match string 'Work Phone:' then go two lines up and insert character '|' in the begining of line. s... | Python - go to two lines above match | In a text file like this:
First Name last name #
secone name
Address Line 1
Address Line 2
Work Phone:
Home Phone:
Status:
First Name last name #
....same as above...
I need to match string 'Work Phone:' then go two lines up and insert character '|' in the begining of line. so pseudo code would be:
if "Work Phone:" i... | [
"This solution doesn't read whole file into memory\np=\"\"\nq=\"\"\nfor line in open(\"file\"):\n line=line.rstrip()\n if \"Work Phone\" in line:\n p=\"|\"+p\n if p: print p\n p,q=q,line\nprint p\nprint q\n\noutput\n$ python test.py\nFirst Name last name #\nsecone name\n|Address Line 1\nAddress Li... | [
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0003985705_python.txt |
Q:
conversion of string representing HH:MM:SS.sss format into HH:MM:SS.ssssss format in python
I have string which is representing time in HH:MM:SS.sss format ,Now i have to convert this sting into HH:MM:SS.ssssss format.Please let me know how to do this?
A:
Can you not just append "000" on the end?
So "13:23:12.34... | conversion of string representing HH:MM:SS.sss format into HH:MM:SS.ssssss format in python | I have string which is representing time in HH:MM:SS.sss format ,Now i have to convert this sting into HH:MM:SS.ssssss format.Please let me know how to do this?
| [
"Can you not just append \"000\" on the end?\nSo \"13:23:12.345\" => \"13:23:12.345000\"\n"
] | [
4
] | [] | [] | [
"python"
] | stackoverflow_0003986003_python.txt |
Q:
Python: Comparing Lists
I have come across a small problem. Say I have two lists:
list_A = ['0','1','2']
list_B = ['2','0','1']
I then have a list of lists:
matrix = [
['56','23','4'],
['45','5','67'],
['1','52','22']
]
I then need to iterate through list_A and list_B and effectively use them as co-ordinates. Fo... | Python: Comparing Lists | I have come across a small problem. Say I have two lists:
list_A = ['0','1','2']
list_B = ['2','0','1']
I then have a list of lists:
matrix = [
['56','23','4'],
['45','5','67'],
['1','52','22']
]
I then need to iterate through list_A and list_B and effectively use them as co-ordinates. For example I take the firs num... | [
"matrix = [\n['56','23','4'],\n['45','5','67'],\n['1','52','22']\n]\n\nlist_A = ['0','1','2']\nlist_B = ['2','0','1']\n\nfor x in zip(list_A,list_B):\n a,b=map(int,x)\n print(matrix[a][b])\n# 4\n# 45\n# 52\n\n",
"[matrix[int(a)][int(b)] for (a,b) in zip(list_A, list_B)]\n\n",
"The 'zip' function could be ... | [
8,
2,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0003986222_list_python.txt |
Q:
How do you wrap the view of a 3rd-party Django app
How do you wrap the view of a 3rd-party app (let's call the view to wrap "view2wrap" and the app "3rd_party_app") so you can do some custom things before the app does its thing?
I've set urls.py to capture the correct url:
url( r'^foo/bar/$', view_wrapper, name=... | How do you wrap the view of a 3rd-party Django app | How do you wrap the view of a 3rd-party app (let's call the view to wrap "view2wrap" and the app "3rd_party_app") so you can do some custom things before the app does its thing?
I've set urls.py to capture the correct url:
url( r'^foo/bar/$', view_wrapper, name='my_wrapper'),
I've created my custom view:
from 3rd_pa... | [
"The third party application is not in your python path.\n",
"Is the 3rd Party App listed in INSTALLED_APPS in your settings.py?\n",
"Try placing the 3rd party package folder within your project folder. :)\n"
] | [
3,
0,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0003982443_django_python.txt |
Q:
In a Django template for loop, checking if current item different from previous item
I'm new to django and can't find a way to get this to work in django templates. The idea is to check if previous items first letter is equal with current ones, like so:
{% for item in items %}
{% ifequal item.name[0] previous_... | In a Django template for loop, checking if current item different from previous item | I'm new to django and can't find a way to get this to work in django templates. The idea is to check if previous items first letter is equal with current ones, like so:
{% for item in items %}
{% ifequal item.name[0] previous_item.name[0] %}
{{ item.name[0] }}
{% endifequal %}
{{ item.name }}<br />
... | [
"Use the {% ifchanged %} tag.\n{% for item in items %}\n {% ifchanged item.name.0 %}\n {{ item.name.0 }}\n {% endifchanged %}\n{% endfor %}\n\nAlso remember you have to always use dot syntax - brackets are not valid template syntax.\n"
] | [
60
] | [] | [] | [
"django",
"django_templates",
"python"
] | stackoverflow_0003986183_django_django_templates_python.txt |
Q:
Rename dictionary keys according to another dictionary
(In Python 3)
I have dictionary old. I need to change some of its keys; the keys that need to be changed and the corresponding new keys are stored in a dictionary change. What's a good way to do it? Note that there may be an overlap between old.keys() and chan... | Rename dictionary keys according to another dictionary | (In Python 3)
I have dictionary old. I need to change some of its keys; the keys that need to be changed and the corresponding new keys are stored in a dictionary change. What's a good way to do it? Note that there may be an overlap between old.keys() and change.values(), which requires that I'm careful applying the ch... | [
"old = {change.get(k,k):v for k,v in old.items()}\n\n"
] | [
10
] | [] | [] | [
"dictionary",
"python",
"python_3.x"
] | stackoverflow_0003986549_dictionary_python_python_3.x.txt |
Q:
Law of Demeter and Python
Is there a tool to check if a Python code conforms to the law of Demeter?
I found a mention of Demeter in pychecker, but it seems that the tool understands this law different to what I expect: http://en.wikipedia.org/wiki/Law_of_Demeter
The definition from wikipedia: the Law of Demeter fo... | Law of Demeter and Python | Is there a tool to check if a Python code conforms to the law of Demeter?
I found a mention of Demeter in pychecker, but it seems that the tool understands this law different to what I expect: http://en.wikipedia.org/wiki/Law_of_Demeter
The definition from wikipedia: the Law of Demeter for functions requires that a met... | [
"The way this law is explained in the link you provide it is far too vague and subjective to be efficiently checked by any automated tool. You would need to think of specific rules that lead to code that abides by this law. Then you can check for these rules.\n",
"\nlaw of Demeter ... method M of an object O may ... | [
1,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0003985947_python.txt |
Q:
converting tiff to gif in php
I need to convert tiff file to gif . can some one give me php or python script to do that ?
A:
Try phpThumb in conjunction with the Imagick extension in PHP.
A:
http://php.net/manual/en/book.imagick.php
try
{
$image = '/tmp/image.tiff';
$im = new Imagick(); ... | converting tiff to gif in php | I need to convert tiff file to gif . can some one give me php or python script to do that ?
| [
"Try phpThumb in conjunction with the Imagick extension in PHP.\n",
"http://php.net/manual/en/book.imagick.php\ntry\n{\n $image = '/tmp/image.tiff'; \n $im = new Imagick(); \n $im->pingImage( $image ); \n $im->readImage( $image ); \n $im->setImageFormat( 'gif' ); ... | [
1,
1
] | [] | [] | [
"image_manipulation",
"php",
"python",
"tiff"
] | stackoverflow_0003985573_image_manipulation_php_python_tiff.txt |
Q:
Is this usage of python tempfile.NamedTemporaryFile secure?
Is this usage of Python tempfile.NamedTemporaryFile secure (i.e. devoid security issues of deprecated tempfile.mktemp)?
def mktemp2():
"""Create and close an empty temporary file.
Return the temporary filename"""
tf = tempfile.NamedTemporaryFi... | Is this usage of python tempfile.NamedTemporaryFile secure? | Is this usage of Python tempfile.NamedTemporaryFile secure (i.e. devoid security issues of deprecated tempfile.mktemp)?
def mktemp2():
"""Create and close an empty temporary file.
Return the temporary filename"""
tf = tempfile.NamedTemporaryFile(delete=False)
tfilename = tf.name
tf.close()
retur... | [
"Totally unsafe. There is an opportunity for an attacker to create the file with whatever permissions they like (or a symlink) with that name between when it is deleted and opened by the subprocess\nIf you can instead create the file in a directory other than /tmp that is owned and onnly read/writeable by your proc... | [
4
] | [] | [] | [
"file",
"python",
"temporary_files"
] | stackoverflow_0003986364_file_python_temporary_files.txt |
Q:
How to find the local minima of a smooth multidimensional array in NumPy efficiently?
Say I have an array in NumPy containing evaluations of a continuous differentiable function, and I want to find the local minima. There is no noise, so every point whose value is lower than the values of all its neighbors meets m... | How to find the local minima of a smooth multidimensional array in NumPy efficiently? | Say I have an array in NumPy containing evaluations of a continuous differentiable function, and I want to find the local minima. There is no noise, so every point whose value is lower than the values of all its neighbors meets my criterion for a local minimum.
I have the following list comprehension which works for a ... | [
"The location of the local minima can be found for an array of arbitrary dimension\nusing Ivan's detect_peaks function, with minor modifications:\nimport numpy as np\nimport scipy.ndimage.filters as filters\nimport scipy.ndimage.morphology as morphology\n\ndef detect_local_minima(arr):\n # https://stackoverflow.... | [
20,
5
] | [] | [] | [
"discrete_mathematics",
"mathematical_optimization",
"numpy",
"python"
] | stackoverflow_0003986345_discrete_mathematics_mathematical_optimization_numpy_python.txt |
Q:
What is the Pythonic way to create informative comments in Python 2.x?
For further clarification, C# has the '///' directive which invokes the super-secret-styled Comments which allow you to have nice comments built into intellisense. Java has the '@' directive that allows you to have nice comments as well.
Does P... | What is the Pythonic way to create informative comments in Python 2.x? | For further clarification, C# has the '///' directive which invokes the super-secret-styled Comments which allow you to have nice comments built into intellisense. Java has the '@' directive that allows you to have nice comments as well.
Does Python have something like this? I hope this question is clear enough, thanks... | [
"They are called docstrings in Python. See the documentation.\nA nice feature are the code samples (explained here). They allow to put code in the documentation:\n>>> 1 + 1\n2\n>>>\n\nWhile this doesn't look like much, there is a tool which can scan the docstrings for such patterns and execute this code as unit tes... | [
7,
2,
2,
0,
0
] | [] | [] | [
"comments",
"python"
] | stackoverflow_0003987163_comments_python.txt |
Q:
efficient way to compress a numpy array (python)
I am looking for an efficient way to compress a numpy array.
I have an array like: dtype=[(name, (np.str_,8), (job, (np.str_,8), (income, np.uint32)] (my favourite example).
if I'm doing something like this: my_array.compress(my_array['income'] > 10000) I'm getting ... | efficient way to compress a numpy array (python) | I am looking for an efficient way to compress a numpy array.
I have an array like: dtype=[(name, (np.str_,8), (job, (np.str_,8), (income, np.uint32)] (my favourite example).
if I'm doing something like this: my_array.compress(my_array['income'] > 10000) I'm getting a new array with only incomes > 10000, and it's quite ... | [
"It's not quite as nice as what you'd like, but I think you can do:\nmask = my_array['job'] == 'this'\nfor condition in ['that', 'other']:\n mask = numpy.logical_or(mask,my_array['job'] == condition)\nselected_array = my_array[mask]\n\n",
"The best way to compress a numpy array is to use pytables. It is the defa... | [
1,
1,
0
] | [] | [] | [
"compression",
"filter",
"numpy",
"python"
] | stackoverflow_0001870871_compression_filter_numpy_python.txt |
Q:
Beautiful Soup: Get the Contents of Sub-Nodes
I have following python code:
def scrapeSite(urlToCheck):
html = urllib2.urlopen(urlToCheck).read()
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(html)
tdtags = soup.findAll('td', { "class" : "c" })
for t in tdtags:
print ... | Beautiful Soup: Get the Contents of Sub-Nodes | I have following python code:
def scrapeSite(urlToCheck):
html = urllib2.urlopen(urlToCheck).read()
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(html)
tdtags = soup.findAll('td', { "class" : "c" })
for t in tdtags:
print t.encode('latin1')
This will return me following h... | [
"In this case, you can use t.contents[1].contents[0] to get FOO and BAR. \nThe thing is that contents returns a list with all elements (Tags and NavigableStrings), if you print contents, you can see it's something like\n[u'\\n', <a href=\"more.asp\">FOO</a>, u'\\n']\nSo, to get to the actual tag you need to access ... | [
3,
1
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0003987732_beautifulsoup_python.txt |
Q:
Redefining python list
is it possible to redefine the behavior of a Python List from Python, I mean, without having to write anything in the Python sourcecode?
A:
You could always create your own subclass inheriting from list.
An example (although you would probably never want to use this):
class new_list(list):... | Redefining python list | is it possible to redefine the behavior of a Python List from Python, I mean, without having to write anything in the Python sourcecode?
| [
"You could always create your own subclass inheriting from list.\nAn example (although you would probably never want to use this):\nclass new_list(list):\n '''A list that will return -1 for non-existent items.'''\n def __getitem__(self, i):\n if i >= len(self):\n return -1\n else:\n ... | [
3
] | [] | [] | [
"python"
] | stackoverflow_0003988069_python.txt |
Q:
add multiple columns to an sqlite database in python
I want to create a table with multiple columns, say about 100 columns, in an sqlite database. Is there a better solution than naming each column individually? I am trying the following:
conn = sqlite3.connect('trialDB')
cur = conn.cursor()
listOfVars = ("added0... | add multiple columns to an sqlite database in python | I want to create a table with multiple columns, say about 100 columns, in an sqlite database. Is there a better solution than naming each column individually? I am trying the following:
conn = sqlite3.connect('trialDB')
cur = conn.cursor()
listOfVars = ("added0",)
for i in range(1,100):
newVar = ("added" + str(i),... | [
"I guess you could do it through string formatting, like this :\nfor i in listOfVars:\n cur.execute('''ALTER TABLE testTable ADD COLUMN %s TEXT''' % i)\n\nBut having 100 columns in a sqlite db is certainly not common, are you sure of having a proper db design ?\n"
] | [
6
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0003988055_python_sqlite.txt |
Q:
Custom field's to_python not working? - Django
I'm trying to implement an encrypted char field.
I'm using pydes for encryption
This is what I have:
from pyDes import triple_des, PAD_PKCS5
from binascii import unhexlify as unhex
from binascii import hexlify as dohex
class BaseEncryptedField(models.CharField):
... | Custom field's to_python not working? - Django | I'm trying to implement an encrypted char field.
I'm using pydes for encryption
This is what I have:
from pyDes import triple_des, PAD_PKCS5
from binascii import unhexlify as unhex
from binascii import hexlify as dohex
class BaseEncryptedField(models.CharField):
def __init__(self, *args, **kwargs):
self.... | [
"You've forgotten to set the metaclass:\nclass BaseEncryptedField(models.CharField):\n\n __metaclass__ = models.SubfieldBase\n\n ... etc ...\n\nAs the documentation explains, to_python is only called when the SubfieldBase metaclass is used.\n"
] | [
16
] | [] | [] | [
"django",
"django_models",
"encryption",
"python"
] | stackoverflow_0003988171_django_django_models_encryption_python.txt |
Q:
Checking for duplicates
I have a small problem. I am trying to check to see if status's value already exists and make sure I do not create another instance of it, but I am having some trouble. Ex. If the project status was once "Quote" I do not want to be able make the status "Quote" again. Right now, I check ... | Checking for duplicates | I have a small problem. I am trying to check to see if status's value already exists and make sure I do not create another instance of it, but I am having some trouble. Ex. If the project status was once "Quote" I do not want to be able make the status "Quote" again. Right now, I check to make sure if the user sele... | [
"value = models.CharField(max_length=20, choices=STATUS_CHOICES, verbose_name='Status', unique=True)\n\n"
] | [
2
] | [] | [] | [
"django",
"django_forms",
"django_models",
"python"
] | stackoverflow_0003988418_django_django_forms_django_models_python.txt |
Q:
sqlalchemy many-to-many, but inverse?
I'm sorry if inverse is not the preferred nomenclature, which may have hindered my searching. In any case, I'm dealing with two sqlalchemy declarative classes, which is a many-to-many relationship. The first is Account, and the second is Collection. Users "purchase" collection... | sqlalchemy many-to-many, but inverse? | I'm sorry if inverse is not the preferred nomenclature, which may have hindered my searching. In any case, I'm dealing with two sqlalchemy declarative classes, which is a many-to-many relationship. The first is Account, and the second is Collection. Users "purchase" collections, but I want to show the first 10 collecti... | [
"I would not use the relationship for the purpose, as technically it it not a relationship you are building (so all the tricks of keeping it synchronized on both sides etc would not work).\nIMO, the cleanest way would be to define a simple query which will return you the objects you are looking for:\nclass Account(... | [
5
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0003983593_python_sqlalchemy.txt |
Q:
Django Formset management-form validation error
I have a form and a formset on my template. The problem is that the formset is throwing validation error claiming that the management form is "missing or has been tampered with".
Here is my view
@login_required
def home(request):
user = UserProfile.objects.get(p... | Django Formset management-form validation error | I have a form and a formset on my template. The problem is that the formset is throwing validation error claiming that the management form is "missing or has been tampered with".
Here is my view
@login_required
def home(request):
user = UserProfile.objects.get(pk=request.session['_auth_user_id'])
blogz = list(... | [
"To avoid this error just wrap your formset POST bounding in a try/except block like so.\nfrom django.core.exceptions import ValidationError # add this to your imports\n\nif request.method == 'POST':\n try:\n delblogformset = delblog(request.POST)\n except ValidationError:\n delblogformset = None\n ... | [
7,
2
] | [] | [] | [
"django",
"django_forms",
"django_templates",
"python"
] | stackoverflow_0002536285_django_django_forms_django_templates_python.txt |
Q:
Set a variable equal to result if result exists
This seems very verbose, particularly with long function names, is there a better way to do this in Python?
if someRandomFunction():
variable = someRandomFunction()
Edit: For more context variable is not already defined, and it will be a new node on a tree. I on... | Set a variable equal to result if result exists | This seems very verbose, particularly with long function names, is there a better way to do this in Python?
if someRandomFunction():
variable = someRandomFunction()
Edit: For more context variable is not already defined, and it will be a new node on a tree. I only want to create this node if someRandomFunction() r... | [
"Could you:\nvariable = someRandomFunction() or variable\n\nSee Boolean Operations in the Python documentation for more information.\n",
"temp= someRandomFunction()\nif temp:\n variable = temp\n\n",
"A bit unorthodox perhaps, but you could modify someRandomFunction() so that it saves its last result in a fun... | [
15,
6,
0,
0
] | [
"(Apparently you can't delete your answers if you haven't registered.)\nThese are not the droids you're looking for... move along... \n"
] | [
-1
] | [
"python"
] | stackoverflow_0003982948_python.txt |
Q:
Python: Use Regular expression to remove something
I've got a string looks like this
ABC(a =2,b=3,c=5,d=5,e=Something)
I want the result to be like
ABC(a =2,b=3,c=5)
What's the best way to do this? I prefer to use regular expression in Python.
Sorry, something changed, the raw string changed to
ABC(a =2,b=3,c=5,... | Python: Use Regular expression to remove something | I've got a string looks like this
ABC(a =2,b=3,c=5,d=5,e=Something)
I want the result to be like
ABC(a =2,b=3,c=5)
What's the best way to do this? I prefer to use regular expression in Python.
Sorry, something changed, the raw string changed to
ABC(a =2,b=3,c=5,dddd=5,eeee=Something)
| [
"longer = \"ABC(a =2,b=3,c=5,d=5,e=Something)\"\n\nshorter = re.sub(r',\\s*d=\\d+,\\s*e=[^)]+', '', longer)\n\n# shorter: 'ABC(a =2,b=3,c=5)'\n\nWhen the OP finally knows how many elements are there in the list, he can also use:\nshorter = re.sub(r',\\s*d=[^)]+', '', longer)\n\nit cuts the , d= and everything after... | [
3,
2,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0003988632_python_regex.txt |
Q:
How to use ConfigParser with virtualenv?
I wrote a tool that looks in several places for an INI config file: in /usr/share, /usr/local/share, ~/.local/share, and in the current directory.
c = ConfigParser.RawConfigParser()
filenames = ['/usr/share/myconfig.conf',
'/usr/local/share/myconfig.conf',
... | How to use ConfigParser with virtualenv? | I wrote a tool that looks in several places for an INI config file: in /usr/share, /usr/local/share, ~/.local/share, and in the current directory.
c = ConfigParser.RawConfigParser()
filenames = ['/usr/share/myconfig.conf',
'/usr/local/share/myconfig.conf',
os.path.expanduser('~/.local/share/my... | [
"You should be able to get the venv share path with\nos.path.join(sys.prefix, 'share', 'myconfig.conf')\n\nIncluding /usr/share or /usr/local/share would depend on your application and if multiple installations by different users would be more likely to benefit or be harmed by global machine settings. Using the ab... | [
1
] | [] | [] | [
"configparser",
"python",
"virtualenv"
] | stackoverflow_0003988460_configparser_python_virtualenv.txt |
Q:
How to customize pynotify?
How to set icon size in the notifications?
How to set how much time the notification have to be shown?
Where is a complete pynotify documentation?
Can the notification be clickable? (example: if I click on the notification, print "hello world" in the terminal).
A:
How to set how much ... | How to customize pynotify? |
How to set icon size in the notifications?
How to set how much time the notification have to be shown?
Where is a complete pynotify documentation?
Can the notification be clickable? (example: if I click on the notification, print "hello world" in the terminal).
| [
"\nHow to set how much time the\n notification have to be shown?\n\nUbuntu uses Notify OSD, which does not allow you to control the timeout. The timeout duration depends on the length of the message.\n\nWhere is a complete pynotify\n documentation?\n\nOn Ubuntu, pynotify is provided by the python-notify package.\... | [
1
] | [] | [] | [
"pynotify",
"python",
"ubuntu"
] | stackoverflow_0003988292_pynotify_python_ubuntu.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.