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:
python comparison for trees represented as tuples
I'm representing trees with tuples. Say
t1=(t2,t3) and t4=(t5,t6)
Is it true that when comparing two such trees with ==, it first tests if references t2 and t5 are equal then if references t3 and t6 are equal, if they are not equal then it tries to compare the a... | python comparison for trees represented as tuples | I'm representing trees with tuples. Say
t1=(t2,t3) and t4=(t5,t6)
Is it true that when comparing two such trees with ==, it first tests if references t2 and t5 are equal then if references t3 and t6 are equal, if they are not equal then it tries to compare the actual contents of t2 and t5, then the contents of t3 an... | [
"Yes, tuples attempt to short-circuit the comparison process so two tuples are equal if they are the same tuple or if their elements are either identical or equal.\nIn particular:\n>>> nan = float('NaN')\n>>> left = (nan, nan)\n>>> right = (nan, nan)\n>>> left==right\nTrue\n>>> left[0]==right[0]\nFalse\n\nwhich see... | [
4,
3,
1
] | [] | [] | [
"comparison",
"python",
"tree",
"tuples"
] | stackoverflow_0006492994_comparison_python_tree_tuples.txt |
Q:
Implementation of functions with very basic scripting
I've been playing around with python for some time and decided to better my generalized understanding of programming languages by writing a custom script handler in python. I have so far successfully implemented a basic memory handler and hooked a memory addres... | Implementation of functions with very basic scripting | I've been playing around with python for some time and decided to better my generalized understanding of programming languages by writing a custom script handler in python. I have so far successfully implemented a basic memory handler and hooked a memory address ordinate to printing to the screen. My question can be po... | [
"I am struggling a bit to understand what you are asking. Where is your function definition to be given? In the script handler or in the script?\nIf it is in the script handler, the obvious solution would be to use the lambda expression. Using the example you used in the question f0(x, y, z):=x^2 would translate in... | [
3,
2,
2,
1
] | [] | [] | [
"programming_languages",
"python"
] | stackoverflow_0006384181_programming_languages_python.txt |
Q:
Python dependency analyzer library
I need a way to find the dependencies for each of my Python package's sub-modules at runtime so I can initialize them in a proper order (see my current [EDIT: former] solution here, which doesn't work to well), so at first I used the standard Python module modulefinder, but that ... | Python dependency analyzer library | I need a way to find the dependencies for each of my Python package's sub-modules at runtime so I can initialize them in a proper order (see my current [EDIT: former] solution here, which doesn't work to well), so at first I used the standard Python module modulefinder, but that was way too slow (~1-2 seconds per modul... | [
"I think I have a solution to my own question :)\nHere's what would go into the dependency_analyzer module talked about above:\nimport sys\nfrom sys import _getframe as getframe\nimport atexit\n\nexamined_modules = []\n\ndef gendeps():\n \"\"\"Adds the calling module to the initialization queue.\"\"\"\n # Get... | [
3
] | [] | [] | [
"dependency_management",
"python"
] | stackoverflow_0006475964_dependency_management_python.txt |
Q:
super() argument 1 must be type, not None
A class in one of my modules in my django application has a problem constructing itself using super...
class LinkshareExternalAffiliateProperties(AffiliateExternalProperties):
def __init__(self, aggregator_affiliate_id, account_username, account_password, api_token):
... | super() argument 1 must be type, not None | A class in one of my modules in my django application has a problem constructing itself using super...
class LinkshareExternalAffiliateProperties(AffiliateExternalProperties):
def __init__(self, aggregator_affiliate_id, account_username, account_password, api_token):
super(LinkshareExternalAffiliatePropert... | [
"Check that you're not assigning over the class after you declare it. The following will cause the error you're seeing:\nclass foo(object):\n def x(self):\n print \"foo\"\n\nclass bar(foo):\n def x(self):\n super(bar, self).x()\n\nbaz = bar\nbar = None\n\na = baz()\na.x()\n\n",
"Gunicorn has ... | [
1,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006474023_django_python.txt |
Q:
Get binary data out of usb port
I've written a PRN generator in Python and I am trying to test the sequences to validate them. I have a bit error rate tester, but in order for everything to work, I need to provide it with clocked data.
Is there any way of getting raw binary data out of the computer via USB or se... | Get binary data out of usb port | I've written a PRN generator in Python and I am trying to test the sequences to validate them. I have a bit error rate tester, but in order for everything to work, I need to provide it with clocked data.
Is there any way of getting raw binary data out of the computer via USB or serial? I haven't found any python modu... | [
"To get the data from the serial port use pyserial. To convert the binary data use the struct module. These tools should work for Windows, Linux, and Mac.\nEdit:\nMaybe, by \"raw data\", the OP means he would like to use the serial port as a DIO interface with no serial protocol? This type of thing is generally... | [
2
] | [] | [] | [
"binary",
"python",
"random",
"serial_port",
"usb"
] | stackoverflow_0006494596_binary_python_random_serial_port_usb.txt |
Q:
Python not outputing to file when script is run in vb program
I am making a vb text editor that can run scripting code. I have successfully gotten it to run the code and show up but I would like to be able to have the output from the the code redirected to a file without having to do anything to the python code. I... | Python not outputing to file when script is run in vb program | I am making a vb text editor that can run scripting code. I have successfully gotten it to run the code and show up but I would like to be able to have the output from the the code redirected to a file without having to do anything to the python code. Is that possible?
This is the code I'm using to try it but it does n... | [
"After some more research into the the matter I found a way to make it work.\nHere is the working code:\nShell(\"cmd.exe /c \" & compiler & \" \"\"\" & fileName & \" \"\" > \"\"C:\\output.txt\"\" \", vbNormalFocus)\n\nSo I am actually running the line through the command prompt which is being called by the shell fu... | [
0
] | [] | [] | [
"python",
"visual_studio_2010"
] | stackoverflow_0006470294_python_visual_studio_2010.txt |
Q:
find the type of all variables in scope python
I want to write a function which gets all the variables in a scope, and then determines the
type of each variables.
I am a aware of vars(), dir() and similar, but these functions return a list of strings.
How can I actually get the types ?
I would like to do someth... | find the type of all variables in scope python | I want to write a function which gets all the variables in a scope, and then determines the
type of each variables.
I am a aware of vars(), dir() and similar, but these functions return a list of strings.
How can I actually get the types ?
I would like to do something like that:
#this is just pseudo code
for item ... | [
"You may be looking for locals, which returns a dict with locals vars name and their values:\nfor name, value in locals().items():\n if isinstance(value, someclass):\n do something\n\nOK, I am editing this answer, because it is the closest of what I want:\nI wanted to erase all numpy array. I find it ann... | [
5,
4,
0,
0
] | [] | [] | [
"python",
"scope",
"types"
] | stackoverflow_0006495104_python_scope_types.txt |
Q:
Parse Python's serialized object in Perl
I need to make my Perl code read some Python's serialized object for later processing. I came with parser based on Parse::MGC, but it's slow. May be I did it wrong or may be someone knows better way to convert Python's serialized object in some sort of Perl structure?
Here ... | Parse Python's serialized object in Perl | I need to make my Perl code read some Python's serialized object for later processing. I came with parser based on Parse::MGC, but it's slow. May be I did it wrong or may be someone knows better way to convert Python's serialized object in some sort of Perl structure?
Here is my Parse code:
package Room::HandParser;
us... | [
"How about you use a different format? JSON for example is fairly easy to parse, and there are implementations in Perl that should work out-of-the box. Python has JSON serialization and deserialization built into it, so you won't have to reinvent any wheels there either.\n",
"If anyone interested: I end up with f... | [
6,
0
] | [] | [] | [
"parsing",
"perl",
"python"
] | stackoverflow_0006163505_parsing_perl_python.txt |
Q:
How can I use a positional argument with a space in it in Pythonbrew?
I have been using the argparse module for accepting input into a program, with much success. I have defined about six optional arguments (arguments that need to be prepended with a -- can be placed anywhere in the list) and one positional argume... | How can I use a positional argument with a space in it in Pythonbrew? | I have been using the argparse module for accepting input into a program, with much success. I have defined about six optional arguments (arguments that need to be prepended with a -- can be placed anywhere in the list) and one positional argument (required arguments that use the order placed to determine the argument)... | [
"The problem is in pythonbrew/commands/py.py. Each call to subprocess.Popen() needs to be modified so that it uses a list for the command instead of a string.\n",
"I can not post a comment since I am too new, but have you tried to escape the space, by placing a \\ in front of it? Maybe something like :\npythonbre... | [
2,
1
] | [] | [] | [
"argparse",
"arguments",
"python"
] | stackoverflow_0006495673_argparse_arguments_python.txt |
Q:
Searching lists and comparing with another not exact list
I have two lists that are not exact matches but do not content that almost match and I want to compare them and get out a list of one that match and do not match:
name = ['group', 'sound', 'bark', 'dentla', 'test']
compare = ['notification[bark]', 'notific... | Searching lists and comparing with another not exact list | I have two lists that are not exact matches but do not content that almost match and I want to compare them and get out a list of one that match and do not match:
name = ['group', 'sound', 'bark', 'dentla', 'test']
compare = ['notification[bark]', 'notification[dentla]',
'notification[group]', 'notification... | [
"for n in name:\n match = any(('[%s]'%n) in e for e in compare)\n print \"%10s %s\" % (n, \"YES\" if match else \"NO\")\n\n",
"You can use comprehensions for making compare list usable; and you can check items in name with item in clean_compare:\n>>> clean_compare = [i[13:-1] for i in compare]\n>>> clean_co... | [
2,
2,
0
] | [] | [] | [
"compare",
"list",
"match",
"python"
] | stackoverflow_0006495813_compare_list_match_python.txt |
Q:
How to make a PyGTK widget respond quickly when the callback takes too long?
I do a time-consuming processing in the _init callback function. Therefore, at the GUI, when I activate the check-button, the program freezes, while the processing runs to completion, and then the check mark appears and execution resumes ... | How to make a PyGTK widget respond quickly when the callback takes too long? | I do a time-consuming processing in the _init callback function. Therefore, at the GUI, when I activate the check-button, the program freezes, while the processing runs to completion, and then the check mark appears and execution resumes normally.
self.init = gtk.CheckButton("Init", False)
self.init.connect("toggled",... | [
"You have several solutions:\n\nMake the computation in a worker thread, which will send the result to the main thread. But don't change GUI items in the worker thread. Like most toolkits, GTK is not thread safe. I don't really like that one, as I don't really like threads, as they tend to make debugging harder...\... | [
2
] | [
"In the handler, register the rest of the init as idle-handler and return. gtk.idle_add IIRC. That way it will run after the gui events are handled. Check documentation to see which value you need to return so the function is not started again.\n"
] | [
-1
] | [
"gtk",
"pygtk",
"python"
] | stackoverflow_0006491345_gtk_pygtk_python.txt |
Q:
Django query sets on many-2-many field
I am working on the following:
# models.py
class FinancialProduct(models.Model):
active = models.BooleanField(default=True)
businesses = models.ManyToManyField(Business)
name = models.CharField(max_length=40, unique=True)
class Item(models.Model):
main_clien... | Django query sets on many-2-many field | I am working on the following:
# models.py
class FinancialProduct(models.Model):
active = models.BooleanField(default=True)
businesses = models.ManyToManyField(Business)
name = models.CharField(max_length=40, unique=True)
class Item(models.Model):
main_client = models.ForeignKey(Client)
financial_... | [
"This is wrong:\nFinancialProduct(1,'Company1,Company2', 'Large Product')\n\nYou save an M2M with multiple queries. Say, like:\nFinancialProduct(1,'Company1', 'Large Product').save()\nFinancialProduct(1,'Company2', 'Large Product').save()\n\n",
"This absolutely fried my noodle (because all of this is highly count... | [
1,
0
] | [] | [] | [
"django",
"django_views",
"python"
] | stackoverflow_0006490818_django_django_views_python.txt |
Q:
Non-linear scaling of a colormap to enhance contrast
The following python code creates a heatmap of a matrix that contains normally distributed values
import numpy as np
from matplotlib import pylab as plt
np.random.seed(123) #make sure we all have same data
m = np.random.randn(200).reshape(10, 20)
plt.imshow(m, ... | Non-linear scaling of a colormap to enhance contrast | The following python code creates a heatmap of a matrix that contains normally distributed values
import numpy as np
from matplotlib import pylab as plt
np.random.seed(123) #make sure we all have same data
m = np.random.randn(200).reshape(10, 20)
plt.imshow(m, cmap='RdYlGn', interpolation='nearest')
plt.colorbar()
T... | [
"A colormap contains a dictionary of red, green and blue values mapped over the interval [0,1]. The Linear Segmented Colormap class docs give the example \ncdict = {'red': [(0.0, 0.0, 0.0),\n (0.5, 1.0, 1.0),\n (1.0, 1.0, 1.0)],\n\n 'green': [(0.0, 0.0, 0.0),\n (... | [
4
] | [] | [] | [
"color_mapping",
"color_scheme",
"matplotlib",
"python"
] | stackoverflow_0006492514_color_mapping_color_scheme_matplotlib_python.txt |
Q:
How to concat python lxml trees
I'm working with the freshbooks api using the refreshbooks[1] python script they've created. I'm limited to 100 results per call, so I was trying to put a group of calls together to put together a large list of elements to use with jquery datatables. My question is how do I concat t... | How to concat python lxml trees | I'm working with the freshbooks api using the refreshbooks[1] python script they've created. I'm limited to 100 results per call, so I was trying to put a group of calls together to put together a large list of elements to use with jquery datatables. My question is how do I concat two of these element trees?
Here are ... | [
"I was able to concatenate these items into list by first converting the items to lists then extending:\nclients = list(client_response.clients.client)\nclients.extend(list(client_response2.clients.client))\n\n"
] | [
1
] | [] | [] | [
"lxml",
"python"
] | stackoverflow_0006496061_lxml_python.txt |
Q:
Python Tkinter - canvas scrolling with mouse position
I think this is a very common question, but I couldn't find the answer.
I'm trying to make a window that scrolls depending on the mouse position: if the mouse is close to top of the screen, it scrolls to the top, if it is close to the right border, it scrolls t... | Python Tkinter - canvas scrolling with mouse position | I think this is a very common question, but I couldn't find the answer.
I'm trying to make a window that scrolls depending on the mouse position: if the mouse is close to top of the screen, it scrolls to the top, if it is close to the right border, it scrolls to the right and so on. Here is the code:
from tkinter impor... | [
"As you said this works only if mouse is in movement, otherwise the <Motion> event is not triggered. You can use a timer that is triggered after a timeout and only if the mouse is in the scrolling area. The following is just a pseudo-code which uses a resettable timer I found in ActiveState:\nTIMEOUT = 0.5\ntimer =... | [
0,
0
] | [
"The obvious reason for your program getting stuck is the moment x is less than 30 it goes into the loop and unless it gets out of the loop, you are not going to be able to control the mouse and unless you are able to control the mouse, the position will always be < 30 so your loop will be forever satisfied and wi... | [
-1
] | [
"mouse",
"python",
"scroll",
"tkinter"
] | stackoverflow_0006495317_mouse_python_scroll_tkinter.txt |
Q:
Run rtorrent on background use Python
Can I run the rtorrent client in the background using Python?
I am trying to do it using PIPE import threading from subprocess import Popen, PIPE
class RunClient(threading.Thread):
queue_cmd = None
torrent = None
def __init__(self,q_cmd,torrent):
self.queu... | Run rtorrent on background use Python | Can I run the rtorrent client in the background using Python?
I am trying to do it using PIPE import threading from subprocess import Popen, PIPE
class RunClient(threading.Thread):
queue_cmd = None
torrent = None
def __init__(self,q_cmd,torrent):
self.queue_cmd = q_cmd
threading.Thread.__in... | [
"Two problems here:\n\nprocess.communicate() will block until the process is terminated.\nrtorrent is designed to be run in a terminal, it is useless if you don't run it in a tty/pty.\n\n"
] | [
0
] | [] | [] | [
"background",
"daemon",
"python"
] | stackoverflow_0006496355_background_daemon_python.txt |
Q:
Compress whitespaces in string
Possible Duplicate:
Substitute multiple whitespace with single whitespace in Python
How do I compress multiple whitespaces to 1 whitespace, in python?
For example, let's say I have a string
"some user entered text"
and I want that to become
"some user entered text"
A:
' '... | Compress whitespaces in string |
Possible Duplicate:
Substitute multiple whitespace with single whitespace in Python
How do I compress multiple whitespaces to 1 whitespace, in python?
For example, let's say I have a string
"some user entered text"
and I want that to become
"some user entered text"
| [
"' '.join(\"some user entered text\".split())\n\n",
">>> import re\n>>> re.sub(\"\\s+\",\" \",\"some user entered text\")\n'some user entered text'\n>>> \n\nEDIT:\nThis will also replace line breaks and tabs etc.\nIf you specifically want spaces / tabs you could use\n>>> import re\n>>> re.sub(\"[ \\t]... | [
28,
10,
2,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006496884_python_regex.txt |
Q:
How can I create a buffer which Python would not free?
I need to call a function in a C library from python, which would free() the parameter.
So I tried create_string_buffer(), but it seems like that this buffer would be freed by Python later, and this would make the buffer be freed twice.
I read on the web that ... | How can I create a buffer which Python would not free? | I need to call a function in a C library from python, which would free() the parameter.
So I tried create_string_buffer(), but it seems like that this buffer would be freed by Python later, and this would make the buffer be freed twice.
I read on the web that Python would refcount the buffers, and free them when there ... | [
"Try the following in the given order:\n\nTry by all means to manage your memory in Python, for example using create_string_buffer(). If you can control the behaviour of the C function, modify it to not free() the buffer.\nIf the library function you call frees the buffer after using it, there must be some library... | [
3
] | [] | [] | [
"buffer",
"c",
"ctypes",
"free",
"python"
] | stackoverflow_0006496981_buffer_c_ctypes_free_python.txt |
Q:
\ characters adding where they shouldn't be
PHP:
$var = "Sum Random'z String"s with quotemarks"
$send = base64_encode($var)
Then it sends the base64 encoded string to server.
Server part (Python) tryes to decode the base64-encoded content and write it into file:
f = open("/root/data.yml","w")
f.write(base64.b64de... | \ characters adding where they shouldn't be | PHP:
$var = "Sum Random'z String"s with quotemarks"
$send = base64_encode($var)
Then it sends the base64 encoded string to server.
Server part (Python) tryes to decode the base64-encoded content and write it into file:
f = open("/root/data.yml","w")
f.write(base64.b64decode(sys.argv[1]))
f.close()
sys.argv[1] is $sen... | [
"You don't need to escape both the single and double quote. You only need to escape what you're quoting the string with (i.e. \")\n$var = \"Sum Random'z String\\\"s with quotemarks\";\n\nThis may not be your only problem. But it is part of the problem.\nUPDATE\nPer your update of $var being set with data from a for... | [
4,
1,
0,
0
] | [
"Try this:-\nf = open(\"/root/data.yml\",\"w\")\nx = base64.b64decode(sys.argv[1])\nx.replace(\"\\\"\", \"\")\nf.write(x)\nf.close()\n\nHope it helps.\n"
] | [
-1
] | [
"php",
"python",
"ssh",
"ubuntu_11.04"
] | stackoverflow_0006497075_php_python_ssh_ubuntu_11.04.txt |
Q:
Problem with Python's is None test?
I like using the is None test for empty variables, it's very flexible, easy and useful. It seems to have stopped working now:
>"" is None
False
>[] is None
False
>{} is None
False
What's going on?
I'm using Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5], on Deb... | Problem with Python's is None test? | I like using the is None test for empty variables, it's very flexible, easy and useful. It seems to have stopped working now:
>"" is None
False
>[] is None
False
>{} is None
False
What's going on?
I'm using Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5], on Debian/Sid i686 GNU/Linux.
Edit: Awesome tip... | [
"The test x is None tests if x really is the None object (that is, if the name x references the object None). What you are looking for is truth value testing:\nif \"\":\n print \"non-empty\"\nelse:\n print \"empty\"\n\nif implicitly converts the condition to bool. You can also explicitly do this:\n>>> bool(... | [
7,
2,
1,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0006497166_python.txt |
Q:
Remove -#### in zipcodes
How do I remove the +4 from zipcodes, in python?
I've got data like
85001
52804-3233
Winston-Salem
And I want that to become
85001
52804
Winston-Salem
A:
>>> zip = '52804-3233'
>>> zip[:5]
'52804'
...and of course when you parse your lines from the original data you should insert some ... | Remove -#### in zipcodes | How do I remove the +4 from zipcodes, in python?
I've got data like
85001
52804-3233
Winston-Salem
And I want that to become
85001
52804
Winston-Salem
| [
">>> zip = '52804-3233'\n>>> zip[:5]\n'52804'\n\n...and of course when you parse your lines from the original data you should insert some kind of rule to distinguish between zipcode to fix and other strings, but I don't know how your data looks like, so I can't help much (you could check if they are only digits and... | [
3,
3,
2,
2,
1,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006497293_python_regex.txt |
Q:
How to create a very large file cheaply using Python in Windows 7?
Possible Duplicate:
Quickly create large file on a windows system?
For testing purposes, I would like to be able to create and delete very large files (several GB's). I have no need to write anything specific to them. They could be random data... | How to create a very large file cheaply using Python in Windows 7? |
Possible Duplicate:
Quickly create large file on a windows system?
For testing purposes, I would like to be able to create and delete very large files (several GB's). I have no need to write anything specific to them. They could be random data. Is there a way to generate a large file by simply allocating the spa... | [
"This should work on ntfs filesystems, since they support sparse files. It's almost instantaneous.\nwith open(\"file.to.create\", \"w\") as file:\n file.truncate(10 ** 10)\n\nThe file will appearantly be filled with \\x00 bytes, but those are in fact just created as needed when you read from the file. It uses al... | [
23
] | [] | [] | [
"file",
"filesystems",
"python",
"windows_7"
] | stackoverflow_0006497722_file_filesystems_python_windows_7.txt |
Q:
how do i equate raw input with a variable value in python
This is my first 'program' or script or whatev. So if I am going about this completely wrong, feel free to make fun of me.
I wanted to make a textual, player vs player chess program.
My first instinct was to make the board an 8x8 list of lists like [[a1,a2.... | how do i equate raw input with a variable value in python | This is my first 'program' or script or whatev. So if I am going about this completely wrong, feel free to make fun of me.
I wanted to make a textual, player vs player chess program.
My first instinct was to make the board an 8x8 list of lists like [[a1,a2...a8]...[h1,h2...h8]], but was unsure how to attach values to t... | [
"I think what you actually want here is a dictionary containing the complete state of the board --\nboard = { \"a1\" : \"o\", \"a2\" : \"k\", # ...\n}\n\nthen you do\nif board[move] == \"o\":\n # take appropriate action\n\nAny time you find yourself thinking \"I want to look up a variable by its name\", a dictio... | [
3,
2,
2
] | [] | [] | [
"python"
] | stackoverflow_0006497744_python.txt |
Q:
Python Logging - Apply formatter globally
I use phrase !Silent to determine where the log record will be saved.
If log record message contains !Silent at the beginning of string, my Filter subclass rejects this message in a StreamHandler. But message is passed to other handlers such as FileHandler or MemoryHandler... | Python Logging - Apply formatter globally | I use phrase !Silent to determine where the log record will be saved.
If log record message contains !Silent at the beginning of string, my Filter subclass rejects this message in a StreamHandler. But message is passed to other handlers such as FileHandler or MemoryHandler, and is passed with !Silent phrase.
I created ... | [
"Honestly, I am not sure I fully understood your question, so forgive me if my answer is not what you are lookng for... yet, instead applying a filter on the input of every handler, I would add a property to the unicode (or string) object that you are passing around. Something like:\n>>> class LogMsg(unicode):\n...... | [
1
] | [] | [] | [
"logging",
"python"
] | stackoverflow_0006497556_logging_python.txt |
Q:
Supporting both Tcl and Python?
I have a binary application that is statically linked against Tcl and the front end is the Tcl interpreter. I would like to offer users the capability of using Python to execute the same commands, as keyword options. A sample of the Tcl syntax is:
set_foo -foo 1.0 -bar 3.0 -cat x
... | Supporting both Tcl and Python? | I have a binary application that is statically linked against Tcl and the front end is the Tcl interpreter. I would like to offer users the capability of using Python to execute the same commands, as keyword options. A sample of the Tcl syntax is:
set_foo -foo 1.0 -bar 3.0 -cat x
so the python equivalent might look ... | [
"You perhaps want to look at something like SWIG, which will allow you to create an application with a straitforward C interface (implemented any way you like) and expose that interface to a variety of other scripting languages. SWIG supports Tcl and Python, as well as Ruby, PHP, Scheme, Perl, and many others.\n",... | [
1,
0,
0
] | [] | [] | [
"api",
"c++",
"python",
"tcl"
] | stackoverflow_0006495965_api_c++_python_tcl.txt |
Q:
unable to send data using urllib and urllib2 (python)
Hello everybody (first post here).
I am trying to send data to a webpage. This webpage request two fields (a file and an e-mail address) if everything is ok the webpage returns a page saying "everything is ok" and sends a file to the provided e-mail address. I ... | unable to send data using urllib and urllib2 (python) | Hello everybody (first post here).
I am trying to send data to a webpage. This webpage request two fields (a file and an e-mail address) if everything is ok the webpage returns a page saying "everything is ok" and sends a file to the provided e-mail address. I execute the code below and I get nothing in my e-mail accou... | [
"Thanks everybody for your answers. I solve my problem using the mechanize library.\nimport mechanize \n\nbr = mechanize.Browser()\nbr.open('webpage.com') \n\nemail='user@domain.com'\n\nbr.select_form(nr=0) \nbr['email'] = email \nbr.form.add_file(open('filename'), 'mime-type', 'filename') \nbr.form.set_all_read... | [
3,
1
] | [] | [] | [
"file_upload",
"python",
"urllib",
"urllib2"
] | stackoverflow_0006479539_file_upload_python_urllib_urllib2.txt |
Q:
Python 'none' acting weird from one version to another
I'm working on an open source project. Python was upgraded, I THINK from 2.5 to 2.6, and this problem came up.
get_custom_fields(self.env) was called. self.env was None.
def get_custom_fields(self, customfield=None):
if not customfield:
... | Python 'none' acting weird from one version to another | I'm working on an open source project. Python was upgraded, I THINK from 2.5 to 2.6, and this problem came up.
get_custom_fields(self.env) was called. self.env was None.
def get_custom_fields(self, customfield=None):
if not customfield:
...
else:
...
Previo... | [
"Although None is still false, it is always recommended to compare to it using is for performance and correctness reasons (i.e. if foo is None).\n",
"\nDid the python upgrade change how optional arguments handle None for some conditionals?\n\nNo. None is still false. Check the value of self.env, it might have bee... | [
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0006497952_python.txt |
Q:
Converting a python list into a javascript array
So I'm trying to form a javascript array of dates that I can feed as input to a jquery datepicker addon. My Django view is:
def autofill_featured(request):
show_id = request.GET.get('show_id')
show = Show.objects.get(id=show_id)
data = []
for listi... | Converting a python list into a javascript array | So I'm trying to form a javascript array of dates that I can feed as input to a jquery datepicker addon. My Django view is:
def autofill_featured(request):
show_id = request.GET.get('show_id')
show = Show.objects.get(id=show_id)
data = []
for listing in show.listings.all():
string = str(listin... | [
"This portion of code is wrong:\nvar preselect = function () {\n var results = $.ajax({\n url: \"/autofill_featured\",\n dataType: \"json\",\n data: {show_id: $(\"#id_show_id\").val()}\n });\n return results;\n};\n\n$.ajax function does return jqXHR object, not ajax call result. What Y... | [
1
] | [] | [] | [
"django",
"javascript",
"jquery",
"json",
"python"
] | stackoverflow_0006497642_django_javascript_jquery_json_python.txt |
Q:
What language is better for serial programming and working with MySQL database? Python? Realbasic?
I'm doing a project that is serial based and has to update a database when a barcode is being read. Which programming language has better tools for working with a MySQl database and Serial communication. I debating r... | What language is better for serial programming and working with MySQL database? Python? Realbasic? | I'm doing a project that is serial based and has to update a database when a barcode is being read. Which programming language has better tools for working with a MySQl database and Serial communication. I debating right now between python and realbasic.
| [
"It's hard to imagine that Realbasic is a better choice than Python for any project.\n",
"Python is a general purpose language with tremendous community support and a \"batteries-included\" philosophy that leads to simple-designs that focus on the business problem at hand. It is a good choice for a wide variety o... | [
3,
3
] | [] | [] | [
"mysql",
"python",
"realbasic",
"serial_port"
] | stackoverflow_0006498272_mysql_python_realbasic_serial_port.txt |
Q:
Rich JavaScript Applications With django
I am working to build a django application and will relay on a lot of JavaScripting using JQuery. When using heavy javascripting I will require to pass some variables on run time and am trying to keep my code neat without inline js.
My first question: Is there a best pract... | Rich JavaScript Applications With django | I am working to build a django application and will relay on a lot of JavaScripting using JQuery. When using heavy javascripting I will require to pass some variables on run time and am trying to keep my code neat without inline js.
My first question: Is there a best practices for how to manage the js libraries that a... | [
"Rich applications: heavy client side, somewhat light server side\nI think, you should take a look at JavaScript frameworks that implement some sort of model-view-controller pattern on the client side (if you haven't done it already).\nHere is a quote from a discussion about one of these frameworks, backbone.js. I ... | [
9
] | [] | [] | [
"django",
"jquery",
"python"
] | stackoverflow_0006497354_django_jquery_python.txt |
Q:
python delayed execution
To implement streams as delayed lists in Lisp it's recommended to use Lisp macros.
(defmacro cons-stream (a b)
(cons ,a (delay ,b)))
(defmacro delay (expr)
`(memo-proc (lambda () ,expr)))
What would by Python and Perl way to do the same thing?
EDIT. Is it possible to use such a cool... | python delayed execution | To implement streams as delayed lists in Lisp it's recommended to use Lisp macros.
(defmacro cons-stream (a b)
(cons ,a (delay ,b)))
(defmacro delay (expr)
`(memo-proc (lambda () ,expr)))
What would by Python and Perl way to do the same thing?
EDIT. Is it possible to use such a cool construct as streams
(define... | [
"In Python, the closest structure would probably be a generator expression.\nIn Perl, there is not a native lazy list, but the language provides all of the primitives that are needed to build one. I have written a lazy list library called List::Gen which is available on CPAN.\nuse List::Gen '*';\n\nmy $primes = <2... | [
5,
4,
3,
1
] | [] | [] | [
"lisp",
"perl",
"python",
"sicp"
] | stackoverflow_0006497816_lisp_perl_python_sicp.txt |
Q:
Python method's arguments validation, ArgError
When programming in C# I usually write following arguments validation code:
void Process(object item) {
if (item == null) throw ArgumentNullException();
// code
}
Is it 'Pythonic' to do similar validation in Python? I really don't want anybody pass None to Pr... | Python method's arguments validation, ArgError | When programming in C# I usually write following arguments validation code:
void Process(object item) {
if (item == null) throw ArgumentNullException();
// code
}
Is it 'Pythonic' to do similar validation in Python? I really don't want anybody pass None to Process method. What type of Python Exception should I... | [
"Usually, you'd just try to make do with the arguments you got -- if someone passes None to your function it will fail anyway. There is no need to add complexity to your code without any benefit. Quite the contrary -- often such tests prevent your code from working for cases it would work fine wwithout the tests.... | [
5,
3
] | [] | [] | [
"arguments",
"python",
"validation"
] | stackoverflow_0006499390_arguments_python_validation.txt |
Q:
Suggestions for Making a Flowchart Library that uses JSON as Markup
So recently at work I have been tasked with creating a Flowchart library. I would just like to get some general suggestions on how I should approach this. We use mongodb for persistence, and Tornado Web Server as a backend. Basically what I nee... | Suggestions for Making a Flowchart Library that uses JSON as Markup | So recently at work I have been tasked with creating a Flowchart library. I would just like to get some general suggestions on how I should approach this. We use mongodb for persistence, and Tornado Web Server as a backend. Basically what I need is to create a library in javascript that has a means of importing JSON... | [
"Wouldn't it be easiest to just define different types of nodes in the flowchart, and then define which nodes each node is connected to? \nSimply display each type as different looking node and connections would simply be drawn as lines between them.\nWhy do loops or conditions need to be any different from the res... | [
1
] | [] | [] | [
"flowchart",
"javascript",
"jquery",
"json",
"python"
] | stackoverflow_0006497690_flowchart_javascript_jquery_json_python.txt |
Q:
Format a nested list in place
I have the following list of tuples --
[('one',[1,2,5,3,9,8]), ('two',[9,8,5,1])]
And need to sort the nested list, while keeping the ordering of the tuples as is --
[('one',[1,2,3,5,8,9]), ('two',[1,5,8,9])]
The way that I am currently doing this is with a for loop --
list_of_tuple... | Format a nested list in place | I have the following list of tuples --
[('one',[1,2,5,3,9,8]), ('two',[9,8,5,1])]
And need to sort the nested list, while keeping the ordering of the tuples as is --
[('one',[1,2,3,5,8,9]), ('two',[1,5,8,9])]
The way that I am currently doing this is with a for loop --
list_of_tuples = [('one',[1,2,5,3,9,8]), ('two',... | [
"Doesn't get much easier:\nfor t in list_of_tuples:\n t[1].sort()\n\n",
"Just us a list comprehension.\nsorted_list = [(x[0],sorted(x[1])) for x in list_of_tuples]\n\n"
] | [
8,
1
] | [] | [] | [
"python"
] | stackoverflow_0006499616_python.txt |
Q:
Making a flat list out of a multi-type nested list
Possible Duplicate:
Flatten (an irregular) list of lists in Python
I have the following list --
[1,[2,3],4,[5,[6,7]]]
And I need to make it flat --
[1,2,3,4,5,6,7]
To do this, I am currently using a for loop with isinstance, with the number of loops being #nes... | Making a flat list out of a multi-type nested list |
Possible Duplicate:
Flatten (an irregular) list of lists in Python
I have the following list --
[1,[2,3],4,[5,[6,7]]]
And I need to make it flat --
[1,2,3,4,5,6,7]
To do this, I am currently using a for loop with isinstance, with the number of loops being #nests - 1.
What woud be the simplest way to make the nest... | [
"Hauled from webhelpers.misc.flatten\ndef flatten(iterable):\n \"\"\"Recursively iterate lists and tuples.\n \"\"\"\n for elm in iterable:\n if isinstance(elm, (list, tuple)):\n for relm in flatten(elm):\n yield relm\n else:\n yield elm\n\nEDIT: The iterab... | [
8,
1
] | [] | [] | [
"python"
] | stackoverflow_0006499839_python.txt |
Q:
A multimedia-rich application for windows, is Python enough good?
I'm going to develop a multimedia application which is running mostly on windows.
I don't know whether python is a good choice or not and which GUI library (Wxpython or pyqt) is suitable for that. Maybe pyQt is enough(like it).
The major features of... | A multimedia-rich application for windows, is Python enough good? | I'm going to develop a multimedia application which is running mostly on windows.
I don't know whether python is a good choice or not and which GUI library (Wxpython or pyqt) is suitable for that. Maybe pyQt is enough(like it).
The major features of the application include:
Must have a rich GUI, a great look and feel ... | [
"Python 3 doesn't work with wxPython right now. Python 3 does work with pyQT, but it is under GPL, so you will need to buy a license if you do not want to release your software under the GPL.\n"
] | [
0
] | [] | [] | [
"multimedia",
"programming_languages",
"python",
"user_interface"
] | stackoverflow_0006499507_multimedia_programming_languages_python_user_interface.txt |
Q:
Why is my Django URL Dispatcher not working?
I'm really confused as to why my URL dispatcher is not matching this url
http://127.0.0.1:8000/2011/jun/26/third-entry/
This is what my main url dispatcher looks like
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
(r'^blog/', include('django... | Why is my Django URL Dispatcher not working? | I'm really confused as to why my URL dispatcher is not matching this url
http://127.0.0.1:8000/2011/jun/26/third-entry/
This is what my main url dispatcher looks like
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
(r'^blog/', include('djangoblog.blog.urls')),
)
And inside my blog folder I ... | [
"Your regexp is wrong.\n(?P<year>d{4}) should be (?P<year>\\d{4})\nThe same applies to the other parts of the URI:\n\n(?P<day>\\d{1,2})\n(?P<slug>[-\\w]+)\n\n"
] | [
3
] | [] | [] | [
"dispatcher",
"django",
"python",
"url"
] | stackoverflow_0006500090_dispatcher_django_python_url.txt |
Q:
Meaning of the map function in couchdb-pythons ViewField
I'm using the couchdb.mapping in one of my projects. I have a class called SupportCase derived from Document that contains all the fields I want.
My database (called admin) contains multiple document types. I have a type field in all the documents which I u... | Meaning of the map function in couchdb-pythons ViewField | I'm using the couchdb.mapping in one of my projects. I have a class called SupportCase derived from Document that contains all the fields I want.
My database (called admin) contains multiple document types. I have a type field in all the documents which I use to distinguish between them. I have many documents of type ... | [
"I think what you need is:\n@classmethod\ndef all(cls):\n result = cls.view(db, \"support/all\", include_docs=True)\n return result.rows\n\nDocument class has a classmethod view which wraps the rows by class on which it is called. So the following returns you a ViewResult with rows of type SupportCase and tak... | [
3,
0,
0
] | [] | [] | [
"couchdb",
"couchdb_python",
"python"
] | stackoverflow_0005883068_couchdb_couchdb_python_python.txt |
Q:
Ruby vs. Python: which one is easier to keep track of different language versions?
I've heard that there are issues with the more recent versions of Python (3.x?) that have led to slower adoption. Is that true? And if so, is it an issue when different people are using different versions of the language? Which vers... | Ruby vs. Python: which one is easier to keep track of different language versions? | I've heard that there are issues with the more recent versions of Python (3.x?) that have led to slower adoption. Is that true? And if so, is it an issue when different people are using different versions of the language? Which version of Python is most widespread?
Does Ruby have a similar issue, or did most people swi... | [
"The issues aren't with Python 3.x, but the lack of a reasonable transition path from 2.x to 3.x causing most people to stay on 2.x.\nIt was a serious blunder, but an isolated one: aside from that, Python updates are very straightforward.\n",
"As far as Python, most people are using the latest version of the 2 se... | [
3,
1,
1,
1,
1
] | [] | [] | [
"python",
"ruby"
] | stackoverflow_0006499829_python_ruby.txt |
Q:
How do I create a list of links for all pastes in a Django pastebin app?
I have set up a pastebin app with Django but I would like to be able to create a list of links to each individual paste on my homepage's template. I have been trying out a number of different things but am struggling to figure it out.
Here i... | How do I create a list of links for all pastes in a Django pastebin app? | I have set up a pastebin app with Django but I would like to be able to create a list of links to each individual paste on my homepage's template. I have been trying out a number of different things but am struggling to figure it out.
Here is what I have so far on the template, the app is named oxybeles:
<ul>
{% for ... | [
"for item in items\n\nwhere items is a queryset full of PastedItem's:\nitems = PastedItem.objects.all()\n\nand items is proffered to the template:\n{'form':form, 'items': items}\n\n"
] | [
1
] | [] | [] | [
"django",
"pastebin",
"python"
] | stackoverflow_0006500262_django_pastebin_python.txt |
Q:
Overriding __getattr__ to support dynamic nested attributes
What is the best approach to take if you want to dynamically create and reference nested attributes?
I was writing a simple Flickr client, and wanted to match the documented API as closely as possible, without actually defining every method. For instance,... | Overriding __getattr__ to support dynamic nested attributes | What is the best approach to take if you want to dynamically create and reference nested attributes?
I was writing a simple Flickr client, and wanted to match the documented API as closely as possible, without actually defining every method. For instance, to make a request to Flickr's flickr.people.getInfo API method:
... | [
"Thanks to Thomas K for pointing out that flipy already does this (and seems like a nice library for interacting with flickr). A cleaner approach:\nclass Method(object):\n def __init__(self, client, method_name):\n self.client = client\n self.method_name = method_name\n\n def __getattr__(self, k... | [
7
] | [] | [] | [
"getattr",
"python"
] | stackoverflow_0006498777_getattr_python.txt |
Q:
In Pyramid, using traversal, how do create dynamic urls?
I am new to Pyramid and have created an application. I have a database with a table of categories. A category might be color with the attributes Red and Green, and another category might be size with the attributes 4 and 5.
I'd like to be able to create link... | In Pyramid, using traversal, how do create dynamic urls? | I am new to Pyramid and have created an application. I have a database with a table of categories. A category might be color with the attributes Red and Green, and another category might be size with the attributes 4 and 5.
I'd like to be able to create links that are like: domain.com/{category}.
So let's say I have tw... | [
"First, you'll want your Root resource to return different resource types from __getitem__:\nclass Root(object):\n def __getitem__(self, key):\n if key in ['Red', 'Green']:\n return ColorCategory(key)\n elif key in ['4', '5']:\n return SizeCategory(key)\n\nclass ColorCategory(... | [
6
] | [] | [] | [
"pyramid",
"python",
"traversal"
] | stackoverflow_0006499735_pyramid_python_traversal.txt |
Q:
python urllib2 question
I am trying to print some info from an url, but I want to skip the print if a certain text if found, I have:
import urllib2
url_number = 1
url_number_str = number
a = 1
while a != 10:
f = urllib2.urlopen('http://example.com/?=' + str(url_number_str)
f_contents = f.read()
if f_... | python urllib2 question | I am trying to print some info from an url, but I want to skip the print if a certain text if found, I have:
import urllib2
url_number = 1
url_number_str = number
a = 1
while a != 10:
f = urllib2.urlopen('http://example.com/?=' + str(url_number_str)
f_contents = f.read()
if f_contents != '{"Response":"Par... | [
"Although your question is a bit unclear, try this:\nf = urllib2.urlopen('http://example.com/?id=1000')\nfor line in f.readlines():\n if line != '{\"Response\":\"Parse Error\"}':\n print line\n\nThis loops over every line in the webpage, and stops at '{\"Response\":\"Parse Error\"}'.\nEdit: Nevermind, thi... | [
0,
0,
0
] | [] | [] | [
"json",
"printing",
"python",
"urllib2"
] | stackoverflow_0006499480_json_printing_python_urllib2.txt |
Q:
Why can't I unpack a float with other types and get the expected result?
I'm trying to parse out some data packed into this binary file and Python's struct module is causing me all sorts of problems. It won't seem to give me the correct float variable when it's trying to do more than one type at a time:
import st... | Why can't I unpack a float with other types and get the expected result? | I'm trying to parse out some data packed into this binary file and Python's struct module is causing me all sorts of problems. It won't seem to give me the correct float variable when it's trying to do more than one type at a time:
import struct
# a fragment of the binary file
a = '\x39\x00\xFF\x00\x00\x0A\x00\x1F\x0... | [
"\nBy default, C types are represented in the machine’s native format and byte order, and properly aligned by skipping pad bytes if necessary (according to the rules used by the C compiler).\n\nThe unpacking expects the float to be aligned on an 8-byte boundary and skips over 1 padding byte to get there. You can co... | [
8
] | [] | [] | [
"python",
"struct"
] | stackoverflow_0006500604_python_struct.txt |
Q:
Failed to start post-commit hook
I'm struggling to get a subversion post commit hook to work.
When I commit, I get the error:
Failed to start '/svn/web/hooks/post-commit' hook
I read around a bit with people that had similar problems, and they all related to the lack of environment, or incorrect file permissions,... | Failed to start post-commit hook | I'm struggling to get a subversion post commit hook to work.
When I commit, I get the error:
Failed to start '/svn/web/hooks/post-commit' hook
I read around a bit with people that had similar problems, and they all related to the lack of environment, or incorrect file permissions, so I ran this:
sudo -u www-data env -... | [
"It was a problem with my line endings.\n fromdos post-commit\n\nDid the trick.\n"
] | [
0
] | [] | [] | [
"bash",
"python",
"svn"
] | stackoverflow_0006407446_bash_python_svn.txt |
Q:
python "re" package, strange phenomenon with "raw" string
I am seeing the following phenomenon, couldn't seem to figure it out, and didn't find anything with some search through archives:
if I type in:
>>> if re.search(r'\n',r'this\nis\nit'):<br>
... print 'found it!'<br>
... else:<br>
... print "didn't fi... | python "re" package, strange phenomenon with "raw" string | I am seeing the following phenomenon, couldn't seem to figure it out, and didn't find anything with some search through archives:
if I type in:
>>> if re.search(r'\n',r'this\nis\nit'):<br>
... print 'found it!'<br>
... else:<br>
... print "didn't find it"<br>
...
I will get:
didn't find it!
However, if I typ... | [
"re.search(r'\\n', r'this\\nis\\nit')\n\nAs you said, \"there will never be a regular expression in the second string.\" So we need to look at these strings differently: the first string is a regex, the second just a string. Usually your second string will not be raw, so any backslashes are Python-escapes, not rege... | [
3,
2,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006500521_python_regex.txt |
Q:
Consistency in postgresql with locking and select for update
I have an application that can support a certain number of concurrent actions. This is represented by a table of "slots" in postgres. When nodes come online, they insert a number of rows into the table, one per slot. As jobs claim the slots, they upda... | Consistency in postgresql with locking and select for update | I have an application that can support a certain number of concurrent actions. This is represented by a table of "slots" in postgres. When nodes come online, they insert a number of rows into the table, one per slot. As jobs claim the slots, they update a row in the table claiming one of the slots and release it aga... | [
"BEGIN; \nLOCK TABLE slots IN ACCESS EXCLUSIVE MODE; \nUPDATE slots SET job_name = '111' WHERE id IN (SELECT id FROM slots WHERE job_name IS NULL LIMIT 1) RETURNING *;\nCOMMIT;\n\nThis seems to work in Read Committed. It is only sql (same as your code) and can be executed in one call (faster).\n@Seth Robertson: It ... | [
4,
2,
1
] | [] | [] | [
"postgresql",
"python",
"sql"
] | stackoverflow_0006497545_postgresql_python_sql.txt |
Q:
how to create index in elixir? by using sqlalchemy or what?
I'm using elixir, and I cannot find any index creation method,
and I'm not familiar with sqlalchemy, any examples?
A:
asked this question elsewhere, with this answer:
Field(Unicode(10), index=True)
| how to create index in elixir? by using sqlalchemy or what? | I'm using elixir, and I cannot find any index creation method,
and I'm not familiar with sqlalchemy, any examples?
| [
"asked this question elsewhere, with this answer:\nField(Unicode(10), index=True)\n\n"
] | [
2
] | [] | [] | [
"python",
"python_elixir",
"sqlalchemy"
] | stackoverflow_0006500747_python_python_elixir_sqlalchemy.txt |
Q:
Lexical error: Encountered: "" (0), after : ""
I needed to start dealing with foreign characters, and in doing so, I think I royally screwed up a file's encoding.
The error I'm getting is:
Lexical error at line 1, column 8. Encountered: "" (0), after : ""
The first line of the file is:
import xml.etree.cElement... | Lexical error: Encountered: "" (0), after : "" | I needed to start dealing with foreign characters, and in doing so, I think I royally screwed up a file's encoding.
The error I'm getting is:
Lexical error at line 1, column 8. Encountered: "" (0), after : ""
The first line of the file is:
import xml.etree.cElementTree as ET
Also of note: when I pasted the line abo... | [
"If it is indeed a zero character in there, you may find you've injected some UTF-16/UCS-2 text. That particular Unicode encoding would have a zero byte in between every ASCII character.\nThe best way to find out is to do a hex dump of you file with something like od -xcb myfile.py.\nIf that is the case, then you'l... | [
3
] | [] | [] | [
"lexical",
"python"
] | stackoverflow_0006501115_lexical_python.txt |
Q:
Tornado: Make Blocking HTTP Request in Async Handler
I'm trying to write an app in Tornado that, upon receiving a POST request containing a category, will call a function that will make (blocking) HTTP requests to a list of RSS feeds (held in a CouchDB database) with that topic, then perform some sorting on the da... | Tornado: Make Blocking HTTP Request in Async Handler | I'm trying to write an app in Tornado that, upon receiving a POST request containing a category, will call a function that will make (blocking) HTTP requests to a list of RSS feeds (held in a CouchDB database) with that topic, then perform some sorting on the data, returning a dictionary to the Tornado async request ha... | [
"without more details it's hard to answer. It sounds like an issue using global variables or something like that. A good way to help debug this type of issue is to add logging statements before and after you modify data at each step.\nrun your tornado app with --logging=debug on the command line to enable DEBUG lev... | [
1
] | [] | [] | [
"asynchronous",
"python",
"tornado"
] | stackoverflow_0006498992_asynchronous_python_tornado.txt |
Q:
Help with finding item in csv in python
I'm very novice in python. I have an unchanging csv, here's an example (I just printed it by row in the python console)
['george', 'williams', '277389', 'susan thompson', '2042228888']
['john', 'smith', '833999', 'george smith', '2041118833']
['michael', 'jackson', '281038',... | Help with finding item in csv in python | I'm very novice in python. I have an unchanging csv, here's an example (I just printed it by row in the python console)
['george', 'williams', '277389', 'susan thompson', '2042228888']
['john', 'smith', '833999', 'george smith', '2041118833']
['michael', 'jackson', '281038', 'ronald jackson', '2041128493']
these are t... | [
"I would personally go with a dictionary:\nrecords = [\n ['george', 'williams', '277389', 'susan thompson', '2042228888'],\n ['john', 'smith', '833999', 'george smith', '2041118833'],\n ['michael', 'jackson', '281038', 'ronald jackson', '2041128493'],\n ]\n\nfrom operator import itemgetter\nrecordsbyid ... | [
4,
1,
1,
0,
0
] | [] | [] | [
"csv",
"field",
"python",
"return",
"search"
] | stackoverflow_0006501316_csv_field_python_return_search.txt |
Q:
When using the proxy pattern in Python, how can proxy classes access state in the calling object?
In the following code, Graph() is acting as a proxy to Vertex and Edge -- clients only access Vertex and Edge through Graph():
from rest import Resource
from elements import Vertex, Edge
class Graph(object):
de... | When using the proxy pattern in Python, how can proxy classes access state in the calling object? | In the following code, Graph() is acting as a proxy to Vertex and Edge -- clients only access Vertex and Edge through Graph():
from rest import Resource
from elements import Vertex, Edge
class Graph(object):
def __init__(self,db_url):
self.resource = Resource(db_url)
self.vertices = Vertex
... | [
"If your resource object is unique, could you make it a singleton? The fact that you want to use it from a class method makes me think that it's probably the case. If its only purpose is to provide the database connection, could you consider using a connection pool?\nIf you still need to pass it to your classes, yo... | [
1
] | [] | [] | [
"dependency_injection",
"design_patterns",
"global_variables",
"proxy_classes",
"python"
] | stackoverflow_0006501193_dependency_injection_design_patterns_global_variables_proxy_classes_python.txt |
Q:
Mercurial and hgweb on IIS 7.5 - python error
I am trying to get Mercurial to host on IIS 7.5 (Win 7 x64) and keep running into an error I cant seem to fix.
I have followed Jeremy Skinners tutorial here: Mercurial on IIS7
Instead of hgwebdir, I use hgweb as I am using Mercurial 1.7.2
I have python installed and wo... | Mercurial and hgweb on IIS 7.5 - python error | I am trying to get Mercurial to host on IIS 7.5 (Win 7 x64) and keep running into an error I cant seem to fix.
I have followed Jeremy Skinners tutorial here: Mercurial on IIS7
Instead of hgwebdir, I use hgweb as I am using Mercurial 1.7.2
I have python installed and working. I set up a IIS application for Mercurial at... | [
"I've been struggling with this same setup for the past week or so.\nIt looks to me like they have made some significant changes to how mercurial works in IIS recently, so the link above to Jeremy Skinners tutorial will be problematic for 1.7.2\nThis is a more recent link\nI found I had to do a couple things differ... | [
15,
3,
3,
1
] | [] | [] | [
"hgweb",
"iis",
"mercurial",
"python"
] | stackoverflow_0004355256_hgweb_iis_mercurial_python.txt |
Q:
Removing strings in brackets for unicode lines - python
i've got some problems with my regex and removing my the strongs bounded by brackets.
here's my code:
import sys, re
import codecs
reload(sys)
sys.setdefaultencoding('utf-8')
reader = codecs.open("input",'r','utf-8')
p = re.compile('s/[\[\(].+?[\]\)]//g', r... | Removing strings in brackets for unicode lines - python | i've got some problems with my regex and removing my the strongs bounded by brackets.
here's my code:
import sys, re
import codecs
reload(sys)
sys.setdefaultencoding('utf-8')
reader = codecs.open("input",'r','utf-8')
p = re.compile('s/[\[\(].+?[\]\)]//g', re.DOTALL)
# i've also tried several regex but it didn't work
... | [
"Would this work for you?\n# -*- coding: utf-8 -*-\nimport sys, re\nimport codecs\n\n#reload(sys)\n#sys.setdefaultencoding('utf-8')\n\n#prepareing the examples to work on\nwriter = codecs.open(\"input.txt\",'w','utf-8')\nexamples = [u'가시 돋친(신랄한)평 spinosity',\n u'가장 완전한 (같은 종류의 것 중에서)',\n u'알코올... | [
2
] | [] | [] | [
"brackets",
"dictionary",
"python",
"regex",
"string"
] | stackoverflow_0006501044_brackets_dictionary_python_regex_string.txt |
Q:
Decompose list of lists into single list with non-iterable list elements
Ref:
python decompose a list
Flattening a shallow list in Python
While the above mentioned solutions are helpful, my problem is slightly different, and I was wondering if there is a pythonic way to solve it.
a = [['a-3','b-3'],'r',['j']]
... | Decompose list of lists into single list with non-iterable list elements | Ref:
python decompose a list
Flattening a shallow list in Python
While the above mentioned solutions are helpful, my problem is slightly different, and I was wondering if there is a pythonic way to solve it.
a = [['a-3','b-3'],'r',['j']]
What I would like, is a clean way of making 'a' equal the following:
a = ['a-3... | [
"Pythonic solution can mean many thing. With readability counts (PEP 20) in mind, this is my contribution to the thread:\ndef dec(input_, output_):\n if type(input_) is list:\n for subitem in input_:\n dec(subitem, output_)\n else:\n output_.append(input_)\n\nExample:\ninput_ = [['a-3... | [
5,
2,
2,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0006498671_python.txt |
Q:
Scrapy Python spider: Storing results in Latin-1, not in unicode
Currently my spider fetches results as needed but encodes them in unicode (UTF-8, I believe). When I save these results to a csv, I have a ton of cleaning to do as a result, with all the [u' & other characters that Scrapy inserts.
How exactly would ... | Scrapy Python spider: Storing results in Latin-1, not in unicode | Currently my spider fetches results as needed but encodes them in unicode (UTF-8, I believe). When I save these results to a csv, I have a ton of cleaning to do as a result, with all the [u' & other characters that Scrapy inserts.
How exactly would I store the results as Latin characters, & not unicode. Where exactly ... | [
"The item_extracted is of type unicode. You can either encode it to latin where it's extracted (in the parse function) or in an item pipeline or output processor\nEasiest way is to add this line to your parse function\nitem_to_be_stored = item_extracted.encode('latin-1','ignore')\n\nOr you could define a function i... | [
4,
1
] | [] | [] | [
"python",
"scrapy",
"unicode"
] | stackoverflow_0006499803_python_scrapy_unicode.txt |
Q:
How do I take elements from diffrent XML files to create a new one through python?
I have two xml files:
1.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>... | How do I take elements from diffrent XML files to create a new one through python? | I have two xml files:
1.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</... | [
"The SubElement function expects a tag name (text string) as the second argument, not an element . Instead of calling SubElement try append. The last part of your script should be:\n#3.xml\nroot_element = ET.Element(\"root\")\nroot_element.append(Bookstore)\nroot_element.append(root2)\ntree = ET.ElementTree(root_el... | [
1
] | [] | [] | [
"python",
"xml"
] | stackoverflow_0006501512_python_xml.txt |
Q:
Loading shared library in Python that contains python API code?
I'm playing around with automatically generating some C code, compiling it to a shared library and loading it with ctypes, and I'm curious if anyone can enlighten me as to what might be required to use parts of the Python API from within such a librar... | Loading shared library in Python that contains python API code? | I'm playing around with automatically generating some C code, compiling it to a shared library and loading it with ctypes, and I'm curious if anyone can enlighten me as to what might be required to use parts of the Python API from within such a library (without creating a full-fledged module)
For example, I have some q... | [
"It seems it can be done in Python 2.7, which supports a ctypes.py_object as a type. I built a library from your example code and used the following:\nPython 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n... | [
3
] | [] | [] | [
"ctypes",
"python"
] | stackoverflow_0006501184_ctypes_python.txt |
Q:
python call-by-reference on primitive types
I have experience with the imperative languages(C most often), and that's probably why I am confused in learning python.
I am trying to implement a simple bitwise flag-setter functions. So in C it would be like:
void set_state(int *state, int var, int set)
{
(set)? *... | python call-by-reference on primitive types | I have experience with the imperative languages(C most often), and that's probably why I am confused in learning python.
I am trying to implement a simple bitwise flag-setter functions. So in C it would be like:
void set_state(int *state, int var, int set)
{
(set)? *state |= var : *state &= ~var
}
int is_state(int... | [
"Python ints are immutable, so while a reference is being passed in, it is not possible to change the value of the int object. As you have seen, the local variable is a copy of the reference, so they are both bound to the same integer. However when you change the value of the local variable, a new integer object is... | [
8,
5,
1
] | [] | [] | [
"pass_by_reference",
"primitive_types",
"python"
] | stackoverflow_0006502575_pass_by_reference_primitive_types_python.txt |
Q:
Is the better way to match two different repetitions of the same character class in a regex?
I had been using [0-9]{9,12} all along to signify that the numeric string has a length of 9 or 12 characters. However I now realized that it will match input strings of length 10 or 11 as well. So I came out with the naive... | Is the better way to match two different repetitions of the same character class in a regex? | I had been using [0-9]{9,12} all along to signify that the numeric string has a length of 9 or 12 characters. However I now realized that it will match input strings of length 10 or 11 as well. So I came out with the naive:
( [0-9]{9} | [0-9]{12} )
Is there a more succinct regex to represent this ?
| [
"You could save one character by using\n[0-9]{9}([0-9]{3})?\n\nbut in my opinion your way is better because it conveys your intention more clearly. Regexes are hard enough to read already.\nOf course you could use \\d instead of [0-9].\n(Edit: I first thought you could drop the parens around [0-9]{3} but you can't;... | [
7,
6,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006502592_python_regex.txt |
Q:
creating a color coded time chart using colorbar and colormaps in python
I'm trying to make a time tracking chart based on a daily time tracking file that I used. I wrote code that crawls through my files and generates a few lists.
endTimes is a list of times that a particular activity ends in minutes going from ... | creating a color coded time chart using colorbar and colormaps in python | I'm trying to make a time tracking chart based on a daily time tracking file that I used. I wrote code that crawls through my files and generates a few lists.
endTimes is a list of times that a particular activity ends in minutes going from 0 at midnight the first day of the month to however many minutes are in a mont... | [
"It sounds like you want something like a stacked bar chart with the color values mapped to a given range? In that case, here's a rough example: \nimport matplotlib.pyplot as plt\nimport matplotlib.cm as cm\nimport numpy as np\n\n# Generate data....\nintervals, weights = [], []\nmax_weight = 5\nfor _ in range(30):... | [
7
] | [] | [] | [
"color_mapping",
"colorbar",
"matplotlib",
"python"
] | stackoverflow_0006475082_color_mapping_colorbar_matplotlib_python.txt |
Q:
Running Scrapy from a script - Hangs
I'm trying to run scrapy from a script as discussed here. It suggested using this snippet, but when I do it hangs indefinitely. This was written back in version .10; is it still compatible with the current stable?
A:
from scrapy import signals, log
from scrapy.xlib.pydispatc... | Running Scrapy from a script - Hangs | I'm trying to run scrapy from a script as discussed here. It suggested using this snippet, but when I do it hangs indefinitely. This was written back in version .10; is it still compatible with the current stable?
| [
"from scrapy import signals, log\nfrom scrapy.xlib.pydispatch import dispatcher\nfrom scrapy.crawler import CrawlerProcess\nfrom scrapy.conf import settings\nfrom scrapy.http import Request\n\ndef handleSpiderIdle(spider):\n '''Handle spider idle event.''' # http://doc.scrapy.org/topics/signals.html#spider-idle\... | [
7
] | [] | [] | [
"python",
"scrapy"
] | stackoverflow_0006494067_python_scrapy.txt |
Q:
Django Pinax - How to use apps in other projects, not cloned Pinax projects?
This is a similar question,
Django "and" Pinax or just Pinax?
and one of the answers specifies a link to documentation, but that documentation doesn't describe how to plug a Pinax app into a separate project. Or I just can't find it there... | Django Pinax - How to use apps in other projects, not cloned Pinax projects? | This is a similar question,
Django "and" Pinax or just Pinax?
and one of the answers specifies a link to documentation, but that documentation doesn't describe how to plug a Pinax app into a separate project. Or I just can't find it there. Are there any other sources that have the easy way of achieving this?
| [
"Pinax, is a collection of reusable django apps packaged together with templates and some \"project code.\"\nIf you want just a particular feature of pinax like mailer, wiki, notification, photos, you are better of using the original projects that pinax included.\nIf you are going to tie up all these into some proj... | [
2
] | [] | [] | [
"django",
"pinax",
"python"
] | stackoverflow_0006500561_django_pinax_python.txt |
Q:
Understanding nested yield / return in python
I have a function in python whose output is a generator :
def main_function(x):
r = get_range()
for i in range(r):
yield x+i
I want to refactor the code (I've simplified the use case but actual computation might be complex & longer. Please see EDIT be... | Understanding nested yield / return in python | I have a function in python whose output is a generator :
def main_function(x):
r = get_range()
for i in range(r):
yield x+i
I want to refactor the code (I've simplified the use case but actual computation might be complex & longer. Please see EDIT below). Based on my understanding, this is what I sho... | [
"You're right; the initial example and a) do the same thing since both return a generator.\nb) is different: It returns a generator which yields a single element (which is another generator). To use that, you need two loops (one over the outer and one over the inner generator).\nThere are no advantages per se but s... | [
13
] | [] | [] | [
"generator",
"nested",
"python",
"yield"
] | stackoverflow_0006503079_generator_nested_python_yield.txt |
Q:
Can't localize python HTMLCalendar in django
Update: After researching a bit about the problem, (solved ASCII error, but now returns ValueError) I found that this is a documented bug (issue #3067) and therefore irresolvable until the bug is fixed in Python 2.7.3
I'm trying to localize a calendar made with python ... | Can't localize python HTMLCalendar in django | Update: After researching a bit about the problem, (solved ASCII error, but now returns ValueError) I found that this is a documented bug (issue #3067) and therefore irresolvable until the bug is fixed in Python 2.7.3
I'm trying to localize a calendar made with python HTMLCalendar in django, with no results. The calen... | [
"Funny, I just did this yesterday and stumbled across your question by accident.\nHere's how I got past the hurdles, sorry a bit complicated:\nsettings:\nLANGUAGE_CODE = 'en-us'\nFIRST_DAY_OF_WEEK = 0 # 0 is Sunday\n# Convert to calendar module, where 0 is Monday :/\nFIRST_DAY_OF_WEEK_CAL = (F... | [
7,
0
] | [] | [] | [
"calendar",
"django",
"localization",
"python"
] | stackoverflow_0006496247_calendar_django_localization_python.txt |
Q:
Get the frames values from the frames bytes
i'm using the aifc library for open an aif file and his method readframes(nframes) for read the frame in bytes.
But now i have to convert the bytes in a float list of values.
How can i do it?
A:
Did you look at the struct lib in python standard lib?
| Get the frames values from the frames bytes | i'm using the aifc library for open an aif file and his method readframes(nframes) for read the frame in bytes.
But now i have to convert the bytes in a float list of values.
How can i do it?
| [
"Did you look at the struct lib in python standard lib?\n"
] | [
0
] | [] | [] | [
"aif",
"audio",
"python"
] | stackoverflow_0006503340_aif_audio_python.txt |
Q:
Prevent memory error in itertools.permutation
Firstly I would like to mention that i have a 3 gb ram.
I am working on an algorithm that is exponential in time on the nodes so for it I have in the code
perm = list( itertools.permutations(list(graph.Nodes))) # graph.Nodes is a tuple of 1 , 2 , ... n integers
whic... | Prevent memory error in itertools.permutation | Firstly I would like to mention that i have a 3 gb ram.
I am working on an algorithm that is exponential in time on the nodes so for it I have in the code
perm = list( itertools.permutations(list(graph.Nodes))) # graph.Nodes is a tuple of 1 , 2 , ... n integers
which generates all the combinations of vertices in a l... | [
"Try to use the iterator generated by the permutations instead of recreating a list with it : \nperm_iterator = itertools.permutations(list(graph.Nodes))\n\nfor item in perm_iterator:\n do_the_stuff(item)\n\nby doing this, python will keep in memory only the currently used permutation, not all the permutations (i... | [
29,
4
] | [] | [] | [
"python",
"python_itertools"
] | stackoverflow_0006503388_python_python_itertools.txt |
Q:
custom libindicator icon is not displayed
I want to change the status icon of my own little reminder program. Currently I am using GTK.StatusIcon but I want to use a ApplicationIndicator.
Therefore I created an own Icon and moved it to:
/usr/share/icons/ubuntu-mono-dark/status/22
It is named indicator-notify.svg
... | custom libindicator icon is not displayed | I want to change the status icon of my own little reminder program. Currently I am using GTK.StatusIcon but I want to use a ApplicationIndicator.
Therefore I created an own Icon and moved it to:
/usr/share/icons/ubuntu-mono-dark/status/22
It is named indicator-notify.svg
Heres the code for the icon.
ind = appindicator... | [
"You don't need to register it, but your icon cache needs to be updated after installing new icons. You can do this via gtk-update-icon-cache (see http://developer.gnome.org/gtk/2.24/gtk-update-icon-cache.html)\n"
] | [
1
] | [] | [] | [
"gtk",
"python",
"ubuntu"
] | stackoverflow_0005315359_gtk_python_ubuntu.txt |
Q:
How can i use one view for different forms in Django
I have 5 Model forms like below
class AccountForm(ModelForm):
class Meta:
model = Account
class TransactionForm(ModelForm):
class Meta:
model = Transaction
.
.
.
.
Now for first form i have this view
def cr... | How can i use one view for different forms in Django | I have 5 Model forms like below
class AccountForm(ModelForm):
class Meta:
model = Account
class TransactionForm(ModelForm):
class Meta:
model = Transaction
.
.
.
.
Now for first form i have this view
def create_account(request, acc_id=None):
if acc_id:
... | [
"Store the forms in a dictionary, keyed by the model name.\nFORMS = {\n 'account': AccountForm,\n 'transaction': TransactionForm,\n ...\n}\n\ndef create_object(request, object_class, object_id=None):\n form_class = FORMS[object_class]\n model = form_class._meta.model\n if object_id:\n objec... | [
3,
0
] | [] | [] | [
"django",
"forms",
"python"
] | stackoverflow_0006502803_django_forms_python.txt |
Q:
How to approach IIS log parsing in a Pythonic way?
Ok, so I have some IIS logs that I would like to parse with Python (which I am fairly new to atm). A sample of IIS log looks like this:
#Software: Microsoft Internet Information Server 6.0
#Version: 1.0
#Date: 1998-11-19 22:48:39
#Fields: date time c-ip cs-use... | How to approach IIS log parsing in a Pythonic way? | Ok, so I have some IIS logs that I would like to parse with Python (which I am fairly new to atm). A sample of IIS log looks like this:
#Software: Microsoft Internet Information Server 6.0
#Version: 1.0
#Date: 1998-11-19 22:48:39
#Fields: date time c-ip cs-username s-ip cs-method cs-uri-stem cs-uri-query sc-status ... | [
"assuming that skip_header(file) returns only the log lines from the file and that parse(line) extracts the (ip, path) from the line:\nfrom collections import defaultdict\nfirst = defaultdict(int)\nsecond = defaultdict(lambda: defaultdict(int))\nfor line in skip_header(file):\n ip, path = parse(line)\n first[... | [
4
] | [] | [] | [
"iis",
"parsing",
"python"
] | stackoverflow_0006503798_iis_parsing_python.txt |
Q:
Python Database Structure and Updating Values and transition to GUI
Im working on a program in python that takes approximately 100 inputs and generates around 500 outputs.There are many calculations that have to be done in the middle and I am having several problems with structuring this program. I am currently se... | Python Database Structure and Updating Values and transition to GUI | Im working on a program in python that takes approximately 100 inputs and generates around 500 outputs.There are many calculations that have to be done in the middle and I am having several problems with structuring this program. I am currently setting up the program to receive inputs through command line and haven't d... | [
"What you describe in terms of having class instances containing other class instances with different types of data fits in really well with sqlalchemy. This provides you with a way to tie classes directly to underlying database tables.\nIf you define a class describing your output with relationships to your input ... | [
0
] | [] | [] | [
"database",
"differential_equations",
"excel",
"python",
"user_interface"
] | stackoverflow_0006503793_database_differential_equations_excel_python_user_interface.txt |
Q:
Python multiprocessing BETWEEN Amazon cloud instances
I'm looking to run a long-running python analysis process on a few Amazon EC2 instances. The code already runs using the python multiprocessing module and can take advantage of all cores on a single machine.
The analysis is completely parellel and each instance... | Python multiprocessing BETWEEN Amazon cloud instances | I'm looking to run a long-running python analysis process on a few Amazon EC2 instances. The code already runs using the python multiprocessing module and can take advantage of all cores on a single machine.
The analysis is completely parellel and each instance does not need to communicate with any of the others. All o... | [
"the docs give you a good setup for running multiprocessing on multiple machines. Using s3 is a good way to share files across ec2 instances, but with multiprocessing you can share queues and pass data.\nif you can use hadoop for parallel tasks, it is a very good way to extract parallelism across machines, but if y... | [
4,
0,
0
] | [] | [] | [
"amazon_ec2",
"multiprocessing",
"python",
"python_multithreading"
] | stackoverflow_0006457091_amazon_ec2_multiprocessing_python_python_multithreading.txt |
Q:
A-z Index Django
Im looking for advice on desinging a web page with an A - Z index.
Kind of like :
http://www.bls.gov/bls/topicsaz.htm
I have a long list of objects, with a title, that I want do display alphabetically, easy!
But I want to put in the A-Z with anchors, do I do this in the template,
I would have to ... | A-z Index Django | Im looking for advice on desinging a web page with an A - Z index.
Kind of like :
http://www.bls.gov/bls/topicsaz.htm
I have a long list of objects, with a title, that I want do display alphabetically, easy!
But I want to put in the A-Z with anchors, do I do this in the template,
I would have to loop through all the o... | [
"Looking through the django template tags I found a nice way of doing it {{ifchanged}}, its worth mentioning for future use.\nMy list of objects is passed to my template ordered alphabetically:\nObjects.get.all().order_by('title')\n\nThen in my template i do :\n# loop through all objects\n{% for obj in objs %}\n #... | [
5,
3,
2,
0,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0003617041_django_python.txt |
Q:
Automating selection in Javascript-generated type-ahead drop-down menu
I am writing a script to automate the filling out of a form using Selenium RC for python. One of the input fields has an AJAX type-ahead estimator that generates a drop-down list of suggestions as you type. I would like to select the first opti... | Automating selection in Javascript-generated type-ahead drop-down menu | I am writing a script to automate the filling out of a form using Selenium RC for python. One of the input fields has an AJAX type-ahead estimator that generates a drop-down list of suggestions as you type. I would like to select the first option, but since there is no HTML representation of the dynamically generated l... | [
"Use the following code that i tried on google page\n sel = self.selenium\n sel.open(\"http://www.google.co.in/\")\n sel.type_keys(\"q\", \"vi\")\n time.sleep(2)\n sel.key_down(\"q\", \"\\\\40\")\n sel.key_up(\"q\", \"\\\\40\")\n sel.key_press(\"q\", \"\\\\13\")\n\n"
] | [
0
] | [] | [] | [
"drop_down_menu",
"javascript",
"keypress",
"python",
"selenium_rc"
] | stackoverflow_0006498489_drop_down_menu_javascript_keypress_python_selenium_rc.txt |
Q:
Single Statement Fibonacci
Possible Duplicate:
Fibonacci numbers, with an one-liner in Python 3?
It may be very easy thing, but I am very new to Python. I came up with this single statement Fibonacci.
[fibs.append(fibs[-2]+fibs[-1]) for i in xrange(1000)]
Not really single statement, though. I need to initiali... | Single Statement Fibonacci |
Possible Duplicate:
Fibonacci numbers, with an one-liner in Python 3?
It may be very easy thing, but I am very new to Python. I came up with this single statement Fibonacci.
[fibs.append(fibs[-2]+fibs[-1]) for i in xrange(1000)]
Not really single statement, though. I need to initialise the list, fibs, before firin... | [
"This works:\nfor n in range(1000):\n print(0.4472135954999579392818347337462552470881236719223051448541*(pow(1.6180339887498948482045868343656381177203091798057628621354,n) - pow(-0.618033988749894848204586834365638117720309179805762862135,n)))\n\nThis is an implementation of Binet's Formula.\nhttp://en.wikiped... | [
3,
2,
1
] | [] | [] | [
"fibonacci",
"list_comprehension",
"python"
] | stackoverflow_0006504319_fibonacci_list_comprehension_python.txt |
Q:
implementing lisp in Python
First: yes, i have taken a very long look at Norvig's lispy. Second: I have reused part of his code.
On to my code, and my question. I am writing a really non-idiomatic lisp interpreter in Python, and I'm curious as to how I would write nested function definitions (e.g. (define square (... | implementing lisp in Python | First: yes, i have taken a very long look at Norvig's lispy. Second: I have reused part of his code.
On to my code, and my question. I am writing a really non-idiomatic lisp interpreter in Python, and I'm curious as to how I would write nested function definitions (e.g. (define square (lambda (x) (* x x))) then (define... | [
"Have a look at the output of pre_in:\n>>> pre_in(read_from(tok(\"(+ (square x) (square y))\")))\n'((x) + (y))'\n\nThat should be '(square(x) + square(y))'.\n(By the way, your example code contains a syntax error. SoS should be defined as (lambda (x y) (+ (square x) (square y))).)\n",
"in read_from you have the ... | [
2,
0
] | [] | [] | [
"implementation",
"interpreter",
"lisp",
"python",
"scheme"
] | stackoverflow_0006502795_implementation_interpreter_lisp_python_scheme.txt |
Q:
How to inject template code in Plone?
My goal is to inject some HTML-Code in front of every Plone article (between the page's header and the first paragraph)? I'm running Plone 4. Does anyone have a hint on how to realize that?
The other question is: is it possible to place some HTML code randomly in every Plone a... | How to inject template code in Plone? | My goal is to inject some HTML-Code in front of every Plone article (between the page's header and the first paragraph)? I'm running Plone 4. Does anyone have a hint on how to realize that?
The other question is: is it possible to place some HTML code randomly in every Plone article?
| [
"Use viewlets for both usecases. A viewlet can be inserted in different parts of the rendered page, depending on both the viewlet manager you register it to and and what interfaces the viewlet applies to.\nThe viewlet manager determines the location the viewlet is inserted at, and the interface you register the vie... | [
11
] | [
"Perhaps you could approach this from a Javascript way? A lot of applications have like a global js file, that's included in all pages. Starting from that you could modify the DOM easily.\n"
] | [
-1
] | [
"html",
"plone",
"python",
"templates",
"zope"
] | stackoverflow_0006503861_html_plone_python_templates_zope.txt |
Q:
Serve Django site using Nginx without proxy_pass
I have done the nginx configuration for serving django app .i am able to serve the django site using proxy pass for that i have to run the server manualy and then nginx serves the site.I want to execute the site using nginx but the server should get start automatica... | Serve Django site using Nginx without proxy_pass | I have done the nginx configuration for serving django app .i am able to serve the django site using proxy pass for that i have to run the server manualy and then nginx serves the site.I want to execute the site using nginx but the server should get start automaticaly it shoud not be go through proxy_pass is this possi... | [
"I think the problem here is that you try to serve your development server through nginx; That's not what it's for, it's for development purposes only. \nTo set up a production server you could use \n\ngunicorn in combination with supervisord to keep everything running (my preferred way of working these days), tuto... | [
3,
1
] | [] | [] | [
"django",
"nginx",
"python",
"uwsgi"
] | stackoverflow_0006504182_django_nginx_python_uwsgi.txt |
Q:
how to have a list of dictionaries in Objective C?
here is a an example in python
temy_dict_list = []
my_dict_list.append({'text':'first value', 'value':'number 1'})
my_dict_list.append({'text':'second value', 'value':'number 2'})
my_dict_list.append({'text':'third value', 'value':'number 3'})
I want to imple... | how to have a list of dictionaries in Objective C? | here is a an example in python
temy_dict_list = []
my_dict_list.append({'text':'first value', 'value':'number 1'})
my_dict_list.append({'text':'second value', 'value':'number 2'})
my_dict_list.append({'text':'third value', 'value':'number 3'})
I want to implement something the same as this in objective-c !
how can... | [
"NSMutableArray* list = [NSMutableArray array];\n[list addObject:[NSDictionary dictionaryWithObjectsAndKeys:@\"first value\",@\"text\", @\"number 1\",@\"value\", nil]];\n[list addObject:[NSDictionary dictionaryWithObjectsAndKeys:@\"second value\",@\"text\", @\"number 2\",@\"value\", nil]];\n[list addObject:[NSDicti... | [
6,
2,
2
] | [] | [] | [
"list",
"nsdictionary",
"objective_c",
"python"
] | stackoverflow_0006504287_list_nsdictionary_objective_c_python.txt |
Q:
Python socketserver problem
I'm trying to use threading socket server
self.server = SocketServer.ThreadingTCPServer( ( HOST, PORT ), MCRequestHandler )
and the destructor
def __del__( self ):
self.server.shutdown();
self.server.server_close()
print( 'Server closed ! ' );
When I close th... | Python socketserver problem | I'm trying to use threading socket server
self.server = SocketServer.ThreadingTCPServer( ( HOST, PORT ), MCRequestHandler )
and the destructor
def __del__( self ):
self.server.shutdown();
self.server.server_close()
print( 'Server closed ! ' );
When I close the GUI the del function will be ca... | [
"Make a subclass of TCPServer, and add this to it:\nclass TCPServer(SocketServer.TCPServer):\nallow_reuse_address = True \n\nBasically the same as setsockopt, but, easier.\n"
] | [
3
] | [] | [] | [
"python",
"tcp"
] | stackoverflow_0006505105_python_tcp.txt |
Q:
Get rid of a label inside a thread?
so i have this code:
import thread
from Tkinter import *
import random
import time
Admin=Tk()
def moveit(number):
songas=Label(Admin,text=number,bg='red')
def ji():
plad=0.0
recount=0
times=0
while 1:
plad-=0.1
reco... | Get rid of a label inside a thread? | so i have this code:
import thread
from Tkinter import *
import random
import time
Admin=Tk()
def moveit(number):
songas=Label(Admin,text=number,bg='red')
def ji():
plad=0.0
recount=0
times=0
while 1:
plad-=0.1
recount+=1
times+=1
t... | [
"Tkinter isn't thread safe -- you can't manipulate widgets in any thread except the main one or you'll get undefined results. \nYou don't need threads for this. Your code adds an infinite loop, but the application already has an infinite loop (the event loop) that you can take advantage of.\nIf you want to move som... | [
1,
0
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0006502013_python_tkinter.txt |
Q:
Recommend a good DAL for a Python/Tornado app
I've been googling for hours and it just failed me.
Are there any DAL/ORMs that support mysql/google app engine besides the one in web2py?
I'm working on a tornado webapp and I need the abstraction badly.
A:
Django with Django-nonrel for AppEngine support.
A:
As f... | Recommend a good DAL for a Python/Tornado app | I've been googling for hours and it just failed me.
Are there any DAL/ORMs that support mysql/google app engine besides the one in web2py?
I'm working on a tornado webapp and I need the abstraction badly.
| [
"Django with Django-nonrel for AppEngine support. \n",
"As far as i know , you cannot use a relation database inside GAE, (although you can use a webservice to do the same), there is no way to achieve the same directly. \n\nDjango-nonrel is an independent\n branch of Django that adds NoSQL\n database support to... | [
2,
1
] | [] | [] | [
"data_access_layer",
"google_app_engine",
"mysql",
"python",
"tornado"
] | stackoverflow_0006505491_data_access_layer_google_app_engine_mysql_python_tornado.txt |
Q:
Display streaming video and result of a python code at the same time in a web-browser
I need to display a streaming video and also the output of a python code running simultaneously. What is the best framework to go about designing it.
A:
Are you actually sending the video, or are you sending an HTML page with a... | Display streaming video and result of a python code at the same time in a web-browser | I need to display a streaming video and also the output of a python code running simultaneously. What is the best framework to go about designing it.
| [
"Are you actually sending the video, or are you sending an HTML page with an embedded video (either with Flash or HTML5)? If the former, showing other output would be impossible. If the latter, you can have it anywhere else on the page.\n"
] | [
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006506064_django_python.txt |
Q:
Python: Pitfalls of creating a super object
We have found that we have a set of attributes(all are not going to change and pulled from the environment at runtime) exist in majority of our classes. I tried searching around for this but unfortunately "object" is a very common word.
What type of issues will I cau... | Python: Pitfalls of creating a super object | We have found that we have a set of attributes(all are not going to change and pulled from the environment at runtime) exist in majority of our classes. I tried searching around for this but unfortunately "object" is a very common word.
What type of issues will I cause if I do the following:
class MasterObjectv2(ob... | [
"Do you really need those as attributes in your actual classes? Sounds like keeping them in some \"configuration object\" and just accessing it from the classes is a more robust idea.\nPrefer to keep inheritance strictly for cases where an is-a relationship is implied, which in your case isn't true, AFAIU.\n",
"W... | [
1,
1,
0,
0
] | [] | [] | [
"python",
"python_2.7"
] | stackoverflow_0006454904_python_python_2.7.txt |
Q:
Add a value to queryset
The title of my questions isn't really correct but I wasn't sure how to word it.
I have a queryset of books.
Book.objects.all()
I have a book relation:
class BookRelation(models.Model):
user = models.ForeignKey(User, related_name='books')
book = models.ForeignKey(Book, related_name... | Add a value to queryset | The title of my questions isn't really correct but I wasn't sure how to word it.
I have a queryset of books.
Book.objects.all()
I have a book relation:
class BookRelation(models.Model):
user = models.ForeignKey(User, related_name='books')
book = models.ForeignKey(Book, related_name='users')
STATES = (
... | [
"You can do this in two queries, plus a bit of processing. First, get all books; then, get all BookRelations for the user; then, iterate through to associate the books with the relations.\nbooks = Book.objects.all()\nuser_relations = BookRelation.objects.filter(user=my_user)\n# now create a dict of relations keyed ... | [
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006506639_django_python.txt |
Q:
How to server static web page with webapp on GAE
i like to know how to serve a static HTML page by GAE using webapp framework. using python , the api states
self.response.out.write(htmlcontent)
is there any way to just provide the html filename, and GAE automatically servers it? Or do I have to manually load the... | How to server static web page with webapp on GAE | i like to know how to serve a static HTML page by GAE using webapp framework. using python , the api states
self.response.out.write(htmlcontent)
is there any way to just provide the html filename, and GAE automatically servers it? Or do I have to manually load the file and put the contents using the above function?
| [
"You can serve a static HTML page like this, in app.yaml:\n- url: /\n static_files: main.html\n upload: main\\.html\n\nThis will serve the file main.html on the root (/) of the app.\n"
] | [
5
] | [] | [] | [
"google_app_engine",
"html",
"python",
"web_applications"
] | stackoverflow_0006506810_google_app_engine_html_python_web_applications.txt |
Q:
Django - Admin/Add running model.clean even though fields are missing
Ok, so I have a model like this:
class Airplane(models.Model):
tail = models.ForeignKey(Tails)
wheel = models.CharField(max_length=500,blank=True)
window = models.CharField(max_length=500,blank=True)
def clean(self):
if ... | Django - Admin/Add running model.clean even though fields are missing | Ok, so I have a model like this:
class Airplane(models.Model):
tail = models.ForeignKey(Tails)
wheel = models.CharField(max_length=500,blank=True)
window = models.CharField(max_length=500,blank=True)
def clean(self):
if self.tail and self.wheel and self.window:
raise ValidationError... | [
"Your tails field does not accept null values. You will need to add null=True to it to make it work.\n",
"Ok, as a workaround I ended up defining a custom form with my validation in admin.py for this model.\nI still don't understand why model.clean gets called before Django has determined that the required field... | [
0,
0
] | [] | [] | [
"django",
"django_admin",
"django_models",
"django_validation",
"python"
] | stackoverflow_0006497882_django_django_admin_django_models_django_validation_python.txt |
Q:
Finding Only HTML Nodes Whose Attributes Match Exactly
I'm working through a Selenium test where I want to assert a particular HTML node is an exact match as far as what attributes are present and their values (order is unimportant) and also that no other attributes are present. For example given the following fra... | Finding Only HTML Nodes Whose Attributes Match Exactly | I'm working through a Selenium test where I want to assert a particular HTML node is an exact match as far as what attributes are present and their values (order is unimportant) and also that no other attributes are present. For example given the following fragment:
<input name="test" value="something"/>
I am trying t... | [
"How about testing that the value and name attributes are present, and that the total number of attributes is exactly 2:\n//input[@value='something' and @name='test' and count(attribute::*)=2]\n\n",
"If you're not bent upon XPath, you could also employ CSS locators. Here's a snippet to count the number of element... | [
2,
1,
0
] | [] | [] | [
"beautifulsoup",
"lxml",
"python",
"selenium",
"xpath"
] | stackoverflow_0006506372_beautifulsoup_lxml_python_selenium_xpath.txt |
Q:
python, how to write an iterative function
I am quering a database for some paramaters which depend on a attribute called count! count can be incremented incase the 1st query does not return anything. Here is a sample code
sls = {(213.243, 55.556): {}, (217.193, 55.793): {}, (213.403, 55.369): {}}
for key in sls... | python, how to write an iterative function | I am quering a database for some paramaters which depend on a attribute called count! count can be incremented incase the 1st query does not return anything. Here is a sample code
sls = {(213.243, 55.556): {}, (217.193, 55.793): {}, (213.403, 55.369): {}}
for key in sls.keys:
if not sls[key]:
ra, dec = key[0],... | [
"Here is the most fundamental recursive function\ndef countdown(n):\n if n == 0:\n return \"Blastoff\"\n else:\n print \"T minus %s\" % n\n return countdown(n-1)\n\nYou will notice that countdown returns itself with a modified argument, in this case n but -1, so if you actually followed t... | [
4,
1,
1
] | [] | [] | [
"iteration",
"python"
] | stackoverflow_0006507048_iteration_python.txt |
Q:
Python HTTPConnection file send with httplib, retrieving progress
In a django app I'm using a third-party Python script to allow users to upload files to blip.tv through httplib.HTTPConnection.send on an EC2 instance. Since these files are generally large I will use a message queue to process the upload asynchrono... | Python HTTPConnection file send with httplib, retrieving progress | In a django app I'm using a third-party Python script to allow users to upload files to blip.tv through httplib.HTTPConnection.send on an EC2 instance. Since these files are generally large I will use a message queue to process the upload asynchronously (RabbitMQ/Celery), and give feedback on the progress to the user i... | [
"It turns out that the poster library has a callback hook in multipart_encode, which can be used to get the progress out (upload or download). Good stuff...\nAlthough i suppose I technically answered this question, I'm sure there are other ways to skin this cat, so i'll post more if I find other methods or details... | [
1
] | [] | [] | [
"asynchronous",
"django",
"httpresponse",
"progress",
"python"
] | stackoverflow_0006425320_asynchronous_django_httpresponse_progress_python.txt |
Q:
Creating a sandbox in virtualenv with python 2.7 fails on ubuntu?
Why is virtualenv complaining about missing _weakrefset
laptop:~/sandbox$ virtualenv --python=/usr/bin/python2.7 --no-site-packages play
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in play/bin/python2.7
Also creatin... | Creating a sandbox in virtualenv with python 2.7 fails on ubuntu? | Why is virtualenv complaining about missing _weakrefset
laptop:~/sandbox$ virtualenv --python=/usr/bin/python2.7 --no-site-packages play
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in play/bin/python2.7
Also creating executable in play/bin/python
Traceback (most recent call last):
Fi... | [
"See https://github.com/pypa/virtualenv/issues/76\nFor use with Python 2.7, upgrade virtualenv to 1.5.1 or newer. You can check your current version with virtualenv --version.\n"
] | [
9
] | [] | [] | [
"python",
"python_2.7",
"virtualenv"
] | stackoverflow_0006327689_python_python_2.7_virtualenv.txt |
Q:
How do I select the last 5 minutes of data from an ms access db using pyodbc?
I have the following query (python pyodbc on windows 7 accessing an access db .mdb):
SQL = 'SELECT acq_spill_3_1_sec.time_stamp, acq_spill_3_1_sec.float_value
FROM acq_spill_3_1_sec WHERE acq_spill_3_1_sec.time_stamp > DateADD(n,-5,... | How do I select the last 5 minutes of data from an ms access db using pyodbc? | I have the following query (python pyodbc on windows 7 accessing an access db .mdb):
SQL = 'SELECT acq_spill_3_1_sec.time_stamp, acq_spill_3_1_sec.float_value
FROM acq_spill_3_1_sec WHERE acq_spill_3_1_sec.time_stamp > DateADD(n,-5,Now())'
The DateADD doesn't seem to work. I get the following error:
pyodbc.Error:... | [
"Two problems: 1) Put double quotes around the n parameter. 2) Put square brackets around the time_stamp. (Access interprets your underscore in the time_stamp field as a special character under certain circumstances. The query parser does its best to interpret special characters, but sometimes it gets it wrong. The... | [
2
] | [
"According to the examples on the DATADD MSDN page (http://msdn.microsoft.com/en-us/library/ms186819.aspx), try using \nDATEADD(minute, -5, NOW())\n\n"
] | [
-1
] | [
"ms_access",
"pyodbc",
"python",
"sql"
] | stackoverflow_0006505326_ms_access_pyodbc_python_sql.txt |
Q:
Regular expression to find any number in a string
What's the notation for any number in re?
Like if I'm searching a string for any number, positive or negative.
I've been using \d+ but that can't find 0 or -1
A:
Searching for positive, negative, and/or decimals, you could use [+-]?\d+(?:\.\d+)?
>>> nums = re.com... | Regular expression to find any number in a string | What's the notation for any number in re?
Like if I'm searching a string for any number, positive or negative.
I've been using \d+ but that can't find 0 or -1
| [
"Searching for positive, negative, and/or decimals, you could use [+-]?\\d+(?:\\.\\d+)?\n>>> nums = re.compile(r\"[+-]?\\d+(?:\\.\\d+)?\")\n>>> nums.search(\"0.123\").group(0)\n'0.123'\n>>> nums.search(\"+0.123\").group(0)\n'+0.123'\n>>> nums.search(\"123\").group(0)\n'123'\n>>> nums.search(\"-123\").group(0)\n'-12... | [
27,
4,
3,
0,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006508043_python_regex.txt |
Q:
Consuming a rabbitmq message queue with multiple threads (Python Kombu)
I have a single RabbitMQ exchange with a single queue. I wish to create a daemon that runs multiple threads and works through this queue as quickly as possible.
The "work" involves communicating with external services, so there will be a fa... | Consuming a rabbitmq message queue with multiple threads (Python Kombu) | I have a single RabbitMQ exchange with a single queue. I wish to create a daemon that runs multiple threads and works through this queue as quickly as possible.
The "work" involves communicating with external services, so there will be a fair amount of blocking going on within each consumer. As such, I want to have... | [
"Take a look at celery - it is designed to queue and process tasks from an AMPQ broker (but also works with other queuing backends). It handles multiprocess or multithreaded concurrency and makes it very easy to create and consume tasks.\n"
] | [
3
] | [] | [] | [
"kombu",
"multithreading",
"python",
"rabbitmq"
] | stackoverflow_0006504005_kombu_multithreading_python_rabbitmq.txt |
Q:
Django: change inlines based on select option
Category has "types" (for example, three types of categories). Each category may have any number of Videos. And each Video, published in Category of '1' type may have any number of Pictures. But for Video, published in '2' and '3' Category types there are no Pictures.
... | Django: change inlines based on select option | Category has "types" (for example, three types of categories). Each category may have any number of Videos. And each Video, published in Category of '1' type may have any number of Pictures. But for Video, published in '2' and '3' Category types there are no Pictures.
models.py:
class Category(models.Model):
title ... | [
"Just use JavaScript to dynamically hide/show the inline set. The id of the inline set is always #[related_name]-group.\n(function($){\n $(document).ready(function(){\n\n function togglePictureInline(selected) {\n $.getJSON('/ajax/category-type/', { id: selected }, function (data, jqXHR) {\n ... | [
2
] | [] | [] | [
"django",
"django_admin",
"django_views",
"python"
] | stackoverflow_0006506439_django_django_admin_django_views_python.txt |
Q:
What is the difference between sys and os.sys
What is the difference between sys and os.sys in python? I have seen many projects using sys when they have imported os. When I tried dir(sys) and dir(os.sys) they had same functions and their output was same.
I often see code using sys.exit like this, rather than usin... | What is the difference between sys and os.sys | What is the difference between sys and os.sys in python? I have seen many projects using sys when they have imported os. When I tried dir(sys) and dir(os.sys) they had same functions and their output was same.
I often see code using sys.exit like this, rather than using os.sys.exit, but both do the same thing.
import o... | [
"os.sys is os's \"private\" name for sys; Python does not hide imports performed in another module. You should not depend on its existence, and should instead import sys directly yourself.\n"
] | [
35
] | [] | [] | [
"python"
] | stackoverflow_0006508576_python.txt |
Q:
How does django-cron work?
A normal approach to cron jobs with a django site would be to use cron to run custom management commands periodically.
But I found this http://code.google.com/p/django-cron/
How does it work, without needing cron? What invokes it to poll?
If it just sets up an address for an http request... | How does django-cron work? | A normal approach to cron jobs with a django site would be to use cron to run custom management commands periodically.
But I found this http://code.google.com/p/django-cron/
How does it work, without needing cron? What invokes it to poll?
If it just sets up an address for an http request to hit periodically, what if th... | [
"It continually fires off a Timer thread, whose whole purpose is to wait a defined amount of time (the polling frequency you set in settings.py) and then run the execute on the django-cron queue again.\n",
"It depends on Django being a long-lived process, which if configured correctly it is. It runs a thread to c... | [
6,
4
] | [] | [] | [
"cron",
"django",
"django_cron",
"python"
] | stackoverflow_0006508497_cron_django_django_cron_python.txt |
Q:
Django: get a NoReverseMatch while rendering error
I seem to be getting a Caught NoReverseMatch error. I am not so sure what is causing the problem. Have a look at the full error.
Caught NoReverseMatch while rendering: Reverse for 'mmc.views.edit_note' with arguments '(1L, '')' and keyword arguments '{}' not found... | Django: get a NoReverseMatch while rendering error | I seem to be getting a Caught NoReverseMatch error. I am not so sure what is causing the problem. Have a look at the full error.
Caught NoReverseMatch while rendering: Reverse for 'mmc.views.edit_note' with arguments '(1L, '')' and keyword arguments '{}' not found.
On my get_client page. I have a link to the edit note... | [
"The client.pk and note.pk are empty values, so they don't match the regex.\n",
"(r'^clients/(?P<client_id>\\d+)/$', views.get_client) should be something like url(r'^clients/(?P<client_id>\\d+)/$', views.get_client, name='MY_URL_NAME') then called with {% url MY_URL_NAME client.pk %}\nand import url from django.... | [
1,
0
] | [] | [] | [
"django",
"django_urls",
"parameters",
"python",
"templates"
] | stackoverflow_0006507747_django_django_urls_parameters_python_templates.txt |
Q:
Python & Amazon EC2 -- Recommended Library?
What is the recommended library for python to do everything that is Amazon EC2 related?
I came across boto and libcloud. Which one is easier to use? does libcloud offer the same functionality as boto?
A:
The big advantage of libcloud is that it provides a unified inter... | Python & Amazon EC2 -- Recommended Library? | What is the recommended library for python to do everything that is Amazon EC2 related?
I came across boto and libcloud. Which one is easier to use? does libcloud offer the same functionality as boto?
| [
"The big advantage of libcloud is that it provides a unified interface to multiple providers, which is a big plus in my mind. You won't have to rewrite everything if you plan to migrate some instances to Rackspace later, or mix and match, etc. I haven't used it extensively but it looks fairly complete as far as EC2... | [
10
] | [] | [] | [
"amazon_ec2",
"python"
] | stackoverflow_0006507708_amazon_ec2_python.txt |
Q:
location of twitter.py file (python-twitter library) in Mac OS X 10.6.7 with Python 2.6.7
I have python 2.6.7 installed in my mac (/usr/local/bin/python).
Previously, I installed python-twitter library. I follow these steps when I installed it:
tar -xvf python-twitter-0.8.3.tar.gz
cd python-twitter-0.8.3
python s... | location of twitter.py file (python-twitter library) in Mac OS X 10.6.7 with Python 2.6.7 | I have python 2.6.7 installed in my mac (/usr/local/bin/python).
Previously, I installed python-twitter library. I follow these steps when I installed it:
tar -xvf python-twitter-0.8.3.tar.gz
cd python-twitter-0.8.3
python setup.py build
python setup.py install
But, right now, I want to modify the twitter.py file gen... | [
"It's inside the .egg file, which is actually a zip archive.\n/Library/Python/2.6/site-packages-> zipinfo python_twitter-0.8.2-py2.6.egg\nArchive: python_twitter-0.8.2-py2.6.egg 60381 bytes 8 files\n-rw-r--r-- 2.0 unx 122153 b- defN 16-Apr-11 16:57 twitter.py\n-rw-r--r-- 2.0 unx 128307 b- defN 28-Jun-11 ... | [
1,
0
] | [] | [] | [
"python",
"python_twitter",
"twitter"
] | stackoverflow_0006508649_python_python_twitter_twitter.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.