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 Socket help (Syntax error)
import socket
HOST = "swemach.se"
PORT = 21
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT)
data = s.recv(1024)
s.close()
print "%s" % data
Gives me error
File "main.txt", line 7
data = s.recv(1024)
^
SyntaxError: invaild syntax
What im going wron... | Python Socket help (Syntax error) | import socket
HOST = "swemach.se"
PORT = 21
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT)
data = s.recv(1024)
s.close()
print "%s" % data
Gives me error
File "main.txt", line 7
data = s.recv(1024)
^
SyntaxError: invaild syntax
What im going wrong? any tip/solution?
| [
"You've forgot parenthesis.\ns.connect((HOST, PORT))\n\n",
"(( HOST, PORT)\n\n^ there you go\n"
] | [
4,
4
] | [] | [] | [
"python"
] | stackoverflow_0000577779_python.txt |
Q:
How do I prevent Python's os.walk from walking across mount points?
In Unix all disks are exposed as paths in the main filesystem, so os.walk('/') would traverse, for example, /media/cdrom as well as the primary hard disk, and that is undesirable for some applications.
How do I get an os.walk that stays on a singl... | How do I prevent Python's os.walk from walking across mount points? | In Unix all disks are exposed as paths in the main filesystem, so os.walk('/') would traverse, for example, /media/cdrom as well as the primary hard disk, and that is undesirable for some applications.
How do I get an os.walk that stays on a single device?
Related:
Is there a way to determine if a subdirectory is in t... | [
"From os.walk docs:\n\nWhen topdown is true, the caller can\n modify the dirnames list in-place\n (perhaps using del or slice\n assignment), and walk() will only\n recurse into the subdirectories whose\n names remain in dirnames; this can be\n used to prune the search\n\nSo something like this should work:\nf... | [
19,
3,
1
] | [] | [] | [
"linux",
"python",
"unix"
] | stackoverflow_0000577761_linux_python_unix.txt |
Q:
How to pass values by ref in Python?
Basically I am using the C++ API of an app, but there is no reference for its python access. One variable is passed by ref, like so:
GetPoint ( Point &p, Object obj )
so how can I translate to Python? Is there a pass by ref symbol?
A:
There is no pass by reference symbol in... | How to pass values by ref in Python? | Basically I am using the C++ API of an app, but there is no reference for its python access. One variable is passed by ref, like so:
GetPoint ( Point &p, Object obj )
so how can I translate to Python? Is there a pass by ref symbol?
| [
"There is no pass by reference symbol in Python.\nJust modify the passed in point, your modifications will be visible from the calling function.\n>>> def change(obj):\n... obj.x = 10\n...\n>>> class Point(object): x,y = 0,0\n...\n>>> p = Point()\n>>> p.x\n0\n>>> change(p)\n>>> p.x\n10\n\n...\n\nSo I should pass... | [
5,
3,
2,
1,
1
] | [] | [] | [
"pass_by_reference",
"python",
"variables"
] | stackoverflow_0000578635_pass_by_reference_python_variables.txt |
Q:
Python 2.5 to Python 2.2 converter
I am working on a PyS60 application for S60 2nd Edition devices. I have coded my application logic in Python 2.5.
Is there any tool that automates th conversion from Python 2.5 to Python 2.2 or do I need to do in manually?
A:
The latest Python for S60, 1.9.0, actually includes ... | Python 2.5 to Python 2.2 converter | I am working on a PyS60 application for S60 2nd Edition devices. I have coded my application logic in Python 2.5.
Is there any tool that automates th conversion from Python 2.5 to Python 2.2 or do I need to do in manually?
| [
"The latest Python for S60, 1.9.0, actually includes Python 2.5.1. So maybe you don't need to convert.\n",
"I don't know of any tool that would go from 2.5 to 2.2 automatically; but there was one a while ago that did 2.3 to 2.2 by RADLogic.\nDepending on how many recent features your code uses, it may be trivial ... | [
3,
1
] | [] | [] | [
"pys60",
"python"
] | stackoverflow_0000578262_pys60_python.txt |
Q:
Python package import error
I'm trying to package my modules, but I can't seem to get it working.
My directory tree is something like the following:
snappy/
__init__.py
main/
__init__.py
main.py
config.py
...
...
and the code I'm using is
from snappy.main.config ... | Python package import error | I'm trying to package my modules, but I can't seem to get it working.
My directory tree is something like the following:
snappy/
__init__.py
main/
__init__.py
main.py
config.py
...
...
and the code I'm using is
from snappy.main.config import *
I'm getting the error:
... | [
"Is the parent directory of snappy in sys.path? If it's not, that's the only thing I can think of that would be causing your error.\n",
"It depends on where your script using the import resides and your system PYTHONPATH. Basically, to have that import working you should run your script (the one having the import... | [
5,
5
] | [] | [] | [
"package",
"python",
"python_import"
] | stackoverflow_0000578983_package_python_python_import.txt |
Q:
Is there a pattern for propagating details of both errors and warnings?
Is there a common pattern for propagating details of both errors and warnings? By errors I mean serious problems that should cause the flow of code to stop. By warnings I mean issues that merit informing the user of a problem, but are too triv... | Is there a pattern for propagating details of both errors and warnings? | Is there a common pattern for propagating details of both errors and warnings? By errors I mean serious problems that should cause the flow of code to stop. By warnings I mean issues that merit informing the user of a problem, but are too trivial to stop program flow.
I currently use exceptions to deal with hard errors... | [
"Look into Python's warnings module, http://docs.python.org/library/warnings.html\nI don't think there's much you can say about this problem without specifying the language, as non-terminal error handling varies greatly from one language to another.\n"
] | [
7
] | [
"Serious errors should bubble up, warning should just be logged in place without throwing exceptions.\n"
] | [
-1
] | [
"design_patterns",
"error_handling",
"python",
"warnings"
] | stackoverflow_0000579097_design_patterns_error_handling_python_warnings.txt |
Q:
Need help understanding function passing in Python
I am trying to teach myself Python by working through some problems I came up with, and I need some help understanding how to pass functions.
Let's say I am trying to predict tomorrow's temperature based on today's and yesterday's temperature, and I have written t... | Need help understanding function passing in Python | I am trying to teach myself Python by working through some problems I came up with, and I need some help understanding how to pass functions.
Let's say I am trying to predict tomorrow's temperature based on today's and yesterday's temperature, and I have written the following function:
def predict_temp(temp_today, temp... | [
"Here is an example of how to pass a function into another function. apply_func_to will take a function f and a number num as parameters and return f(num).\ndef my_func(x):\n return x*x\n\ndef apply_func_to(f, num):\n return f(num)\n\n>>>apply_func_to(my_func, 2)\n4\n\nIf you wanna be clever you can use lamb... | [
13,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0000578812_python.txt |
Q:
PyGame not receiving events when 3+ keys are pressed at the same time
I am developing a simple game in PyGame... A rocket ship flying around and shooting stuff.
Question: Why does pygame stop emitting keyboard events when too may keys are pressed at once?
About the Key Handling: The program has a number of vari... | PyGame not receiving events when 3+ keys are pressed at the same time | I am developing a simple game in PyGame... A rocket ship flying around and shooting stuff.
Question: Why does pygame stop emitting keyboard events when too may keys are pressed at once?
About the Key Handling: The program has a number of variables like KEYSTATE_FIRE, KEYSTATE_TURNLEFT, etc...
When a KEYDOWN event i... | [
"This sounds like a input problem, not a code problem - are you sure the problem isn't the keyboard itself? Most keyboards have limitations on the number of keys that can be pressed at the same time. Often times you can't press more than a few keys that are close together at a time.\nTo test it out, just start pr... | [
11,
5,
2,
1
] | [] | [] | [
"keyboard_events",
"pygame",
"python"
] | stackoverflow_0000576634_keyboard_events_pygame_python.txt |
Q:
Is there a known Win32 Tkinter bug with respect to displaying photos on a canvas?
I'm noticing a pretty strange bug with tkinter, and I am wondering if it's because there's something in how the python interacts with the tcl, at least in Win32.
Here I have a super simple program that displays a gif image. It works... | Is there a known Win32 Tkinter bug with respect to displaying photos on a canvas? | I'm noticing a pretty strange bug with tkinter, and I am wondering if it's because there's something in how the python interacts with the tcl, at least in Win32.
Here I have a super simple program that displays a gif image. It works perfectly.
from Tkinter import *
canvas = Canvas(width=300, height=300, bg='white') ... | [
"Do that as a quick solution, and I'll try to explain:\ndef set_canvas(cv):\n global photo # here!\n photo=PhotoImage(file=sys.argv[1])\n cv.create_image(0, 0, image=photo, anchor=NW) # embed a photo\n print cv\n print photo\n\nA PhotoImage needs to have at least one reference from any Python object... | [
6
] | [] | [] | [
"python",
"tkinter",
"user_interface",
"winapi"
] | stackoverflow_0000576843_python_tkinter_user_interface_winapi.txt |
Q:
How do I code a source code converter from python to ruby?
My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter.
Python to Ruby (the simplest he said)
Now my question to you: how hard is it to code a simple source code converter for pyth... | How do I code a source code converter from python to ruby? | My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter.
Python to Ruby (the simplest he said)
Now my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Stateme... | [
"I think your teacher is fibbing - this is pretty hard. It is equivalent to writing a compiler/interpreter. I don't know how much time you have available for this project, but you are typically looking at several man-years of work.\n",
"There is a name for a program which converts one type of code to another. It... | [
13,
2,
0,
0,
0,
0,
0,
0
] | [] | [] | [
"converter",
"python",
"ruby"
] | stackoverflow_0000579524_converter_python_ruby.txt |
Q:
What's the Pythonic way to combine two sequences into a dictionary?
Is there a more concise way of doing this in Python?:
def toDict(keys, values):
d = dict()
for k,v in zip(keys, values):
d[k] = v
return d
A:
Yes:
dict(zip(keys,values))
A:
If keys' size may be larger then values' one then you could... | What's the Pythonic way to combine two sequences into a dictionary? | Is there a more concise way of doing this in Python?:
def toDict(keys, values):
d = dict()
for k,v in zip(keys, values):
d[k] = v
return d
| [
"Yes:\ndict(zip(keys,values))\n\n",
"If keys' size may be larger then values' one then you could use itertools.izip_longest (Python 2.6) which allows to specify a default value for the rest of the keys:\nfrom itertools import izip_longest\n\ndef to_dict(keys, values, default=None):\n return dict(izip_longest(k... | [
43,
4
] | [] | [] | [
"python"
] | stackoverflow_0000579856_python.txt |
Q:
Easiest way to create a scrollable area using wxPython?
Okay, so I want to display a series of windows within windows and have the whole lot scrollable. I've been hunting through the wxWidgets documentation and a load of examples from various sources on t'internet. Most of those seem to imply that a wx.ScrolledWin... | Easiest way to create a scrollable area using wxPython? | Okay, so I want to display a series of windows within windows and have the whole lot scrollable. I've been hunting through the wxWidgets documentation and a load of examples from various sources on t'internet. Most of those seem to imply that a wx.ScrolledWindow should work if I just pass it a nested group of sizers(?)... | [
"Oops.. turns out I was creating my child windows badly:\nwind = MyCustomWindow(self)\n\nshould be:\nwind = MyCustomWindow(self.scrolling_window)\n\n..which meant the child windows were waiting for the top-level window (the frame) to be re-drawn instead of listening to the scroll window. Changing that makes it all ... | [
0
] | [] | [] | [
"python",
"scroll",
"scrolledwindow",
"wxwidgets"
] | stackoverflow_0000578200_python_scroll_scrolledwindow_wxwidgets.txt |
Q:
Change basic (immutable) types inside a function in Python?
I am using a C++ SDK where there is a function like (it has a python wrapper, but not docs):
getPos ( int uvId, float & u, float & v ) const
How do I specify in Python so that the passed variables are changed?
I tried this example to see if I could modi... | Change basic (immutable) types inside a function in Python? | I am using a C++ SDK where there is a function like (it has a python wrapper, but not docs):
getPos ( int uvId, float & u, float & v ) const
How do I specify in Python so that the passed variables are changed?
I tried this example to see if I could modify floats inside a function, but it didn't work, so printed 12.0:... | [
"In Python:\ndef getPos(uvID):\n # compute u, v\n return u, v\n\n# \nu, v = getPos(uvID)\n\n",
"As far I know, Python doesn't support call-by-reference, so the exact code you are suggesting doesn't work (obviously).\nThe tool (or person) that generated the Python wrapper for the C++ function must have done ... | [
5,
2,
2,
0
] | [] | [] | [
"pass_by_reference",
"python",
"variables"
] | stackoverflow_0000579782_pass_by_reference_python_variables.txt |
Q:
How can I change a huge file into csv in python
I'm a beginner in python. I have a huge text file (hundreds of GB) and I want to convert the file into csv file. In my text file, I know the row delimiter is a string "<><><><><><><>". If a line contains that string, I want to replace it with ". Is there a way to do ... | How can I change a huge file into csv in python | I'm a beginner in python. I have a huge text file (hundreds of GB) and I want to convert the file into csv file. In my text file, I know the row delimiter is a string "<><><><><><><>". If a line contains that string, I want to replace it with ". Is there a way to do it without having to read the old file and rewriting ... | [
"@richard-levasseur\nI agree, sed seems like the right way to go. Here's a rough cut at what the OP describes:\n sed -i -e's/<><><><><><><>/\"/g' foo.txt \n\nThis will do the replacement in-place in the existing foo.txt. For that reason, I recommend having the original file under some sort of version control; any o... | [
5,
4,
1,
1,
1,
1,
0,
0
] | [] | [] | [
"csv",
"file",
"python"
] | stackoverflow_0000576967_csv_file_python.txt |
Q:
Python ORM that auto-generates/updates tables and uses SQLite?
I am doing some prototyping for a new desktop app i am writing in Python, and i want to use SQLite and an ORM to store data.
My question is, are there any ORM libraries that support auto-generating/updating the database schema and work with SQLite?
A:... | Python ORM that auto-generates/updates tables and uses SQLite? | I am doing some prototyping for a new desktop app i am writing in Python, and i want to use SQLite and an ORM to store data.
My question is, are there any ORM libraries that support auto-generating/updating the database schema and work with SQLite?
| [
"SQLAlchemy is a great choice in the Python ORM space that supports SQLite.\n",
"SQLAlchemy, when used with the sqlalchemy-migrate library.\n"
] | [
16,
2
] | [] | [] | [
"auto_generate",
"orm",
"python",
"sqlite"
] | stackoverflow_0000579770_auto_generate_orm_python_sqlite.txt |
Q:
Need help debugging python html generator
The program is supposed to take user input, turn it into html and pass it into the clipboard.
Start the program with welcome_msg()
If you enter 1 in the main menu, it takes you through building an anchor tag. You'll add the link text, the url, then the title. After you ent... | Need help debugging python html generator | The program is supposed to take user input, turn it into html and pass it into the clipboard.
Start the program with welcome_msg()
If you enter 1 in the main menu, it takes you through building an anchor tag. You'll add the link text, the url, then the title. After you enter the title, I get the following errors:
File ... | [
"In your make_link function you construct a link_output, but you don't actually return it as the functions result. Use return to do this:\ndef make_link(in_link):\n ...\n if title == '':\n link_output = ...\n else:\n link_output = ...\n return link_output\n\nThis way you get the value passed to your ancho... | [
3
] | [] | [] | [
"python",
"pywin32"
] | stackoverflow_0000580397_python_pywin32.txt |
Q:
AuiNotebook, where did the event happend
How can I find out from which AuiNotebook page an event occurred?
EDIT: Sorry about that. Here are a code example. How do I find the notebook page
from witch the mouse was clicked in?
#!/usr/bin/python
#12_aui_notebook1.py
import wx
import wx.lib.inspection
class MyFrame... | AuiNotebook, where did the event happend | How can I find out from which AuiNotebook page an event occurred?
EDIT: Sorry about that. Here are a code example. How do I find the notebook page
from witch the mouse was clicked in?
#!/usr/bin/python
#12_aui_notebook1.py
import wx
import wx.lib.inspection
class MyFrame(wx.Frame):
def __init__(self, *args, **kw... | [
"For a mouse click you can assume the current selected page is the one that got the click. I added a few lines to your code. See comments\ndef new_panel(self, nm):\n pnl = wx.Panel(self)\n # just to debug, I added a string attribute to the panel\n # don't you love dynamic languages? :)\n pnl.identifierT... | [
1
] | [] | [] | [
"python",
"wxpython",
"wxwidgets"
] | stackoverflow_0000578800_python_wxpython_wxwidgets.txt |
Q:
Python list serialization - fastest method
I need to load (de-serialize) a pre-computed list of integers from a file in a Python script (into a Python list). The list is large (upto millions of items), and I can choose the format I store it in, as long as loading is fastest.
Which is the fastest method, and why?
... | Python list serialization - fastest method | I need to load (de-serialize) a pre-computed list of integers from a file in a Python script (into a Python list). The list is large (upto millions of items), and I can choose the format I store it in, as long as loading is fastest.
Which is the fastest method, and why?
Using import on a .py file that just contains th... | [
"I would guess cPickle will be fastest if you really need the thing in a list.\nIf you can use an array, which is a built-in sequence type, I timed this at a quarter of a second for 1 million integers:\nfrom array import array\nfrom datetime import datetime\n\ndef WriteInts(theArray,filename):\n f = file(filenam... | [
7,
3,
2,
2,
2,
1
] | [] | [] | [
"caching",
"python",
"serialization"
] | stackoverflow_0000556730_caching_python_serialization.txt |
Q:
Alternative to 'for i in xrange(len(x))'
So I see in another post the following "bad" snippet, but the only alternatives I have seen involve patching Python.
for i in xrange(len(something)):
workwith = something[i]
# do things with workwith...
What do I do to avoid this "antipattern"?
A:
If you need to know... | Alternative to 'for i in xrange(len(x))' | So I see in another post the following "bad" snippet, but the only alternatives I have seen involve patching Python.
for i in xrange(len(something)):
workwith = something[i]
# do things with workwith...
What do I do to avoid this "antipattern"?
| [
"If you need to know the index in the loop body:\nfor index, workwith in enumerate(something):\n print \"element\", index, \"is\", workwith\n\n",
"See Pythonic\nfor workwith in something:\n # do things with workwith\n\n",
"As there are two answers to question that are perfectly valid (with an assumption e... | [
23,
22,
12,
0
] | [
"What is x? If its a sequence or iterator or string then \nfor i in x:\n workwith = i\n\nwill work fine.\n"
] | [
-3
] | [
"anti_patterns",
"for_loop",
"python"
] | stackoverflow_0000578677_anti_patterns_for_loop_python.txt |
Q:
Double buffering with wxpython
I'm working on an multiplatform application with wxpython and I had flickering problems on windows, while drawing on a Panel.
I used to draw on a buffer (wx.Bitmap) during mouse motions events and my OnPaint method was composed of just on line:
dc = wx.BufferedPaintDC(self, self.buff... | Double buffering with wxpython | I'm working on an multiplatform application with wxpython and I had flickering problems on windows, while drawing on a Panel.
I used to draw on a buffer (wx.Bitmap) during mouse motions events and my OnPaint method was composed of just on line:
dc = wx.BufferedPaintDC(self, self.buffer)
Pretty standard but still I had... | [
"There is a high probability that the SetDoubleBuffered actually makes your panel use a buffered dc automatically, the documentation doesn't mention that those classes are deprecated (and I rather think they would if that were the case).\nAbout wxPython in Action... 2006 was a long time ago... it is possible that t... | [
5
] | [] | [] | [
"doublebuffered",
"python",
"user_interface",
"wxpython"
] | stackoverflow_0000581085_doublebuffered_python_user_interface_wxpython.txt |
Q:
Python web programming
Good morning.
As the title indicates, I've got some questions about using python for web development.
What is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win... | Python web programming | Good morning.
As the title indicates, I've got some questions about using python for web development.
What is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win environment.
My major conc... | [
"What is the best setup for a development environment?\nDoesn't much matter. We use Django, which runs in Windows and Unix nicely. For production, we use Apache in Red Hat.\nIs having to reload webserver to see the changes considered normal?\nYes. Not clear why you'd want anything different. Web application sof... | [
8,
6,
6,
2,
1
] | [] | [] | [
"cherrypy",
"python"
] | stackoverflow_0000581038_cherrypy_python.txt |
Q:
Wrapping objects to extend/add functionality while working around isinstance
In Python, I've seen the recommendation to use holding or wrapping to extend the functionality of an object or class, rather than inheritance. In particular, I think that Alex Martelli spoke about this in his Python Design Patterns talk.... | Wrapping objects to extend/add functionality while working around isinstance | In Python, I've seen the recommendation to use holding or wrapping to extend the functionality of an object or class, rather than inheritance. In particular, I think that Alex Martelli spoke about this in his Python Design Patterns talk. I've seen this pattern used in libraries for dependency injection, like pycontai... | [
"If the library code you depend on uses isinstance and relies on inheritance why not follow this route? If you cannot change the library then it is probably best to stay consistend with it.\nI also think that there are legitimate uses for isinstance, and with the introduction of abstract base classes in 2.6 this ha... | [
2,
1,
0,
0,
0
] | [] | [] | [
"design_patterns",
"python"
] | stackoverflow_0000579620_design_patterns_python.txt |
Q:
regex '|' operator vs separate runs for each sub-expression
I've got a fairly large string (~700k) against which I need to run 10 regexes and count all the matches of any of the regexes. My quick and dirty impl was to do something like re.search('(expr1)|(expr2)|...'), but I was wondering if we'd see any performa... | regex '|' operator vs separate runs for each sub-expression | I've got a fairly large string (~700k) against which I need to run 10 regexes and count all the matches of any of the regexes. My quick and dirty impl was to do something like re.search('(expr1)|(expr2)|...'), but I was wondering if we'd see any performance gains by matching in a loop instead:
In other words, I want t... | [
"The two things will give slightly different results, unless it is guaranteed that a match will match one and only one regex. Otherwise if something matches 2 it will be counted twice.\nIn theory your solution ought to be quicker (if the expression are mutually exclusive) because the regex compiler ought to be able... | [
7,
5,
2,
1,
0,
0,
0
] | [] | [] | [
"performance",
"python",
"regex"
] | stackoverflow_0000580993_performance_python_regex.txt |
Q:
PyGTK widget opacity
Is there any way to set a widget's opacity in PyGTK?
I know there's a function for windows:
gtk.Window.set_opacity(0.85)
but there seems to be no equivalent for arbitrary widgets.
Anyone have any ideas?
Thanks in advance for your help.
A:
From pygtk reference:
For setting up per-pixel alph... | PyGTK widget opacity | Is there any way to set a widget's opacity in PyGTK?
I know there's a function for windows:
gtk.Window.set_opacity(0.85)
but there seems to be no equivalent for arbitrary widgets.
Anyone have any ideas?
Thanks in advance for your help.
| [
"From pygtk reference:\n\nFor setting up per-pixel alpha, see gtk.gdk.Screen.get_rgba_colormap(). For making non-toplevel windows translucent, see gtk.gdk.Window.set_composited().\n\n",
"It might also be worth looking into pygtkglext for fancier widget stuff.\n"
] | [
3,
0
] | [] | [] | [
"gtk",
"pygtk",
"python",
"user_interface"
] | stackoverflow_0000583906_gtk_pygtk_python_user_interface.txt |
Q:
How would I make the output of this for loop into a string, into a variable?
In this loop, I'm trying to take user input and continually put it in a list till they write "stop". When the loop is broken, the for loop prints out all of the li's.
How would I take the output of the for loop and make it a string so tha... | How would I make the output of this for loop into a string, into a variable? | In this loop, I'm trying to take user input and continually put it in a list till they write "stop". When the loop is broken, the for loop prints out all of the li's.
How would I take the output of the for loop and make it a string so that I can load it into a variable?
x = ([])
while True:
item = raw_input('Enter ... | [
"In python, strings support a join method (conceptually the opposite of split) that allows you to join elements of a list (technically, of an iterable) together using the string. One very common use case is ', '.join(<list>) to copy the elements of the list into a comma separated string.\nIn your case, you probabl... | [
3,
2,
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0000583986_python.txt |
Q:
How does one enable authentication across a Django site, and transparently preserving any POST or GET data?
Suppose someone is editing a HTML form, and their session times out, how can one have Django re-authenticate that individual without losing the content the user had entered into the form?
The snippet Django ... | How does one enable authentication across a Django site, and transparently preserving any POST or GET data? | Suppose someone is editing a HTML form, and their session times out, how can one have Django re-authenticate that individual without losing the content the user had entered into the form?
The snippet Django Snippets: Require login across entire site suggests how to do site-wide authentication, but I expect it will lose... | [
"I have two suggestions.\nRedirect/Middleware\nSince you're already using middleware to handle the login requirement, you could modify this middleware. Or possibly, create another middleware class that is called after the login middleware. These ideas are intertwined so it may make more sense to modify the existi... | [
3,
2,
2,
0
] | [] | [] | [
"authentication",
"django",
"middleware",
"python",
"wsgi"
] | stackoverflow_0000583857_authentication_django_middleware_python_wsgi.txt |
Q:
How to determine number of files on a drive with Python?
I have been trying to figure out how to retrieve (quickly) the number of files on a given HFS+ drive with python.
I have been playing with os.statvfs and such, but can't quite get anything (that seems helpful to me).
Any ideas?
Edit: Let me be a bit more spe... | How to determine number of files on a drive with Python? | I have been trying to figure out how to retrieve (quickly) the number of files on a given HFS+ drive with python.
I have been playing with os.statvfs and such, but can't quite get anything (that seems helpful to me).
Any ideas?
Edit: Let me be a bit more specific. =]
I am writing a timemachine-like wrapper around rsync... | [
"The right answer for your purpose is to live without a progress bar once, store the number rsync came up with and assume you have the same number of files as last time for each successive backup.\nI didn't believe it, but this seems to work on Linux:\nos.statvfs('/').f_files - os.statvfs('/').f_ffree\n\nThis compu... | [
7,
2,
1,
0
] | [] | [] | [
"filesystems",
"hard_drive",
"macos",
"python"
] | stackoverflow_0000574236_filesystems_hard_drive_macos_python.txt |
Q:
tkinter - set geometry without showing window
I'm trying to line up some label and canvas widgets. To do so I need to know how wide my label boxes are. I'd like my widget to auto-adjust if the user changes the system font size, so I don't want to hard code 12 pixels per character. If I measure the label widget ... | tkinter - set geometry without showing window | I'm trying to line up some label and canvas widgets. To do so I need to know how wide my label boxes are. I'd like my widget to auto-adjust if the user changes the system font size, so I don't want to hard code 12 pixels per character. If I measure the label widget it's always 1 pixel wide. Until I call .update(), ... | [
"Withdraw the window before calling update. The command you want is wm_withdraw\nroot = Tk()\nroot.wm_withdraw()\n<your code here>\nroot.wm_deiconify()\n\nHowever, if your real problem is lining up widgets you usually don't need to know the size of widgets. Use the grid geometry manager. Get out a piece of graph pa... | [
1
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0000584127_python_tkinter.txt |
Q:
Django development server shutdown error
Whenever i shut down my development server (./manage.py runserver) with CTRL+c i get following message:
[24/Feb/2009 22:05:23] "GET /home/ HTTP/1.1" 200 1571
[24/Feb/2009 22:05:24] "GET /contact HTTP/1.1" 301 0
[24/Feb/2009 22:05:24] "GET /contact/ HTTP/1.1" 200 2377
^C
Err... | Django development server shutdown error | Whenever i shut down my development server (./manage.py runserver) with CTRL+c i get following message:
[24/Feb/2009 22:05:23] "GET /home/ HTTP/1.1" 200 1571
[24/Feb/2009 22:05:24] "GET /contact HTTP/1.1" 301 0
[24/Feb/2009 22:05:24] "GET /contact/ HTTP/1.1" 200 2377
^C
Error in atexit._run_exitfuncs:
Traceback (most r... | [
"It appears that you are using the Mac's default python install. I know this has been reputed to have odd issues from time to time. I would recommend install MacPython and installing Django into that python instance. \n"
] | [
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000583740_django_python.txt |
Q:
Database design of survey query system
I am working on a so-called Behavioral Risk Factor Surveillance System (BRFSS), a web query system dealing with questionnaires coming every year.
I had hard time in coming up with a suitable database design for it. Here is the problem: Each questionnaire contains about 80 qu... | Database design of survey query system | I am working on a so-called Behavioral Risk Factor Surveillance System (BRFSS), a web query system dealing with questionnaires coming every year.
I had hard time in coming up with a suitable database design for it. Here is the problem: Each questionnaire contains about 80 questions, with demographic info, e.g. age, ed... | [
"Have you checked DatabaseAnswers to see if there is a schema you could use as a starting point?\n",
"Sounds like a case for a star schema.\nYou would have a (huge) fact table like this:\nquestion_id, survey_id, age_group_id, health_classifier_id, is_smoking ... , answer_value\nand denormalised dimension tables:\... | [
6,
1,
1,
0
] | [] | [] | [
"database",
"django",
"python",
"sqlite"
] | stackoverflow_0000585006_database_django_python_sqlite.txt |
Q:
What are good ways to upload bulk .csv data into a webapp using Django/Python?
I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. Thi... | What are good ways to upload bulk .csv data into a webapp using Django/Python? | I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. This process works ok operationally, but my issue is with the format of the csv file. ... | [
"I'd check out Python's built-in csv module. Frankly a .replace() on your first row should cover your synonyms issue, and if you're using csv.DictReader you should be able to deal with missing columns very easily:\nmy_dict_reader = csv.DictReader(somecsvfile)\nfor row in my_dict_reader:\n SomeDBModel.address2=ro... | [
4,
3,
1,
1,
1,
1
] | [] | [] | [
"csv",
"django",
"django_models",
"jquery",
"python"
] | stackoverflow_0000586517_csv_django_django_models_jquery_python.txt |
Q:
How to produce a colored GUI in a console application?
For the following questions, answers may be for C/C++, C#, or Python. I would like the answers to be cross platform if possible but I realize I will probably need conio or ncurses
How do I output colored text?
How would I do a GUI like top or nethack where ce... | How to produce a colored GUI in a console application? | For the following questions, answers may be for C/C++, C#, or Python. I would like the answers to be cross platform if possible but I realize I will probably need conio or ncurses
How do I output colored text?
How would I do a GUI like top or nethack where certain things are "drawn" to certain spaces in the terminal? ... | [
"Yes, these are VT100 escape codes. The simplest thing is to use some flavor of Curses. Once, you choose a curses flavor it is pretty simple to do both 1 and 2.\nHere's a HowTo on ncurses.\nhttp://web.cs.mun.ca/~rod/ncurses/ncurses.html\n",
"Most terminal windows understand the ANSI escape sequences, which allow ... | [
4,
1,
1,
0,
0
] | [] | [] | [
"c",
"c#",
"c++",
"console_application",
"python"
] | stackoverflow_0000588622_c_c#_c++_console_application_python.txt |
Q:
Python persistent Popen
Is there a way to do multiple calls in the same "session" in Popen? For instance, can I make a call through it and then another one after it without having to concatenate the commands into one long string?
A:
You're not "making a call" when you use popen, you're running an executable and ... | Python persistent Popen | Is there a way to do multiple calls in the same "session" in Popen? For instance, can I make a call through it and then another one after it without having to concatenate the commands into one long string?
| [
"You're not \"making a call\" when you use popen, you're running an executable and talking to it over stdin, stdout, and stderr. If the executable has some way of doing a \"session\" of work (for instance, by reading lines from stdin) then, yes, you can do it. Otherwise, you'll need to exec multiple times.\nsubproc... | [
3,
1,
0
] | [] | [] | [
"popen",
"python",
"subprocess"
] | stackoverflow_0000589093_popen_python_subprocess.txt |
Q:
What's the fastest way to test the validity of a large number of well-formed URLs
My project requires me to validate a large number of web URLs. These URLs have been captured by a very unreliable process which I do not control. All of the URLs have already been regexp validated and are known to be well-formed. I a... | What's the fastest way to test the validity of a large number of well-formed URLs | My project requires me to validate a large number of web URLs. These URLs have been captured by a very unreliable process which I do not control. All of the URLs have already been regexp validated and are known to be well-formed. I also know that they all have valid TLDs
I want to be able to filter these URLs quickly i... | [
"To really make this fast you might also use eventlet which uses non-blocking IO to speed things up.\nYou can use a head request like this:\nfrom eventlet import httpc\ntry:\n res = httpc.head(url)\nexcept httpc.NotFound:\n # handle 404\n\nYou can then put this into some simple script like that example script... | [
8,
6,
4,
3,
1,
0,
0,
0
] | [] | [] | [
"http",
"python"
] | stackoverflow_0000563384_http_python.txt |
Q:
Python or IronPython
How does IronPython stack up to the default Windows implementation of Python from python.org? If I am learning Python, will I be learning a subtley different language with IronPython, and what libraries would I be doing without?
Are there, alternatively, any pros to IronPython (not including .... | Python or IronPython | How does IronPython stack up to the default Windows implementation of Python from python.org? If I am learning Python, will I be learning a subtley different language with IronPython, and what libraries would I be doing without?
Are there, alternatively, any pros to IronPython (not including .NET IL compiled classes) t... | [
"There are a number of important differences:\n\nInteroperability with other .NET languages. You can use other .NET libraries from an IronPython application, or use IronPython from a C# application, for example. This interoperability is increasing, with a movement toward greater support for dynamic types in .NET ... | [
32,
13,
5,
3,
2,
2,
2,
0
] | [] | [] | [
"cpython",
"ironpython",
"python"
] | stackoverflow_0000590007_cpython_ironpython_python.txt |
Q:
python variables not accepting names
I'm trying to declare a few simple variables as part of a function in a very basic collision detection programme. For some reason it's rejecting my variables (although only some of them even though they're near identical). Here's the code for the function;
def TimeCheck():
... | python variables not accepting names | I'm trying to declare a few simple variables as part of a function in a very basic collision detection programme. For some reason it's rejecting my variables (although only some of them even though they're near identical). Here's the code for the function;
def TimeCheck():
timechecknumber = int(time.time())
tim... | [
"You have mismatched parentheses on the line beginning with backgroundr. I think maybe you want this:\nbackgroundr = int(random.random() * 255) + 1\n\nNote that each of the next two lines also have mismatched parentheses, so you'll have to fix those, too.\n",
"mipadi's answer will always yield a 1. You need to m... | [
8,
2
] | [] | [] | [
"python",
"syntax_error",
"variables"
] | stackoverflow_0000591421_python_syntax_error_variables.txt |
Q:
Python Win32 - DriveInfo On Mapped Drive
Does anyone know how I can determine the server and share name of a mapped network drive?
For example:
import win32file, win32api
for logDrive in win32api.GetLogicalDriveStrings().split("\x00"):
if win32file.GetDriveType(logDrive) != win32file.DRIVE_REMOTE: continue
# g... | Python Win32 - DriveInfo On Mapped Drive | Does anyone know how I can determine the server and share name of a mapped network drive?
For example:
import win32file, win32api
for logDrive in win32api.GetLogicalDriveStrings().split("\x00"):
if win32file.GetDriveType(logDrive) != win32file.DRIVE_REMOTE: continue
# get server and share name here
Is there a han... | [
"You'll have to call the win32 API: WNetGetUniversalName\n"
] | [
2
] | [] | [] | [
"python",
"winapi"
] | stackoverflow_0000591443_python_winapi.txt |
Q:
pygame function appears to be being ignored
I'm building a relatively simple programme to test collision detection, it's all working fine at the moment except one thing, I'm trying to make the background colour change randomly, the only issue is that it appears to be completely skipping the function to do this;
im... | pygame function appears to be being ignored | I'm building a relatively simple programme to test collision detection, it's all working fine at the moment except one thing, I'm trying to make the background colour change randomly, the only issue is that it appears to be completely skipping the function to do this;
import pygame
from pygame.locals import *
import ra... | [
"I believe backgroundr, backgroundg, and backgroundb are local variables to your ColourCheck() function.\nIf you're determined to use global variables, try this at the top of your file:\nglobal backgroundr;\nglobal backgroundg;\nglobal backgroundb;\nbackgroundr = int(random.random()*255)+1\nbackgroundg = int(random... | [
6,
0
] | [] | [] | [
"function",
"pygame",
"python"
] | stackoverflow_0000591776_function_pygame_python.txt |
Q:
Python - How to check if a file is used by another application?
I want to open a file which is periodically written to by another application. This application cannot be modified. I'd therefore like to only open the file when I know it is not been written to by an other application.
Is there a pythonic way to do t... | Python - How to check if a file is used by another application? | I want to open a file which is periodically written to by another application. This application cannot be modified. I'd therefore like to only open the file when I know it is not been written to by an other application.
Is there a pythonic way to do this? Otherwise, how do I achieve this in Unix and Windows?
edit: I'll... | [
"Will your python script desire to open the file for writing or for reading? Is the legacy application opening and closing the file between writes, or does it keep it open?\nIt is extremely important that we understand what the legacy application is doing, and what your python script is attempting to achieve.\nThi... | [
7,
0,
0
] | [] | [] | [
"file_io",
"logging",
"python",
"unix",
"windows"
] | stackoverflow_0000589407_file_io_logging_python_unix_windows.txt |
Q:
In Python what is the preferred way to create and manage threads?
Python provides several methods to create threads. Which provides
the best API and the most control?
Thanks.
A:
When necessary, the threading module and its high-level interface is preferred. Of course, many people suggest that it's rarely/never n... | In Python what is the preferred way to create and manage threads? | Python provides several methods to create threads. Which provides
the best API and the most control?
Thanks.
| [
"When necessary, the threading module and its high-level interface is preferred. Of course, many people suggest that it's rarely/never necessary, and threads aren't very nice to deal with. The thread module may be necessary for some weird use-case or other, but I've never needed it (and of course, I've only rarely ... | [
8,
4
] | [] | [] | [
"multithreading",
"python"
] | stackoverflow_0000592143_multithreading_python.txt |
Q:
PyQt4: Databinding?
Coming from the .NET world over to Python and PyQt4. Was wondering if anyone is familiar with any functionality that would allow me to bind data to Qt widgets? For example (using sqlalchemy for data):
gems = session.query(Gem).all()
list = QListWidget()
list.datasource = gems
Is such a thing p... | PyQt4: Databinding? | Coming from the .NET world over to Python and PyQt4. Was wondering if anyone is familiar with any functionality that would allow me to bind data to Qt widgets? For example (using sqlalchemy for data):
gems = session.query(Gem).all()
list = QListWidget()
list.datasource = gems
Is such a thing possible?
| [
"Although not a direct replacement, you might find it useful to look at the QDataWidgetMapper class:\nhttp://pyqt.sourceforge.net/Docs/PyQt4/qdatawidgetmapper.html\nIf you're not scared of reading C++ code, this example might also prove to be helpful:\nhttps://doc.qt.io/qt-4.8/qt-sql-sqlwidgetmapper-example.html\nN... | [
4,
3
] | [] | [] | [
"data_binding",
"pyqt4",
"python",
"qt4"
] | stackoverflow_0000592404_data_binding_pyqt4_python_qt4.txt |
Q:
How can you print a variable name in python?
Say I have a variable named choice it is equal to 2. How would I access the name of the variable? Something equivalent to
In [53]: namestr(choice)
Out[53]: 'choice'
for use in making a dictionary. There's a good way to do this and I'm just missing it.
EDIT:
The reason ... | How can you print a variable name in python? | Say I have a variable named choice it is equal to 2. How would I access the name of the variable? Something equivalent to
In [53]: namestr(choice)
Out[53]: 'choice'
for use in making a dictionary. There's a good way to do this and I'm just missing it.
EDIT:
The reason to do this is thus. I am running some data analysi... | [
"If you insist, here is some horrible inspect-based solution.\nimport inspect, re\n\ndef varname(p):\n for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:\n m = re.search(r'\\bvarname\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)\n if m:\n return m.group(1)\n\nif __name__ == '__main_... | [
144,
103,
16,
10,
9,
4,
4,
3
] | [] | [] | [
"dictionary",
"introspection",
"python",
"variables"
] | stackoverflow_0000592746_dictionary_introspection_python_variables.txt |
Q:
Can I use a decorator to mutate the local scope of a function in Python?
Is there any way of writing a decorator such that the following would work?
assert 'z' not in globals()
@my_decorator
def func(x, y):
print z
EDIT: moved from anwser
In answer to hop's "why?": syntax sugar / DRY.
It's not about caching, ... | Can I use a decorator to mutate the local scope of a function in Python? | Is there any way of writing a decorator such that the following would work?
assert 'z' not in globals()
@my_decorator
def func(x, y):
print z
EDIT: moved from anwser
In answer to hop's "why?": syntax sugar / DRY.
It's not about caching, it's about calculating z (and z1, z2, z3, ...) based upon the values of x & y... | [
"Echoing Hop's answer\n\nDon't do it.\nSeriously, don't do this. Lisp and Ruby are more appropriate languages for writing your own custom syntax. Use one of those. Or find a cleaner way to do this\nIf you must, you want dynamic scoped variables, not lexically scoped.\n\nPython doesn't have dynamically scoped var... | [
11,
8,
7,
2,
1,
1,
0
] | [] | [] | [
"decorator",
"python"
] | stackoverflow_0000591200_decorator_python.txt |
Q:
Parsing an HTML file with selectorgadget.com
How can I use beautiful soup and selectorgadget to scrape a website. For example I have a website - (a newegg product) and I would like my script to return all of the specifications of that product (click on SPECIFICATIONS) by this I mean - Intel, Desktop, ......, 2.4GH... | Parsing an HTML file with selectorgadget.com | How can I use beautiful soup and selectorgadget to scrape a website. For example I have a website - (a newegg product) and I would like my script to return all of the specifications of that product (click on SPECIFICATIONS) by this I mean - Intel, Desktop, ......, 2.4GHz, 1066Mhz, ...... , 3 years limited.
After using... | [
"Inspecting the page, I can see that the specifications are placed in a div with the ID pcraSpecs:\n<div id=\"pcraSpecs\">\n <script type=\"text/javascript\">...</script>\n <TABLE cellpadding=\"0\" cellspacing=\"0\" class=\"specification\">\n <TR>\n <TD colspan=\"2\" class=\"title\">Model</TD>\n </TR>\... | [
1,
0
] | [] | [] | [
"beautifulsoup",
"css",
"html_content_extraction",
"python",
"screen_scraping"
] | stackoverflow_0000592910_beautifulsoup_css_html_content_extraction_python_screen_scraping.txt |
Q:
Rotating a glViewport?
In a "multitouch" environement, any application showed on a surface can be rotated/scaled to the direction of an user. Actual solution is to drawing the application on a FBO, and draw a rotated/scaled rectangle with the texture on it. I don't think it's good for performance, and all graphics... | Rotating a glViewport? | In a "multitouch" environement, any application showed on a surface can be rotated/scaled to the direction of an user. Actual solution is to drawing the application on a FBO, and draw a rotated/scaled rectangle with the texture on it. I don't think it's good for performance, and all graphics cards don't provide FBO.
Th... | [
"If you already have the code set up to render your scene, try adding a glRotate() call to the viewmodel matrix setup, to \"rotate the camera\" before rendering the scene.\n",
"There's no way to have a rotated viewport in OpenGL, you have to handle it manually. I see the following possible solutions :\n\nKeep on ... | [
2,
2
] | [] | [] | [
"math",
"opengl",
"python"
] | stackoverflow_0000577639_math_opengl_python.txt |
Q:
How do I find images with a similar color using Python and PIL?
I have a lot of images in a folder, and I would like to find images with a similar color to a pre chosen image.
I would like to be able to do something like:
python find_similar.py sample.jpg
and have that return something like:
234324.jpg
55.jpg
99... | How do I find images with a similar color using Python and PIL? | I have a lot of images in a folder, and I would like to find images with a similar color to a pre chosen image.
I would like to be able to do something like:
python find_similar.py sample.jpg
and have that return something like:
234324.jpg
55.jpg
9945.jpg
345434.jpg
104.jpg
Is this doable?
| [
"I cannot give you a canned solution, but here's an angle to tackle the problem. It's not PIL-specific, and it might be entirely bogus, since I have no experience in image processing.\n\nPerform color quantization on the image. That gives you a palette that encodes the color information in the image without any sha... | [
4,
1
] | [] | [] | [
"image_processing",
"python",
"python_imaging_library"
] | stackoverflow_0000593925_image_processing_python_python_imaging_library.txt |
Q:
Choosing between different switch-case replacements in Python - dictionary or if-elif-else?
I recently read the questions that recommend against using switch-case statements in languages that do support it. As far as Python goes, I've seen a number of switch case replacements, such as:
Using a dictionary (Many ... | Choosing between different switch-case replacements in Python - dictionary or if-elif-else? | I recently read the questions that recommend against using switch-case statements in languages that do support it. As far as Python goes, I've seen a number of switch case replacements, such as:
Using a dictionary (Many variants)
Using a Tuple
Using a function decorator (http://code.activestate.com/recipes/44049... | [
"Sigh. Too much hand-wringing over the wrong part of the problem. The switch statement is not the issue. There are many ways of expressing \"alternative\" that don't add meaning.\nThe issue is meaning -- not technical statement choices. \nThere are three common patterns.\n\nMapping a key to an object. Use a dic... | [
24,
8,
2,
2,
1,
1,
1
] | [] | [] | [
"python",
"switch_statement"
] | stackoverflow_0000594442_python_switch_statement.txt |
Q:
Make a python property with the same name as the class member name
Is it possible in python to create a property with the same name as the member variable name of the class. e.g.
Class X:
...
self.i = 10 # marker
...
property(fget = get_i, fset = set_i)
Please tell me how I can do so. Because if I... | Make a python property with the same name as the class member name | Is it possible in python to create a property with the same name as the member variable name of the class. e.g.
Class X:
...
self.i = 10 # marker
...
property(fget = get_i, fset = set_i)
Please tell me how I can do so. Because if I do so, for the statement at marker I get stack overflow for the assingm... | [
"\nIs it possible in python to create a property with the same name as the member variable name\n\nNo. properties, members and methods all share the same namespace.\n\nthe statement at marker I get stack overflow\n\nClearly. You try to set i, which calls the setter for property i, which tries to set i, which calls ... | [
23
] | [] | [] | [
"python"
] | stackoverflow_0000594856_python.txt |
Q:
admin template for manytomany
I have a manytomany relationship between publication and pathology. Each publication can have many pathologies. When a publication appears in the admin template, I need to be able to see the many pathologies associated with that publication. Here is the model statement:
class Patho... | admin template for manytomany | I have a manytomany relationship between publication and pathology. Each publication can have many pathologies. When a publication appears in the admin template, I need to be able to see the many pathologies associated with that publication. Here is the model statement:
class Pathology(models.Model):
pathology =... | [
"Unless you are using a intermediate table as documented here http://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-many-to-many-intermediary-models, I don't think you need to create an Inline class. Try removing the line includes=[PathologyInline] and see what happens.\n",
"I realize now that Djan... | [
1,
0,
0
] | [] | [] | [
"django",
"django_admin",
"many_to_many",
"python"
] | stackoverflow_0000570138_django_django_admin_many_to_many_python.txt |
Q:
Django - designing models with virtual fields?
I'd like to ask about the most elegant approach when it comes to designing models with virtual fields such as below in Django...
Let's say we're building an online store and all the products in the system are defined by the model "Product".
class Product(models.Model... | Django - designing models with virtual fields? | I'd like to ask about the most elegant approach when it comes to designing models with virtual fields such as below in Django...
Let's say we're building an online store and all the products in the system are defined by the model "Product".
class Product(models.Model):
# common fields that all products share
n... | [
"Products have Features.\nclass Feature( models.Model ):\n feature_name = models.CharField( max_length=128 )\n feature_value = models.TextField()\n part_of = models.ForeignKey( Product )\n\nLike that.\nJust a list of features. \np= Product( \"iPhone\", \"Apple\", 350 )\np.save()\nf= Feature( \"mp3 capacit... | [
13,
3,
2,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0000590921_django_django_models_python.txt |
Q:
Python: efficiently join chunks of bytes into one big chunk?
I'm trying to jury-rig the Amazon S3 python library to allow chunked handling of large files. Right now it does a "self.body = http_response.read()", so if you have a 3G file you're going to read the entire thing into memory before getting any control ov... | Python: efficiently join chunks of bytes into one big chunk? | I'm trying to jury-rig the Amazon S3 python library to allow chunked handling of large files. Right now it does a "self.body = http_response.read()", so if you have a 3G file you're going to read the entire thing into memory before getting any control over it.
My current approach is to try to keep the interface for the... | [
"''join() is the best method for joining chunks of data. The alternative boils down to repeated concatenation, which is O(n**2) due to the immutability of strings and the need to create more at every concatenation. Given, this repeated concatenation is optimized by recent versions of CPython if used with += to beco... | [
3,
2,
1,
0
] | [] | [] | [
"amazon_s3",
"python"
] | stackoverflow_0000597289_amazon_s3_python.txt |
Q:
AttributeError: 'str' object has no attribute 'readline'
Update: My current question is how can I get my code to read to the EOF starting from the beginning with each new search phrase.
This is an assignment I am doing and currently stuck on. Mind you this is a beginner's programming class using Python.
jargon = o... | AttributeError: 'str' object has no attribute 'readline' | Update: My current question is how can I get my code to read to the EOF starting from the beginning with each new search phrase.
This is an assignment I am doing and currently stuck on. Mind you this is a beginner's programming class using Python.
jargon = open("jargonFile.txt","r")
searchPhrase = raw_input("Enter the ... | [
"First you open the file and read it into a string with readline(). Later on you try to readline() from the string you obtained in the first step.\nYou need to take care what object (thing) you're handling: open() gave you a file \"jargon\", readline on jargon gave you the string \"jargonFile\".\nSo jargonFile.read... | [
3,
2,
2,
2,
1,
1
] | [] | [] | [
"file",
"python",
"readline"
] | stackoverflow_0000596886_file_python_readline.txt |
Q:
wxPython toolbar help
I am new to Python. I am writing an application using wxPython and I currently my code that generates a toolbar looks like this:
class Window(wx.Frame)
def __init__(self, parent, plot):
wx.Frame.__init__(self, parent, wx.ID_ANY, "Name", size =(900, 600))
self.Centre()
self.toolba... | wxPython toolbar help | I am new to Python. I am writing an application using wxPython and I currently my code that generates a toolbar looks like this:
class Window(wx.Frame)
def __init__(self, parent, plot):
wx.Frame.__init__(self, parent, wx.ID_ANY, "Name", size =(900, 600))
self.Centre()
self.toolbar = self.CreateToolBar(styl... | [
"Instead of a class that sets up your toolbar, use a function. The function can be a member function of your Window that subclasses wx.Frame. That way, the toolbar will get Created from the correct window, and be attached the way you would expect.\nThe class that you're writing above would work, if it knew which... | [
3,
1
] | [] | [] | [
"python",
"toolbars",
"user_interface",
"wxpython"
] | stackoverflow_0000596190_python_toolbars_user_interface_wxpython.txt |
Q:
Is it possible to make text translucent in wxPython?
I am adding some wx.StaticText objects on top of my main wx.Frame, which already has a background image applied. However, the StaticText always seems to draw with a solid (opaque) background color, hiding the image. I have tried creating a wx.Color object and ch... | Is it possible to make text translucent in wxPython? | I am adding some wx.StaticText objects on top of my main wx.Frame, which already has a background image applied. However, the StaticText always seems to draw with a solid (opaque) background color, hiding the image. I have tried creating a wx.Color object and changing the alpha value there, but that yields no results. ... | [
"You probably need some graphics rendering widget. As far as I know, in wxPython you can use either built-in wxGraphicsContext or pyCairo directly. Cairo is more powerful. However, I don't know the details.\n",
"I would try aggdraw into a small canvas.\nAny Static Text uses the platform's native label machinery, ... | [
1,
0
] | [] | [] | [
"opacity",
"python",
"transparency",
"wxpython"
] | stackoverflow_0000462933_opacity_python_transparency_wxpython.txt |
Q:
Calling function defined in exe
I need to know a way to call a function defined in the exe from a python script.
I know how to call entire exe from py file.
A:
Unless your EXE is a COM object, or specifically exports certain functions like a dll does, then this is not possible.
For the COM method take a look ... | Calling function defined in exe | I need to know a way to call a function defined in the exe from a python script.
I know how to call entire exe from py file.
| [
"Unless your EXE is a COM object, or specifically exports certain functions like a dll does, then this is not possible. \nFor the COM method take a look at these resources:\n\nPython Programming On Win32 book, by Mark Hammond and Andy Robinson.\nCOM and Python quick start on learning COM with python\n\nFor the ex... | [
7,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0000598569_python.txt |
Q:
Difference between class (Python) and struct (C)
I'm new to python. I've studied C and I noticed that that the C structure (struct) seemed to have the same task as "class" in python. So what is, conceptually, the difference?
A:
Structs encapsulate data.
Classes encapsulate behavior and data.
A:
Aside from num... | Difference between class (Python) and struct (C) | I'm new to python. I've studied C and I noticed that that the C structure (struct) seemed to have the same task as "class" in python. So what is, conceptually, the difference?
| [
"Structs encapsulate data.\nClasses encapsulate behavior and data.\n",
"Aside from numerous technical differences between how they're implemented, they serve roughly the same purpose: the organization of data. \nThe big difference is that in Python (and other object oriented languages such as C++, Java, or C#), a... | [
25,
13,
5,
5,
3
] | [] | [] | [
"c",
"python"
] | stackoverflow_0000598931_c_python.txt |
Q:
What SHOULDN'T Django's admin interface be used for?
I've been applying Django's automatic administration capabilities to some applications who had previously been very difficult to administer. I'm thinking of a lot of ways to apply it to other applications we use (including using it to replace some internal apps... | What SHOULDN'T Django's admin interface be used for? | I've been applying Django's automatic administration capabilities to some applications who had previously been very difficult to administer. I'm thinking of a lot of ways to apply it to other applications we use (including using it to replace some internal apps altogether). Before I go overboard though, is there anyt... | [
"User-specific privileges. I myself had been trying to work it into that-- some of the new (and at least at the time, undocumented) features (from newforms-admin) make it actually possible. Depending on how fine you want the control to be, though, you can end up getting very, very deep into the Django/admin interna... | [
7,
5
] | [] | [] | [
"administration",
"django",
"python"
] | stackoverflow_0000598577_administration_django_python.txt |
Q:
How to match a text node then follow parent nodes using XPath
I'm trying to parse some HTML with XPath. Following the simplified XML example below, I want to match the string 'Text 1', then grab the contents of the relevant content node.
<doc>
<block>
<title>Text 1</title>
<content>Stuff I want... | How to match a text node then follow parent nodes using XPath | I'm trying to parse some HTML with XPath. Following the simplified XML example below, I want to match the string 'Text 1', then grab the contents of the relevant content node.
<doc>
<block>
<title>Text 1</title>
<content>Stuff I want</content>
</block>
<block>
<title>Text 2</title>
... | [
"Do you want that?\n//title[text()='Text 1']/../content/text()\n\n",
"Use:\nstring(/*/*/title[. = 'Text 1']/following-sibling::content)\n\nThis represents at least two improvements as compared to the currently accepted solution of Johannes Weiß:\n\nThe very expensive abbreviation \"//\" (usually causing the whole... | [
23,
16
] | [] | [] | [
"html",
"lxml",
"python",
"xpath"
] | stackoverflow_0000598722_html_lxml_python_xpath.txt |
Q:
choosing between Modules and Classes
In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
Make a separate appstate.py file with global variables ... | choosing between Modules and Classes | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
Make a separate appstate.py file with global variables with functions over them. It looks fine in... | [
"Sounds like the classic conundrum :-).\nIn Python, there's nothing dirty or shameful about choosing to use a module if that's the best approach. After all, modules, functions, and the like are, in fact, first-class citizens in the language, and offer introspection and properties that many other programming languag... | [
28,
6,
4,
1,
1,
0,
0
] | [] | [] | [
"module",
"oop",
"python"
] | stackoverflow_0000600190_module_oop_python.txt |
Q:
Cheap exception handling in Python?
I read in an earlier answer that exception handling is cheap in Python so we shouldn't do pre-conditional checking.
I have not heard of this before, but I'm relatively new to Python. Exception handling means a dynamic call and a static return, whereas an if statement is static c... | Cheap exception handling in Python? | I read in an earlier answer that exception handling is cheap in Python so we shouldn't do pre-conditional checking.
I have not heard of this before, but I'm relatively new to Python. Exception handling means a dynamic call and a static return, whereas an if statement is static call, static return.
How can doing the che... | [
"Don't sweat the small stuff. You've already picked one of the slower scripting languages out there, so trying to optimize down to the opcode is not going to help you much. The reason to choose an interpreted, dynamic language like Python is to optimize your time, not the CPU's.\nIf you use common language idioms... | [
36,
26,
23,
9,
8,
4,
1,
1
] | [] | [] | [
"exception_handling",
"performance",
"python"
] | stackoverflow_0000598157_exception_handling_performance_python.txt |
Q:
Python error when using urllib.open
When I run this:
import urllib
feed = urllib.urlopen("http://www.yahoo.com")
print feed
I get this output in the interactive window (PythonWin):
<addinfourl at 48213968 whose fp = <socket._fileobject object at 0x02E14070>>
I'm expecting to get the source of the above URL. I... | Python error when using urllib.open | When I run this:
import urllib
feed = urllib.urlopen("http://www.yahoo.com")
print feed
I get this output in the interactive window (PythonWin):
<addinfourl at 48213968 whose fp = <socket._fileobject object at 0x02E14070>>
I'm expecting to get the source of the above URL. I know this has worked on other computers ... | [
"Try this:\nprint feed.read()\nSee Python docs here.\n",
"urllib.urlopen actually returns a file-like object so to retrieve the contents you will need to use:\nimport urllib\n\nfeed = urllib.urlopen(\"http://www.yahoo.com\")\n\nprint feed.read()\n\n",
"In python 3.0:\nimport urllib\nimport urllib.request\n\nfh ... | [
55,
17,
7
] | [] | [] | [
"python",
"urllib"
] | stackoverflow_0000600389_python_urllib.txt |
Q:
What's the best technology for connecting from linux to MS SQL Server using python? ODBC?
By best, I mean most-common, easiest to setup, free. Performance doesn't matter.
A:
I decided that pyodbc was the best fit. Very simple, stable, supported:
http://code.google.com/p/pyodbc/
A:
pymssql, the simple MS SQL ... | What's the best technology for connecting from linux to MS SQL Server using python? ODBC? | By best, I mean most-common, easiest to setup, free. Performance doesn't matter.
| [
"I decided that pyodbc was the best fit. Very simple, stable, supported:\nhttp://code.google.com/p/pyodbc/\n",
"pymssql, the simple MS SQL Python extension module.\n",
"FreeTDS\n",
"I'm just learning Python myself, but it seems like there are Python libraries that look more like Java JDBC drivers. Google fo... | [
3,
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0000598979_python.txt |
Q:
Solution basis of underdetermined equation set in python
I have an underdetermined equation set (m equations of n variables, m smaller than n). As such, if it is solvable then the set of solutions are a linear space (if it is a homogenic set) or affine space (non-homogenic).
Is there an easy way in Python (possibl... | Solution basis of underdetermined equation set in python | I have an underdetermined equation set (m equations of n variables, m smaller than n). As such, if it is solvable then the set of solutions are a linear space (if it is a homogenic set) or affine space (non-homogenic).
Is there an easy way in Python (possibly with other libraries) to obtain this space - for example, a ... | [
"Use linalg package from SciPy\n",
"Like the previous poster said, you'll want linalg from SciPy, but focus on the Singular Value Decomposition solution. The matrix U is the basis for the output vectors.\n"
] | [
2,
1
] | [] | [] | [
"linear_equation",
"python"
] | stackoverflow_0000601941_linear_equation_python.txt |
Q:
Making a 2-player web-based textual game
I'm making a simple web-based, turn-based game and am trying to determine what modules exist out there to help me on this task.
Here's the web app I'm looking to build:
User visits the homepage, clicks on a "play game" link
This takes the user to a "game room" where he ei... | Making a 2-player web-based textual game | I'm making a simple web-based, turn-based game and am trying to determine what modules exist out there to help me on this task.
Here's the web app I'm looking to build:
User visits the homepage, clicks on a "play game" link
This takes the user to a "game room" where he either joins someone else who has been waiting f... | [
"Try the Jabber protocol ... It works great for IM, but was designed for use by other types of systems as well and there's already a set of bindings for Python since it has become so popular.\n",
"If you're not going to have huge numbers of concurrent users or want it done quickly I would go for holding game stat... | [
1,
1
] | [] | [] | [
".net",
"ajax",
"javascript",
"python"
] | stackoverflow_0000600621_.net_ajax_javascript_python.txt |
Q:
Evil code from the Python standard library
So, we have had this: The 1000% Speedup, or, the stdlib sucks. It demonstrates a rather bad bug that is probably costing the universe a load of cycles even as we speak. It's fixed now, which is great.
So what parts of the standard library have you noticed to be evil?
I wo... | Evil code from the Python standard library | So, we have had this: The 1000% Speedup, or, the stdlib sucks. It demonstrates a rather bad bug that is probably costing the universe a load of cycles even as we speak. It's fixed now, which is great.
So what parts of the standard library have you noticed to be evil?
I would expect all the responsible people to match u... | [
"The rexec module has so many security holes in it that it's almost useless.\n",
"(since this is a different module, placing it in a different answer)\ncgitb has some weird threading issues. See this bug report.\n"
] | [
3,
2
] | [] | [] | [
"python",
"standard_library"
] | stackoverflow_0000602445_python_standard_library.txt |
Q:
How to show the output of 'l' in python pdb after every command entered
I would like to have the output of the python pdb 'l' command printed to the screen after every command I enter in an interactive debugging session.
Is there a way to setup python pdb to do this?
A:
One way to do this is to alias your favour... | How to show the output of 'l' in python pdb after every command entered | I would like to have the output of the python pdb 'l' command printed to the screen after every command I enter in an interactive debugging session.
Is there a way to setup python pdb to do this?
| [
"One way to do this is to alias your favourite commands to run the command and then l.\ne.g.\n(Pdb) alias s step ;; l\n(Pdb) s\n> /usr/lib/python2.5/distutils/core.py(14)<module>()\n-> from types import *\n 9 # This module should be kept compatible with Python 2.1.\n10 \n11 __revision__ = \"$Id: core... | [
6,
2
] | [] | [] | [
"debugging",
"pdb",
"python"
] | stackoverflow_0000602599_debugging_pdb_python.txt |
Q:
How can I modify password expiration in Windows using Python?
How can I modify the password expiration to "never" on Windows XP for a local user with Python? I have the PyWIN and WMI modules on board but have no solution. I managed to query the current settings via WMI(based on Win32_UserAccount class), but how ca... | How can I modify password expiration in Windows using Python? | How can I modify the password expiration to "never" on Windows XP for a local user with Python? I have the PyWIN and WMI modules on board but have no solution. I managed to query the current settings via WMI(based on Win32_UserAccount class), but how can modify it?
| [
"If you are running your python script with ActvePython against Active Directory, then you can use something like this:\nimport win32com.client\nads = win32com.client.Dispatch('ADsNameSpaces')\nuser = ads.getObject(\"\", \"WinNT://DOMAIN/username,user\")\nuser.Getinfo()\nuser.Put('userAccountControl', 65536 | user.... | [
1,
0,
0
] | [] | [] | [
"passwords",
"python",
"windows"
] | stackoverflow_0000591300_passwords_python_windows.txt |
Q:
What is the proper way to address permissions?
I added a new model with one permission, and now I need to add that permission to a few users on the production machine after deploying the code and running syncdb for the new app involved. I haven't found the correct way to do this. The auth docs mention User.user_pe... | What is the proper way to address permissions? | I added a new model with one permission, and now I need to add that permission to a few users on the production machine after deploying the code and running syncdb for the new app involved. I haven't found the correct way to do this. The auth docs mention User.user_permissions.add(permission), but never tell me what 'p... | [
"Permission (which lives in django.contrib.auth.models) is a database object. You'll be able to see all of them with Permission.objects.all(). They are created automatically by a post-sync signal for each model (and as the docs mention, you can also define your own).\nTo assign the permissions to a User, you will f... | [
4
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000603595_django_python.txt |
Q:
Need python lxml syntax help for parsing html
I am brand new to python, and I need some help with the syntax for finding and iterating through html tags using lxml. Here are the use-cases I am dealing with:
HTML file is fairly well formed (but not perfect). Has multiple tables on screen, one containing a set of ... | Need python lxml syntax help for parsing html | I am brand new to python, and I need some help with the syntax for finding and iterating through html tags using lxml. Here are the use-cases I am dealing with:
HTML file is fairly well formed (but not perfect). Has multiple tables on screen, one containing a set of search results, and one each for a header and foote... | [
"Okay, first, in regards to parsing the HTML: if you follow the recommendation of zweiterlinde and S.Lott at least use the version of beautifulsoup included with lxml. That way you will also reap the benefit of a nice xpath or css selector interface.\nHowever, I personally prefer Ian Bicking's HTML parser included... | [
27,
5
] | [] | [] | [
"html_parsing",
"lxml",
"python"
] | stackoverflow_0000603287_html_parsing_lxml_python.txt |
Q:
Differential AJAX updates for HTML table?
I have a game that's based on a 25x20 HTML table (the game board). Every 3 seconds the user can "move," which sends an AJAX request to the server, at which time the server rerenders the entire HTML table and sends it to the user.
This was easy to write, but it wastes a lot... | Differential AJAX updates for HTML table? | I have a game that's based on a 25x20 HTML table (the game board). Every 3 seconds the user can "move," which sends an AJAX request to the server, at which time the server rerenders the entire HTML table and sends it to the user.
This was easy to write, but it wastes a lot of bandwidth. Are there any libraries, client ... | [
"If you known the state between refreshes on the server side (see comment on question), you an send the data using JSON like so (not sure about exact syntax):\n[\n { x: 3, y: 5, class: \"asdf\", content: \"1234\" },\n { x: 6, y: 5, class: \"asdf\", content: \"8156\" },\n { x: 2, y: 2, class: \"qwer\", cont... | [
2,
2,
1
] | [] | [] | [
"dhtml",
"html",
"jquery",
"python"
] | stackoverflow_0000602322_dhtml_html_jquery_python.txt |
Q:
Find all strings in python code files
I would like to list all strings within my large python project.
Imagine the different possibilities to create a string in python:
mystring = "hello world"
mystring = ("hello "
"world")
mystring = "hello " \
"world"
I need a tool that outputs "filenam... | Find all strings in python code files | I would like to list all strings within my large python project.
Imagine the different possibilities to create a string in python:
mystring = "hello world"
mystring = ("hello "
"world")
mystring = "hello " \
"world"
I need a tool that outputs "filename, linenumber, string" for each string in m... | [
"unwind's suggestion of using the ast module in 2.6 is a good one. (There's also the undocumented _ast module in 2.5.) Here's example code for that\ncode = \"\"\"a = 'blah'\nb = '''multi\nline\nstring'''\nc = u\"spam\"\n\"\"\"\n\nimport ast\nroot = ast.parse(code)\n\nclass ShowStrings(ast.NodeVisitor):\n def visit... | [
12,
9,
3,
2,
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0000585529_python.txt |
Q:
How would you draw cell borders in a wxPython FlexGridSizer?
I'm new to Python, but I can't really find much decent documentation on the web, so I'm hoping somebody will know the answer or where the answer is...
I have a wxPython FlexGridSizer bound to a panel that contains other FlexGridSizers, I'd like to displa... | How would you draw cell borders in a wxPython FlexGridSizer? | I'm new to Python, but I can't really find much decent documentation on the web, so I'm hoping somebody will know the answer or where the answer is...
I have a wxPython FlexGridSizer bound to a panel that contains other FlexGridSizers, I'd like to display some cell borders on the main FlexGridSizer, so each section loo... | [
"Sizers are used just to organize widgets spatially, as a matter of a fact they are 'invisible'.\nI think you're on the right track with putting a panel inside each cell and turning on it's borders. Try adding it with wx.EXPAND flag, it has a chance to help.\nConcerning documentation:\nwxPython is essentially a wra... | [
1
] | [] | [] | [
"drawing",
"python",
"wxpython"
] | stackoverflow_0000603831_drawing_python_wxpython.txt |
Q:
Finding anchor text when there are tags there
I want to find the text between a pair of <a> tags that link to a given site
Here's the re string that I'm using to find the content:
r'''(<a([^<>]*)href=("|')(http://)?(www\.)?%s([^'"]*)("|')([^<>]*)>([^<]*))</a>''' % our_url
The result will be something like this:
r... | Finding anchor text when there are tags there | I want to find the text between a pair of <a> tags that link to a given site
Here's the re string that I'm using to find the content:
r'''(<a([^<>]*)href=("|')(http://)?(www\.)?%s([^'"]*)("|')([^<>]*)>([^<]*))</a>''' % our_url
The result will be something like this:
r'''(<a([^<>]*)href=("|')(http://)?(www\.)?stackover... | [
"Instead of:\n[^<>]*\n\nTry:\n((?!</a).)*\n\nIn other words, match any character that isn't the start of a </a sequence.\n",
">>> import re\n>>> pattern = re.compile(r'<a.+href=[\\'|\\\"](.+)[\\'|\\\"].*?>(.+)</a>', re.IGNORECASE)\n>>> link = '<a href=\"http://stackoverflow.com/questions/603199/finding-anchor-tex... | [
3,
3,
2,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000603199_python_regex.txt |
Q:
Should I check the types of constructor arguments (and at other places too)?
Python discourages checking the types. But in many cases this may be useful:
Checking constructor arguments. e.g. checking foe Boolean, string, dict etc. If I don't and set the object's members to the arguments it will cause problems lat... | Should I check the types of constructor arguments (and at other places too)? | Python discourages checking the types. But in many cases this may be useful:
Checking constructor arguments. e.g. checking foe Boolean, string, dict etc. If I don't and set the object's members to the arguments it will cause problems later.
Checking functions arguments.
In properties. If someone sets a wrong value or ... | [
"The answer is almost always \"no\". The general idea in Python, Ruby, and some other languages us called \"Duck Typing\". You shouldn't care what something is, only how it works. In other words, \"if all you want is something that quacks, you don't need to check that it's actually a duck.\"\nIn real life, the prob... | [
14,
13,
5,
3,
2,
0,
0
] | [] | [] | [
"python",
"typechecking"
] | stackoverflow_0000602046_python_typechecking.txt |
Q:
What's the search engine used in the new Python documentation?
Is it built-in in Sphinx?
A:
It look like Sphinx contains own search engine for English language. See http://sphinx.pocoo.org/_static/searchtools.js and searchindex.js/.json (see Sphinx docs index 36Kb, Python docs index 857Kb, and Grok docs 37Kb).
... | What's the search engine used in the new Python documentation? | Is it built-in in Sphinx?
| [
"It look like Sphinx contains own search engine for English language. See http://sphinx.pocoo.org/_static/searchtools.js and searchindex.js/.json (see Sphinx docs index 36Kb, Python docs index 857Kb, and Grok docs 37Kb). \nIndex is being precomputed when docs are generated.\nWhen one searches, static page is being ... | [
24,
5
] | [
"Yes. Sphinx is not built-in, however. The search widget is part of sphinx. What context did you mean by \"built-in\"? \nOn the page iteself: http://docs.python.org/about.html\nhttp://sphinx.pocoo.org/\n"
] | [
-3
] | [
"python",
"python_sphinx"
] | stackoverflow_0000605888_python_python_sphinx.txt |
Q:
How do I access my webcam in Python?
I would like to access my webcam from Python.
I tried using the VideoCapture extension (tutorial), but that didn't work very well for me, I had to work around some problems such as it's a bit slow with resolutions >320x230, and sometimes it returns None for no apparent reason.
... | How do I access my webcam in Python? | I would like to access my webcam from Python.
I tried using the VideoCapture extension (tutorial), but that didn't work very well for me, I had to work around some problems such as it's a bit slow with resolutions >320x230, and sometimes it returns None for no apparent reason.
Is there a better way to access my webcam ... | [
"OpenCV has support for getting data from a webcam, and it comes with Python wrappers by default, you also need to install numpy for the OpenCV Python extension (called cv2) to work.\nAs of 2019, you can install both of these libraries with pip:\npip install numpy\npip install opencv-python\nMore information on usi... | [
107,
3
] | [] | [] | [
"python",
"webcam"
] | stackoverflow_0000604749_python_webcam.txt |
Q:
Python variable assigned by an outside module is accessible for printing but not for assignment in the target module
I have two files, one is in the webroot, and another is a bootstrap located one folder above the web root (this is CGI programming by the way).
The index file in the web root imports the bootstrap a... | Python variable assigned by an outside module is accessible for printing but not for assignment in the target module | I have two files, one is in the webroot, and another is a bootstrap located one folder above the web root (this is CGI programming by the way).
The index file in the web root imports the bootstrap and assigns a variable to it, then calls a a function to initialize the application. Everything up to here works as expecte... | [
"try this:\n\n\ndef initialize():\n global VAR\n print('Content-type: text/html\\n\\n')\n print(VAR)\n VAR = 'h'\n print(VAR)\n\n\nWithout 'global VAR' python want to use local variable VAR and give you \"UnboundLocalError: local variable 'VAR' referenced before assignment\" \n",
"Don't declare it ... | [
3,
0
] | [] | [] | [
"python",
"scoping"
] | stackoverflow_0000605399_python_scoping.txt |
Q:
How do I configure my sys.path variable in linux?
I want to automatically add entries to python's sys.path variable when run by my user in linux.
Is there something I can tweak in my home directory to get it done?
A:
The environment variable PYTHONPATH sets the initial sys.path value.
You can set that it your sh... | How do I configure my sys.path variable in linux? | I want to automatically add entries to python's sys.path variable when run by my user in linux.
Is there something I can tweak in my home directory to get it done?
| [
"The environment variable PYTHONPATH sets the initial sys.path value.\nYou can set that it your shell initialization script (e.g. .bashrc or .cshrc)\n"
] | [
6
] | [] | [] | [
"configuration",
"linux",
"path",
"python"
] | stackoverflow_0000606226_configuration_linux_path_python.txt |
Q:
python regex trouble
I have the following code :
what = re.match("get|post|put|head\s+(\S+) ",data,re.IGNORECASE)
and in the data variable let's say I have this line :
GET some-site.com HTTP/1.0 ...
If I stop the script in the debugger, and inspect the what variable, I can see it only matched GET. Why doesn't it m... | python regex trouble | I have the following code :
what = re.match("get|post|put|head\s+(\S+) ",data,re.IGNORECASE)
and in the data variable let's say I have this line :
GET some-site.com HTTP/1.0 ...
If I stop the script in the debugger, and inspect the what variable, I can see it only matched GET. Why doesn't it match some-site.com ?
| [
"Regex language operator precedence puts head\\s+(\\S+) as the 4th alternative. The parenthesis in @Mykola Kharechko's answer arrange for head as the 4th alternative, and \\s+(\\S+) is appended to whatever alternative matched the group.\n",
"\n\n>>> re.match(\"(get|post|put|head)\\s+(\\S+) \",'GET some-site.com H... | [
4,
3,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000606221_python_regex.txt |
Q:
How do I install python's sphinx documentation generator in linux?
And how do I run it?
A:
Sphinx website says:
easy_install -U Sphinx
If you want that installed in system python you'd probably need elevated permissions with sudo:
sudo easy_install -U Sphinx
If you do not have easy_install yet, see http://peak... | How do I install python's sphinx documentation generator in linux? | And how do I run it?
| [
"Sphinx website says:\neasy_install -U Sphinx\n\nIf you want that installed in system python you'd probably need elevated permissions with sudo:\nsudo easy_install -U Sphinx\n\nIf you do not have easy_install yet, see http://peak.telecommunity.com/DevCenter/EasyInstall\n",
"How do I run it?\nhttp://sphinx-doc.org... | [
6,
1,
1
] | [] | [] | [
"python",
"python_sphinx"
] | stackoverflow_0000606283_python_python_sphinx.txt |
Q:
How to load an RSA key from a PEM file and use it in python-crypto
I have not found a way to load an RSA private key from a PEM file to use it in python-crypto (signature).
python-openssl can load a PEM file but the PKey object can't be used to retrieved key information (p, q, ...) to use with Crypto.PublicKey.con... | How to load an RSA key from a PEM file and use it in python-crypto | I have not found a way to load an RSA private key from a PEM file to use it in python-crypto (signature).
python-openssl can load a PEM file but the PKey object can't be used to retrieved key information (p, q, ...) to use with Crypto.PublicKey.construct().
| [
"I recommend M2Crypto instead of python-crypto. You will need M2Crypto to parse PEM anyway and its EVP api frees your code from depending on a particular algorithm.\nprivate = \"\"\"\n-----BEGIN RSA PRIVATE KEY-----\nMIIBOwIBAAJBANQNY7RD9BarYRsmMazM1hd7a+u3QeMPFZQ7Ic+BmmeWHvvVP4Yj\nyu1t6vAut7mKkaDeKbT3yiGVUgAEUaWMX... | [
15,
7
] | [] | [] | [
"cryptography",
"python"
] | stackoverflow_0000595114_cryptography_python.txt |
Q:
Django Override form
Another question on some forms
Here is my model
class TankJournal(models.Model):
user = models.ForeignKey(User)
tank = models.ForeignKey(TankProfile)
ts = models.IntegerField(max_length=15)
title = models.CharField(max_length=50)
body = models.TextField()
Here is my modelf... | Django Override form | Another question on some forms
Here is my model
class TankJournal(models.Model):
user = models.ForeignKey(User)
tank = models.ForeignKey(TankProfile)
ts = models.IntegerField(max_length=15)
title = models.CharField(max_length=50)
body = models.TextField()
Here is my modelform
class JournalForm(Mode... | [
"I think you want this:\nclass JournalForm(ModelForm):\n tank = forms.ModelChoiceField(label=\"\",\n queryset=TankProfile.objects.all(),\n widget=forms.HiddenInput)\n\n",
"Why are you overriding the definition of tank?\nclass JournalForm(ModelFo... | [
5,
2
] | [] | [] | [
"django",
"forms",
"python"
] | stackoverflow_0000606946_django_forms_python.txt |
Q:
Preserving last new line when reading a file
I´m reading a file in Python where each record is separated by an empty new line. If the file ends in two or more new lines, the last record is processed as expected, but if the file ends in a single new line it´s not processed. Here´s the code:
def fread():
record ... | Preserving last new line when reading a file | I´m reading a file in Python where each record is separated by an empty new line. If the file ends in two or more new lines, the last record is processed as expected, but if the file ends in a single new line it´s not processed. Here´s the code:
def fread():
record = False
for line in open('somefile.txt'):
... | [
"The way it's written now probably doesn't work anyway; with d = SomeObject() inside your loop, a new SomeObject is being created for every line. Yet, if I understand correctly, what you want is for all of the lines in between empty lines to contribute to that one object. You could do something like this instead:... | [
6,
5,
0,
0,
0
] | [] | [] | [
"file",
"python"
] | stackoverflow_0000607375_file_python.txt |
Q:
Integrate postfix mail into my (python)webapp
I have a postfix server listening and receiving all emails received at mywebsite.com Now I want to show these postfix emails in a customized interface and that too for each user
To be clear, all the users of mywebsite.com will be given mail addresses like someguy@myweb... | Integrate postfix mail into my (python)webapp | I have a postfix server listening and receiving all emails received at mywebsite.com Now I want to show these postfix emails in a customized interface and that too for each user
To be clear, all the users of mywebsite.com will be given mail addresses like someguy@mywebsite.com who receives email on my production machin... | [
"You want to have postfix deliver to a local mailbox, and then use a webmail system for people to access that stored mail.\nDon't get hung up on postfix - it just a transfer agent - it takes messages from one place, and puts them somewhere else, it doesn't store messages.\nSo postfix will take the messages over SMT... | [
9,
7,
0
] | [] | [] | [
"email",
"message",
"postfix_mta",
"python"
] | stackoverflow_0000607548_email_message_postfix_mta_python.txt |
Q:
Python parsing
I'm trying to parse the title tag in an RSS 2.0 feed into three different variables for each entry in that feed. Using ElementTree I've already parsed the RSS so that I can print each title [minus the trailing )] with the code below:
feed = getfeed("http://www.tourfilter.com/dallas/rss/by_concert_... | Python parsing | I'm trying to parse the title tag in an RSS 2.0 feed into three different variables for each entry in that feed. Using ElementTree I've already parsed the RSS so that I can print each title [minus the trailing )] with the code below:
feed = getfeed("http://www.tourfilter.com/dallas/rss/by_concert_date")
for item in ... | [
"Don't let regex scare you off... it's well worth learning.\nGiven the examples above, you might try putting the trailing parenthesis back in, and then using this pattern:\nimport re\npat = re.compile('([\\w\\s]+)\\(([\\w\\s]+)(\\d+/\\d+)\\)')\ninfo = pat.match(s)\nprint info.groups()\n\n('Michael Schenker Group ',... | [
17,
7,
0
] | [] | [] | [
"parsing",
"python",
"regex",
"text_parsing"
] | stackoverflow_0000607760_parsing_python_regex_text_parsing.txt |
Q:
Model and Validation Confusion - Looking for advice
I'm somewhat new to Python, Django, and I'd like some advice on how to layout the code I'd like to write.
I have the model written that allows a file to be uploaded. In the models save method I'm checking if the file has a specific extension. If it has an XML ext... | Model and Validation Confusion - Looking for advice | I'm somewhat new to Python, Django, and I'd like some advice on how to layout the code I'd like to write.
I have the model written that allows a file to be uploaded. In the models save method I'm checking if the file has a specific extension. If it has an XML extension I'm opening the file and grabbing some information... | [
"The Form errors are automatically part of the administrative view.\nSee http://docs.djangoproject.com/en/dev/ref/forms/validation/#ref-forms-validation\nYou're happiest if you validate in a Form -- that's what Forms are for. The admin interface will use the Form you associate with your model; your own views can a... | [
4,
1,
1,
0
] | [] | [] | [
"django",
"python",
"validation"
] | stackoverflow_0000606782_django_python_validation.txt |
Q:
Django email
I am using the Gmail SMTP server to send out emails from users of my website.
These are the default settings in my settings.py
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'example@example.com'
EMAIL_HOST_PASSWORD = 'pwd'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
SERVER_EMAIL = EMAIL_HOST_USER
DEFAULT_... | Django email | I am using the Gmail SMTP server to send out emails from users of my website.
These are the default settings in my settings.py
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'example@example.com'
EMAIL_HOST_PASSWORD = 'pwd'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
SERVER_EMAIL = EMAIL_HOST_USER
DEFAULT_FROM_EMAIL = EMAIL... | [
"Django only uses settings.DEFAULT_FROM_EMAIL when any of the mail sending functions pass None or empty string as the sender address. This can be verified in django/core/mail.py.\nWhen there is an unhandled exception Django calls the mail_admins() function in django/core/mail.py which always uses settings.SERVER_E... | [
23
] | [] | [] | [
"django",
"django_email",
"email",
"python"
] | stackoverflow_0000607819_django_django_email_email_python.txt |
Q:
What will I lose or gain from switching database APIs? (from pywin32 and pysqlite to QSql)
I am writing a Python (2.5) GUI Application that does the following:
Imports from Access to an Sqlite database
Saves ui form settings to an Sqlite database
Currently I am using pywin32 to read Access, and pysqlite2/dbapi2... | What will I lose or gain from switching database APIs? (from pywin32 and pysqlite to QSql) | I am writing a Python (2.5) GUI Application that does the following:
Imports from Access to an Sqlite database
Saves ui form settings to an Sqlite database
Currently I am using pywin32 to read Access, and pysqlite2/dbapi2 to read/write Sqlite.
However, certain Qt objects don't automatically cast to Python or Sqlite ... | [
"When dealing with databases and PyQt UIs, I'll use something similar to model-view-controller model to help organize and simplify the code. \nView module\n\nuses/holds any QObjects that are necessary\nfor the UI \ncontain simple functions/methods\nfor updating your QTGui Object, as\nwell as extracting in... | [
0
] | [] | [] | [
"pyqt4",
"python",
"pywin32",
"qt",
"sqlite"
] | stackoverflow_0000608098_pyqt4_python_pywin32_qt_sqlite.txt |
Q:
Python port binding
I've recently been learning python and I just started playing with networking using python's socket library. Everything has been going well until recently when my script terminated without closing the connection. The next time I ran the script, I got:
File "./alert_server.py", line 9, in <modul... | Python port binding | I've recently been learning python and I just started playing with networking using python's socket library. Everything has been going well until recently when my script terminated without closing the connection. The next time I ran the script, I got:
File "./alert_server.py", line 9, in <module>
s.bind((HOST, PORT))... | [
"What you want to do is just before the bind, do:\ns.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n\nThe reason you are seeing the behaviour you are is that the OS is reserving that particular port for some time after the last connection terminated. This is so that it can properly discard any stray further... | [
16
] | [] | [] | [
"python"
] | stackoverflow_0000608558_python.txt |
Q:
django- run a script from admin
I would like to write a script that is not activated by a certain URL, but by clicking on a link from the admin interface.
How do I do this?
Thanks!
A:
But a link has to go to a URL, so I think what you mean is you want to have a view function that is only visible in the admin int... | django- run a script from admin | I would like to write a script that is not activated by a certain URL, but by clicking on a link from the admin interface.
How do I do this?
Thanks!
| [
"But a link has to go to a URL, so I think what you mean is you want to have a view function that is only visible in the admin interface, and that view function runs a script?\nIf so, override admin/base_site.html template with something this simple:\n{% extends \"admin/base.html\" %}\n{% block nav-global %}\n <p>... | [
11
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000608789_django_python.txt |
Q:
Monitoring user idle time
Developing a mac app, how can I tell whether the user is currently at their computer or not? Or how long ago they last pressed a key or moved the mouse?
A:
it turns out the answer was here
http://osdir.com/ml/python.pyobjc.devel/2006-09/msg00013.html
A:
You can use Quartz event taps a... | Monitoring user idle time | Developing a mac app, how can I tell whether the user is currently at their computer or not? Or how long ago they last pressed a key or moved the mouse?
| [
"it turns out the answer was here\nhttp://osdir.com/ml/python.pyobjc.devel/2006-09/msg00013.html\n",
"You can use Quartz event taps and an NSTimer. Any time one of your event taps lights up, postpone the timer by setting its fire date. When the timer fires, the user is idle.\nI'm not sure whether Quartz event tap... | [
1,
0
] | [] | [] | [
"cocoa",
"idle_processing",
"macos",
"python"
] | stackoverflow_0000608710_cocoa_idle_processing_macos_python.txt |
Q:
Fast way to determine if a PID exists on (Windows)?
I realize "fast" is a bit subjective so I'll explain with some context. I'm working on a Python module called psutil for reading process information in a cross-platform way. One of the functions is a pid_exists(pid) function for determining if a PID is in the cur... | Fast way to determine if a PID exists on (Windows)? | I realize "fast" is a bit subjective so I'll explain with some context. I'm working on a Python module called psutil for reading process information in a cross-platform way. One of the functions is a pid_exists(pid) function for determining if a PID is in the current process list.
Right now I'm doing this the obvious w... | [
"OpenProcess could tell you w/o enumerating all. I have no idea how fast.\nEDIT: note that you also need GetExitCodeProcess to verify the state of the process even if you get a handle from OpenProcess.\n",
"Turns out that my benchmarks evidently were flawed somehow, as later testing reveals OpenProcess and GetExi... | [
8,
4,
3,
3
] | [] | [] | [
"c",
"pid",
"python",
"winapi"
] | stackoverflow_0000592256_c_pid_python_winapi.txt |
Q:
is there COMMIT analog in python for writing into a file?
I have a file open for writing, and a process running for days -- something is written into the file in relatively random moments. My understanding is -- until I do file.close() -- there is a chance nothing is really saved to disk. Is that true?
What if the... | is there COMMIT analog in python for writing into a file? | I have a file open for writing, and a process running for days -- something is written into the file in relatively random moments. My understanding is -- until I do file.close() -- there is a chance nothing is really saved to disk. Is that true?
What if the system crashes when the main process is not finished yet? Is t... | [
"You should be able to use file.flush() to do this.\n",
"If you don't want to kill the current process to add f.flush() (it sounds like it's been running for days already?), you should be OK. If you see the file you are writing to getting bigger, you will not lose that data...\nFrom Python docs:\n\nwrite(str)\n ... | [
21,
3,
2,
2
] | [] | [] | [
"buffering",
"commit",
"file_io",
"python"
] | stackoverflow_0000608316_buffering_commit_file_io_python.txt |
Q:
Is there anything that cannot appear inside parentheses?
I was intrigued by this answer to my question about getting vim to highlight unmatched brackets in python code. Specifically, I'm talking about the second part of his answer where he mentions that the C syntax highlighting is actually flagging as an error a... | Is there anything that cannot appear inside parentheses? | I was intrigued by this answer to my question about getting vim to highlight unmatched brackets in python code. Specifically, I'm talking about the second part of his answer where he mentions that the C syntax highlighting is actually flagging as an error any instance of curly braces inside parens. It is an unobtrusi... | [
"Any Python statement (import, if, for, while, def, class etc.) cannot be in the parentheses:\nIn [1]: (import sys)\n------------------------------------------------------------\nFile \"<ipython console>\", line 1\n (import sys)\n ^\n<type 'exceptions.SyntaxError'>: invalid syntax\n\n",
"Here's an exact an... | [
5,
4,
0
] | [] | [] | [
"python",
"syntax",
"syntax_highlighting",
"vim"
] | stackoverflow_0000609169_python_syntax_syntax_highlighting_vim.txt |
Q:
When is it (not) appropriate to bundle dependencies with an application?
Summary
I recently had a conversation with the creator of a framework that one of my applications depends on. During that conversation he mentioned as a sort of aside that it would make my life simpler if I just bundled his framework with my... | When is it (not) appropriate to bundle dependencies with an application? | Summary
I recently had a conversation with the creator of a framework that one of my applications depends on. During that conversation he mentioned as a sort of aside that it would make my life simpler if I just bundled his framework with my application and delivered to the end user a version that I knew was consisten... | [
"I favor bundling dependencies, if it's not feasible to use a system for automatic dependency resolution (i.e. setuptools), and if you can do it without introducing version conflicts. You still have to consider your application and your audience; serious developers or enthusiasts are more likely to want to work wi... | [
10,
4,
3,
3,
2,
1,
1,
1
] | [] | [] | [
"dependencies",
"distribution",
"packaging",
"python"
] | stackoverflow_0000598299_dependencies_distribution_packaging_python.txt |
Q:
Catching Python exceptions using 'expect' method?
import sys
try:
file = open("words.txt")
expect(IOError):
if file:
print "%s" % file
else:
print "Cant the %s file" % "words.txt"
this gives me an a error -
File "main.py", line 4
expect(IOError):
SyntaxError: invaild syntax
What im goi... | Catching Python exceptions using 'expect' method? | import sys
try:
file = open("words.txt")
expect(IOError):
if file:
print "%s" % file
else:
print "Cant the %s file" % "words.txt"
this gives me an a error -
File "main.py", line 4
expect(IOError):
SyntaxError: invaild syntax
What im going wrong/ how do you fix this
| [
"Actually, it is except as in exception:\nFor instance:\nexcept IOError:\n print \"Error opening file!\"\n\n",
"I assume you are trying to handle exceptions. In that case, use except, not expect. In any case except is not a function, rather it precedes a block of error handling code. When using files, you may ... | [
12,
4,
1,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0000610403_python.txt |
Q:
How to use boolean 'and' in Python
In C# we can use && (boolean and) like this:
int i = 5;
int ii = 10;
if(i == 5 && ii == 10) {
Console.WriteLine("i is 5, and ii is 10");
}
Console.ReadKey(true);
But try that with python:
i = 5
ii = 10
if i == 5 && ii == 10:
print "i is 5 and ii is 10";
I get an e... | How to use boolean 'and' in Python | In C# we can use && (boolean and) like this:
int i = 5;
int ii = 10;
if(i == 5 && ii == 10) {
Console.WriteLine("i is 5, and ii is 10");
}
Console.ReadKey(true);
But try that with python:
i = 5
ii = 10
if i == 5 && ii == 10:
print "i is 5 and ii is 10";
I get an error: SyntaxError: invalid syntax
If I u... | [
"Try this:\ni = 5\nii = 10\nif i == 5 and ii == 10:\n print \"i is 5 and ii is 10\"\n\nEdit: Oh, and you dont need that semicolon on the last line (edit to remove it from my code).\n",
"As pointed out, \"&\" in python performs a bitwise and operation, just as it does in C#. and is the appropriate equivalent ... | [
75,
29,
16,
7,
6,
6
] | [] | [] | [
"boolean_logic",
"python"
] | stackoverflow_0000609972_boolean_logic_python.txt |
Q:
has no foreign key to in Django when trying to inline models
I need to be able to create a quiz type application with 20 some odd multiple choice questions.
I have 3 models: Quizzes, Questions, and Answers.
I want in the admin interface to create a quiz, and inline the quiz and answer elements.
The goal is to ... | has no foreign key to in Django when trying to inline models | I need to be able to create a quiz type application with 20 some odd multiple choice questions.
I have 3 models: Quizzes, Questions, and Answers.
I want in the admin interface to create a quiz, and inline the quiz and answer elements.
The goal is to click "Add Quiz", and be transferred to a page with 20 question fiel... | [
"You can't do \"nested\" inlines in the Django admin (i.e. you can't have a Quiz with inline Questions, with each inline Question having inline Answers). So you'll need to lower your sights to just having inline Questions (then if you navigate to view a single Question, it could have inline Answers).\nSo your mode... | [
15,
3,
2
] | [] | [] | [
"django",
"django_admin",
"python"
] | stackoverflow_0000609556_django_django_admin_python.txt |
Q:
pysqlite user types in select statement
Using pysqlite how can a user-defined-type be used as a value in a comparison, e. g: “... WHERE columnName > userType”?
For example, I've defined a bool type with the requisite registration, converter, etc. Pysqlite/Sqlite responds as expected for INSERT and SELECT operation... | pysqlite user types in select statement | Using pysqlite how can a user-defined-type be used as a value in a comparison, e. g: “... WHERE columnName > userType”?
For example, I've defined a bool type with the requisite registration, converter, etc. Pysqlite/Sqlite responds as expected for INSERT and SELECT operations (bool 'True' stored as an integer 1 and ret... | [
"Use the correct way of passing variables to queries: Don't build the query, use question marks and pass the parameters as a tuple to execute().\nmyvar = True\ncur.execute('SELECT * FROM tasks WHERE display = ?', (myvar,))\n\nThat way the sqlite driver will use the value directly. No escapeing, quoting, conversion ... | [
1,
0
] | [] | [] | [
"pysqlite",
"python",
"sqlite"
] | stackoverflow_0000609516_pysqlite_python_sqlite.txt |
Q:
Is there something like CherryPy or Cerise in the Java world?
CherryPy and Cerise are two small frameworks that implement nothing but the barebones of a web-framework and I love their simplicity: in fact I reckon that if Classic ASP was implemented that way (and didn't pretty much require VBScript) I could have se... | Is there something like CherryPy or Cerise in the Java world? | CherryPy and Cerise are two small frameworks that implement nothing but the barebones of a web-framework and I love their simplicity: in fact I reckon that if Classic ASP was implemented that way (and didn't pretty much require VBScript) I could have settled for it and lived happily ever after.
But now I'm living at th... | [
"Stripes\nURLs to methods, check, form validation, check. Powerful but stays out of your way unless you need it.\n",
"OOWeb, essentially a port of CherryPy.\n",
"Groovy and Grails. If you like MVC or even have a existing library written in Java/JVM, that are the tools you're looking for! \n\nGrails aims to bri... | [
2,
2,
0
] | [] | [] | [
"java",
"python"
] | stackoverflow_0000610516_java_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.