content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
How would I make a simple URL extracter in Python?
How would I start on a single web page, let's say at the root of DMOZ.org and index every single url attached to it. Then store those links inside a text file. I don't want the content, just the links themselves. An example would be awesome.
A:
This, for instan... | How would I make a simple URL extracter in Python? | How would I start on a single web page, let's say at the root of DMOZ.org and index every single url attached to it. Then store those links inside a text file. I don't want the content, just the links themselves. An example would be awesome.
| [
"This, for instance, would print out links on this very related (but poorly named) question:\nimport urllib2\nfrom BeautifulSoup import BeautifulSoup\n\nq = urllib2.urlopen('https://stackoverflow.com/questions/3884419/')\nsoup = BeautifulSoup(q.read())\n\nfor link in soup.findAll('a'):\n if link.has_key('href'):... | [
2,
0,
0
] | [] | [] | [
"hyperlink",
"python",
"web_crawler"
] | stackoverflow_0003925585_hyperlink_python_web_crawler.txt |
Q:
Python: how can I initialize my empty objects?
how can initialize empty objects in python ?
I need to initialize my class members (for examples tk.frames, vtk visualizations etc)
thanks
A:
Access the attributes of self in your __init__() method.
class C(object):
def __init__(self, val):
self.val = val
| Python: how can I initialize my empty objects? | how can initialize empty objects in python ?
I need to initialize my class members (for examples tk.frames, vtk visualizations etc)
thanks
| [
"Access the attributes of self in your __init__() method.\nclass C(object):\n def __init__(self, val):\n self.val = val\n\n"
] | [
4
] | [] | [] | [
"initialization",
"member",
"object",
"python"
] | stackoverflow_0003931481_initialization_member_object_python.txt |
Q:
compare two windows paths, one containing tilde, in python
I'm trying to use the TMP environment variable in a program. When I ask for
tmp = os.path.expandvars("$TMP")
I get
C:\Users\STEVE~1.COO\AppData\Local\Temp
Which contains the old-school, tilde form. A function I have no control over returns paths like
C... | compare two windows paths, one containing tilde, in python | I'm trying to use the TMP environment variable in a program. When I ask for
tmp = os.path.expandvars("$TMP")
I get
C:\Users\STEVE~1.COO\AppData\Local\Temp
Which contains the old-school, tilde form. A function I have no control over returns paths like
C:\Users\steve.cooper\AppData\Local\Temp\file.txt
My problem is ... | [
"Here is alternative solution using only ctypes from Standard Python Library.\ntmp = unicode(os.path.expandvars(\"$TMP\"))\n\nimport ctypes\nGetLongPathName = ctypes.windll.kernel32.GetLongPathNameW\nbuffer = ctypes.create_unicode_buffer(GetLongPathName(tmp, 0, 0))\nGetLongPathName(tmp, buffer, len(buffer))\nprint ... | [
8,
4
] | [] | [] | [
"directory",
"path",
"python",
"string_comparison",
"windows"
] | stackoverflow_0002738473_directory_path_python_string_comparison_windows.txt |
Q:
variable scope in python nested functions
As I am studying decorators, I noticed something strange :
def f():
... msg='aa'
... def a():
... print msg
... msg='bb'
... def b():
... print msg
... return a,b
...
>>> a,b = f()
>>> a()
bb
>>> b()
bb
>>>
Why a() returns 'bb... | variable scope in python nested functions | As I am studying decorators, I noticed something strange :
def f():
... msg='aa'
... def a():
... print msg
... msg='bb'
... def b():
... print msg
... return a,b
...
>>> a,b = f()
>>> a()
bb
>>> b()
bb
>>>
Why a() returns 'bb' and not 'aa' ??
| [
"Because a and b have the same outer scope, in which msg is bound to 'bb'. Put them in separate functions if you want them to have separate scopes.\n",
"Both a and b have read access to the outer scope (the local scope of f). As you overwrite the value of msg, the later call to a/b will read the new value.\n"
] | [
3,
1
] | [] | [] | [
"python",
"scope"
] | stackoverflow_0003931957_python_scope.txt |
Q:
win32com - Write String values in Excel sheet
I'm using win32com to write some dates that I receive from a database, and my problem is that I'm having values like '01' and in Excel is just '1' - not '01'.
Example:
b = row[1] # b has the value 01
c = "-"+b+"-" # c has value -01-
sheet.Cells(1,1).Value ... | win32com - Write String values in Excel sheet | I'm using win32com to write some dates that I receive from a database, and my problem is that I'm having values like '01' and in Excel is just '1' - not '01'.
Example:
b = row[1] # b has the value 01
c = "-"+b+"-" # c has value -01-
sheet.Cells(1,1).Value = b # I have in Excel '1' ; I've try with str(b), ... | [
"Thanks eumiro for the point\nI've found the solution - I'm formating the cells to contain String values:\nrange = sheet.Range(sheet.Cells(1, 1), sheet.Cells(100, 2) )\nrange.NumberFormat = '@'\n\nI'm doing this before I'm puting the values in cells and it works ok, now in Excel cells I have String values.\n"
] | [
3
] | [] | [] | [
"excel",
"python",
"win32com"
] | stackoverflow_0003931791_excel_python_win32com.txt |
Q:
Object generator pattern
I have a class that represents a pretty complex object. The objects can be created by many ways: incremental building, by parsing text strings in different formats and by analyzing binary files. So far my strategy was as follows:
Have the constructor (__init__, in my case) initialize all ... | Object generator pattern | I have a class that represents a pretty complex object. The objects can be created by many ways: incremental building, by parsing text strings in different formats and by analyzing binary files. So far my strategy was as follows:
Have the constructor (__init__, in my case) initialize all the internal variables to None... | [
"What might be a better idea in your case is dependency injection and inversion of control. The idea is to create another class that has all of the settings that you are parsing out of all of these different sources. Then subclasses can define the method to actually parse it. Then when you instantiate the class, pa... | [
3,
2,
1,
1
] | [] | [] | [
"design_patterns",
"factory",
"factory_pattern",
"oop",
"python"
] | stackoverflow_0003931123_design_patterns_factory_factory_pattern_oop_python.txt |
Q:
What is for Python as json_encode for PHP
Possible Duplicate:
Easy JSON encoding with Python
I want to get a record from database and built it in to json. I know we can do it with json_encode when using PHP. But how can we do it in Python
A:
# Python 2.6+
import json
result = json.dumps(value)
or
# Python 2.6... | What is for Python as json_encode for PHP |
Possible Duplicate:
Easy JSON encoding with Python
I want to get a record from database and built it in to json. I know we can do it with json_encode when using PHP. But how can we do it in Python
| [
"# Python 2.6+\nimport json\nresult = json.dumps(value)\nor\n# Python 2.6+\nimport json\njson.dump(value, out_file)\n\nGot if from google first result. http://www.php2python.com/wiki/function.json-encode/\nPlease do your research before asking simple, searchable questions!\n",
"There are several json implementati... | [
9,
2
] | [] | [] | [
"json",
"php",
"python"
] | stackoverflow_0003932087_json_php_python.txt |
Q:
Finding permuations and combinations using Python
I have 2 variables - a and b. I need to fill up k places using these variables. So if k = 3 output should be
[a,a,a], [a,a,b] , [a,b,a], [b,a,a], [a,b,b], [b,a,b], [b,b,a] and [b,b,b]
Input - k
Output - All the combinations
How do I code this in Python? Can itert... | Finding permuations and combinations using Python | I have 2 variables - a and b. I need to fill up k places using these variables. So if k = 3 output should be
[a,a,a], [a,a,b] , [a,b,a], [b,a,a], [a,b,b], [b,a,b], [b,b,a] and [b,b,b]
Input - k
Output - All the combinations
How do I code this in Python? Can itertools be of any help here?
| [
">>> import itertools\n>>> list(itertools.product('ab', repeat=3))\n[('a', 'a', 'a'), ('a', 'a', 'b'), ('a', 'b', 'a'), ('a', 'b', 'b'), ('b', 'a', 'a'), ('b', 'a', 'b'), ('b', 'b', 'a'), ('b', 'b', 'b')]\n\n",
"def genPerm(varslist, pos,resultLen, result, resultsList)\n if pos>resultLen:\n return;\n fo... | [
6,
1
] | [] | [] | [
"permutation",
"python"
] | stackoverflow_0003932148_permutation_python.txt |
Q:
Integrating C++ code with any web technology on Linux
i am writing an program in c++ and i need an web interface to control the program and which will be efficient and best programming language ...
A:
Your application will just have to listen to messages from the network that your web application would send to i... | Integrating C++ code with any web technology on Linux | i am writing an program in c++ and i need an web interface to control the program and which will be efficient and best programming language ...
| [
"Your application will just have to listen to messages from the network that your web application would send to it.\nAny web application (whatever the language) implementation could use sockets so don't worry about the details, just make sure your application manage messages that you made a protocol for.\nNow, if y... | [
1,
0,
0,
0
] | [
"The Win32 API method.\nMSDN - Getting Started with Winsock:\nhttp://msdn.microsoft.com/en-us/library/ms738545%28v=VS.85%29.aspx\n(Since you didn't specify an OS, we're assuming Windows)\n",
"This is not as simple as it seems!\nThere is a mis-match between your C++ program (which presumibly is long running otherw... | [
-1,
-1,
-1
] | [
"c++",
"linux",
"python",
"web_technologies"
] | stackoverflow_0003733994_c++_linux_python_web_technologies.txt |
Q:
Number of matches in regex substitution
I am looking for a Pythonic way to simplify this code:
fix = re.compile(r'((?<=>\n)(\t){2}(?=<))')
fixed_output = re.sub(fix, 1*2*' ', fixed_output)
fix = re.compile(r'((?<=>\n)(\t){3}(?=<))')
fixed_output = re.sub(fix, 2*2*' ', fixed_output)
# and so on...
That is: if ther... | Number of matches in regex substitution | I am looking for a Pythonic way to simplify this code:
fix = re.compile(r'((?<=>\n)(\t){2}(?=<))')
fixed_output = re.sub(fix, 1*2*' ', fixed_output)
fix = re.compile(r'((?<=>\n)(\t){3}(?=<))')
fixed_output = re.sub(fix, 2*2*' ', fixed_output)
# and so on...
That is: if there are n tab characters between ">" and "<", t... | [
"You can use a function instead of a fixed replacement string and take the number of matched tabulator characters to generate the replacement, for example:\nre.sub(r'((?<=>\\n)\\t{2,}(?=<))', lambda m: (len(m.group(0))-1)*2*\" \", string)\n\nHere the lambda expression lambda m: (len(m.group(0))-1)*2*\" \" is used t... | [
3
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0003932710_python_regex.txt |
Q:
django : unique name for object within foreign-key set
I'm trying to upload files for an article model. Since an object can have multiple images, I'm using a foreign-key from file model to my article model. However, I want all the files to have unique titles. Herez the code snippet.
class Article(models.Model):
... | django : unique name for object within foreign-key set | I'm trying to upload files for an article model. Since an object can have multiple images, I'm using a foreign-key from file model to my article model. However, I want all the files to have unique titles. Herez the code snippet.
class Article(models.Model):
name = models.CharField(max_length=64)
class Files(model... | [
"def add_file(request, article_id): \n if request.method == 'POST': \n form = FileForm(request.POST, request.FILES) \n if form.is_valid(): \n file = form.save(commit=False) \n article = Article.objects.get(id=article_id) \n file.article = article \n... | [
1
] | [] | [] | [
"admin",
"django",
"file_upload",
"foreign_keys",
"python"
] | stackoverflow_0003932969_admin_django_file_upload_foreign_keys_python.txt |
Q:
Calling staticmethod inside class level containers initialization
Given the following example class:
class Foo:
def aStaticMethod():
return "aStaticMethod"
aVariable = staticmethod(aStaticMethod)
aTuple = (staticmethod(aStaticMethod),)
aList = [staticmethod(aStaticMethod)]
print Foo.aVar... | Calling staticmethod inside class level containers initialization | Given the following example class:
class Foo:
def aStaticMethod():
return "aStaticMethod"
aVariable = staticmethod(aStaticMethod)
aTuple = (staticmethod(aStaticMethod),)
aList = [staticmethod(aStaticMethod)]
print Foo.aVariable()
print Foo.aTuple[0]()
print Foo.aList[0]()
Why would the call ... | [
"It's because a static method is a descriptor. When you attach it to a class and call it with the usual syntax, then python calls its __get__ method which returns a callable object. When you deal with it as a bare descriptor, python never calls its __get__ method and you end up attempting to call the descriptor dir... | [
16
] | [] | [] | [
"python",
"static_methods"
] | stackoverflow_0003932948_python_static_methods.txt |
Q:
how to insert text inside bar if bar color equal to purple
So I've this image :
What I trying to do if to leave 'H37Rv' only in the purple bar.
My code is the following:
rects = ax.bar(ind, num, width, color=colors)
for rect in rects:
height = int(rect.get_height())
if height < 5:
... | how to insert text inside bar if bar color equal to purple | So I've this image :
What I trying to do if to leave 'H37Rv' only in the purple bar.
My code is the following:
rects = ax.bar(ind, num, width, color=colors)
for rect in rects:
height = int(rect.get_height())
if height < 5:
yloc = height + 2
clr = '#182866'
else:
... | [
"If you move the last three lines of your first example in one indent level, so they are part of the \"else\" clause that sets the colour to purple, that should do it. \n[Edit: Sorry, I misread slightly. That would also leave the text in the 2nd bar. There's no way to get the colour of a rectangle as far as I know,... | [
2,
2
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0003932547_matplotlib_python.txt |
Q:
What is the difference between None check and var or default syntax in Python?
I noted this syntax listed as a gotchya but with no explanation as to why:
def func(x=None):
#good
if x == None:
x = []
#bad
x = x or []
In what ways can this be a gotchya?
A:
In this particular case, it’s ba... | What is the difference between None check and var or default syntax in Python? | I noted this syntax listed as a gotchya but with no explanation as to why:
def func(x=None):
#good
if x == None:
x = []
#bad
x = x or []
In what ways can this be a gotchya?
| [
"In this particular case, it’s bad because an empty list evaluates to false. If you mutate the list, then the results won’t be as expected\ndef func(x=None):\n x = x or []\n x.append('hello')\n\nmylist = []\nfunc(mylist)\nprint mylist[0] # doesn't work\n\nSince you want to check to see if the caller passed No... | [
3,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0003933083_python.txt |
Q:
Facebook connect button
I can't seem to find how to generate the classic Facebook Connect button:
all I can find how to generate is the following:
I'm using the documentation here http://developers.facebook.com/docs/guides/web
Any ideas? :)
A:
http://developers.facebook.com/docs/reference/plugins/login
If you... | Facebook connect button | I can't seem to find how to generate the classic Facebook Connect button:
all I can find how to generate is the following:
I'm using the documentation here http://developers.facebook.com/docs/guides/web
Any ideas? :)
| [
"http://developers.facebook.com/docs/reference/plugins/login\nIf you wanna change the image you must doing manually:\n<div id='login'><a href=\"#\" id='facebook-login' onclick='fblogin();'><img src=\"your image url here\" /></a></div>\n</a>\n<script>\n function fblogin(){\n FB.login(function(response) {\n... | [
3,
1
] | [] | [] | [
"django",
"django_socialauth",
"facebook",
"python"
] | stackoverflow_0003931649_django_django_socialauth_facebook_python.txt |
Q:
Why an error in nosetests and not in Eclipse?
I'm using a third-party library which needs urlfetch from google.appengine.api. It is imported into the executing tests using this line:
from google.appengine.api import urlfetch
The google_appengine directory is on my PYTHONPATH, and if I execute my unit tests direc... | Why an error in nosetests and not in Eclipse? | I'm using a third-party library which needs urlfetch from google.appengine.api. It is imported into the executing tests using this line:
from google.appengine.api import urlfetch
The google_appengine directory is on my PYTHONPATH, and if I execute my unit tests directly from Eclipse, I see no errors. However, if I us... | [
"Calls to App Engine APIs are handled by API proxy modules. In the dev_appserver, local, development versions of these are set up for you, but if you try and run your code directly from the command line, they're not set up.\nYou can set them up yourself something like this, or you can just use nosegae.\n"
] | [
1
] | [] | [] | [
"eclipse",
"google_app_engine",
"nosetests",
"python",
"unit_testing"
] | stackoverflow_0003929842_eclipse_google_app_engine_nosetests_python_unit_testing.txt |
Q:
Why do we need readlines() when we can iterate over the file handle itself?
In Python, after
fh = open('file.txt')
one may do the following to iterate over lines:
for l in fh:
pass
Then why do we have fh.readlines()?
A:
I would imagine that it's from before files were iterators and is maintained for backwa... | Why do we need readlines() when we can iterate over the file handle itself? | In Python, after
fh = open('file.txt')
one may do the following to iterate over lines:
for l in fh:
pass
Then why do we have fh.readlines()?
| [
"I would imagine that it's from before files were iterators and is maintained for backwards compatibility. Even for a one-liner, it's totally1 fairly redundant as list(fh) will do the same thing in a more intuitive way. That also gives you the freedom to do set(fh), tuple(fh), etc.\n1 See John La Rooy's answer.\n",... | [
18,
16,
1
] | [] | [] | [
"python"
] | stackoverflow_0003933223_python.txt |
Q:
How to display a sequence of widgets on the same row?
I'm new to tkinter, and I was wondering if I can display a sequence of widgets on the same row instead of placing them one below the other one in a column.
I'm currently using frames to place my components, however if I have several widgets (buttons) in a frame... | How to display a sequence of widgets on the same row? | I'm new to tkinter, and I was wondering if I can display a sequence of widgets on the same row instead of placing them one below the other one in a column.
I'm currently using frames to place my components, however if I have several widgets (buttons) in a frame, I would prefer to directly place the button as I want, in... | [
"You use geometry managers to lay out widgets within a container. Tkinter's geometry managers are grid, pack and place. \ngrid allows you to lay out your widgets in rows and columns. pack allows you to lay out your widgets along sides of a box (and great for making single horizontal or vertical columns). place lets... | [
5
] | [] | [] | [
"layout",
"python",
"tkinter"
] | stackoverflow_0003931386_layout_python_tkinter.txt |
Q:
Best Practices for Python UnicodeDecodeError
I use Pylons framework, Mako template for a web based application. I wasn't really bother too deep into the way Python handles the unicode strings. I had tense moment when I did see my site crash when the page is rendered and later I came to know that it was related to ... | Best Practices for Python UnicodeDecodeError | I use Pylons framework, Mako template for a web based application. I wasn't really bother too deep into the way Python handles the unicode strings. I had tense moment when I did see my site crash when the page is rendered and later I came to know that it was related to UnicodeDecodeError.
After seeing the error, I star... | [
"If you have influence on it, this is the painless way:\n\nknow your input encoding (or decode with ignore) and decode(encoding) the data as soon as it hits your app\nwork internally only with unicode (u'something' is unicode), also in the database\nfor rendering, export etc, anytime it leaves your app, encode('utf... | [
11,
2
] | [] | [] | [
"exception_handling",
"mako",
"pylons",
"python",
"unicode"
] | stackoverflow_0003933911_exception_handling_mako_pylons_python_unicode.txt |
Q:
Sharing model between Camelot and non-Camelot apps
I would like to share my data model between different Elixir/SQLAlchemy applications, one of which would be a Camelot UI and the others stuff like web interfaces and so on. They would all connect to the same underlying database.
As far as I know, to build a Camelo... | Sharing model between Camelot and non-Camelot apps | I would like to share my data model between different Elixir/SQLAlchemy applications, one of which would be a Camelot UI and the others stuff like web interfaces and so on. They would all connect to the same underlying database.
As far as I know, to build a Camelot app my model would do from camelot import blah and tha... | [
"I can't speak as to whether it would be a good idea, but it's easy to make the imports central because modules are 'singletons' in the Java idiom: they share state. In other words, you could do the following:\ndataProxy.py\ntry:\n from camelot import Integer, Numeric, ...\nexcept ImportError:\n from elixir i... | [
0
] | [] | [] | [
"python",
"python_elixir",
"sqlalchemy"
] | stackoverflow_0003934351_python_python_elixir_sqlalchemy.txt |
Q:
Django admin inline form error
I have an inline formset in my admin site. I also have save_as = True in admin.py.
My models are, for example:
class Poll(models.Model):
question = models.CharField(max_length=200, unique = True)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
... | Django admin inline form error | I have an inline formset in my admin site. I also have save_as = True in admin.py.
My models are, for example:
class Poll(models.Model):
question = models.CharField(max_length=200, unique = True)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
poll = models.ForeignKey(Poll)
... | [
"I've never had much luck with Save as and relationships. Although, I think I was trying to do complicated many to many stuff.\nWhat is the url of the page that is giving that error... From the errors it looks like it would be something like.... /admin/myapp/poll// whereas it should be something more like /admin/m... | [
1,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0002221901_django_django_models_python.txt |
Q:
How do I use this information in Python? I don't know how to use this data-type
According to the NLTK book, I first apply the grammar, and parse it.
grammar = r"""
NP: {<DT|PP\$>?<JJ>*<NN>}
{<NNP>+}
"""
cp = nltk.RegexpParser(grammar)
chunked_sent = cp.parse(sentence)
... | How do I use this information in Python? I don't know how to use this data-type | According to the NLTK book, I first apply the grammar, and parse it.
grammar = r"""
NP: {<DT|PP\$>?<JJ>*<NN>}
{<NNP>+}
"""
cp = nltk.RegexpParser(grammar)
chunked_sent = cp.parse(sentence)
When I print chunked_sent, I get this:
(S
i/PRP
use/VBP
to/TO
work/VB
with/... | [
"Well you might have already found the answer. I am posting it for the people who might face this scenario in the future.\nfor subtree in chunked_sent.subtrees():\n if subtree.node == 'NP': print subtree\n\n"
] | [
0
] | [] | [] | [
"list",
"python",
"tuples",
"types",
"variables"
] | stackoverflow_0001896260_list_python_tuples_types_variables.txt |
Q:
Non-blocking class in python (detached Thread)
I'm trying to create a kind of non-blocking class in python, but I'm not sure how.
I'd like a class to be a thread itself, detached from the main thread so other threads can interact with it.
In a little example:
#!/usr/bin/python2.4
import threading
import time
cla... | Non-blocking class in python (detached Thread) | I'm trying to create a kind of non-blocking class in python, but I'm not sure how.
I'd like a class to be a thread itself, detached from the main thread so other threads can interact with it.
In a little example:
#!/usr/bin/python2.4
import threading
import time
class Sample(threading.Thread):
def __init__(self):... | [
"The object's run() method is what executes in a separate thread. When you call sample.test(), that executes in the main thread, so you get your infinite loop.\n",
"Perhaps something like this?\nimport threading\nimport time\n\nclass Sample(threading.Thread):\n def __init__(self):\n super(Sample, self).... | [
4,
2
] | [] | [] | [
"multithreading",
"nonblocking",
"python"
] | stackoverflow_0003935094_multithreading_nonblocking_python.txt |
Q:
Beautiful Soup findAll() on the results of a findall() returns TypeError
Hi I'm new to both Python and Beautiful soup. I'm trying to get the text only from a certain part of a table. But it seems the result of a findAll is not a BeautifulSoup type that I can run findAll on again.
select = soup.find('table',{'id':"... | Beautiful Soup findAll() on the results of a findall() returns TypeError | Hi I'm new to both Python and Beautiful soup. I'm trying to get the text only from a certain part of a table. But it seems the result of a findAll is not a BeautifulSoup type that I can run findAll on again.
select = soup.find('table',{'id':"tp_section_1"})
print "got the right table"
tissues = select.findAll('td',{"cl... | [
"Yes, you need to do it element-wise. find returns a single element. findAll returns a list, even if the list only contains one item.\n"
] | [
3
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0003935224_beautifulsoup_python.txt |
Q:
Django's equivalent to Rails 5 min blog demo
Some how some way I'm trying to get out of Ruby because things are just working and I don't necessarily know why. I'm taking the forest for the trees approach by which I mean I'm trying to get perspective by learning a new language; Python/Django seems to be the right w... | Django's equivalent to Rails 5 min blog demo | Some how some way I'm trying to get out of Ruby because things are just working and I don't necessarily know why. I'm taking the forest for the trees approach by which I mean I'm trying to get perspective by learning a new language; Python/Django seems to be the right way to go.
The first application I built in Rails w... | [
"With a little bit of google-fu I turned up this relatively recent example:\n\nDjango Tutorial: A Simple Blog, Part 1\nDjango Tutorial: A Simple Blog, Part 2\n\n",
"I would check out the official \"writing your first...\" tutorial on djangoproject.com: http://docs.djangoproject.com/en/dev/intro/tutorial01/\nIt's ... | [
3,
2,
2
] | [] | [] | [
"blogs",
"django",
"python"
] | stackoverflow_0003935454_blogs_django_python.txt |
Q:
What is the most general python type to which I can add attributes?
I have a class Foo with a method isValid. Then I have a method bar() that receives a Foo object and whose behavior depends on whether it is valid or not.
For testing this, I wanted to pass some object to bar whose isValid method returns always Fa... | What is the most general python type to which I can add attributes? | I have a class Foo with a method isValid. Then I have a method bar() that receives a Foo object and whose behavior depends on whether it is valid or not.
For testing this, I wanted to pass some object to bar whose isValid method returns always False. For other reasons, I cannot create an object of Foo at the time of t... | [
"you have the right idea but you can make it more general. Either \n tmptype = type('tmptype', (object,) {})\n\nor\n class tmptype(object):\n pass\n\nThen you can just do\nfoo = tmptype()\nfoo.is_valid = lambda: False\n\nlike you wanted to do with object. This way, you can use the same class for all of your dyn... | [
7,
4,
1
] | [] | [] | [
"attributes",
"object",
"python",
"types"
] | stackoverflow_0003933904_attributes_object_python_types.txt |
Q:
build recent numpy on recent ubuntu
How do I build numpy 1.5 on ubuntu 10.10?
The instructions I found seems outdated or not clear.
Thanks
A:
One way to try, which isn't guaranteed to work, but worth a shot is to see if uupdate can sucessfully update the package. Get a tarball of numpy 1.5. run "apt-get source... | build recent numpy on recent ubuntu | How do I build numpy 1.5 on ubuntu 10.10?
The instructions I found seems outdated or not clear.
Thanks
| [
"One way to try, which isn't guaranteed to work, but worth a shot is to see if uupdate can sucessfully update the package. Get a tarball of numpy 1.5. run \"apt-get source numpy\" which should fetch and unpack the current source from ubuntu. cd into this source directory and run \"uupdate ../numpytarballname\". ... | [
2,
1
] | [] | [] | [
"numpy",
"python",
"ubuntu"
] | stackoverflow_0003933923_numpy_python_ubuntu.txt |
Q:
Find and replace in CSV files with Python
Related to a previous question, I'm trying to do replacements over a number of large CSV files.
The column order (and contents) change between files, but for each file there are about 10 columns that I want and can identify by the column header names. I also have 1-2 dicti... | Find and replace in CSV files with Python | Related to a previous question, I'm trying to do replacements over a number of large CSV files.
The column order (and contents) change between files, but for each file there are about 10 columns that I want and can identify by the column header names. I also have 1-2 dictionaries for each column I want. So for the colu... | [
"There's a ton of things that you can do to speed this up:\nFirst, use the csv module. It provides efficient and bug-free methods for reading and writing CSV files. The DictReader object in particular is what you're interested in: it will present every row it reads from the file as a dictionary keyed by its colu... | [
3,
1,
0
] | [] | [] | [
"csv",
"dictionary",
"function",
"performance",
"python"
] | stackoverflow_0003934133_csv_dictionary_function_performance_python.txt |
Q:
xapian-bindings python compatibility
i am able to get xapian working as expected with python on my development server but i am having issues with my web server.
i keep running into this error:
import xapian
Traceback (most recent call last):
File "", line 1, in
File "/home/x/lib/python2.6/x... | xapian-bindings python compatibility | i am able to get xapian working as expected with python on my development server but i am having issues with my web server.
i keep running into this error:
import xapian
Traceback (most recent call last):
File "", line 1, in
File "/home/x/lib/python2.6/xapian/init.py", line 28, in
_... | [
"I believe the problem here will be in the installation of the xapian-bindings package.\nThe xapian bindings for Python consist of two parts - a part written in python, and a compiled module. You've clearly installed the python part successfully (ie, /home/x/lib/python2.6/xapian/init.py), but when the python part ... | [
3
] | [] | [] | [
"python",
"swig",
"xapian"
] | stackoverflow_0003936138_python_swig_xapian.txt |
Q:
Python "++" operator doesn't work
Possible Duplicate:
Python: Behaviour of increment and decrement operators
Hi, I've tried this.
++num
and the num doesn't change at all, always show the value when initialized
if I change ++num to num+=1 then it works.
So, my question is how that ++ operator works?
A:
There i... | Python "++" operator doesn't work |
Possible Duplicate:
Python: Behaviour of increment and decrement operators
Hi, I've tried this.
++num
and the num doesn't change at all, always show the value when initialized
if I change ++num to num+=1 then it works.
So, my question is how that ++ operator works?
| [
"There isn't a ++ operator in python. You're applying unary + twice to the variable.\n",
"Answer: there is no ++ operator in Python. += 1 is the correct way to increment a number, but note that since integers and floats are immutable in Python,\n>>> a = 2\n>>> b = a\n>>> a += 2\n>>> b\n2\n>>> a\n4\n\nThis behavi... | [
27,
14
] | [] | [] | [
"operator_keyword",
"python"
] | stackoverflow_0003936691_operator_keyword_python.txt |
Q:
C / Python ctypes shared object introspection libraries/techniques
I was looking for a way to list .text section defined symbols on a C shared object loaded on a python program using the ctypes wrapper. In other words, i am trying to get a list of defined functions on a CDLL loaded object.
If there is no way to do... | C / Python ctypes shared object introspection libraries/techniques | I was looking for a way to list .text section defined symbols on a C shared object loaded on a python program using the ctypes wrapper. In other words, i am trying to get a list of defined functions on a CDLL loaded object.
If there is no way to do this with ctypes or library ( or python binding ), another option is a ... | [
"Adding to the list of methods that you are trying to use to get the list of functions that is exported by the dll.\nThere is a script at : http://projects.scipy.org/numpy/wiki/MicrosoftToolchainSupport that dumps the symbol tables of the dll, parses it to get the public table and output the table into a .def file.... | [
1,
0
] | [] | [] | [
"ctypes",
"object",
"python",
"shared"
] | stackoverflow_0003936190_ctypes_object_python_shared.txt |
Q:
Python lxml.html linebreaks?
Im using lxml.html.cleaner to clean html from an input text. how can i change \n to <br /> in lxml.html?
A:
Fairly easy, slightly hacky way: You could do this as part of a two step process, assuming you have used lxml.html.parse or whichever method to build DOM.
iterate through th... | Python lxml.html linebreaks? | Im using lxml.html.cleaner to clean html from an input text. how can i change \n to <br /> in lxml.html?
| [
"Fairly easy, slightly hacky way: You could do this as part of a two step process, assuming you have used lxml.html.parse or whichever method to build DOM. \n\niterate through the text and tail attributes of the nodes with string replacements. Look at the iterdescendants method, which walks through everything for y... | [
1
] | [] | [] | [
"lxml",
"python"
] | stackoverflow_0003936754_lxml_python.txt |
Q:
What is the Python equivalent of Perl's backticks?
Possible Duplicate:
Equivalent of Backticks in Python
When I want to write directly to the command prompt in Perl, I can do something like this:
Perl File test.pl:
$directory = `dir`;
print $directory;
Which would output something like..
C:\Documents a... | What is the Python equivalent of Perl's backticks? |
Possible Duplicate:
Equivalent of Backticks in Python
When I want to write directly to the command prompt in Perl, I can do something like this:
Perl File test.pl:
$directory = `dir`;
print $directory;
Which would output something like..
C:\Documents and
Settings\joslim\Desktop>perl test.pl
Volume in d... | [
"What you are referring to in Perl is the backtick operator, which also behaves identically in PHP.\nWhat you are looking to achieve is to execute a command line operation.\nThe equivalent in Python of the backtick operator, and how to run a command line program and retrieve the output, has been answered in: Equiva... | [
6,
3
] | [] | [] | [
"cmd",
"perl",
"python",
"terminal"
] | stackoverflow_0003936982_cmd_perl_python_terminal.txt |
Q:
Add repository url to install_requires in project's setup.py
I'm developing a django app which depends on an app in a private
bitbucket repository, for example ssh:/...@bitbucket.org/username/my-django-app.
is it possible to add this url to the list of install_requires in my
setup.py? tried various possibilities, ... | Add repository url to install_requires in project's setup.py | I'm developing a django app which depends on an app in a private
bitbucket repository, for example ssh:/...@bitbucket.org/username/my-django-app.
is it possible to add this url to the list of install_requires in my
setup.py? tried various possibilities, but none worked.
| [
"I don't know if you can do this with setuptools, but it's possible with distribute (wich can be consider as the new setuptools). Check Dependencies that aren’t in PyPI sections in distribute documentation.\n"
] | [
5
] | [] | [] | [
"python",
"setuptools"
] | stackoverflow_0003880605_python_setuptools.txt |
Q:
nltk custom tokenizer and tagger
Here is my requirement. I want to tokenize and tag a paragraph in such a way that it allows me to achieve following stuffs.
Should identify date and time in the paragraph and Tag them as DATE and TIME
Should identify known phrases in the paragraph and Tag them as CUSTOM
And rest c... | nltk custom tokenizer and tagger | Here is my requirement. I want to tokenize and tag a paragraph in such a way that it allows me to achieve following stuffs.
Should identify date and time in the paragraph and Tag them as DATE and TIME
Should identify known phrases in the paragraph and Tag them as CUSTOM
And rest content should be tokenized should be t... | [
"The proper answer is to compile a large dataset tagged in the way you want, then train a machine learned chunker on it. If that's too time-consuming, the easy way is to run the POS tagger and post-process its output using regular expressions. Getting the longest match is the hard part here:\ns = \"They all like to... | [
7,
2
] | [] | [] | [
"nlp",
"nltk",
"python"
] | stackoverflow_0003930267_nlp_nltk_python.txt |
Q:
How do I use rstrip to remove trailing characters?
I am trying to loop through a bunch of documents I have to put each word in a list for that document. I am doing it like this. stoplist is just a list of words that I want to ignore by default.
texts = [[word for word in document.lower().split() if word not in st... | How do I use rstrip to remove trailing characters? | I am trying to loop through a bunch of documents I have to put each word in a list for that document. I am doing it like this. stoplist is just a list of words that I want to ignore by default.
texts = [[word for word in document.lower().split() if word not in stoplist]
for document in documents]
I am return... | [
">>> a = ['agency[15]','assignment72,','you’11','america’s']\n>>> import re\n>>> b = re.compile('\\w+')\n>>> for item in a:\n... print b.search(item).group(0)\n...\nagency\nassignment72\nyou\namerica\n>>> b = re.compile('[a-z]+')\n>>> for item in a:\n... print b.search(item).group(0)\n...\nagenc... | [
3,
1
] | [] | [] | [
"python",
"regex",
"string"
] | stackoverflow_0003937273_python_regex_string.txt |
Q:
What does raise in Python raise?
Consider the following code:
try:
raise Exception("a")
except:
try:
raise Exception("b")
finally:
raise
This will raise Exception: a. I expected it to raise Exception: b (need I explain why?). Why does the final raise raise the original exception rather... | What does raise in Python raise? | Consider the following code:
try:
raise Exception("a")
except:
try:
raise Exception("b")
finally:
raise
This will raise Exception: a. I expected it to raise Exception: b (need I explain why?). Why does the final raise raise the original exception rather than (what I thought) was the last ex... | [
"\nRaise is re-raising the last exception you caught, not the last exception you raised\n\n(reposted from comments for clarity)\n",
"On python2.6\nI guess, you are expecting the finally block to be tied with the \"try\" block where you raise the exception \"B\". The finally block is attached to the first \"try\" ... | [
28,
14
] | [] | [] | [
"exception",
"python"
] | stackoverflow_0003935603_exception_python.txt |
Q:
elegant way to match two wildcarded strings
I'm OCRing some text from two different sources. They can each make mistakes in different places, where they won't recognize a letter/group of letters. If they don't recognize something, it's replaced with a ?. For example, if the word is Roflcopter, one source might ret... | elegant way to match two wildcarded strings | I'm OCRing some text from two different sources. They can each make mistakes in different places, where they won't recognize a letter/group of letters. If they don't recognize something, it's replaced with a ?. For example, if the word is Roflcopter, one source might return Ro?copter, while another, Roflcop?er. I'd lik... | [
"Well, as long as one ? corresponds to one character, then I can suggest a performant and a compact enough method.\ndef match(str1, str2):\n if len(str1) != len(str2): return False\n for index, ch1 in enumerate(str1):\n ch2 = str2[index]\n if ch1 == '?' or ch2 == '?': continue\n if ch1 !=... | [
2,
2,
1,
1
] | [] | [] | [
"python",
"regex",
"string",
"string_matching"
] | stackoverflow_0003936566_python_regex_string_string_matching.txt |
Q:
Python Method Placement
Can someone give me a solution to this
dosomething()
def dosomething():
print 'do something'
I don't want my method defines up at the top of the file, is there a way around this?
A:
The "standard" way is to do things inside a main function at the top of your file and then call main(... | Python Method Placement | Can someone give me a solution to this
dosomething()
def dosomething():
print 'do something'
I don't want my method defines up at the top of the file, is there a way around this?
| [
"The \"standard\" way is to do things inside a main function at the top of your file and then call main() at the bottom. E.g. \ndef main():\n print 'doing stuff'\n foo()\n bar()\n\ndef foo():\n print 'inside foo'\n\ndef bar():\n print 'inside bar'\n\nif __name__ == '__main__':\n main()\n\nif if __... | [
13,
3
] | [] | [] | [
"python"
] | stackoverflow_0003937450_python.txt |
Q:
accessing python dictionary
I am writing code that will search twitter for key words and store them in a python dictionary:
base_url = 'http://search.twitter.com/search.json?rpp=100&q=4sq.com/'
query = '7bOHRP'
url_string = base_url + query
logging.info("url string = " + url_string)... | accessing python dictionary | I am writing code that will search twitter for key words and store them in a python dictionary:
base_url = 'http://search.twitter.com/search.json?rpp=100&q=4sq.com/'
query = '7bOHRP'
url_string = base_url + query
logging.info("url string = " + url_string)
json_text = fetch(url_st... | [
"result[0][u'from_user']\n\nThe u prefix means that it's a unicode instead of a str.\n",
"You access the item ala\nprint Contents['from_user']\n\nThe 'u' in front of the string indicates that the string is uni-code.\n",
"note that in Python 3.x you don't need the 'u' before the string 'cause all the string are ... | [
11,
1,
0,
0
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0003933478_dictionary_python.txt |
Q:
what is the concept of store in OpenID
Hi so this is what I understand how Openid works:-
the user enters his openid url on the site say"hii.com"
The app does a redirect to the openid provider and either does the login or denies it and sends the response back to the site i.e"hii.com"
If authentication was succesf... | what is the concept of store in OpenID | Hi so this is what I understand how Openid works:-
the user enters his openid url on the site say"hii.com"
The app does a redirect to the openid provider and either does the login or denies it and sends the response back to the site i.e"hii.com"
If authentication was succesful then the response object provided by the ... | [
"upd.: my previous answer was wrong\nThe store you are referring to is where your app stores the data during auth.\nStoring it in a shared memcached instance should be the best option (faster than db and reliable enough).\n"
] | [
1
] | [] | [] | [
"openid",
"python",
"store"
] | stackoverflow_0003937456_openid_python_store.txt |
Q:
Difference between "if x" and "if x is not None"
It appears that "if x" is almost like short-hand for the longer "if x is not None" syntax. Are they functionally identical or are there cases where for a given value of x the two would evaluate differently?
I would assume the behavior should also be identical across... | Difference between "if x" and "if x is not None" | It appears that "if x" is almost like short-hand for the longer "if x is not None" syntax. Are they functionally identical or are there cases where for a given value of x the two would evaluate differently?
I would assume the behavior should also be identical across Python implementations - but if there are subtle diff... | [
"In the following cases: \ntest = False \ntest = \"\" \ntest = 0\ntest = 0.0 \ntest = []\ntest = () \ntest = {} \ntest = set()\n\nthe if test will differ:\nif test: #False\n\nif test is not None: #True \n\nThis is the case because is tests for identity, meaning\ntest is not None\n\nis equivalent to \nid(test) == id... | [
66,
37,
5,
5,
3
] | [] | [] | [
"boolean",
"python"
] | stackoverflow_0003901144_boolean_python.txt |
Q:
Convert higher order function from Python to Haskell
I have the following code:
import operator
def stagger(l, w):
if len(l)>=w:
return [tuple(l[0:w])]+stagger(l[1:], w)
return []
def pleat(f, l, w=2):
return map(lambda p: f(*p), stagger(l, w))
if __name__=="__main__":
print pleat(operat... | Convert higher order function from Python to Haskell | I have the following code:
import operator
def stagger(l, w):
if len(l)>=w:
return [tuple(l[0:w])]+stagger(l[1:], w)
return []
def pleat(f, l, w=2):
return map(lambda p: f(*p), stagger(l, w))
if __name__=="__main__":
print pleat(operator.add, range(10))
print pleat(lambda x, y, z: x*y/z, ... | [
"The type signatures below are optional:\n\nstagger :: [a] -> Int -> [[a]]\nstagger l w\n | length l >= w = take w l : stagger (tail l) w\n | otherwise = []\n\npleat :: ([a] -> b) -> [a] -> Int -> [b]\npleat f l w = map f $ stagger l w\n\nmain = do\n print $ pleat (\\[x, y] -> x+y) [0..9] 2\n pr... | [
6
] | [] | [] | [
"haskell",
"higher_order_functions",
"python"
] | stackoverflow_0003937683_haskell_higher_order_functions_python.txt |
Q:
splitting the bill algorithmically & fair, afterwards :)
I'm trying to solve the following real-life problem you might have encountered yourselves:
You had dinner with some friends and you all agreed to split the bill evenly. Except that when the bill finally arrives, you find out not everyone has enough cash on t... | splitting the bill algorithmically & fair, afterwards :) | I'm trying to solve the following real-life problem you might have encountered yourselves:
You had dinner with some friends and you all agreed to split the bill evenly. Except that when the bill finally arrives, you find out not everyone has enough cash on them (if any, cheap bastards).
So, some of you pays more than ... | [
"http://www.billmonk.com/\nAmongst others. The problem has already been solved. Many times over.\n\n\n\"Theoratically, the sum of the differences should be zero, right?\"\n\nYes. Since you've used float, however, you have representation issues when the number of people is not a power of two.\nNever. Use. float F... | [
9,
5,
2,
1,
1
] | [] | [] | [
"algorithm",
"floating_accuracy",
"math",
"python"
] | stackoverflow_0003918567_algorithm_floating_accuracy_math_python.txt |
Q:
Is it really possible to POST files with python?
So I'm struggling with this for a second day in a row and still nothing. Found few solutions on the internet but still I'm getting "Internal Server Error" when trying to send files with POST. The idea is as follows : I'm sending a file opened in python's shell to a ... | Is it really possible to POST files with python? | So I'm struggling with this for a second day in a row and still nothing. Found few solutions on the internet but still I'm getting "Internal Server Error" when trying to send files with POST. The idea is as follows : I'm sending a file opened in python's shell to a django function on my server that will read and store ... | [
"MAJOR EDIT:\nIm very sorry, I gave you the wrong code. The working code, which I use, is based on this:\nhttp://code.activestate.com/recipes/146306-http-client-to-post-using-multipartform-data/\nso I won't repeat it here and claim It being mine. \nBecause of your comment I read RFC1867 and realised I gave you the ... | [
3
] | [] | [] | [
"file_upload",
"post",
"python",
"request"
] | stackoverflow_0003937877_file_upload_post_python_request.txt |
Q:
Any value in catching an exception and immediately raising it again?
Possible Duplicate:
Does a exception with just a raise have any use?
Is there any value to re-raising an exception with no other code in between?
try:
#code
except Exception:
raise
I was recently looking through some code and saw a few blo... | Any value in catching an exception and immediately raising it again? |
Possible Duplicate:
Does a exception with just a raise have any use?
Is there any value to re-raising an exception with no other code in between?
try:
#code
except Exception:
raise
I was recently looking through some code and saw a few blocks like these with nothing extra in the except block but another raise. ... | [
"I am not able to come up with something useful, other than to keep it as a placeholder for later insertion to catch useful exceptions.\nIt kind of avoids re-indenting the code, when you want to include the \"try .. except..\" blocks later on.\n",
"I've seen similar code before in a (set of) horrible VB.NET proje... | [
2,
2,
2,
1,
1,
0,
0,
0
] | [] | [] | [
"exception_handling",
"python"
] | stackoverflow_0003937597_exception_handling_python.txt |
Q:
How do I encode and decode PER-encoded data in Python?
I need to be able to decode and encode PER-encoded octet strings using Python. I found PyASN1, but it doesn't include a PER codec. Is there another solution out there? How difficult would it be to write a PER codec?
A:
If, I remember well, there is an inc... | How do I encode and decode PER-encoded data in Python? | I need to be able to decode and encode PER-encoded octet strings using Python. I found PyASN1, but it doesn't include a PER codec. Is there another solution out there? How difficult would it be to write a PER codec?
| [
"If, I remember well, there is an incomplete implementation / support of PER encoding format in SNMPy .\n\nhttp://sourceforge.net/projects/snmpy/\n\n"
] | [
0
] | [] | [] | [
"asn.1",
"python"
] | stackoverflow_0003937889_asn.1_python.txt |
Q:
When would my Python test suite file coverage not be 100%?
We are using Hudson and coverage.py to report the code coverage of our test suite. Hudson breaks down coverage into:
packages
files
classes
lines
conditionals
Coverage.py only reports coverage on files executed/imported during the tests, and so it seems ... | When would my Python test suite file coverage not be 100%? | We are using Hudson and coverage.py to report the code coverage of our test suite. Hudson breaks down coverage into:
packages
files
classes
lines
conditionals
Coverage.py only reports coverage on files executed/imported during the tests, and so it seems is oblivious to any files not executed during the tests. Is ther... | [
"Currently, coverage.py doesn't know how to find files that are never executed and report them as not covered, but that will be coming in the next release. So now, the file coverage will always be 100%. This is an area where Hudson (using the Cobertura plugin) and coverage.py don't mesh very well.\n",
"Coverage... | [
3,
3
] | [] | [] | [
"code_coverage",
"coverage.py",
"hudson",
"python",
"python_coverage"
] | stackoverflow_0003562643_code_coverage_coverage.py_hudson_python_python_coverage.txt |
Q:
How to pause Python while Tkinter window is open?
I'm writing a program that sometimes encounters an error. When it does, it pops up a Tkinter dialog asking the user whether to continue. It's a more complicated version of this:
keep_going = False
KeepGoingPrompt(keep_going)
if not keep_going:
return
The prompt... | How to pause Python while Tkinter window is open? | I'm writing a program that sometimes encounters an error. When it does, it pops up a Tkinter dialog asking the user whether to continue. It's a more complicated version of this:
keep_going = False
KeepGoingPrompt(keep_going)
if not keep_going:
return
The prompt sets keep_going to True or leaves it False.
Problem is... | [
"You can use the tkMessageBox class to pop up a question dialog that is modal and won't return until the user clicks a button. See the Tkinter book for details.\n",
"1) Are you running your code inside IDLE? It might be responsible for making the dialogue non-blocking while it really should be blocking.\n2) If ru... | [
1,
0
] | [] | [] | [
"loops",
"pausing_execution",
"python",
"tkinter"
] | stackoverflow_0003938549_loops_pausing_execution_python_tkinter.txt |
Q:
Why does Django's time filter not pickup the TIME_FORMAT by default?
Using {{today|time:"TIME_FORMAT"}} correctly localises times when I switch languages in my Django 1.2.3 project. E.g. for English I see "12:19 a.m." and when I switch to German it changes to "12:19:25".
As far as I can tell from looking at the do... | Why does Django's time filter not pickup the TIME_FORMAT by default? | Using {{today|time:"TIME_FORMAT"}} correctly localises times when I switch languages in my Django 1.2.3 project. E.g. for English I see "12:19 a.m." and when I switch to German it changes to "12:19:25".
As far as I can tell from looking at the docs and code (defaultfilters.py and formats.py) just using {{today:time}} s... | [
"The docs say (emphasis mine):\n\nWhen used without a format string:\n {{ value|time }}\n\n...the formatting string defined in the TIME_FORMAT setting will be used, without applying any localization.\n\nYou have two options:\n\nEdit all your templates to make the change, or\nCreate a new filter of your own that doe... | [
3,
1
] | [] | [] | [
"django",
"internationalization",
"localization",
"python"
] | stackoverflow_0003938700_django_internationalization_localization_python.txt |
Q:
Appengine create and export yaml file
I´m having trouble in creating a file and export to .yaml.
I´m using Google App Engine with Python 2.5.
Don´t understand the Yaml doc´s, it makes me confused.
What i want is to create a file and save it. It´s necessary to get entities from Models.
class SaveYAML(webapp.Request... | Appengine create and export yaml file | I´m having trouble in creating a file and export to .yaml.
I´m using Google App Engine with Python 2.5.
Don´t understand the Yaml doc´s, it makes me confused.
What i want is to create a file and save it. It´s necessary to get entities from Models.
class SaveYAML(webapp.RequestHandler):
def post(self):
user ... | [
"Do not use print, use self.response.out.write(...).\nYes, you will want to import yaml to output yaml, it will make it easier.\nTry this:\nimport yaml\n\nusers = model.Users.all().fetch(10)\nusers = [{'user': {'name': user.name,\n 'address': user.address,\n 'phone': user.phone,\... | [
1
] | [] | [] | [
"google_app_engine",
"python",
"pyyaml",
"yaml"
] | stackoverflow_0003937964_google_app_engine_python_pyyaml_yaml.txt |
Q:
Iterator (iter()) function in Python.
For dictionary, I can use iter() for iterating over keys of the dictionary.
y = {"x":10, "y":20}
for val in iter(y):
print val
When I have the iterator as follows,
class Counter:
def __init__(self, low, high):
self.current = low
self.high = high
d... | Iterator (iter()) function in Python. | For dictionary, I can use iter() for iterating over keys of the dictionary.
y = {"x":10, "y":20}
for val in iter(y):
print val
When I have the iterator as follows,
class Counter:
def __init__(self, low, high):
self.current = low
self.high = high
def __iter__(self):
return self
... | [
"All of these work fine, except for a typo--you probably mean:\nx = Counter(3,8)\nfor i in x:\n print i\n\nrather than\nx = Counter(3,8)\nfor i in x:\n print x\n\n",
"I think your actual problem is that you print x when you mean to print i\niter() is used to obtain an iterator over a given object. If you ha... | [
17,
8
] | [] | [] | [
"iterator",
"python"
] | stackoverflow_0003938927_iterator_python.txt |
Q:
Any good references for python and C code mixing?
I've been looking at docs but I can't seem to understand very clearly, them do you guys know of anything that would be good at teaching it.
Say I had a program,
int main() {
return 3;
}
How do I call cprogram.exe and get the return value (not neccesarily an int... | Any good references for python and C code mixing? | I've been looking at docs but I can't seem to understand very clearly, them do you guys know of anything that would be good at teaching it.
Say I had a program,
int main() {
return 3;
}
How do I call cprogram.exe and get the return value (not neccesarily an int, structs too). I don't have a specific project that I'... | [
"The simplest way of doing this would be to create a dll or so (depending on your platform) then use the ctypes module to call into it. The exact method for creating the dll depends on your compiler. For ctypes see http://python.net/crew/theller/ctypes/tutorial.html\n",
"Wesley Chun has a nice chapter showing how... | [
1,
0,
0
] | [] | [] | [
"c",
"python"
] | stackoverflow_0003938941_c_python.txt |
Q:
Read in CLI argumnet, then use regex's to look for it. -Python
Sorry if this is probably a simple fix but I can't think of one. I am trying to take a command line argument (in this case a name) and search through a file hierarchy and keep track of the number of times that name comes up. I was just wondering how to... | Read in CLI argumnet, then use regex's to look for it. -Python | Sorry if this is probably a simple fix but I can't think of one. I am trying to take a command line argument (in this case a name) and search through a file hierarchy and keep track of the number of times that name comes up. I was just wondering how to store the CL input and then search through files using a regular ex... | [
"import sys\nimport os\nthe_name= sys.argv[1]\ncount=0\nfor r,d,f in os.walk(\"/mypath\"):\n for file in f:\n if the_name in file:\n count+=1\n\nIf you want to search IN the file themselves,\nfor r,d,f in os.walk(\"/mypath\"):\n for file in f:\n for line in open(os.path.join(r,file)) ... | [
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0003939053_python_regex.txt |
Q:
Run command line arguments in python script
I have a program that is run from the command line like this
python program.py 100 rfile
How can I write a new script so that instead of running it with just the '100' argument, I can run it consecutively with a list of arguments like [50, 100, 150, 200]?
Edit: The reas... | Run command line arguments in python script | I have a program that is run from the command line like this
python program.py 100 rfile
How can I write a new script so that instead of running it with just the '100' argument, I can run it consecutively with a list of arguments like [50, 100, 150, 200]?
Edit: The reason I am asking is that I want to record how 'prog... | [
"If you create a bash file like this\n#!/bin/bash\nfor i in 1 2 3 4 5\ndo\n python program.py $i rfile\ndone\n\nthen do chmod +x on that file, when you run it, it will run these consecutively:\npython program.py 1 rfile\npython program.py 2 rfile\npython program.py 3 rfile\npython program.py 4 rfile\npython progra... | [
8,
6,
4,
2
] | [] | [] | [
"python",
"shell"
] | stackoverflow_0003939196_python_shell.txt |
Q:
developing for modularity & reusability: how to handle While True loops?
I've been playing around with the pybluez module recently to scan for nearby Bluetooth devices. What I want to do now is extend the program to also find nearby WiFi client devices.
The WiFi client scanner will have need to have a While True l... | developing for modularity & reusability: how to handle While True loops? | I've been playing around with the pybluez module recently to scan for nearby Bluetooth devices. What I want to do now is extend the program to also find nearby WiFi client devices.
The WiFi client scanner will have need to have a While True loop to continually monitor the airwaves. If I were to write this as a straight... | [
"I think the best approach is going to be to have the scanner run on a separate thread from the main program. The module should have methods that start and stop the scanner, and another that returns the current access point list (using a lock to synchronize). See the threading module.\n",
"How about something pre... | [
1,
1,
1,
0
] | [] | [] | [
"modularity",
"module",
"python"
] | stackoverflow_0003939138_modularity_module_python.txt |
Q:
Save images as string? IS it possible
Is it possible to save images as string, and then I load it up to Image?
A:
You can save it to a StringIO buffer:
import pylab, numpy
from StringIO import StringIO
from PIL import Image
# plot a histogram
pylab.hist(numpy.random.rand(100))
buf = StringIO()
pylab.savefig(bu... | Save images as string? IS it possible | Is it possible to save images as string, and then I load it up to Image?
| [
"You can save it to a StringIO buffer:\nimport pylab, numpy\nfrom StringIO import StringIO\nfrom PIL import Image\n\n# plot a histogram\npylab.hist(numpy.random.rand(100))\n\nbuf = StringIO()\npylab.savefig(buf, format='png')\n\nbuf.seek(0)\nim = Image.open(buf)\nim.show()\n\n"
] | [
6
] | [] | [] | [
"image",
"python",
"string"
] | stackoverflow_0003939342_image_python_string.txt |
Q:
How to make a screenshot in Windows 7 with python?
I along with some friends are trying to do an anti cheats for a game, we chose python because it is multiplatform.
The problem is we're trying to make a screenshot of what is shown on the screen, not just the game (with OpenGL) but any windows that are open to det... | How to make a screenshot in Windows 7 with python? | I along with some friends are trying to do an anti cheats for a game, we chose python because it is multiplatform.
The problem is we're trying to make a screenshot of what is shown on the screen, not just the game (with OpenGL) but any windows that are open to detect programs that are superimposed on the image of the g... | [
"The ImageGrab module should work on Windows 7.\nhttp://effbot.org/imagingbook/imagegrab.htm\n"
] | [
1
] | [] | [] | [
"aero",
"opengl",
"python",
"screenshot",
"windows"
] | stackoverflow_0003938776_aero_opengl_python_screenshot_windows.txt |
Q:
Os Check And prompt proper if
Can python see which windows i use e.x. windows 7 windows xp windows vista and if windows vista print you use windows vista, or execute other command
A:
Absolutely. Look at platform.
A:
import platform
platform.system() # => 'Windows'
platform.release() # => 'Vista'
platform.vers... | Os Check And prompt proper if | Can python see which windows i use e.x. windows 7 windows xp windows vista and if windows vista print you use windows vista, or execute other command
| [
"Absolutely. Look at platform.\n",
"import platform\nplatform.system() # => 'Windows'\nplatform.release() # => 'Vista'\nplatform.version() # => '6.1.7600'\n\nI believe if platform.version() returns a value of 6.1.7000 or higher, you're on a Windows 7 machine, otherwise it is Vista.\n"
] | [
2,
2
] | [] | [] | [
"operating_system",
"python"
] | stackoverflow_0003933375_operating_system_python.txt |
Q:
Python execution speed: laptop vs desktop
I am running a program that does simple data processing:
parses text
populates dictionaries
calculates some functions over the resulting data
The program only uses CPU, RAM, and HDD:
run from Windows command line
input/output to the local hard drive
nothing displayed on... | Python execution speed: laptop vs desktop | I am running a program that does simple data processing:
parses text
populates dictionaries
calculates some functions over the resulting data
The program only uses CPU, RAM, and HDD:
run from Windows command line
input/output to the local hard drive
nothing displayed on or printed to screen
no networking
The same p... | [
"The increasing performance of hardware brings in most cases automatically results in benefit to user applications. The much maligned \"GIL\" means that you may not be able to take advantage of multicores with CPython unless you design your program to take advantage via various multiprocessing modules / libraries.\... | [
6,
0,
0
] | [] | [] | [
"intel",
"performance",
"python"
] | stackoverflow_0003939912_intel_performance_python.txt |
Q:
How can I query for records based on an attribute of a ReferenceProperty? (Django on App Engine)
If I have the following models in a Python (+ Django) App Engine app:
class Album(db.Model):
private = db.BooleanProperty()
...
class Photo(db.Model):
album = db.ReferenceProperty(Album)
title = db.StringPrope... | How can I query for records based on an attribute of a ReferenceProperty? (Django on App Engine) | If I have the following models in a Python (+ Django) App Engine app:
class Album(db.Model):
private = db.BooleanProperty()
...
class Photo(db.Model):
album = db.ReferenceProperty(Album)
title = db.StringProperty()
...how can I retrieve all Photos that belong to a public Album (that is, an Album with private ... | [
"You can't. App engine doesn't support joins.\nOne approach is to implement the join manually. For example you could fetch all photos, then filter out the private ones in code. Or fetch all public albums, and then fetch each of their photos. It depends on your data as to whether this will perform okay or not.\nThe ... | [
4
] | [] | [] | [
"django",
"google_app_engine",
"google_cloud_datastore",
"python"
] | stackoverflow_0003939830_django_google_app_engine_google_cloud_datastore_python.txt |
Q:
python - multi line stdout refresh issue
I have a stats app written in python that on a timer refreshes the ssh screen with stats. Right now it uses os.system('clear') to clear the screen and then outputs a multi line data with the stats.
I'd like to do just do a \r instead of executing the clear but that only wor... | python - multi line stdout refresh issue | I have a stats app written in python that on a timer refreshes the ssh screen with stats. Right now it uses os.system('clear') to clear the screen and then outputs a multi line data with the stats.
I'd like to do just do a \r instead of executing the clear but that only works with one line, is it possible to do this wi... | [
"solved the issue with:\nimport curses\nwindow = curses.initscr()\nwindow.addstr(1, 0, \"my text\")\nwindow.refresh()\ncurses.endwin() \n\n",
"It doesn't really answer your question, but there isn't really anything wrong with calling os.system to clear out the terminal (other than the system running on different ... | [
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0003939482_python.txt |
Q:
Which openid / oauth library to connect a django project to Google Apps Accounts?
I'm working on an intranet django project (not using GAE) for a company that uses Google Apps for login. So I'd like my users to be able to log in to my django project using their google accounts login. OpenID seems appropriate, al... | Which openid / oauth library to connect a django project to Google Apps Accounts? | I'm working on an intranet django project (not using GAE) for a company that uses Google Apps for login. So I'd like my users to be able to log in to my django project using their google accounts login. OpenID seems appropriate, although maybe Oauth might work too?
I see a lot of similarly named libraries out there t... | [
"I finally got this working, so I'll answer my own question since the previous answers here were helpful but don't tell the whole story.\ndjango-openid-auth is actually quite easy to set up and use. The README file is very clear. If you just want to use standard google accounts (i.e. @gmail.com addresses) then yo... | [
17,
3,
1,
0,
0
] | [] | [] | [
"django",
"google_openid",
"openid",
"python"
] | stackoverflow_0003145453_django_google_openid_openid_python.txt |
Q:
Django: most efficient way to query many records?
I have a table with a few thousands records (products). Each product has a 4 different categories:
CAT1 CAT2 CAT3 CAT4
I wonder if is there a method, or what is the best practice, to dynamically retrive the available categories based on the categories already sele... | Django: most efficient way to query many records? | I have a table with a few thousands records (products). Each product has a 4 different categories:
CAT1 CAT2 CAT3 CAT4
I wonder if is there a method, or what is the best practice, to dynamically retrive the available categories based on the categories already selected (using Ajax).
Example:
if CAT1 = green all the pro... | [
"This is a technique commonly known as \"select chaining\" or \"chained selects\".\nYou can use some fairly simple javascript for this as shown in the answer to How to limit choice field options based on another choice field in django admin\nYou can also use a prepackaged solution such as django-smart-selects (foun... | [
0,
0
] | [] | [] | [
"ajax",
"django",
"django_templates",
"mysql",
"python"
] | stackoverflow_0003933871_ajax_django_django_templates_mysql_python.txt |
Q:
How to control the msn messager's "personal message" displayed to others by python?
How to control the msn messager's "personal message" displayed to others by python?
Want to share some private infomation remotely with this area.
A:
There are many python solutions that allow you to do MSN messaging with Python.... | How to control the msn messager's "personal message" displayed to others by python? | How to control the msn messager's "personal message" displayed to others by python?
Want to share some private infomation remotely with this area.
| [
"There are many python solutions that allow you to do MSN messaging with Python.\n\nmsnp\n\nThis has support for presence states with which you should be able to notify.\n\nhttp://msnp.sourceforge.net/\n\n\nmsnlib\n\nYou could build scripts using this library, which is an opensource Python implementation for the MS... | [
1
] | [] | [] | [
"msn",
"python"
] | stackoverflow_0003940723_msn_python.txt |
Q:
Why Python sets my default timezone to -1?
I use Python to track the version between local SQLite and remote web page. It is useful to compare them by Last-modified and file size information from the HTTP response. I found something interesting during development.
def time_match(web,sql):
print web,sql
t1 = ti... | Why Python sets my default timezone to -1? | I use Python to track the version between local SQLite and remote web page. It is useful to compare them by Last-modified and file size information from the HTTP response. I found something interesting during development.
def time_match(web,sql):
print web,sql
t1 = time.strptime(web,"%a, %d %b %Y %H:%M:%S %Z")
t2... | [
"The -1 at the last position in the time.struct_time object does not mean you are in the 'UTC-01:00'. It represents the undefined attribute is_dst (since YYYY-MM-DD HH:MM:SS format does not contain any information on the current timezone or daylight saving time mode).\ntime.strptime('2010-10-15 11:01:02', '%Y-%m-%d... | [
1
] | [] | [] | [
"python",
"sqlite",
"timezone"
] | stackoverflow_0003940738_python_sqlite_timezone.txt |
Q:
noob question regarding twitter oauth
I'm unfamiliar with the new oauth system. I wanted to crawl the status updates of my friends, and their friends' (if permissions allow) with my specified account credentials using the python-twitter api.
With the new oauth authentication, does it means that I have to first re... | noob question regarding twitter oauth | I'm unfamiliar with the new oauth system. I wanted to crawl the status updates of my friends, and their friends' (if permissions allow) with my specified account credentials using the python-twitter api.
With the new oauth authentication, does it means that I have to first register an application with twitter before I... | [
"Yes, thats right. You need to register it and connect \"grant access\" it with your twitter id, if you want, for example, post something on your twitter wall. Also see \"connections\" in your twitter id.\n",
"For use api you must register your aplication or use GET methods to post into twi through web interface... | [
1,
0
] | [] | [] | [
"oauth",
"python",
"twitter"
] | stackoverflow_0003940774_oauth_python_twitter.txt |
Q:
how the bittorent is compiled to exe
As all know bittorrent is written in python program. whenever i download and install the bittorrent.exe, I never found any file(like dll etc) associated in program files i mean whenever i go to c:\program files\bittorrent i found only single file called bittorrent.exe, i wonder... | how the bittorent is compiled to exe | As all know bittorrent is written in python program. whenever i download and install the bittorrent.exe, I never found any file(like dll etc) associated in program files i mean whenever i go to c:\program files\bittorrent i found only single file called bittorrent.exe, i wonder how this program is compiled to exe , whe... | [
"Actually bittorrent is a protocol. The original program which implemented bittorrent may have been written in Python but that's not the case now.\nA lot of them now are coded in compiled languages, Transmission being the one I'm most familiar with (comes with Ubuntu) - it uses gcc.\n",
"You mean the, umm, \"offi... | [
4,
2,
0,
0
] | [] | [] | [
"executable",
"python"
] | stackoverflow_0003940782_executable_python.txt |
Q:
NaN giving an error depending on Python startup?
I am using Python4Delphi to embed Python in a Delphi program. Versions: Python 2.6.4, Delphi 2009, Windows XP.
The Delphi program crashes with EInvalidOp when importing json. I tracked it to the line
NaN, PosInf, NegInf = float('nan'), float('inf'), float('-inf')
i... | NaN giving an error depending on Python startup? | I am using Python4Delphi to embed Python in a Delphi program. Versions: Python 2.6.4, Delphi 2009, Windows XP.
The Delphi program crashes with EInvalidOp when importing json. I tracked it to the line
NaN, PosInf, NegInf = float('nan'), float('inf'), float('-inf')
in json.decoder.
Sure enough, the command float('nan') ... | [
"This is most likely that Python uses a different 8087 control word (CW) setting than Delphi.\nTry this kind of code:\nvar\n OldControlWord: Word;\nbegin\n OldControlWord := Get8087CW();\n Set8087CW($133F);\n try\n // perform your Python code here\n finally\n Set8087CW(OldControlWord); \n end;\nend... | [
5,
1
] | [] | [] | [
"delphi",
"embedding",
"python"
] | stackoverflow_0003933851_delphi_embedding_python.txt |
Q:
Python - HTML Parsing with Tidy
This code takes a bit of bad html, uses the Tidy library to clean it up and then passes it to an HtmlLib.Reader().
import tidy
options = dict(output_xhtml=1,
add_xml_decl=1,
indent=1,
tidy_mark=0)
from xml.dom.ext.reader import Htm... | Python - HTML Parsing with Tidy | This code takes a bit of bad html, uses the Tidy library to clean it up and then passes it to an HtmlLib.Reader().
import tidy
options = dict(output_xhtml=1,
add_xml_decl=1,
indent=1,
tidy_mark=0)
from xml.dom.ext.reader import HtmlLib
reader = HtmlLib.Reader()
doc =... | [
"tidy's parseString function returns a _Document instance which implements __str__ but not a buffer interface. Therefore HtmlLib.Reader().fromString cannot create a StringIO object out of it.\nThis should be fairly simple, change:\ndoc = reader.fromString(tidy.parseString(\"<Html>Bad Html.\", **options))\n\nto\ndoc... | [
4,
1
] | [] | [] | [
"html_parsing",
"python",
"tidy"
] | stackoverflow_0003941038_html_parsing_python_tidy.txt |
Q:
Passing a sequence of the same form? - Django
the user needs to provide a list of field/values through a form
class FieldForm(forms.Form):
field_name = forms.CharField()
field_value = forms.CharField()
The problem is how do I get a user to pass multiple of these with one submit?
Also as a side question.... | Passing a sequence of the same form? - Django | the user needs to provide a list of field/values through a form
class FieldForm(forms.Form):
field_name = forms.CharField()
field_value = forms.CharField()
The problem is how do I get a user to pass multiple of these with one submit?
Also as a side question... any tips on implementing editing too?
Any ideas... | [
"Sounds like formsets are what you are after.\n"
] | [
1
] | [] | [] | [
"django",
"forms",
"html",
"http",
"python"
] | stackoverflow_0003941260_django_forms_html_http_python.txt |
Q:
Efficient substring searching in Python with MySQL
I'm trying to implement a live search for my website. One that identifies words, or parts of a word, in a given string. The instant results are then underlined where they match the query.
For example, a query of "Fried green tomatoes" would yield:
SELECT *
FROM... | Efficient substring searching in Python with MySQL | I'm trying to implement a live search for my website. One that identifies words, or parts of a word, in a given string. The instant results are then underlined where they match the query.
For example, a query of "Fried green tomatoes" would yield:
SELECT *
FROM articles
WHERE (title LIKE '%fried%' OR
title L... | [
"Sphinx will help you to search fast within the huge amount of data\n",
"they are many FULLTEXT search engine that you can use like sphinx , Apache Solr, Whoosh (it's pure python) and Xapian. django-haystack (if you are using django) which can interface with the 3 last ones;\n"
] | [
2,
0
] | [] | [] | [
"binary_tree",
"database",
"mysql",
"python"
] | stackoverflow_0003939776_binary_tree_database_mysql_python.txt |
Q:
Relating two consecutive lines in a file
I have a txt file of repeating lines like this:
Host: http://de.wikipedia.org
Referer: http://www.wikipedia.org
Host: answers.yahoo.com/
Referer: http://www.yahoo.com
Host: http://de.wikipedia.org
Referer: http://www.wikipedia.org
Host: http://maps.yahoo.com/
Referer: http... | Relating two consecutive lines in a file | I have a txt file of repeating lines like this:
Host: http://de.wikipedia.org
Referer: http://www.wikipedia.org
Host: answers.yahoo.com/
Referer: http://www.yahoo.com
Host: http://de.wikipedia.org
Referer: http://www.wikipedia.org
Host: http://maps.yahoo.com/
Referer: http://www.yahoo.com
Host: http://pt.wikipedia.org... | [
"You could have a set for each referrer in the dictionary, rather than just a number. This way you could just add each host to the set, and duplicates will automatically be discarded. To get the number of hosts for the referrer, get the number of elements in the set.\ndd = {}\nreferrer = None\n\nfor line in open('h... | [
2
] | [] | [] | [
"python"
] | stackoverflow_0003941378_python.txt |
Q:
Using map to process a list-of-objects in python
I want to calculate the center-of-mass using the map function. I don't want to use for loops. Help with bottom two lines?
class Obj():
def __init__(self, mass = 0., x = 0., y = 0.):
self.mass = mass
self.x = x
self.y = y ... | Using map to process a list-of-objects in python | I want to calculate the center-of-mass using the map function. I don't want to use for loops. Help with bottom two lines?
class Obj():
def __init__(self, mass = 0., x = 0., y = 0.):
self.mass = mass
self.x = x
self.y = y
# Create List of Objects
objList = []
n = 0 ... | [
"You can't do the last two lines unless you abandon your anti-for prejudice.\nSumOfMass = sum(obj.mass for obj in objList) \nCenterOfMassX = sum(obj.x * obj.mass for obj in objList)/SumOfMass \n\nWith py2k (which are you using?), map(func, alist) is equivalent to [func(v) for v in alist] i.e. it returns a lis... | [
3,
2,
2
] | [] | [] | [
"list",
"map",
"python"
] | stackoverflow_0003941486_list_map_python.txt |
Q:
Converting list to *args when calling function
In Python, how do I convert a list to *args?
I need to know because the function
scikits.timeseries.lib.reportlib.Report.__init__(*args)
wants several time_series objects passed as *args, whereas I have a list of timeseries objects.
A:
You can use the * operator be... | Converting list to *args when calling function | In Python, how do I convert a list to *args?
I need to know because the function
scikits.timeseries.lib.reportlib.Report.__init__(*args)
wants several time_series objects passed as *args, whereas I have a list of timeseries objects.
| [
"You can use the * operator before an iterable to expand it within the function call. For example:\ntimeseries_list = [timeseries1 timeseries2 ...]\nr = scikits.timeseries.lib.reportlib.Report(*timeseries_list)\n\n(notice the * before timeseries_list)\nFrom the python documentation:\n\nIf the syntax *expression app... | [
263,
25,
3
] | [] | [] | [
"arguments",
"function_call",
"list",
"python"
] | stackoverflow_0003941517_arguments_function_call_list_python.txt |
Q:
MySQL server has gone away error with Pylons, SQLAlchemy, Apache
sorry if this is addressed, but i'm running
apache2
SQLAlchemy 0.5.8
Pylons 1.0
Python 2.5.2
and on a simple page (just retrieve data from DB), I get:
Error - : (OperationalError) (2006,
'MySQL server has gone away')
every few other requests... | MySQL server has gone away error with Pylons, SQLAlchemy, Apache | sorry if this is addressed, but i'm running
apache2
SQLAlchemy 0.5.8
Pylons 1.0
Python 2.5.2
and on a simple page (just retrieve data from DB), I get:
Error - : (OperationalError) (2006,
'MySQL server has gone away')
every few other requests, not after a long time as other posts I've searched
for. I still ad... | [
"You can try to increase max_allowed_packet configuration parameter value in you MySQL config.\nhttp://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_allowed_packet\nFor example:\nmax_allowed_packet=128M\n\n"
] | [
1
] | [] | [] | [
"mysql",
"pylons",
"python",
"sqlalchemy"
] | stackoverflow_0003937945_mysql_pylons_python_sqlalchemy.txt |
Q:
python windows standalone exe file
whenever i build python file to exe file from py2exe, it takes lots of space of minimum 25MB for small project also,it includes all the the python library file. Is there any other way that i can reduce the size.
A:
You should have read the documentation before using. Here's a p... | python windows standalone exe file | whenever i build python file to exe file from py2exe, it takes lots of space of minimum 25MB for small project also,it includes all the the python library file. Is there any other way that i can reduce the size.
| [
"You should have read the documentation before using. Here's a page you can read\n",
"Python programs need python to run. All py2exe does is to include full python and all libraries you use together with your script in a single file.\n",
"py2exe tends to err on the side of caution. You can manually exclude some... | [
6,
3,
0
] | [
"No, not really; you need Python shipped with the exe so that it is standalone. It it not common to create exe Files from Python projects, anyway.\n"
] | [
-2
] | [
"py2exe",
"python"
] | stackoverflow_0003941830_py2exe_python.txt |
Q:
How to speed up python views in CouchDB?
I'm working on my CouchDB with Python, cause I love python. The problem is: On my machine (it's a Seagate Dockstar) it's quite slow. How can I increase the speed?
a) I've tried to use psyco. It's not available for that plattform.
b) I've tried to put the imports outside my ... | How to speed up python views in CouchDB? | I'm working on my CouchDB with Python, cause I love python. The problem is: On my machine (it's a Seagate Dockstar) it's quite slow. How can I increase the speed?
a) I've tried to use psyco. It's not available for that plattform.
b) I've tried to put the imports outside my function-definitons. This doesn't work since t... | [
"I know you said you didn't want to learn Erlang, but I really think you should Learn You Some Erlang for Great Good!\n"
] | [
0
] | [] | [] | [
"couchdb",
"performance",
"python"
] | stackoverflow_0003941893_couchdb_performance_python.txt |
Q:
How to set a python property in __init__
I have a class with an attribute I wish to turn into a property, but this attribute is set within __init__. Not sure how this should be done. Without setting the property in __init__ this is easy and works well
import datetime
class STransaction(object):
"""A statement... | How to set a python property in __init__ | I have a class with an attribute I wish to turn into a property, but this attribute is set within __init__. Not sure how this should be done. Without setting the property in __init__ this is easy and works well
import datetime
class STransaction(object):
"""A statement transaction"""
def __init__(self):
... | [
"I do not see any real problem with your code. In __init__, the class is fully created and thus the properties accessible.\n",
"class STransaction(object):\n \"\"\"A statement transaction\"\"\"\n def __init__(self, date):\n self._date = None #1\n self.date = date #2\n\nIf you want to set the ... | [
30,
10
] | [] | [] | [
"properties",
"python"
] | stackoverflow_0003941919_properties_python.txt |
Q:
Python - Creating a "scripting" system
I'm making a wxpython app that I will compile with the various freezing utility out there to create an executable for multiple platforms.
the program will be a map editer for a tile-based game engine
in this app I want to provide a scripting system so that advanced users can ... | Python - Creating a "scripting" system | I'm making a wxpython app that I will compile with the various freezing utility out there to create an executable for multiple platforms.
the program will be a map editer for a tile-based game engine
in this app I want to provide a scripting system so that advanced users can modify the behavior of the program such as m... | [
"Easy answer: don't.\nYou can forbid certain keywords (import) and operations, and accesses to certain data structures, but ultimately you're giving your power users quite a bit of power. Since this is for a rich client that runs on the user's machine, a malicious user can crash or even trash the whole app if they ... | [
5,
1,
0,
0
] | [] | [] | [
"eval",
"python",
"scripting",
"security",
"wxpython"
] | stackoverflow_0003938184_eval_python_scripting_security_wxpython.txt |
Q:
exhausted iterators - what to do about them?
(In Python 3.1)
(Somewhat related to another question I asked, but this question is about iterators being exhausted.)
# trying to see the ratio of the max and min element in a container c
filtered = filter(lambda x : x is not None and x != 0, c)
ratio = max(filtered) / ... | exhausted iterators - what to do about them? | (In Python 3.1)
(Somewhat related to another question I asked, but this question is about iterators being exhausted.)
# trying to see the ratio of the max and min element in a container c
filtered = filter(lambda x : x is not None and x != 0, c)
ratio = max(filtered) / min(filtered)
It took me half hour to realize wha... | [
"The itertools.tee function can help here:\nimport itertools\n\nf1, f2 = itertools.tee(filtered, 2)\nratio = max(f1) / min(f2)\n\n",
"you can convert an iterator to a tuple simply by calling tuple(iterator)\nhowever I'd rewrite that filter as a list comprehension, which would look something like this\n# original\... | [
10,
7,
5,
3
] | [] | [] | [
"filter",
"iterator",
"python",
"python_3.x"
] | stackoverflow_0003940072_filter_iterator_python_python_3.x.txt |
Q:
PHP desktop applications
I have quite a few years experience of developing PHP web applications, and have recently started to delve into Python as well. Recently I've been interested in getting into desktop applications as well, but have absolutely no experience in that area. I've seen very little written about PH... | PHP desktop applications | I have quite a few years experience of developing PHP web applications, and have recently started to delve into Python as well. Recently I've been interested in getting into desktop applications as well, but have absolutely no experience in that area. I've seen very little written about PHP-gtk and wonder whether it's ... | [
"Building applications in PHP with GTK is possible to create client-side cross-platform applications, but I don't necessarily think it's the optimal choice for GUI development... \nHere are some links:\nhttp://gtk.php.net\nhttp://www.cweiske.de/phpgtk.htm\nGnope.org\nkksou \n",
"Python and Java are both excellent... | [
12,
2,
0,
0
] | [] | [] | [
"desktop",
"gtk",
"php",
"pygtk",
"python"
] | stackoverflow_0001029435_desktop_gtk_php_pygtk_python.txt |
Q:
How do I escape the - character in SQLite FTS3 queries?
I'm using Python and SQLAlchemy to query a SQLite FTS3 (full-text) store and I would like to prevent my users from using the - as an operator. How should I escape the - so users can search for a term containing the - (enabled by changing the default tokenizer... | How do I escape the - character in SQLite FTS3 queries? | I'm using Python and SQLAlchemy to query a SQLite FTS3 (full-text) store and I would like to prevent my users from using the - as an operator. How should I escape the - so users can search for a term containing the - (enabled by changing the default tokenizer) instead of it signifying "does not contain the term followi... | [
"From elsewhere on the internet it seems it may be possible to surround each search term with double quotes \"some-term\". Since we do not need the subtraction operation, my solution was to replace hyphens - with underscores _ when populating the search index and when performing searches.\n",
"From this documenta... | [
1,
0
] | [] | [] | [
"fts3",
"python",
"sqlalchemy",
"sqlite"
] | stackoverflow_0003865733_fts3_python_sqlalchemy_sqlite.txt |
Q:
Is the os.path.join(dir, filename) needed here?
I'm just doing a bunch of Python exercises and there is an exercise where you should. given a directory name, iterate over the 'special files' (containing the pattern __\w+__) and output their absolute paths.
Here's my code:
def get_special_paths(dir):
filenames = ... | Is the os.path.join(dir, filename) needed here? | I'm just doing a bunch of Python exercises and there is an exercise where you should. given a directory name, iterate over the 'special files' (containing the pattern __\w+__) and output their absolute paths.
Here's my code:
def get_special_paths(dir):
filenames = os.listdir(dir)
for filename in filenames:
if ... | [
"\nIf I don't join the filename + dir, and instead pass abspath() only the filename, the output would be the same.\n\nOnly if dir equals the current working directory, which is not necessarily the case. Either you need the join, or get_special_paths should not take an argument, and instead assume dir = os.getcwd().... | [
7
] | [] | [] | [
"path",
"python"
] | stackoverflow_0003942562_path_python.txt |
Q:
What practices would you consider "pythonic"?
If you google for "pythonic" you will mostly find the same three examples. There are a lot of questions here on stackoverflow that ask for how this and that can be done in a pythonoic way, so a collection of some nice pythonic code examples would be nice!
A:
as I wro... | What practices would you consider "pythonic"? | If you google for "pythonic" you will mostly find the same three examples. There are a lot of questions here on stackoverflow that ask for how this and that can be done in a pythonoic way, so a collection of some nice pythonic code examples would be nice!
| [
"as I wrote in the tag description:\n\nPythonic is a description of the most idiomatic Python code. Not only does this mean that the code is easy to understand for other programmers, but it is also very often the most efficient way to use Python.\n\n",
">>> import this\nThe Zen of Python, by Tim Peters\n\nBeautif... | [
5,
2,
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0003942875_python.txt |
Q:
how to delete or destroy the wx.panel from its parent (another wx.panel object)?
I am developing a GUI with wxPython. I draw a square which represents a CD object, inside another square (also with wxPanel class), which represents CD Container Object.
I want to have "delete this CD" in the right click menu of CDWi... | how to delete or destroy the wx.panel from its parent (another wx.panel object)? | I am developing a GUI with wxPython. I draw a square which represents a CD object, inside another square (also with wxPanel class), which represents CD Container Object.
I want to have "delete this CD" in the right click menu of CDWindow, which will remove the CDwindow.
Basically, my code looks like this (for simplic... | [
"Maybe there's a sizer still using the destroyed panel? You should remove the panel from the sizer first.\n"
] | [
3
] | [] | [] | [
"python",
"user_interface",
"wxpython",
"wxwidgets"
] | stackoverflow_0003943035_python_user_interface_wxpython_wxwidgets.txt |
Q:
x,y = getPos() vs. (x, y) = getPos()
Consider this function getPos() which returns a tuple. What is the difference between the two following assignments? Somewhere I saw an example where the first assignment was used but when I just tried the second one, I was surprised it also worked. So, is there really a differ... | x,y = getPos() vs. (x, y) = getPos() | Consider this function getPos() which returns a tuple. What is the difference between the two following assignments? Somewhere I saw an example where the first assignment was used but when I just tried the second one, I was surprised it also worked. So, is there really a difference, or does Python just figure out that ... | [
"Read about tuples:\n\nA tuple consists of a number of values separated by commas (...)\n\nSo parenthesis does not make a tuple a tuple. The commas do it. \nParenthesis are only needed if you have weird nested structures:\nx, (y, (w, z)), r\n\n",
"Yes, it's called tuple unpacking:\n\n\"Tuple unpacking requires th... | [
8,
5,
4,
3,
1
] | [] | [] | [
"python",
"tuples"
] | stackoverflow_0003941407_python_tuples.txt |
Q:
Python regular expression to match file-date.txt
I am trying to match file names in the format filename-isodate.txt
>>> DATE_NAME_PATTERN = re.compile("((.*)(-[0-9]{8})?)\\.txt")
>>> DATE_NAME_PATTERN.match("myfile-20101019.txt").groups()
('myfile-20101019', 'myfile-20101019', None)
However I need to get the file... | Python regular expression to match file-date.txt | I am trying to match file names in the format filename-isodate.txt
>>> DATE_NAME_PATTERN = re.compile("((.*)(-[0-9]{8})?)\\.txt")
>>> DATE_NAME_PATTERN.match("myfile-20101019.txt").groups()
('myfile-20101019', 'myfile-20101019', None)
However I need to get the filename and -isodate parts in seperate groups.
Any sugges... | [
"If you know the filename format will not change, you don't need re:\nfilename = 'myfile-20101019.txt'\nbasename, extension = filename.rsplit('.', 1)\nfirstpart, date = basename.rsplit('-', 1)\n\n\nIn : firstpart, date, extension\nOut: ('myfile', '20101019', 'txt')\n\nor just without extension:\nfirstpart, date = f... | [
2,
1,
1,
0
] | [] | [] | [
"python",
"regex",
"regex_group"
] | stackoverflow_0003941125_python_regex_regex_group.txt |
Q:
Freeze in Python?
I have programmed in Python for a while, and just recently started using Ruby at work. The languages are very similar. However, I just came across a Ruby feature that I don't know how to replicate in Python. It's Ruby's freeze method.
irb(main):001:0> a = [1,2,3]
=> [1, 2, 3]
irb(main):002:0> a[1... | Freeze in Python? | I have programmed in Python for a while, and just recently started using Ruby at work. The languages are very similar. However, I just came across a Ruby feature that I don't know how to replicate in Python. It's Ruby's freeze method.
irb(main):001:0> a = [1,2,3]
=> [1, 2, 3]
irb(main):002:0> a[1] = 'chicken'
=> "chick... | [
">>> a = [1,2,3]\n>>> a[1] = 'chicken'\n>>> a\n[1, 'chicken', 3]\n>>> a = tuple(a)\n>>> a[1] = 'tuna'\nTraceback (most recent call last):\n File \"<pyshell#4>\", line 1, in <module>\n a[1] = 'tuna'\nTypeError: 'tuple' object does not support item assignment\n\nAlso, cf. set vs. frozenset, bytearray vs. bytes.\n... | [
14,
12
] | [] | [] | [
"freeze",
"list",
"python",
"ruby"
] | stackoverflow_0003942825_freeze_list_python_ruby.txt |
Q:
Regex in Python
I have the following string:
schema(field1, field2, field3, field4 ... fieldn)
I need to transform the string to an object with name attribute as schema and the field names as another attribute which is a list.
How do I do this in Python with a regular expression?
A:
Are you looking for somethi... | Regex in Python | I have the following string:
schema(field1, field2, field3, field4 ... fieldn)
I need to transform the string to an object with name attribute as schema and the field names as another attribute which is a list.
How do I do this in Python with a regular expression?
| [
"Are you looking for something like this?\n>>> s = 'schema(field1, field2, field3, field4, field5)'\n>>> name, _, fields = s[:-1].partition('(')\n>>> fields = fields.split(', ')\n>>> if not all(re.match(r'[a-z]+\\d+$', i) for i in fields):\n print('bad input')\n\n>>> sch = type(name, (object,), {'attr': fields})... | [
5,
1,
0
] | [] | [] | [
"python",
"regex",
"string"
] | stackoverflow_0003943062_python_regex_string.txt |
Q:
Destop application in Python with more than one frame!
I have developed many desktop applications in Delphi / Pascal -
Here I have used modal forms.
//Mainform
Form1:= TForm1.Create(Self);
If Form1.Showmodal =mrOK then ….
In Form1 you cal call vars in Mainform like mainform.X := 1
(I know – I normaly use tr... | Destop application in Python with more than one frame! | I have developed many desktop applications in Delphi / Pascal -
Here I have used modal forms.
//Mainform
Form1:= TForm1.Create(Self);
If Form1.Showmodal =mrOK then ….
In Form1 you cal call vars in Mainform like mainform.X := 1
(I know – I normaly use try,except, finally)
I will now switch to Python and my prob... | [
"Just curious, why can't you use a dialog?\nAnyway, a simple solution would be to provide a callback function to the constructor of Frame2, which is called when Frame2 is about to be closed.\n\nclass Frame2(wx.wxFrame):\n def __init__(self, parent, callback, ...)\n wx.wxFrame(self, parent)\n self._... | [
1,
1
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0003937666_python_wxpython.txt |
Q:
Python Tkinter Return
Is there a way to return something when a button is pressed?
Here is my sample program. a simple file reader. Is the global variable to hold text contents the way to go since I can't return the contents?
from Tkinter import *
import tkFileDialog
textcontents = ''
def onopen():
filenam... | Python Tkinter Return | Is there a way to return something when a button is pressed?
Here is my sample program. a simple file reader. Is the global variable to hold text contents the way to go since I can't return the contents?
from Tkinter import *
import tkFileDialog
textcontents = ''
def onopen():
filename = tkFileDialog.askopenfil... | [
"Tk(inter) is event-based, which means, that you do not return values, but bind callbacks (functions) to actions.\nmore info here: http://effbot.org/tkinterbook/button.htm\n",
"If you meant signal back to the user, here's some sample code:\nimport Tkinter\nimport tkMessageBox\n\ntop = Tkinter.Tk()\n\ndef helloCal... | [
1,
0
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0003943495_python_tkinter.txt |
Q:
Does anyone have a Python 3 Cheat Sheet
Does anyone have a python 3 cheat sheet? You know quick reference kind of thing which has everything on one page.
A:
Here's a good one, if you know Python 2 syntax, well:
Python 2 to Python 3
A:
http://www.addedbytes.com/cheat-sheets/python-cheat-sheet/
A:
Not a cheat ... | Does anyone have a Python 3 Cheat Sheet | Does anyone have a python 3 cheat sheet? You know quick reference kind of thing which has everything on one page.
| [
"Here's a good one, if you know Python 2 syntax, well:\nPython 2 to Python 3\n",
"http://www.addedbytes.com/cheat-sheets/python-cheat-sheet/\n",
"Not a cheat sheet, but here are two helpful resources for converting to or learning the new features of Python 3 (from my bookmarks):\n\nPython 3000 and You (Guido va... | [
5,
5,
4
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0003943505_python_python_3.x.txt |
Q:
Slice notation in Scala?
Is there something similar to the slice notation in Python in Scala?
I think this is really a useful operation that should be incorporated in all languages.
A:
Equivalent method in Scala (with a slightly different syntax) exists for all kinds of sequences:
scala> "Hello world" slice(0,4)... | Slice notation in Scala? | Is there something similar to the slice notation in Python in Scala?
I think this is really a useful operation that should be incorporated in all languages.
| [
"Equivalent method in Scala (with a slightly different syntax) exists for all kinds of sequences:\nscala> \"Hello world\" slice(0,4)\nres0: String = Hell\n\nscala> (1 to 10) slice(3,5)\nres1: scala.collection.immutable.Range = Range(4, 5)\n\nThe biggest difference compared to slicing in Python is that start and end... | [
55,
21,
9,
2
] | [] | [] | [
"python",
"scala",
"slice"
] | stackoverflow_0003932582_python_scala_slice.txt |
Q:
GAE Query fetch()
I am trying to learn simple operations with the datastore and I am having problems. Can someone help why this is not working?
class Pet(db.Model):
name = db.StringProperty
pet = Pet(name="Fluffy")
pet.put()
query = Pet.all()
results = query.fetch(limit=5)
print pet.name
When I run this I... | GAE Query fetch() | I am trying to learn simple operations with the datastore and I am having problems. Can someone help why this is not working?
class Pet(db.Model):
name = db.StringProperty
pet = Pet(name="Fluffy")
pet.put()
query = Pet.all()
results = query.fetch(limit=5)
print pet.name
When I run this I get
<class 'google.app... | [
"Try changing\nname = db.StringProperty\n\nto\nname = db.StringProperty()\n\n"
] | [
3
] | [] | [] | [
"google_cloud_datastore",
"python"
] | stackoverflow_0003943713_google_cloud_datastore_python.txt |
Q:
Server Upgrade Script
Does anyone have or know of a good template / plan for doing automated server upgrades? In this case I am upgrading a python/django server, but am going to have to apply this update to many machines, and want to be sure that the operation is fully testable and recoverable should anything go ... | Server Upgrade Script | Does anyone have or know of a good template / plan for doing automated server upgrades? In this case I am upgrading a python/django server, but am going to have to apply this update to many machines, and want to be sure that the operation is fully testable and recoverable should anything go wrong.
Am picturing somethi... | [
"Once you have a plan (and yours looks pretty good), the Fabric site should be your next stop.\n",
"I think you're pretty much covering everything. Identify what's important to you and you're business practices: that's what counts.\n"
] | [
2,
0
] | [] | [] | [
"django",
"python",
"sysadmin"
] | stackoverflow_0003943598_django_python_sysadmin.txt |
Q:
Is there a better way to do this in Python?
ids = []
for object in objects:
ids += [object.id]
A:
You can use a list comprehension:
ids = [object.id for object in objects]
For your reference:
http://docs.python.org/howto/functional.html#generator-expressions-and-list-comprehensions
Both produce the same re... | Is there a better way to do this in Python? | ids = []
for object in objects:
ids += [object.id]
| [
"You can use a list comprehension:\nids = [object.id for object in objects]\n\nFor your reference:\n\nhttp://docs.python.org/howto/functional.html#generator-expressions-and-list-comprehensions\n\nBoth produce the same result. In many cases, a list comprehension is an elegant and pythonic way to do the same as what ... | [
27,
4,
3,
1
] | [] | [] | [
"python"
] | stackoverflow_0003940518_python.txt |
Q:
regex to parse tables wrapped into xml
Suppose we have a table:
Key|Val|Flag
01 |AAA| Y
02 |BBB| N
...
wrapped into xml this way:
<Data>
<R><F>Key</F><F>Val</F><F>Flag</F></R>
<R><F>01</F><F>AAA</F><F>Y</F></R>
<R><F>02</F><F>BBB</F><F>N</F></R>
...
</Data>
There can be more columns and rows, obviously.
... | regex to parse tables wrapped into xml | Suppose we have a table:
Key|Val|Flag
01 |AAA| Y
02 |BBB| N
...
wrapped into xml this way:
<Data>
<R><F>Key</F><F>Val</F><F>Flag</F></R>
<R><F>01</F><F>AAA</F><F>Y</F></R>
<R><F>02</F><F>BBB</F><F>N</F></R>
...
</Data>
There can be more columns and rows, obviously.
Now I'd like to parse XML back to table usin... | [
"Mandatory links:\n\nRegEx match open tags except XHTML self-contained tags and\nCan you provide some examples of why it is hard to parse XML and HTML with a regex?\n\nUse an XML parser. lxml is very good and even provides (among other XML-related thingies) XPath - if you got a fetish with oneliners, I'm sure there... | [
2,
0,
0,
0
] | [] | [] | [
"python",
"regex",
"xml"
] | stackoverflow_0003933121_python_regex_xml.txt |
Q:
Constipated Python urllib2 sockets
I've been scouring the Internet looking for a solution to my problem with Python. I'm trying to use a urllib2 connection to read a potentially endless stream of data from an HTTP server. It's part of some interactive communication, so it's important that I can get the data that'... | Constipated Python urllib2 sockets | I've been scouring the Internet looking for a solution to my problem with Python. I'm trying to use a urllib2 connection to read a potentially endless stream of data from an HTTP server. It's part of some interactive communication, so it's important that I can get the data that's available, even if it's not a whole bu... | [
"urllib2 operates at the HTTP level, which works with complete documents. I don't think there's a way around that without hacking into the urllib2 source code.\nWhat you can do is use plain sockets (you'll have to talk HTTP yourself in this case), and call sock.recv(maxbytes) which does read only available data.\nU... | [
1
] | [] | [] | [
"blocking",
"io",
"python",
"sockets",
"urllib2"
] | stackoverflow_0003939879_blocking_io_python_sockets_urllib2.txt |
Q:
Reading and Writing a new line from a file to another in Python
I'm trying to read from a file and write into another. The problem arises when I'm trying to preserve newlines from the original file to the new one.
def caesar_encrypt(orig , shift):
enctextCC = open("CCencoded.txt" , 'w')
for i in range(len(o... | Reading and Writing a new line from a file to another in Python | I'm trying to read from a file and write into another. The problem arises when I'm trying to preserve newlines from the original file to the new one.
def caesar_encrypt(orig , shift):
enctextCC = open("CCencoded.txt" , 'w')
for i in range(len(orig)):
for j in range(len(orig[i])):
curr = orig[i][j] ... | [
"you are doing it wrong\nout_file = open(\"output.txt\", \"w\")\nfor line in open(\"input.txt\", \"r\"):\n out_file.write(line)\n out_file.write(\"\\n\")\n\nNote that we don't check for newline endings because we fetch items one line at a time, so we are sure that after a line we have read follows a newline\n... | [
2,
1,
0,
0
] | [] | [] | [
"file_io",
"newline",
"python"
] | stackoverflow_0003945028_file_io_newline_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.