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:
Java & Python Type Checking
What really is the difference in the way that Java and Python implement type checking?
And what about how they implement abstract data types?
A:
Python, like Ruby, uses Duck Typing, which is a style of dynamic typing. Java obviously is statically typed, and type checking is done at co... | Java & Python Type Checking | What really is the difference in the way that Java and Python implement type checking?
And what about how they implement abstract data types?
| [
"Python, like Ruby, uses Duck Typing, which is a style of dynamic typing. Java obviously is statically typed, and type checking is done at compile time.\n",
"Java does. \nPython does not.\nPython is strongly dynamically typed. You create an object, and it will always be of that type. However, the variable that po... | [
8,
2
] | [] | [] | [
"java",
"python",
"types"
] | stackoverflow_0006853449_java_python_types.txt |
Q:
Ignoring unrecognized options when parsing argv?
I'm writing a script that acts as a proxy for a plugin class's run method.
The script would be invoked like this:
> main.py -v --plugin=Foo --extra=bar -c
The result of this command would be the equivalent of:
plugin = my.module.Foo()
plugin.run(extra='bar', c=True... | Ignoring unrecognized options when parsing argv? | I'm writing a script that acts as a proxy for a plugin class's run method.
The script would be invoked like this:
> main.py -v --plugin=Foo --extra=bar -c
The result of this command would be the equivalent of:
plugin = my.module.Foo()
plugin.run(extra='bar', c=True)
Note that anything in front of --plugin is used int... | [
"What you want is in the argparse library, see http://docs.python.org/dev/library/argparse.html#partial-parsing:\n>>> parser = argparse.ArgumentParser()\n>>> parser.add_argument('--foo', action='store_true')\n>>> parser.add_argument('bar')\n>>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n(Namespa... | [
3,
0,
0,
0
] | [
"Use a regular expression to search for 'plugin=, and if found, split the line and use getopt to parse each half.\n"
] | [
-1
] | [
"getopt",
"python"
] | stackoverflow_0006852394_getopt_python.txt |
Q:
Dynamically create a message
I have a button on a new form. When this button clicked I need a show some information on new form using label /or other component/. How to do it in OpenERP 6? I don't have any idea. Please give me a hand. thanks.
A:
I don't know if there's an easier way, but one way is to build a wi... | Dynamically create a message | I have a button on a new form. When this button clicked I need a show some information on new form using label /or other component/. How to do it in OpenERP 6? I don't have any idea. Please give me a hand. thanks.
| [
"I don't know if there's an easier way, but one way is to build a wizard that just displays your message.\n",
"are you trying to raise any kind of error message or you want to have confirmation ?\nif you want to raise exception, then it's possible , check in the addons/account.py \nyou'll find something that you ... | [
2,
0
] | [] | [] | [
"openerp",
"python"
] | stackoverflow_0006755995_openerp_python.txt |
Q:
__file__ and os.path module not playing nicely?
import os
print __file__
print os.path.dirname(__file__)
os.chdir('/tmp')
print __file__ # unchanged, of course
print os.path.dirname(__file__) # now broken
I have this issue above where dirname(__file__) can no longer be relied upon after os.chdir has been used i... | __file__ and os.path module not playing nicely? | import os
print __file__
print os.path.dirname(__file__)
os.chdir('/tmp')
print __file__ # unchanged, of course
print os.path.dirname(__file__) # now broken
I have this issue above where dirname(__file__) can no longer be relied upon after os.chdir has been used in the script, after module loader has set __file__. ... | [
"The __file__ must exist in sys.path somewhere.\nfor dirname in sys.path:\n if os.path.exists( os.path.join(dirname,__file__) ):\n # The directory name for `__file__` was dirname\n\n",
"The last example has a relative path element in the __file__ name (./xxx.py). When abspath is called with that it is exp... | [
1,
1
] | [] | [] | [
"module",
"path",
"python"
] | stackoverflow_0006853486_module_path_python.txt |
Q:
How to create a dynamic view on OpenERP
I need a help to create a dynamic view. Let me explain: I have Form1 and Form2 views. Form1 contains expression field and extract button. Form2 contains extracted elements of the expression from Form1. For example when you enter (a+b)*c-d*0,5 to Form1's expression field, For... | How to create a dynamic view on OpenERP | I need a help to create a dynamic view. Let me explain: I have Form1 and Form2 views. Form1 contains expression field and extract button. Form2 contains extracted elements of the expression from Form1. For example when you enter (a+b)*c-d*0,5 to Form1's expression field, Form2 should extract and display this:
( - open ... | [
"To add a dynamic view in openerp v6, override the function fields_view_get()\ndef fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False):\n result = super(<your_class_name>, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar)\n # your modifi... | [
7,
1
] | [
"I'm not sure exactly what you're asking, but if you just want to parse the user's expression, then this question on Python expression parsers should be helpful.\n"
] | [
-1
] | [
"openerp",
"python"
] | stackoverflow_0006569828_openerp_python.txt |
Q:
Django: only blank page
I have a server with Apache and I would like to start website written in Django. I user mod_wsgi. Now I have it prepared. But the respond of a server is empty. And in error log, there is nothing. Do you know what is the reason why?
If some file could help (*.wsgi, settings.py) I will append... | Django: only blank page | I have a server with Apache and I would like to start website written in Django. I user mod_wsgi. Now I have it prepared. But the respond of a server is empty. And in error log, there is nothing. Do you know what is the reason why?
If some file could help (*.wsgi, settings.py) I will append it.
Prochazky.wsgi
import os... | [
"Trying getting a hello world program working first and not Django. Watch:\nhttp://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations\nand read:\nhttp://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide\nAt a guess though, are you perhaps loading mod_python into the same Apache. An inc... | [
7,
1,
0
] | [] | [] | [
"apache",
"django",
"python",
"response",
"wsgi"
] | stackoverflow_0006842049_apache_django_python_response_wsgi.txt |
Q:
Python CGI Error
I have a test.py in my cgi-bin folder on my webserver, and when I run it I get a 500 Internal Server Error. What am I doing wrong? Here's the code:
#!/usr/bin/python
import os
print "Content-type: text/plain\n\n"
print "hi"
What permissions do I need to have?
A:
That won't produce valid HTTP ou... | Python CGI Error | I have a test.py in my cgi-bin folder on my webserver, and when I run it I get a 500 Internal Server Error. What am I doing wrong? Here's the code:
#!/usr/bin/python
import os
print "Content-type: text/plain\n\n"
print "hi"
What permissions do I need to have?
| [
"That won't produce valid HTTP output. The HTTP specification requires two characters per line ending \\r\\n. \nAlso try running the script from a shell. Also look at any debug logs from the server.\n",
"To effectively add an empty line to mark the end of header lines,\nuse CR-LF line endings:\n#!/usr/bin/python\... | [
2,
1
] | [] | [] | [
"cgi",
"python"
] | stackoverflow_0006854202_cgi_python.txt |
Q:
Splitting a K-length list into L sub-lists that are as "even" as possible, even if K/L leaves a remainder
I don't know of a better way to word what I'm looking for, so please bear with me.
Let's say that I have a list of 17 elements. For the sake of brevity we'll represent this list as ABCDEFGHIJKLMNOPQ. If I want... | Splitting a K-length list into L sub-lists that are as "even" as possible, even if K/L leaves a remainder | I don't know of a better way to word what I'm looking for, so please bear with me.
Let's say that I have a list of 17 elements. For the sake of brevity we'll represent this list as ABCDEFGHIJKLMNOPQ. If I wanted to divide this into 7 sufficiently "even" sub-lists, it might look like this:
ABC DE FGH IJ KL MNO PQ
Here, ... | [
">>> s='ABCDEFGHIJKLMNOPQ'\n>>> parts=7\n>>> [s[i*len(s)//parts:(i+1)*len(s)//parts] for i in range(parts)]\n['AB', 'CD', 'EFG', 'HI', 'JKL', 'MN', 'OPQ']\n\n\n>>> import string\n>>> for j in range(26):\n... print [string.uppercase[i*j//parts:(i+1)*j//parts] for i in range(parts)]\n... \n['', '', '', '', '', '', '... | [
3,
1,
0
] | [] | [] | [
"division",
"list",
"math",
"python",
"sublist"
] | stackoverflow_0006854093_division_list_math_python_sublist.txt |
Q:
Is there a way to access outer class in the nested class in python?
just a very simple thing, is there a way to access outer class from the inner class definition, like this:
class Model:
class Options:
model = Model <-- error!
I nest Options inside Model because semantically these Options exist only in ... | Is there a way to access outer class in the nested class in python? | just a very simple thing, is there a way to access outer class from the inner class definition, like this:
class Model:
class Options:
model = Model <-- error!
I nest Options inside Model because semantically these Options exist only in the scope of model, so it seems appropriate.
Thanks,
Alex
| [
"I am not sure this is exactly what you wanted but try:\nclass Model:\n class Option:\n @property\n def model(self): return Model\n\n",
"Well, you can at least instantiate the outer class in a method of the inner class:\nclass Model:\n class Options:\n def __init__(self):\n m... | [
2,
1,
1,
0
] | [] | [] | [
"nested_class",
"python"
] | stackoverflow_0006850617_nested_class_python.txt |
Q:
Python PHP and Perl being used together?
I was reading through Facebook's hiring now job listings and I saw this...
* Competency in Shell, PHP, Perl or Python. C is a plus
This sparked a question in my mind, is it possible to use (for example) python and PHP together?
As in... I write a function in PHP to read a ... | Python PHP and Perl being used together? | I was reading through Facebook's hiring now job listings and I saw this...
* Competency in Shell, PHP, Perl or Python. C is a plus
This sparked a question in my mind, is it possible to use (for example) python and PHP together?
As in... I write a function in PHP to read a MySQL database and cut the data read into raw ... | [
"First, Facebook is a large company. They have many different software projects, apart from the site itself, and some of them are probably written in languages different from the company's mainstream. \nSecond, teaching a good $lang1 programmer $lang2's syntax takes two weeks, while teaching a bad $lang2 programmer... | [
3,
1,
0
] | [] | [] | [
"perl",
"php",
"python"
] | stackoverflow_0006852990_perl_php_python.txt |
Q:
Explain the "setUp" and "tearDown" Python methods used in test cases
Can anyone explain the use of Python's setUp and tearDown methods while writing test cases apart from that setUp is called immediately before calling the test method and tearDown is called immediately after it has been called?
A:
In general you... | Explain the "setUp" and "tearDown" Python methods used in test cases | Can anyone explain the use of Python's setUp and tearDown methods while writing test cases apart from that setUp is called immediately before calling the test method and tearDown is called immediately after it has been called?
| [
"In general you add all prerequisite steps to setUp and all clean-up steps to tearDown.\nYou can read more with examples here.\n\nWhen a setUp() method is defined, the test runner will run that method\n prior to each test. Likewise, if a tearDown() method is defined, the\n test runner will invoke that method afte... | [
106,
71,
11
] | [] | [] | [
"python",
"python_unittest",
"unit_testing"
] | stackoverflow_0006854658_python_python_unittest_unit_testing.txt |
Q:
Can i use all standard Python libraries with IronPython or
... does it requires some sort of wrappers?
I was under expression that IronPython is a .NET implementation of the Python which somehow magically enables applications built with IronPython to use standard Python libraries (which I believe either a raw .py... | Can i use all standard Python libraries with IronPython or | ... does it requires some sort of wrappers?
I was under expression that IronPython is a .NET implementation of the Python which somehow magically enables applications built with IronPython to use standard Python libraries (which I believe either a raw .py sources or .py source packaged into the eggs), but when I was re... | [
"It depends:\n\nIf a library module is implemented in pure python, it is likely to work.\nA library module that is implemented in C will not work. The ironclad project aims to allow IronPython to import and use compiled Python C extensions.\n\n",
"No - you can't use all standard libraries. And even all existing I... | [
12,
2
] | [] | [] | [
"ironpython",
"python"
] | stackoverflow_0006855211_ironpython_python.txt |
Q:
Question about DES encryption in python
I am trying to create an LM/NTLM response for which I require encrypting the challenge sent by server using DES algorithm
The following is what I did:
from M2Crypto.EVP import Cipher
def encryptChallenge(magic, key):
str_key = ""
for iter1 in key:
str_... | Question about DES encryption in python | I am trying to create an LM/NTLM response for which I require encrypting the challenge sent by server using DES algorithm
The following is what I did:
from M2Crypto.EVP import Cipher
def encryptChallenge(magic, key):
str_key = ""
for iter1 in key:
str_key = str_key + chr(iter1)
encrypt = 1... | [
"The problem here is in your source (plaintext) string. You have each character expanded to two bytes, instead of one byte. The Java program will take the input \"0123456789abcdef\", and use internally the hex string of that. Using pycrypto and a properly encoded plaintext I get this.\nPython2> from Crypto.Cipher i... | [
1,
0
] | [] | [] | [
"des",
"python"
] | stackoverflow_0006855054_des_python.txt |
Q:
Python: Modify pickled objects
I am using cPickle to store objects. Later I would like to modify individual records. Unfortunately the file is getting corrupted after modification (I am getting UnpicklingError):
create and Pickle
class Book(object):
def __init__(self, title, author, ISBN, price):
self.... | Python: Modify pickled objects | I am using cPickle to store objects. Later I would like to modify individual records. Unfortunately the file is getting corrupted after modification (I am getting UnpicklingError):
create and Pickle
class Book(object):
def __init__(self, title, author, ISBN, price):
self.title = title
self.author = ... | [
"I am not sure but it seems to me that since you already have a list of books objects(loaded from file) so it will be easier and error free for you if you will rewrite your file with the context of this list(you can remove record you want or simply books[i]=new) using dump instead of trying to finding a plave where... | [
2
] | [] | [] | [
"pickle",
"python"
] | stackoverflow_0006855786_pickle_python.txt |
Q:
What's the best way to assemble Javascript modules server-side in Python?
I'm planning an extensible web app where base objects are extended by JavaScript modules which plug in. Each JavaScript object may just be an independent bit of code, or I might be building a large object to simulate a module namespace. I'll... | What's the best way to assemble Javascript modules server-side in Python? | I'm planning an extensible web app where base objects are extended by JavaScript modules which plug in. Each JavaScript object may just be an independent bit of code, or I might be building a large object to simulate a module namespace. I'll be using a Django back-end and Backbone.js, since you asked.
The system should... | [
"I think this is what you are looking for\nhttp://djangopackages.com/grids/g/asset-managers/\nMediagenerator is my favorite. Easy to use and compress a lot.\nIt does get all your js into one big js file but compressed, and your css too.\nHope it helps\n",
"For one of my projects I simply wrote a small build scrip... | [
0,
0,
0
] | [] | [] | [
"javascript",
"python"
] | stackoverflow_0006648312_javascript_python.txt |
Q:
Python Signals between threads
I created a UDP socket server
self.UDPServer = SocketServer.UDPServer( ( UDP_IP, UDP_PORT ), UDPServerHandler )
self.server_thread = threading.Thread( target = self.UDPServer.serve_forever )
self.server_thread.setDaemon( True )
self.server_thread.start()
And this is ... | Python Signals between threads | I created a UDP socket server
self.UDPServer = SocketServer.UDPServer( ( UDP_IP, UDP_PORT ), UDPServerHandler )
self.server_thread = threading.Thread( target = self.UDPServer.serve_forever )
self.server_thread.setDaemon( True )
self.server_thread.start()
And this is my UDP handler
class UDPServerHandle... | [
"A simple approach is to use the Queue module.\n"
] | [
0
] | [] | [] | [
"python",
"signals"
] | stackoverflow_0006855984_python_signals.txt |
Q:
How to split a zip list in python?
I need to split this list from sqlite3
[(107, u'Ella', u'Fitzgerald'), (108, u'Louis', u'Armstrong'), (109, u'Miles', u'Davis'), (110, u'Benny', u'Goodman')]
into
107, 'Ella', 'Fitzgerald'
108, 'Louis', 'Armstrong'
109, 'Miles', 'Davis'
110, 'Benny', 'Goodman'
How to get this?
... | How to split a zip list in python? | I need to split this list from sqlite3
[(107, u'Ella', u'Fitzgerald'), (108, u'Louis', u'Armstrong'), (109, u'Miles', u'Davis'), (110, u'Benny', u'Goodman')]
into
107, 'Ella', 'Fitzgerald'
108, 'Louis', 'Armstrong'
109, 'Miles', 'Davis'
110, 'Benny', 'Goodman'
How to get this?
Thanks.
| [
"Try the following:\ndata = [(107, u'Ella', u'Fitzgerald'), (108, u'Louis', u'Armstrong'), (109, u'Miles', u'Davis'), (110, u'Benny', u'Goodman')]\n\nfor record in data:\n print '{0:}, {1:}, {2:}'.format(*record)\n\n# or in case you want to get a dictionary\n\nd = dict([(x[0], ', '.join(x[1:])) for x in a])# sur... | [
2,
0
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0006855925_python_sqlite.txt |
Q:
Python: Call function if setter is called?
I have a Python object which has certain attributes that are set after the constructor is called. For example,
def Student(object):
def __init__(name, address=None):
self.name = name
self.address = address
stud = Student("John")
stud.address = "123 Ma... | Python: Call function if setter is called? | I have a Python object which has certain attributes that are set after the constructor is called. For example,
def Student(object):
def __init__(name, address=None):
self.name = name
self.address = address
stud = Student("John")
stud.address = "123 Main St. New York, NY"
I would like to be able to... | [
"What you probably need is a property concept. \nclass C(object):\n def __init__(self, x):\n self._x = x\n\n def get_x(self):\n return self._x\n def set_x(self, x):\n self._x = x\n x = property(get_x, set_x)\n\nobj = C(5)\nobj.x = 6 # set\nprint obj.x # get\n\nSee this link for more details: http:/... | [
7,
3
] | [] | [] | [
"encapsulation",
"object",
"python",
"setter"
] | stackoverflow_0006856177_encapsulation_object_python_setter.txt |
Q:
Python - SQLite SELECT query usable only once?
I have an sqlite query that looks like this:
db_rows = db_cursor.execute(
"SELECT * FROM my_table"
)
# check1
for row in db_rows:
print(row)
# check2
for row in db_rows:
print(row)
What happens is that the first for loop outputs all the rows, and the se... | Python - SQLite SELECT query usable only once? | I have an sqlite query that looks like this:
db_rows = db_cursor.execute(
"SELECT * FROM my_table"
)
# check1
for row in db_rows:
print(row)
# check2
for row in db_rows:
print(row)
What happens is that the first for loop outputs all the rows, and the second does not output anythng at all which I find str... | [
"\n... it should be faster to just re-use db_rows that should be already in memory ...\n\nExcept that it's not in memory; it's being pulled from the database one row at a time. Convert to a list if you want to pull the results into memory.\nrow_list = list(db_rows)\n\nfor row in row_list:\n ...\n\n",
"The retur... | [
4,
3
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0006856199_python_sqlite.txt |
Q:
How to change object variables in for loop in python
I'm not sure, whether it's an easy problem with easy solution or it's something that needs to dig a little deeper.
Let's say I have an object Item with variables Item.a and Item.b.
Now I have two instances of these objects: Item1 and Item2
What I need is somethi... | How to change object variables in for loop in python | I'm not sure, whether it's an easy problem with easy solution or it's something that needs to dig a little deeper.
Let's say I have an object Item with variables Item.a and Item.b.
Now I have two instances of these objects: Item1 and Item2
What I need is something like this:
for (value_1, value_2) in [(Item1.a, Item2.a... | [
"Well, [(Item1.a, Item2.a), (Item1.b, Item2.b)] just creates a list of tuples of some values. Already by creating this you loose the connection to ItemX. Your problem is not related to the loop.\nMaybe you want\nfor prop in ('a', 'b'):\n i2prop = getattr(Item2, prop)\n if getattr(Item1, prop) != i2prop:\n ... | [
13
] | [] | [] | [
"loops",
"python",
"reference"
] | stackoverflow_0006856286_loops_python_reference.txt |
Q:
dealing with a massive list
I am editing my previous post which I could not explain properly before. I have written this code which is,
param_values = {
'aa' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,1.0], [-1,-1]],
'ae' : [[-1,-1], [-1,-1], [0.3,0.4], [-1,-1], [0.15,1.0], [-1,-1]... | dealing with a massive list | I am editing my previous post which I could not explain properly before. I have written this code which is,
param_values = {
'aa' : [[-1,-1], [-1,-1], [-1,-1], [-1,-1], [0.15,1.0], [-1,-1]],
'ae' : [[-1,-1], [-1,-1], [0.3,0.4], [-1,-1], [0.15,1.0], [-1,-1]],
'ah' : [[-1,-1], [-... | [
"Presuming that you already know which phonemes are related to which lip shapes, it sounds like you just need to build a dictionary. This is just an example, probably nonsense in terms of your problem domain:\nlip_shapes = {\n 'aa': ['neutral', 'lower lip under upper teeth'],\n 'ae': ['lips touch', 'lip sprea... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0006856175_python.txt |
Q:
What are the versions of cpython which different implementations(jython/ironpython/pypy/etc) are roughly compatible with
i.e. jython(or other implementation) version x.y is roughly equivalent to cpython version a.b
Please list version of alternative implementation, and feel free to list multiple versions so this l... | What are the versions of cpython which different implementations(jython/ironpython/pypy/etc) are roughly compatible with | i.e. jython(or other implementation) version x.y is roughly equivalent to cpython version a.b
Please list version of alternative implementation, and feel free to list multiple versions so this list will still be useful in the future. If possible list any large incompatibilities (with cpython) for each version excluding... | [
"The most popular alternative implementations are IronPython, Jython, PyPy and Stackless Python.\nJython currently implements Python 2.5.2 support for 2.6 is on their roadmap.\n\nPartial support for ctypes\nDoes not support C API\n\nIronPython implements Python 2.7.1.\n\nPartial support for ctypes\nDoes not support... | [
3
] | [] | [] | [
"incompatibility",
"language_implementation",
"python",
"version"
] | stackoverflow_0006855885_incompatibility_language_implementation_python_version.txt |
Q:
Threading in pyqt4
In my GUI I have to download lots of stuff in between. I use urllib to do that. the problem of course then becomes that the GUI freezes up until everything gets downloaded.
My code is something like following
QtCore.QObject.connect( self.UI.commandLinkButton_2 , QtCore.SIGNAL("clicked()") , self... | Threading in pyqt4 | In my GUI I have to download lots of stuff in between. I use urllib to do that. the problem of course then becomes that the GUI freezes up until everything gets downloaded.
My code is something like following
QtCore.QObject.connect( self.UI.commandLinkButton_2 , QtCore.SIGNAL("clicked()") , self.addStoryToHistory )
wh... | [
"Here's an example I've just stripped from a project I was working on a couple of months back using the http example from PyQt as a base. It'll download SIP from the Riverbank website.\nIt's using QHttp from QtNetwork instead of urllib and the progress bar is connected to its dataReadProgress signal. This should al... | [
5,
0
] | [] | [] | [
"multithreading",
"pyqt4",
"python"
] | stackoverflow_0006852038_multithreading_pyqt4_python.txt |
Q:
how fetchall sqlite3 data into pretytable printing in python
i am new in python so far i need help for this output from sqlite3
(u'GABRIELLA TEGGIA (40)', u'-', u'65')
(u'PUTRA', u'DPS', u'11')
(u'SUASTINI', u'-', u'-')
(u'ARI UTAMA', u'JL.D.BERATAN GG.8/4', u'26')
(u'SUYASA', u'DS.TUNJUK,TABANAN', u'33')
(u'SARAH... | how fetchall sqlite3 data into pretytable printing in python | i am new in python so far i need help for this output from sqlite3
(u'GABRIELLA TEGGIA (40)', u'-', u'65')
(u'PUTRA', u'DPS', u'11')
(u'SUASTINI', u'-', u'-')
(u'ARI UTAMA', u'JL.D.BERATAN GG.8/4', u'26')
(u'SUYASA', u'DS.TUNJUK,TABANAN', u'33')
(u'SARAH(41)', u'BEJI AYU', u'40')
(u'AA.GDE OKA', u'JL.H.WURUK 179 DPS', ... | [
"Put the x.add_row call inside the for-loop:\nfor nm_pasien in cursor: \n x.add_row(nm_pasien)\n # print nm_pasien\n\nIn your orginial code, with x.add_row(nm_pasien) outside the loop, add_row is only called once. Moreover, nm_pasien retains its last value from the for-loop. This is why you only see t... | [
1
] | [] | [] | [
"mod_python",
"python",
"sqlite"
] | stackoverflow_0006857325_mod_python_python_sqlite.txt |
Q:
Learn Python 3.0 or 2.x?
Possible Duplicate:
Tutorial for Python - Should I use 2.x or 3.0?
I have decided to learn python. I have used in the past Java/c++/PHP/Action Script. Should I learn 3.0 or 2.x? Are the majority of libraries still in 2.x? Which book do you recommend? I posted this as I would like an up-t... | Learn Python 3.0 or 2.x? |
Possible Duplicate:
Tutorial for Python - Should I use 2.x or 3.0?
I have decided to learn python. I have used in the past Java/c++/PHP/Action Script. Should I learn 3.0 or 2.x? Are the majority of libraries still in 2.x? Which book do you recommend? I posted this as I would like an up-to-date answer to this questio... | [
"Almost all production software is still written in python 2.x at the moment. You should learn python 2.x, as it is installed much more widely and has many more third party libraries available. Eventually the world will move to 3.x, but the differences are not massive so your effort learning 2.x will not have bee... | [
6,
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0006857362_python.txt |
Q:
sqlalchemy: joining to the same table multiple times using declarative and reflection
Here is a trimmed down version of my problem:
Consider that I have two tables: 'procedure' and 'role'.
role has fields: (role_uid, role_name)
procedure has fields: (procedure_uid, procedure_name, inform_role_uid, consult_role_ui... | sqlalchemy: joining to the same table multiple times using declarative and reflection | Here is a trimmed down version of my problem:
Consider that I have two tables: 'procedure' and 'role'.
role has fields: (role_uid, role_name)
procedure has fields: (procedure_uid, procedure_name, inform_role_uid, consult_role_uid)
So 'role' has two one-to-many relationships with 'procedure'.
Some code:
class Role(Base... | [
"So for completeness, here is the fixed code to the problem above. I added two ForeignKeyContstaints and I also had to specify which relationship to use in the join.\nclass Role(Base):\n __tablename__ = \"role\"\n __table_args__ = ({'autoload':True, 'useexisting': True})\n\n\nclass Procedure(Base):\n __tab... | [
4,
3
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0006819268_python_sqlalchemy.txt |
Q:
Python safe queue
Is it save if I just using put and get_nowait functions in a queue, where the queue is shared between the threads. When Do I need to use a thread lock?
A:
The essential idea of queue is to share it between multiple threads.
The Queue class implements all the required locking semantics.
So you... | Python safe queue | Is it save if I just using put and get_nowait functions in a queue, where the queue is shared between the threads. When Do I need to use a thread lock?
| [
"The essential idea of queue is to share it between multiple threads.\nThe Queue class implements all the required locking semantics. \nSo you don't have to acquire lock explicitly. \nhttp://docs.python.org/library/queue.html#module-Queue\n",
"The Queue module (called queue in Python 3) is specifically designed t... | [
4,
2
] | [] | [] | [
"multithreading",
"python",
"queue"
] | stackoverflow_0006857739_multithreading_python_queue.txt |
Q:
Translate algorithmic C to Python
I would like to translate some C code to Python code or bytecode. The C code in question is what i'd call purely algorithmic: platform independent, no I/O, just algorithms and in-memory data structures.
An example would be a regular expression library. Translation tool would proce... | Translate algorithmic C to Python | I would like to translate some C code to Python code or bytecode. The C code in question is what i'd call purely algorithmic: platform independent, no I/O, just algorithms and in-memory data structures.
An example would be a regular expression library. Translation tool would process library source code and produce a fu... | [
"There is frankly no way to mechanically and meaningfully translate C to Python without suffering an insane performance penalty. As we all know Python isn't anywhere near C speed (with current compilers and interpreters) but worse than that is that what C is good at (bit-fiddling, integer math, tricks with blocks o... | [
12,
4,
3,
1,
0,
0,
0,
0
] | [
"You can always compile the C code, and load in the libraries using ctypes in python.\n"
] | [
-1
] | [
"c",
"code_translation",
"java",
"python",
"sandbox"
] | stackoverflow_0000132411_c_code_translation_java_python_sandbox.txt |
Q:
Using set_http_authentication_callback(self, callback)
I'm using a spynner package fo Python and when I try to load a page like this:
sb = spynner.Browser()
sb.load(URL)
I have an error:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\spynner-1.10-py2.7.egg\spynner\browser.py", line 207, i... | Using set_http_authentication_callback(self, callback) | I'm using a spynner package fo Python and when I try to load a page like this:
sb = spynner.Browser()
sb.load(URL)
I have an error:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\spynner-1.10-py2.7.egg\spynner\browser.py", line 207, in _on_authentication_required
if not self._http_authenti... | [
"First, declare a function named, for example http_auth_callback in the scope in which you are working(ex. in your class or globally)\ndef http_auth_callback(arguments):\n print dir(arguments)\n\nTry something like this:\nsb = spynner.Browser()\n\nsb.set_http_authentication_callback(http_auth_callback) # if usin... | [
0
] | [] | [] | [
"http_authentication",
"python",
"spynner"
] | stackoverflow_0006858256_http_authentication_python_spynner.txt |
Q:
python converter libraries for DOC, DOCX and PDF
Possible Duplicate:
solution to convert PDFs, DOCs, DOCXs into a textual format with python
I am making a document search engine which indexes popular binary formats. I am looking for python libraries for this purpose.
Reliable converters proved too hard to find. ... | python converter libraries for DOC, DOCX and PDF |
Possible Duplicate:
solution to convert PDFs, DOCs, DOCXs into a textual format with python
I am making a document search engine which indexes popular binary formats. I am looking for python libraries for this purpose.
Reliable converters proved too hard to find. PyPDF never works accurately. Please reccomend:
pyth... | [
"\nYou can sort of read .docx by unzipping it and then rootling around in the resulting folder structure. See How can I search a word in a Word 2007 .docx file?.\nIf pyPDF isn't working for you, you can use pdftotext as a subprocess.\n.doc is probably the hardest. Is COM scripting an option for you? That is, asking... | [
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0006857319_python.txt |
Q:
Why use Context with mako?
I reads manual by Makotemplate and see follows code:
from mako.template import Template
from mako.runtime import Context
from StringIO import StringIO
mytemplate = Template("hello, ${name}!")
buf = StringIO()
ctx = Context(buf, name="jack")
mytemplate.render_context(ctx)
print buf.getva... | Why use Context with mako? | I reads manual by Makotemplate and see follows code:
from mako.template import Template
from mako.runtime import Context
from StringIO import StringIO
mytemplate = Template("hello, ${name}!")
buf = StringIO()
ctx = Context(buf, name="jack")
mytemplate.render_context(ctx)
print buf.getvalue()
What profit use Context?
| [
"You probably won't use it directly, it contains both the output buffer and a dictionary of variables that can be referenced from within the template. It's usually preferable to use the render method of Template.\n>>> Template('hello ${name}!').render(name='jack')\n<<< u'hello jack!'\n\nYou can read more about it h... | [
1
] | [] | [] | [
"mako",
"python"
] | stackoverflow_0006858436_mako_python.txt |
Q:
How do I tell my ModelAdmin's filter to not show all records by default?
I added a filter drop down in my django admin page like this.
class MyAdmin(admin.ModelAdmin):
list_filter = ('status',)
By default, if you go to the model in the admin view, it displays all records by default.
But I want it to filter:
s... | How do I tell my ModelAdmin's filter to not show all records by default? | I added a filter drop down in my django admin page like this.
class MyAdmin(admin.ModelAdmin):
list_filter = ('status',)
By default, if you go to the model in the admin view, it displays all records by default.
But I want it to filter:
status="open"
and display it by default. Is this achievable ?
| [
"I think what you need is ModelAdmin.ordering\nhttps://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.ordering\nIf you ONLY need status='open' you could have defined a custom default queryset for your modeladmin\nhttps://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contr... | [
0
] | [
"If i correct understand, you may redefine default model manager in model\n class myManager(models.Manager):\n return self.filter(status = 'open')\n\n class myModel(models.Model):\n ...\n objects = myManager()\n\nBut I think there is a more elegant way.\n"
] | [
-1
] | [
"django",
"python"
] | stackoverflow_0006858060_django_python.txt |
Q:
Error in rpy2- No (non-missing) observations
I m working with rpy2 on Ubuntu 1104. I m following the COX file. The steps given in file are in R. I have to do same steps in python using rpy2.
I didn't get any tutorial with rpy2. I managed to write following,
from rpy2.robjects.packages import importr
from rpy2.rob... | Error in rpy2- No (non-missing) observations | I m working with rpy2 on Ubuntu 1104. I m following the COX file. The steps given in file are in R. I have to do same steps in python using rpy2.
I didn't get any tutorial with rpy2. I managed to write following,
from rpy2.robjects.packages import importr
from rpy2.robjects import IntVector, Formula
import rpy2.robjec... | [
"You read the data using read.csv with sep set to a single space, while the file has two spaces. This makes R interpret this as an existence of empty columns, which then mess with column names and finally create error in coxph.\nRead the data with read.table, and it should be ok.\n"
] | [
2
] | [] | [] | [
"python",
"r",
"rpy2"
] | stackoverflow_0006826652_python_r_rpy2.txt |
Q:
How to model my app in the Google App Engine Datastore
I have a hard time to model my applications data to get reasonable performance.
It is an application that track costs within a group of people and today I have the following entities:
class Event(db.Model):
# Values
name = db.StringProperty(required=Tr... | How to model my app in the Google App Engine Datastore | I have a hard time to model my applications data to get reasonable performance.
It is an application that track costs within a group of people and today I have the following entities:
class Event(db.Model):
# Values
name = db.StringProperty(required=True)
password = db.StringProperty(required=True)
class P... | [
"Generally you want to optimize for reads. \nInstead of calculating a person's balance at read time, calculate changes at write time and denormalize, storing the calculated balance in the Person entity.\n"
] | [
1
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"python"
] | stackoverflow_0006858529_google_app_engine_google_cloud_datastore_python.txt |
Q:
Is it safe to call an overridden method from __init__()?
This is a follow-up from this question:
Effective Java 2nd Edition, Item 17: Design and document for inheritance, or else prohibit it:
There are a few more restrictions that a class must obey to allow inheritance. Constructors must not invoke overridable me... | Is it safe to call an overridden method from __init__()? | This is a follow-up from this question:
Effective Java 2nd Edition, Item 17: Design and document for inheritance, or else prohibit it:
There are a few more restrictions that a class must obey to allow inheritance. Constructors must not invoke overridable methods, directly or indirectly. If you violate this rule, progr... | [
"\nI might be safe in calling overridden methods from __init__()?\n\nYou are. The self binding has already happened before __init__() is evaluated.\n\nancestor class designer getting left at the mercy of my subclass designer?\n\nThat's universally true and has nothing to do with __init__() or anything else.\nSubcl... | [
5
] | [] | [] | [
"constructor",
"inheritance",
"python"
] | stackoverflow_0006858842_constructor_inheritance_python.txt |
Q:
JSONP python script
I've been playing around with the code (HTML2Canvas) from here: https://github.com/niklasvh/html2canvas
It's a client side Javascript tool to convert a HTML page to a canvas element.
Its uses a proxy to fetch the HTML from a remote site, it makes an Ajax call like this:
$.ajax({
data: {... | JSONP python script | I've been playing around with the code (HTML2Canvas) from here: https://github.com/niklasvh/html2canvas
It's a client side Javascript tool to convert a HTML page to a canvas element.
Its uses a proxy to fetch the HTML from a remote site, it makes an Ajax call like this:
$.ajax({
data: {
xhr2:false,
... | [
"I put the source up for the python proxy at https://github.com/niklasvh/html2canvas-proxy. Be warned though, the script will still go through changes which will most likely break the proxy.\n"
] | [
0
] | [] | [] | [
"javascript",
"json",
"jsonp",
"proxy",
"python"
] | stackoverflow_0006857309_javascript_json_jsonp_proxy_python.txt |
Q:
Python: What is an elegant idiom for extending method with one or more keyword arguments?
I'm trying to extend a method with a single keyword argument while remaining impartial to the rest of the method's signature; I just want to pass that on. Attempt 0:
class SomeSuperclass(object):
pass # in reality: some i... | Python: What is an elegant idiom for extending method with one or more keyword arguments? | I'm trying to extend a method with a single keyword argument while remaining impartial to the rest of the method's signature; I just want to pass that on. Attempt 0:
class SomeSuperclass(object):
pass # in reality: some implementation for some_method
class SomeClass(SomeSuperclass):
def some_method(self, my_kw... | [
"I'd use dict.pop(), like so:\nclass SomeSuperclass(object):\n def some_method(self, *args, **kwargs):\n print 'SomeSuperclass: args=%s kwargs=%s' % (args, kwargs)\n\nclass SomeClass(SomeSuperclass):\n def some_method(self, *args, **kwargs):\n my_kwarg = kwargs.pop('my_kwarg', 42) # 42 is the default\n p... | [
6,
1
] | [] | [] | [
"python"
] | stackoverflow_0006859257_python.txt |
Q:
How to refer to the target value of list/dictionary comprehension in condition clause?
In the following examples,
[f(a) for a in range(10) if f(a) < 50]
{k: f(a) for k in range(10) if f(a) < 50}
Is it possible to eliminate the repeated f(a), without introducing a wrapping list/dictionary comprehension?
A:
You c... | How to refer to the target value of list/dictionary comprehension in condition clause? | In the following examples,
[f(a) for a in range(10) if f(a) < 50]
{k: f(a) for k in range(10) if f(a) < 50}
Is it possible to eliminate the repeated f(a), without introducing a wrapping list/dictionary comprehension?
| [
"You can avoid the repeated call to f(a) by introducing a dummy iteration over a single-element list:\n(b for a in range(10) for b in [f(a)] if b < 50)\n\nor by introducing a sub-generator:\n(b for b in (f(a) for a in range(10)) if b < 50)\n\nThey are a bit inelegant, but they work, and are reasonably clear.\nYou'l... | [
4,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0006859245_python.txt |
Q:
difference between python file operation modules open and file.
I am working on file operation in python, i found two module,
What is difference between the two file operation module "open" and "file"
functionality wise i found both same.
thanks.
A:
Python 2.x documentation says it all:
When opening a file, it’... | difference between python file operation modules open and file. | I am working on file operation in python, i found two module,
What is difference between the two file operation module "open" and "file"
functionality wise i found both same.
thanks.
| [
"Python 2.x documentation says it all:\n\nWhen opening a file, it’s preferable to use open() instead of invoking\n this constructor [file()] directly. file is more suited to type testing (for\n example, writing isinstance(f, file)).\n\nIn Python 3.x, file is no longer available.\n"
] | [
8
] | [] | [] | [
"python"
] | stackoverflow_0006859499_python.txt |
Q:
C++ embedded python PyArg_ParseTuple fails with string args
I'm trying to add embedded python to a OpenGL/SDL application.
So far everything works fine, like entering a string via SDL keyboard events and executing it with the embedded python interpreter.
I'm now into adding functions to call C/C++ functions like
v... | C++ embedded python PyArg_ParseTuple fails with string args | I'm trying to add embedded python to a OpenGL/SDL application.
So far everything works fine, like entering a string via SDL keyboard events and executing it with the embedded python interpreter.
I'm now into adding functions to call C/C++ functions like
void set_iterations(int c);
is invoked on the python interpreter ... | [
"Try:\nstatic PyObject* test_addignore(PyObject *self, PyObject *args) {\n char* ignorestring;\n if (!PyArg_ParseTuple(args,\"s\", &ignorestring)) //Note the &\n return NULL; //Never ignore errors\n add_global_ignore(ignorestring);\n\n Py_RETURN_NONE; //Always use ... | [
3
] | [] | [] | [
"c++",
"decode",
"python",
"unicode"
] | stackoverflow_0006859631_c++_decode_python_unicode.txt |
Q:
Should one minify server code when it's in production?
When it comes to the frontend code you always minify it (remove white spaces, comments etc) in production.
Should one do the same with server code? I usually have a lot of comments in my server files. But I have never heard about people doing so.
Wouldn't the ... | Should one minify server code when it's in production? | When it comes to the frontend code you always minify it (remove white spaces, comments etc) in production.
Should one do the same with server code? I usually have a lot of comments in my server files. But I have never heard about people doing so.
Wouldn't the server run faster if the code was optimized in the same way?... | [
"You're not going to have any improvement as the whitespaces and all formatting are lost when your server side code is translated to machine code (or interpreted). It's also not sent over the wire, it's read from the local filesystem, so while having less characters would lead to a faster startup, it would not make... | [
74,
18,
6,
3
] | [] | [] | [
"node.js",
"perl",
"php",
"python",
"ruby"
] | stackoverflow_0006810977_node.js_perl_php_python_ruby.txt |
Q:
How Zope interface is implemented?
I tried to understand how Zope interface work. I know Interface is just an instance of InterfaceClass which is just an ordinary Class. But if Interface is just a class instance, why it can be used as a base class to be inherited from?
e.g.
Class IFoo(Interface):
pass
Could ... | How Zope interface is implemented? | I tried to understand how Zope interface work. I know Interface is just an instance of InterfaceClass which is just an ordinary Class. But if Interface is just a class instance, why it can be used as a base class to be inherited from?
e.g.
Class IFoo(Interface):
pass
Could you give me some insights? Thank you.
| [
"Python is inherently flexible, and any object can be a base class as long as it looks like a base class. As is always the case with Python, that means implementing some attributes that are expected to be found on a Python classes.\nThe Interface class (or it's bases Specification and Element) sets several. Look fo... | [
3
] | [] | [] | [
"interface",
"python",
"zope"
] | stackoverflow_0006808798_interface_python_zope.txt |
Q:
Error while converting to float
I am trying to read a file using csv.DictReader
I have a field that is supposed to be an integer.if it is empty i will set it as DEFAULT
if it is an integer i do nothing.if it is not an integer i check if it is a quoted integer(like '1234').if so I will convert it to integer.Else a... | Error while converting to float | I am trying to read a file using csv.DictReader
I have a field that is supposed to be an integer.if it is empty i will set it as DEFAULT
if it is an integer i do nothing.if it is not an integer i check if it is a quoted integer(like '1234').if so I will convert it to integer.Else an exception is raised.
it works as ex... | [
"The problem is that the single quotes are part of your string:\nIn [7]: float(\"'1234'\")\nValueError: invalid literal for float(): '1234'\n\nIf you remove them, things should work:\nIn [8]: float(\"'1234'\".strip(\"'\"))\nOut[9]: 1234.0\n\n",
"This might not be the smartest way, but if you want to make sure the... | [
4,
1,
0
] | [] | [] | [
"csv",
"python"
] | stackoverflow_0006859991_csv_python.txt |
Q:
XHTML namespace issues with cssselect in lxml
I have problems using cssselect with a XHTML (or XML with namespace). Although the documentation says how to use namespace in csselect I do not understand it: cssselect namespaces
My Input XHTML string:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://w... | XHTML namespace issues with cssselect in lxml | I have problems using cssselect with a XHTML (or XML with namespace). Although the documentation says how to use namespace in csselect I do not understand it: cssselect namespaces
My Input XHTML string:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html x... | [
"The doc string for cssselect.CSSSelector (version 2.0) shows how to use namespaces:\nclass CSSSelector(etree.XPath):\n \"\"\" ...\n To use CSS namespaces, you need to pass a prefix-to-namespace\n mapping as ``namespaces`` keyword argument::\n\n >>> rdfns = 'http://www.w3.org/1999/02/22-rdf-syntax-n... | [
3
] | [] | [] | [
"css",
"lxml",
"python",
"xhtml",
"xml_namespaces"
] | stackoverflow_0006860013_css_lxml_python_xhtml_xml_namespaces.txt |
Q:
Python regex not to match http://
I am facing a problem to match and replace certain words, not contained in http://
Present Regex:
http://.*?\s+
This matches the pattern http://www.egg1.com http://www.egg2.com
I need a regex to match certain words contained outside the http://
Example:
"This is a sample. h... | Python regex not to match http:// | I am facing a problem to match and replace certain words, not contained in http://
Present Regex:
http://.*?\s+
This matches the pattern http://www.egg1.com http://www.egg2.com
I need a regex to match certain words contained outside the http://
Example:
"This is a sample. http://www.egg1.com and http://egg2.com.... | [
"One solution I can think of is to form a combined pattern for HTTP-URLs and your pattern, then filter the matches accordingly:\nimport re\n\nt = \"http://www.egg1.com http://egg2.com egg3 egg4\"\n\np = re.compile('(http://\\S+)|(egg\\d)')\nfor url, egg in p.findall(t):\n if egg:\n print egg\n\nprints:\n\negg3\... | [
6,
2,
1
] | [
"Extending brandizzi's answer, I would just change his regex to this:\n(?<!http://[\\w\\._-]*)(egg1|egg2)\n\n"
] | [
-2
] | [
"python",
"regex",
"regex_negation"
] | stackoverflow_0006859763_python_regex_regex_negation.txt |
Q:
python subprocess
Suppose I have 4 resources which I want to utilize.
I create 4 subprocesses and then wait for 1 of them to be free and as soon as one of them is free I utilize the freed resource again.
I want to know if there is any way we can find out which subprocess has finished working. As of now I am stori... | python subprocess | Suppose I have 4 resources which I want to utilize.
I create 4 subprocesses and then wait for 1 of them to be free and as soon as one of them is free I utilize the freed resource again.
I want to know if there is any way we can find out which subprocess has finished working. As of now I am storing all the pid's of chi... | [
"Retrieve the process ID from the pid field of each subprocess object in your list, and create a dictionary mapping those process IDs back to the subprocess objects. Then call os.wait, which will wait for any of the subprocesses to exit, and use your dictionary to map the PID returned back to the appropriate subpr... | [
3,
2,
1
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0004974209_python_subprocess.txt |
Q:
question about line.split command
This is the txt file I need to deal with:
chr8 148401 153100 duplication
chr8 206001 207100 deletion
chr8 584401 589500 deletion
chr8 615101 616600 deletion
chr8 842601 843200 deletion
chr8 868901 869700 deletion
Basically I want to extract the ... | question about line.split command | This is the txt file I need to deal with:
chr8 148401 153100 duplication
chr8 206001 207100 deletion
chr8 584401 589500 deletion
chr8 615101 616600 deletion
chr8 842601 843200 deletion
chr8 868901 869700 deletion
Basically I want to extract the two numbers, and do subtraction. My cod... | [
"One split is enough!\n>>> s=\"chr8 584401 589500 deletion\"\n>>> l = s.split()\n>>> l\n['chr8', '584401', '589500', 'deletion']\n>>> int(l[1]) - int(l[2])\n-5099\n\n"
] | [
5
] | [] | [] | [
"line",
"python",
"split"
] | stackoverflow_0006860304_line_python_split.txt |
Q:
How to delete a user's cookie using python on app engine?
I'm using the python facebook api on google app engine (webapp). I want to set the user's cookie to expire when the user logs out of the application. This cookie is being set by the Javascript Facebook API.
Here is the facebook api function showing how ... | How to delete a user's cookie using python on app engine? | I'm using the python facebook api on google app engine (webapp). I want to set the user's cookie to expire when the user logs out of the application. This cookie is being set by the Javascript Facebook API.
Here is the facebook api function showing how the facebook api access the facebook cookie:
def get_user_from_... | [
"Update: This method will work if you're the one who set the cookie... but I overlooked the part where you clearly said it's facebook's cookie you want to remove. In that case, the answer to this question appears to be exactly what you need: Facebook Oauth Logout\nIf it's a cookie you set in the first place, you sh... | [
5
] | [] | [] | [
"facebook_graph_api",
"facebook_javascript_sdk",
"google_app_engine",
"python",
"session_cookies"
] | stackoverflow_0006859089_facebook_graph_api_facebook_javascript_sdk_google_app_engine_python_session_cookies.txt |
Q:
Using a global MANIFEST for object execution. Is there a better way?
I find myself repeating a common pattern when trying to execute code across multiple objects.
Arg_list_one = ["first","second", "so on"]
Arg_list_two = ["first","second", "so on"]
MANIFEST = [ ]
class connection(object):
def __init__(self, ... | Using a global MANIFEST for object execution. Is there a better way? | I find myself repeating a common pattern when trying to execute code across multiple objects.
Arg_list_one = ["first","second", "so on"]
Arg_list_two = ["first","second", "so on"]
MANIFEST = [ ]
class connection(object):
def __init__(self, args):
...
MANIFEST.append(self)
def Run(self):
... | [
"Why would you need a list of all objects ever created? Many of those may belong to completely unrelated pieces of your application! A given piece of code shouldn't assume it's the only one to user a class. Especially since there's usually no need to:\n\nA function creates a bunch of objects and then does something... | [
4,
1
] | [] | [] | [
"python"
] | stackoverflow_0006860535_python.txt |
Q:
Testing for UnicodeDecodeError in Python 3
I have the following test for a function that can only accept unicode text in Python 2.x
def testNonUnicodeInput(self):
""" Test falure on non-unicode input. """
input = "foo".encode('utf-16')
self.assertRaises(UnicodeDecodeError, myfunction, input... | Testing for UnicodeDecodeError in Python 3 | I have the following test for a function that can only accept unicode text in Python 2.x
def testNonUnicodeInput(self):
""" Test falure on non-unicode input. """
input = "foo".encode('utf-16')
self.assertRaises(UnicodeDecodeError, myfunction, input)
However, that test fails when run in Python 3... | [
"You shouldn't have to do anything to Python 3 strings; they're all Unicode. Just test isinstance(s, str). Or, if the problem is the other way around, you'd want to use bytes.decode().\n\nOkay, a way to cause UnicodeDecodeError in both Python 3 and Python 2:\nPython 3:\n>>> \"foo\".encode('utf-16').decode('utf-8')\... | [
4,
0
] | [] | [] | [
"python",
"python_3.x",
"unicode",
"unit_testing"
] | stackoverflow_0006849399_python_python_3.x_unicode_unit_testing.txt |
Q:
Problem importing modul2s from boto
I have installed boto like so: python setup.py install; and then when I launch my python script (that imports moduls from boto) on shell, an error like this shows up: ImportError: No module named boto.s3.connection
How to settle the matter?
A:
I fixed same problem at Ubuntu us... | Problem importing modul2s from boto | I have installed boto like so: python setup.py install; and then when I launch my python script (that imports moduls from boto) on shell, an error like this shows up: ImportError: No module named boto.s3.connection
How to settle the matter?
| [
"I fixed same problem at Ubuntu using apt-get install python-boto\n",
"This can happen if the Python script does not use your default python executable. Check the shebang on the first line of the script (on *nix) or the .py file association (on Windows) and run that against setup.py instead.\n"
] | [
5,
2
] | [] | [] | [
"boto",
"python"
] | stackoverflow_0002481417_boto_python.txt |
Q:
How does a whitesapce matched by a positive lookahead assertion appears in the final matched string in Python regex?
Trying to answer this question, I created this Python regular expression to match any egg substring followed by a digit that is not part of a URL preceded by http://:
>>> r = re.compile('(?:\s(?!htt... | How does a whitesapce matched by a positive lookahead assertion appears in the final matched string in Python regex? | Trying to answer this question, I created this Python regular expression to match any egg substring followed by a digit that is not part of a URL preceded by http://:
>>> r = re.compile('(?:\s(?!http://\S*))egg\d')
Then I applied it to the following string:
>>> a = "a egg1 http://egg2.com egg3 http://www.egg4.org egg5... | [
"(?:...) isn't a lookahead assertion, it's simply a non-capturing pair of parens (i.e. what is matched by the sub-regex inside doesn't do into its own group, it only exists for precedence). (?=...) is a lookahead assertion. \n",
"(?: is not a lookahead, but a non-capturing group. As such, it doesn't create its ow... | [
1,
1
] | [] | [] | [
"lookahead",
"python",
"regex"
] | stackoverflow_0006861406_lookahead_python_regex.txt |
Q:
Python command line options fail on one account, but not on another
I am running on Windows Server 2008. We use Python extensively on several servers, and for the most part it works well. However, on at least one server, arguments don't get passed to my python scripts when I run from a command line. If I log on... | Python command line options fail on one account, but not on another | I am running on Windows Server 2008. We use Python extensively on several servers, and for the most part it works well. However, on at least one server, arguments don't get passed to my python scripts when I run from a command line. If I log on as a different user, the script works as expected. I can also run the s... | [
"If you start a Python script, e.g.:\nimport sys\nfor a in sys.argv:\n print a\n\nwith plain\nshowargs.py a b c\n\nthe effective call is controlled by registry settings witch can be checked with ftype\nftype Python.File\nPython.File=\"C:\\Python25\\python.exe\" \"%1\" %*\n\nThe %* is crucial for passing the argume... | [
1
] | [] | [] | [
"python",
"windows",
"windows_server_2008"
] | stackoverflow_0006859048_python_windows_windows_server_2008.txt |
Q:
how to distinguish between a method and an attribute in python by name
Sometimes, I find it hard to distinguish between a method and an attribute by it's name without appending parentheses.
For example:
there're keys() method and text attribute in xml.etree.ElementTree.Element class.
text:The text attribute can be... | how to distinguish between a method and an attribute in python by name | Sometimes, I find it hard to distinguish between a method and an attribute by it's name without appending parentheses.
For example:
there're keys() method and text attribute in xml.etree.ElementTree.Element class.
text:The text attribute can be used to hold additional data associated with the element.
keys():Returns t... | [
"The only real distinction is that one is callable and one is not, so you can use the builtin function callable() with the actual object (not a string with the name of it) to determine whether or not it is callable.\nIn your case:\n>>> from xml.etree import ElementTree\n>>> elt = ElementTree.Element(\"\")\n>>> call... | [
6,
2
] | [] | [] | [
"python"
] | stackoverflow_0006861410_python.txt |
Q:
Use mox to mock a method called by__init__
I'd like to stub out a single method in a class that is called by the init method.
class MyClass(object):
def __init__(self):
# Some initializer code here
...
self.method_with_side_effects()
def method_with_side_effects(self):
... # Load files, etc.
... | Use mox to mock a method called by__init__ | I'd like to stub out a single method in a class that is called by the init method.
class MyClass(object):
def __init__(self):
# Some initializer code here
...
self.method_with_side_effects()
def method_with_side_effects(self):
... # Load files, etc.
According to the Mox documentation, you can moc... | [
"Could you subclass MyClass directly and override method_with_side_effects?\n",
"If you only want to stub out the method, you can use the stubout module:\nimport stubout\n\ns = stubout.StubOutForTesting()\ns.Set(MyClass, 'method_with_side_effects', lambda self: None)\n\nIf you actually want to mock the method, it... | [
3,
1
] | [] | [] | [
"mox",
"python"
] | stackoverflow_0006442018_mox_python.txt |
Q:
django internationalizing a calendar and using single character day name
I have two questions, I've recently built a django custom templatetag which displays a calendar when called. Am currently facing two issues which am not sure how to resolve,
How do I display day names as single character (S, M, T,..etc) I f... | django internationalizing a calendar and using single character day name | I have two questions, I've recently built a django custom templatetag which displays a calendar when called. Am currently facing two issues which am not sure how to resolve,
How do I display day names as single character (S, M, T,..etc) I found calendar.day_abbr which returns (SAT, MON..etc)
My site is being used on ... | [
"calendar.weekheader(n)\n\nReturn a header containing abbreviated weekday names. n specifies the width in characters for one weekday.\n\nThus for n=1 will return single character abbreviations.\n"
] | [
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006861767_django_python.txt |
Q:
function name as as input of another function?
I an image processing enginner, and am using Python as a prototyping language.
Most of the time, as I get thousands of images, named "imagen.jpg", n being the increment.
So the main structure of my program may be seen as :
def main_IP(imgRoot, stop_ncrement):
name... | function name as as input of another function? | I an image processing enginner, and am using Python as a prototyping language.
Most of the time, as I get thousands of images, named "imagen.jpg", n being the increment.
So the main structure of my program may be seen as :
def main_IP(imgRoot, stop_ncrement):
name = update_the_increment(imgRoot, stop_increment)
i... | [
"Functions can be passed around in python just like a string or any other object can.\ndef processImage(...):\n pass\n\ndef main_IP(imgRoot, stop_ncrement, process_image):\n name = update_the_increment(imgRoot, stop_increment)\n img = load_the_image(name)\n out_img = process_image(img)\n displays_ima... | [
8,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0006860366_python.txt |
Q:
Decrement a variable in an incrementing for loop
In my python script, I am itterating through a list (headerRow) starting at index 9. I want to check to see if it is already in the database, and if not then add it to a database with an auto-incementing primary key. I then want to send it through the loop again to ... | Decrement a variable in an incrementing for loop | In my python script, I am itterating through a list (headerRow) starting at index 9. I want to check to see if it is already in the database, and if not then add it to a database with an auto-incementing primary key. I then want to send it through the loop again to retrieve it's primary key.
for i in range (9, len(head... | [
"Why not use a while loop?\ni=9\nwhile (i<len(headerRow)):\n # Attempt to retrieve an entry's corresponding primary key.\n row = cursor.fetchone()\n\n if row == None: # New Entry\n # Add entry to database\n print \"New Entry Added!\"\n else: # Entry already exists\n print \"Existing... | [
6,
1
] | [] | [] | [
"python"
] | stackoverflow_0006861579_python.txt |
Q:
Matching array elements to dictionary keys in Python
I'm trying to match up elements in an array to dictionary keys. More specifically, I have a dictionary whose keys identify a disease state (a set of 0s and 1s) and an age (0-100) (ie, ((0,1,1,0), 35) is a key). I want to loop through these keys and get the cor... | Matching array elements to dictionary keys in Python | I'm trying to match up elements in an array to dictionary keys. More specifically, I have a dictionary whose keys identify a disease state (a set of 0s and 1s) and an age (0-100) (ie, ((0,1,1,0), 35) is a key). I want to loop through these keys and get the corresponding values to put them in specific places in an arr... | [
"With\n>>> sims\narray([[ 0., 0., 0., 1., 5., 0.],\n [ 0., 1., 0., 1., 10., 0.],\n [ 0., 1., 0., 1., 15., 0.],\n [ 0., 0., 0., 0., 20., 0.]])\n\nand\n>>> d\n{ ((0, 0, 0, 1), 5): -1,\n ((0, 0, 0, 0), 20): -4,\n ((0, 1, 0, 1), 15): -3,\n ((0, 1, 0, 1), 10... | [
1
] | [] | [] | [
"arrays",
"dictionary",
"python"
] | stackoverflow_0006862547_arrays_dictionary_python.txt |
Q:
How do I filter with active data? Django
How do I filter with active data?
Model promo have expiration (DataField)
def promo(request):
promo = Promo.objects.filter( ?? )
return render_to_response('promo.html', {'promo':promo})
I'm learning a lot with Django
Can someone teach me this problem?
Thank you for... | How do I filter with active data? Django | How do I filter with active data?
Model promo have expiration (DataField)
def promo(request):
promo = Promo.objects.filter( ?? )
return render_to_response('promo.html', {'promo':promo})
I'm learning a lot with Django
Can someone teach me this problem?
Thank you for your attention!
Bye!
| [
"Your question was a bit vague but i assume you mean DateField and that you want to get all promos where expiration is later than, or today - that means all promos that havn't expired yet.\nFrom the docs on making queries I suppose you can do something like this\nPromo.objects.filter(expiration__gte=datetime.date.n... | [
4
] | [] | [] | [
"date",
"django",
"filter",
"python"
] | stackoverflow_0006863144_date_django_filter_python.txt |
Q:
Help with passing variables w/ csrfContext
I have a login page, and in my view I pass it the csrfContext variable for the csrf_token tag. However, problems arise when I try to pass more than just that variable into the context. For example, if I use locals()
return render_to_response('base_index.html', locals())
... | Help with passing variables w/ csrfContext | I have a login page, and in my view I pass it the csrfContext variable for the csrf_token tag. However, problems arise when I try to pass more than just that variable into the context. For example, if I use locals()
return render_to_response('base_index.html', locals())
I get a csrf error. For some reason it only work... | [
"I would not recommend using locals() in this way. In more complex views you may end up passing much more to the template rendering that is required.\nA better way to do this is to create the RequestContext, and either pass in the values you want to add, or add them after: https://docs.djangoproject.com/en/dev/ref/... | [
0,
0
] | [] | [] | [
"csrf",
"django",
"python"
] | stackoverflow_0006766447_csrf_django_python.txt |
Q:
Python Twisted multiple clients
Im trying to get an hang of twisted for a new project I want to do on my spare time and Im having difficulties getting a grip of it.
I havnt done any "real" work with it yet, just keeping myself busy with reading docs and sites Ive found.
So say that I was making a multiplayer game ... | Python Twisted multiple clients | Im trying to get an hang of twisted for a new project I want to do on my spare time and Im having difficulties getting a grip of it.
I havnt done any "real" work with it yet, just keeping myself busy with reading docs and sites Ive found.
So say that I was making a multiplayer game with multiple zones (maps), kinda lik... | [
"Factories are a way to associate a particular way to create a connection with a particular listening or connecting socket. They are how you say \"this port is speaking protocol X\".\nOnce a connection handler (Protocol instance) is constructed, it's not associated with its factory beyond the .factory attribute. ... | [
0
] | [] | [] | [
"python",
"twisted"
] | stackoverflow_0006858965_python_twisted.txt |
Q:
Google OAuth problem: invalid_signature
I'm trying to get OAuth working in a small Python script. I'm using python-oauth2, and I'm trying to connect to Google to list my Google docs.
Getting the request token and authorizing the token appear to work fine, but whenever I try to get the access token, I get an HTTP 4... | Google OAuth problem: invalid_signature | I'm trying to get OAuth working in a small Python script. I'm using python-oauth2, and I'm trying to connect to Google to list my Google docs.
Getting the request token and authorizing the token appear to work fine, but whenever I try to get the access token, I get an HTTP 400 response, and the response content is "sig... | [
"With Eva's help, I fixed it! This post had the solution.\nI failed to utilize oauth_token_secret, returned from the original request for an unauthorized token. I missed that the Consumer was being reused, but a new Client was being instantiated for the access token fetch at the end of the Twitter Three-legged OAut... | [
1
] | [] | [] | [
"oauth",
"python"
] | stackoverflow_0006851428_oauth_python.txt |
Q:
Python class static/instance defaults
This is actually two questions:
1) What is that logic behind the fact that, when declaring a python class, do variables default to static and methods default to instance? I know i can declare variables in _init _ or add @staticmethod or @classmethod to methods to flip them to ... | Python class static/instance defaults | This is actually two questions:
1) What is that logic behind the fact that, when declaring a python class, do variables default to static and methods default to instance? I know i can declare variables in _init _ or add @staticmethod or @classmethod to methods to flip them to the other side, but it just seems (to me at... | [
"I believe what you're up against is related to the way that things are processed / evaluated as the modules are read in.\nclass Parent(object):\n someAttr = Parser() # Static variable - created as the class is parsed.\n\n def __init__(self):\n self.otherAttr = Reader() # Instance - created when the class is i... | [
3,
2
] | [] | [] | [
"oop",
"programming_languages",
"python"
] | stackoverflow_0006863071_oop_programming_languages_python.txt |
Q:
Matlab to Python sparse matrix conversion , overcoming the zero index problem
I have an N x N sparse matrix in Matlab, that has cell values indexed by (r,c) pairs such that r and c are unique id's.
The problem is, that after converting this matrix into Python, all of the indices values are decremented by 1.
Fo... | Matlab to Python sparse matrix conversion , overcoming the zero index problem | I have an N x N sparse matrix in Matlab, that has cell values indexed by (r,c) pairs such that r and c are unique id's.
The problem is, that after converting this matrix into Python, all of the indices values are decremented by 1.
For example:
Before After
(210058,10326) = 1 (210057,1032... | [
"Thank you all for the good advice. \nI decided to stick with Python. I do most of my data transfers between Matlab and Python\nusing text files now.\n"
] | [
2
] | [] | [] | [
"numpy",
"python",
"scipy",
"sparse_matrix"
] | stackoverflow_0006794221_numpy_python_scipy_sparse_matrix.txt |
Q:
Python run Java command line arguments with incrementing variables asynchronously.
I have a java program which does individual jobs e.g. takes in a file, does some processing on it and creates a new file. To run it I have to type the following in the command line.
java myprogram.jar -input myfile1.txt -output outp... | Python run Java command line arguments with incrementing variables asynchronously. | I have a java program which does individual jobs e.g. takes in a file, does some processing on it and creates a new file. To run it I have to type the following in the command line.
java myprogram.jar -input myfile1.txt -output output/myfile1.txt
However i wish to batch process a few thousand files, so i would like to... | [
"I would use bash or something, but if you need to use python, you can use subprocess.call to do this: \nfrom subprocess import call\nfor i in range(1,1000):\n call([\"java myprogram -input myfile%d.txt -output\" % (i)])\n\n",
"This is a perfect use for a bash script (if you're in a *nix environment) or a .bat... | [
4,
2
] | [
"I would suggest just modifying your Java program to handle processing a whole directory so instead of handing over files pass over a directory to work on then the java program would process all of the files in the directory and write out several output files. Use some simple name mapping scheme for the output. T... | [
-2
] | [
"arguments",
"asynchronous",
"command_line",
"java",
"python"
] | stackoverflow_0006863585_arguments_asynchronous_command_line_java_python.txt |
Q:
How do I pass parameter values to Popen?
From the python console this works:
convert -quality 100 in.pdf out.png
but when I add that command to my Python script like this:
Popen(['convert', '-quality 100', 'in.pdf', 'out.png'])
I get:
unrecognized option `-quality 100'
If I change that parameter to '-quality=10... | How do I pass parameter values to Popen? | From the python console this works:
convert -quality 100 in.pdf out.png
but when I add that command to my Python script like this:
Popen(['convert', '-quality 100', 'in.pdf', 'out.png'])
I get:
unrecognized option `-quality 100'
If I change that parameter to '-quality=100' I still get the error.
I tried fixing it li... | [
"Every argument gets its own list element, so the second variant is correct.\nYou should bear in mind that until a call to communicate finishes, the command may still run (although that's unlikely in your case). Check returncode after calling communicate to find out whether the program encountered any errors (like ... | [
5,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0006863687_python.txt |
Q:
Effeciently Removing Duplicates from a CSV in Python
I am trying to effeciently remove duplicate rows from relatively large (several hundred MB) CSV files that are not ordered in any meaningful way. Although I have a technique to do this, it is very brute force and I am certain there is a moe elegant and more eff... | Effeciently Removing Duplicates from a CSV in Python | I am trying to effeciently remove duplicate rows from relatively large (several hundred MB) CSV files that are not ordered in any meaningful way. Although I have a technique to do this, it is very brute force and I am certain there is a moe elegant and more effecient way.
| [
"In order to remove duplicates you will have to have some sort of memory that tells you if you have seen a line before. Either by remembering the lines or perhaps a checksum of them (which is almost safe...)\nAny solution like that will probably have a \"brute force\" feel to it. \nIf you could have the lines sorte... | [
2,
1
] | [] | [] | [
"csv",
"performance",
"python"
] | stackoverflow_0006863756_csv_performance_python.txt |
Q:
Python watchdog application
Erm... i promise i searched thoroughly the web for this and couldn't find a satisfatory answer so >.<
I'm trying to make a 'controller' for my python app, i mean, it should be executed and then spawn the server, wait to pickup exit signals and if necessary, restart the script.
This code... | Python watchdog application | Erm... i promise i searched thoroughly the web for this and couldn't find a satisfatory answer so >.<
I'm trying to make a 'controller' for my python app, i mean, it should be executed and then spawn the server, wait to pickup exit signals and if necessary, restart the script.
This code is pretty messy but that's what ... | [
"As described here, os.spawnv is a deprecated method, you should use the subprocess module.\nApart this, if you always got 1 returned and no process spawned, maybe it is due to a bad path to the server code or a bad code for the server part. What happen if you launch the server manually ?\n"
] | [
1
] | [] | [] | [
"controller",
"python",
"restart",
"watchdog"
] | stackoverflow_0006863416_controller_python_restart_watchdog.txt |
Q:
How to add a map as a class field?
I want to add a dictionary that maps an object to a list of objects as an instance variable to a class. What is the idiomatic way to do it in Python? Here's how I've done it:
class MyClass:
def __init__(self):
self.myDict = { None : [None] }
A:
You have already hi... | How to add a map as a class field? | I want to add a dictionary that maps an object to a list of objects as an instance variable to a class. What is the idiomatic way to do it in Python? Here's how I've done it:
class MyClass:
def __init__(self):
self.myDict = { None : [None] }
| [
"You have already hit upon the idiomatic way to do it!\n",
"Personally, I'd do it this way, if you want the option of starting out with a certain number of objects, and you want it clearer what you're desiring.\nclass MyClass:\n def __init__(self, objlistdict=None):\n \"Takes an optional initial diction... | [
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0006863792_python.txt |
Q:
How to sort a list of tuples by the alphabetical ordering of one of its elements
I have a list of tuples, say (name, number, birthday, gender). If I wanted to reverse sort this list by their birthday, how could I sort this in python?
A:
This returns a new object:
>>> import operator
>>> sorted(my_list, key=oper... | How to sort a list of tuples by the alphabetical ordering of one of its elements | I have a list of tuples, say (name, number, birthday, gender). If I wanted to reverse sort this list by their birthday, how could I sort this in python?
| [
"This returns a new object:\n>>> import operator\n>>> sorted(my_list, key=operator.itemgetter(2), reverse=True)\n\nOr, in-place:\n>>> import operator\n>>> mylist.sort(key=operator.itemgetter(2), reverse=True)\n\nIf you want to sort by two values; assuming tuples are like (name, birthday, time);\n>>> mylist.sort(key... | [
7
] | [] | [] | [
"python"
] | stackoverflow_0006864051_python.txt |
Q:
Is there an equivalent to Python's os.remove() on Mac?
Currently I have some code deleting some temporary files created by my program:
# Delete the generated files
exts = [".lsys", ".py", ".pyc"]
for ext in exts:
os.remove("{0}{1}{2}".format(self.grammarDir, filename, ext))
Now I'm trying to port the applicat... | Is there an equivalent to Python's os.remove() on Mac? | Currently I have some code deleting some temporary files created by my program:
# Delete the generated files
exts = [".lsys", ".py", ".pyc"]
for ext in exts:
os.remove("{0}{1}{2}".format(self.grammarDir, filename, ext))
Now I'm trying to port the application to Mac. Looking at the documentation for Python 2.7, it ... | [
"Mac OS X is a Unix, too. From the top of the linked documentation:\n\nIf not separately noted, all functions that claim “Availability: Unix”\n are supported on Mac OS X, which builds on a Unix core.\n\n",
"Unix in this context means Mac and Linux, too. Problably all Unix-like/POSIX-compliant systems that you ca... | [
6,
4,
3
] | [] | [] | [
"macos",
"python"
] | stackoverflow_0006864106_macos_python.txt |
Q:
Django installation problem on Windows
I am trying to install Django on Windows XP. Here is what I did:
(1) Downloaded and installed Python 2.7 from
http://python.org/ftp/python/2.7/python-2.7.msi
in C:\Python27
(2) Downloaded Django 1.2.1 from
http://www.djangoproject.com/download/1.2.1/tarball/
(3). After... | Django installation problem on Windows | I am trying to install Django on Windows XP. Here is what I did:
(1) Downloaded and installed Python 2.7 from
http://python.org/ftp/python/2.7/python-2.7.msi
in C:\Python27
(2) Downloaded Django 1.2.1 from
http://www.djangoproject.com/download/1.2.1/tarball/
(3). After unzipping the file I placed Django's folde... | [
"Alternative method\n\nInstall easy_install : http://pypi.python.org/pypi/setuptools\nAdd C:\\Python27\\Scripts to your system path\nOpen a command line and enter easy_install django.\n\nThis will pull the latest version of Django off the PyPI website, and install it in that directory.\neasy_install is definitely m... | [
2,
1,
1
] | [] | [] | [
"django",
"installation",
"python"
] | stackoverflow_0003403062_django_installation_python.txt |
Q:
Django installation on a Mac running Leopard
Here's my problem. I have a mac with 2.5 installed & was using django 1.1 with it. I had no problems until I decided to upgrade python & django. I uninstalled django from my mac as per the djangoproject.com website recommends. I left python 2.5 on my mac as not to inter... | Django installation on a Mac running Leopard | Here's my problem. I have a mac with 2.5 installed & was using django 1.1 with it. I had no problems until I decided to upgrade python & django. I uninstalled django from my mac as per the djangoproject.com website recommends. I left python 2.5 on my mac as not to interfere with pre-installed mac programs. I put python... | [
"Most likely you have more than one version of Django installed; note the path (/usr/local/bin/django-admin.py) in the error message. You may also not have your PATH environment variable set up correctly so that the MacPorts paths appear before /usr/local/bin (where you may have a link to a python.org python) and ... | [
3,
0
] | [] | [] | [
"django",
"installation",
"python"
] | stackoverflow_0003153982_django_installation_python.txt |
Q:
Python zlib inflate error
I'm trying to inflate a zlib compressed file using Python with this code:
import zlib
data = open("3B42.110531.21.6A.HDF.Z", 'rb').read()
inflated = zlib.decompress(data)
f = open('3B42.110531.21.6A.HDF', 'wb')
f.write(inflated)
f.close()
I've already done several attempts with differen... | Python zlib inflate error | I'm trying to inflate a zlib compressed file using Python with this code:
import zlib
data = open("3B42.110531.21.6A.HDF.Z", 'rb').read()
inflated = zlib.decompress(data)
f = open('3B42.110531.21.6A.HDF', 'wb')
f.write(inflated)
f.close()
I've already done several attempts with different options:
Adding a second p... | [
".Z indicates a LZC/compress file. Despite the name similarity, this compression format differs from gzip, which is what zlib implements.\nTry using the command-line compress utility to uncompress the file (Your gzip program may also be able to decompress it).\n",
"The file extension '.Z' and the attempts you tri... | [
2,
1
] | [] | [] | [
"compression",
"python",
"zlib"
] | stackoverflow_0006864258_compression_python_zlib.txt |
Q:
XML differences between WCF and Python SUDS for inheritance?
I have a question regarding the different ways inheritance are represented between WCF and SUDS (Python). I have a C++/CLI WCF server (.NET 3.5 SP1) and I'm trying to communicate with it. I've used a C# (WCF also) client and it work fine, but there are... | XML differences between WCF and Python SUDS for inheritance? | I have a question regarding the different ways inheritance are represented between WCF and SUDS (Python). I have a C++/CLI WCF server (.NET 3.5 SP1) and I'm trying to communicate with it. I've used a C# (WCF also) client and it work fine, but there are problems when using a SUDS client (Python 2.6.4, SUDS 0.3.8). It... | [
"Don't know about the python side but there are couple of options on the WCF side. The more straight foward option is to create a message inspector to detect and convert the python generated soap to something more palatable to the WCF service.\nThe more difficult but \"purer\" option is to determine how to shape th... | [
1,
0
] | [] | [] | [
"inheritance",
"python",
"soap",
"suds",
"wcf"
] | stackoverflow_0002334874_inheritance_python_soap_suds_wcf.txt |
Q:
Any good Python HTTP proxies?
There is a long list of python http proxies. Does anyone have experience with them and have any recommendations? I need to run a proxy for automation tests running on a windows machine in IE. I want a proxy that has an API for monitoring traffic, so I can give go signals to the automa... | Any good Python HTTP proxies? | There is a long list of python http proxies. Does anyone have experience with them and have any recommendations? I need to run a proxy for automation tests running on a windows machine in IE. I want a proxy that has an API for monitoring traffic, so I can give go signals to the automation tests when a page appears to h... | [
"The list seems to be quite old. I would have a look at Twisted. According to this documentation there's something available.\n"
] | [
4
] | [] | [] | [
"automation",
"http",
"proxy",
"python",
"testing"
] | stackoverflow_0006864089_automation_http_proxy_python_testing.txt |
Q:
Python and Smalltalk - Metaprogramming capabilities comparison
I have of late been learning Python, and am amazed by its superb runtime metaprogramming capabilities. Previously I came across the term 'runtime metaprogramming' was when I was reading about Smalltalk, which as far as I know boasts of best runtime met... | Python and Smalltalk - Metaprogramming capabilities comparison | I have of late been learning Python, and am amazed by its superb runtime metaprogramming capabilities. Previously I came across the term 'runtime metaprogramming' was when I was reading about Smalltalk, which as far as I know boasts of best runtime metaprogramming capabilities. How well does Python stack up against Sma... | [
"Python actually holds up fairly well here. Smalltalk usually doesn't make explicit distinction between program and metaprogramm, but Python is more explicit - eg, the special syntax for decorators or the __foo__() naming convention for metaprogramming hooks. This is a good thing. \nOn the other hand, it's a bit of... | [
12,
10
] | [] | [] | [
"metaprogramming",
"oop",
"programming_languages",
"python",
"smalltalk"
] | stackoverflow_0006852189_metaprogramming_oop_programming_languages_python_smalltalk.txt |
Q:
Learn python the hard way, exercise 6.
I searched the site but it seems like this exercise from the book Learn Python the Hard way wasn't covered in previous questions.
I have this exercise:
1)Find all the places where a string is put inside a string. There are four places.
2)Are you sure there's only four places?... | Learn python the hard way, exercise 6. | I searched the site but it seems like this exercise from the book Learn Python the Hard way wasn't covered in previous questions.
I have this exercise:
1)Find all the places where a string is put inside a string. There are four places.
2)Are you sure there's only four places? How do you know? Maybe I like lying.
x = "T... | [
"If you interpret \"putting a string inside a string\" as \"using a format character with a string argument\", you correctly identified all four occurrences. It may be more helpful to put away the useless instructions and explain what happens. For more information, have a look at the offical documentation for forma... | [
9
] | [] | [] | [
"python"
] | stackoverflow_0006864349_python.txt |
Q:
How to handle direct file upload with GAE/python?
Client side (javascript) uploads the application with XMLHttpRequest:
var req = new XMLHttpRequest();
req.open('POST', my_app_url, false);
req.setRequestHeader("Content-Length", req.length);
req.sendAsBinary(req.binary);
I use datastore on the server side ... | How to handle direct file upload with GAE/python? | Client side (javascript) uploads the application with XMLHttpRequest:
var req = new XMLHttpRequest();
req.open('POST', my_app_url, false);
req.setRequestHeader("Content-Length", req.length);
req.sendAsBinary(req.binary);
I use datastore on the server side (not blobstore).
How can I save uploaded file to the da... | [
"You should use self.request.body\nclass YourUploadHandler(webapp.RequestHandler):\n def post(self):\n your_binary_content = self.request.body\n\n",
"If you mean on the appengine side, you just have to have a blobproperty. So something like...\nclass SomeEntity(db.Model):\n file_data = db.BlobProper... | [
3,
0
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0006862934_google_app_engine_python.txt |
Q:
Proper Use of JSON
Is it proper to parse through multiple HTML files in Python (Beautiful Soup), and then store the information in JSON format which will be iterated in Objective-C? If not, how should I format it? (I.e. XML, SQL, etc.?)
Thanks!
Edit: The situation I am dealing is the same as my previous question ... | Proper Use of JSON | Is it proper to parse through multiple HTML files in Python (Beautiful Soup), and then store the information in JSON format which will be iterated in Objective-C? If not, how should I format it? (I.e. XML, SQL, etc.?)
Thanks!
Edit: The situation I am dealing is the same as my previous question (although a different as... | [
"As others have said, your question is vague, but what you're proposing is a perfectly reasonable way of solving your problem as I understand it. I think what you're actually asking is what the best way of storing and loading your data is.\nThere's nothing wrong with using JSON per se, but it may not be particularl... | [
1
] | [] | [] | [
"format",
"json",
"objective_c",
"python",
"sql"
] | stackoverflow_0006862333_format_json_objective_c_python_sql.txt |
Q:
GDAL WriteArray issue
I'm utilizing python GDAL to write a raster data into a .tif file. Here's the code:
import numpy, sys
from osgeo import gdal, utils
from osgeo.gdalconst import *
# register all of the GDAL drivers
gdal.AllRegister()
# open the image
inDs = gdal.Open("C:\\Documents and Settings\\patrick\\De... | GDAL WriteArray issue | I'm utilizing python GDAL to write a raster data into a .tif file. Here's the code:
import numpy, sys
from osgeo import gdal, utils
from osgeo.gdalconst import *
# register all of the GDAL drivers
gdal.AllRegister()
# open the image
inDs = gdal.Open("C:\\Documents and Settings\\patrick\\Desktop\\tiff elevation\\EBK1... | [
"You don't need to Create then Open a raster (which you were reading GA_ReadOnly). You also don't need gdal.AllRegister() at the beginning, as it has already been called when you load GDAL into Python (see the Raster API tutorial).\nPicking up somewhere above (with modifications):\n# Create a new raster data source... | [
23
] | [] | [] | [
"gdal",
"python"
] | stackoverflow_0006791233_gdal_python.txt |
Q:
Interfacing Python With Fortran through Command-Line Using Pexpect
I am using pexpect with python to create a program that allows a user to interact with a FORTRAN program through a website. From the FORTRAN program I am receive the error:
open: Permission denied apparent state: unit 4 named subsat.out.55 last for... | Interfacing Python With Fortran through Command-Line Using Pexpect | I am using pexpect with python to create a program that allows a user to interact with a FORTRAN program through a website. From the FORTRAN program I am receive the error:
open: Permission denied apparent state: unit 4 named subsat.out.55 last format: list io lately writing sequential formatted external IO 55
when I ... | [
"The pexpect module is something I'd not used before, but could be useful to me, so I tried this.\nEdit:\nI've not been able to duplicate the error you're reporting. Looking at this error leads me to believe that it has something to do with reading from a file, which may be a result of other issues. From what I'v... | [
1
] | [] | [] | [
"fortran",
"pexpect",
"python",
"stdin",
"stdout"
] | stackoverflow_0006862882_fortran_pexpect_python_stdin_stdout.txt |
Q:
bash query through Python subprocess, bash variables wont expand
I'm doing a bash query using subprocess over SSH (don't ask). The query includes using find with the -exec option, however, on the remote target host, {} won't expand properly, when viewing what the query actually does on the target host.
For example... | bash query through Python subprocess, bash variables wont expand | I'm doing a bash query using subprocess over SSH (don't ask). The query includes using find with the -exec option, however, on the remote target host, {} won't expand properly, when viewing what the query actually does on the target host.
For example: find / -name "hello.txt" -exec echo {} \; where {} should read hello... | [
"It would be helpful if you posted some code, but my guess is that you are not including shell=True in your subprocess arguments, which is necessary for the variable expansion. For example:\nsubprocess.Popen('find / -name \"hello.txt\" -exec echo {} \\;', shell=True)\n\n"
] | [
4
] | [] | [] | [
"bash",
"python",
"ssh",
"subprocess"
] | stackoverflow_0006865342_bash_python_ssh_subprocess.txt |
Q:
Using MySQLdb to add ints and strings to a MySql server
I'm using MySQLdb to upload a lot of data from text files into a MySQL server. This works fine if I manually prepare a string such as 'as', '123', 12, 23, but I can't figure out how to loop through a list to generate this as I need to concatenate strings and ... | Using MySQLdb to add ints and strings to a MySql server | I'm using MySQLdb to upload a lot of data from text files into a MySQL server. This works fine if I manually prepare a string such as 'as', '123', 12, 23, but I can't figure out how to loop through a list to generate this as I need to concatenate strings and ints.
An example of an insert statement that works is as foll... | [
"MySQLdb can already do this without you having to manually type-cast your variables.\nYOU WANT TO DO IT THIS WAY because MySQLdb will automatically quote things and guard you from SQL injection attacks, to some extent. This is really important in any practical setting, and something you should get used to if you p... | [
5,
1,
1
] | [
"The error is not related to MySQLdb at all.\nYou are using '+' operator to merge string with integer. Your values array contains mixed strings and integers, and you are adding them using string append operator which can't work with mixed str and int (you are doing something like mystry = 1+',').\nSolution for your... | [
-1
] | [
"database",
"mysql",
"python",
"sql",
"string_formatting"
] | stackoverflow_0006865654_database_mysql_python_sql_string_formatting.txt |
Q:
Pig Hadoop Stream help
I am having issues running pig streaming. When I start up an interactive pig instance (fyi, I am doing this on the master node of an interactive pig AWS EMR instance via SSH/Putty) with only one machine my pig streaming work perfectly (it also works on my windows cloudera VM image). However,... | Pig Hadoop Stream help | I am having issues running pig streaming. When I start up an interactive pig instance (fyi, I am doing this on the master node of an interactive pig AWS EMR instance via SSH/Putty) with only one machine my pig streaming work perfectly (it also works on my windows cloudera VM image). However, when I switch to using more... | [
"DEFINE X `stream1.py` SHIP('stream1.py');\n\nAppears valid to me according to your preconditions and having stream1.py in your current local directory.\nA way to be sure of this:\nDEFINE X `python stream1.py` SHIP('/local/path/stream1.py');\n\nThe goal of SHIP is to copy the command in the working directory of all... | [
2
] | [] | [] | [
"apache_pig",
"hadoop",
"python",
"stream"
] | stackoverflow_0006852264_apache_pig_hadoop_python_stream.txt |
Q:
Using php curl to automate website.
Possible Duplicate:
Is there a PHP equivalent of Perl's WWW::Mechanize?
Anyway to do this with curl php?
import mechanize
br=mechanize.Browser()
br.open('https://www.google.com/calendar/exporticalzip')
br.select_form(nr=0)
br['Email']='Username@gmail.com'
br['Passw... | Using php curl to automate website. |
Possible Duplicate:
Is there a PHP equivalent of Perl's WWW::Mechanize?
Anyway to do this with curl php?
import mechanize
br=mechanize.Browser()
br.open('https://www.google.com/calendar/exporticalzip')
br.select_form(nr=0)
br['Email']='Username@gmail.com'
br['Passwd']='Password'
br.submit()
br.retrie... | [
"Read Using cURL to interact with Google Data services.\nRefer to PHP Curl with Google Calendar and Class: Google Calendar Wrapper.\n",
"There is an excellent PHP class which emulates web browsers much like curl does called Snoopy.\nIt allows a lot of extra functionality like extracting links from a fetched page ... | [
0,
0
] | [] | [] | [
"curl",
"php",
"python"
] | stackoverflow_0006860658_curl_php_python.txt |
Q:
Handle assertion dialog box with python subprocess
I am using python to create a sub process to check and see that no assertions occur.
I want to catch the error output along with the return code. That works fine, but the problem I run into is that when it runs into the assertion it gives me a dialog box that jus... | Handle assertion dialog box with python subprocess | I am using python to create a sub process to check and see that no assertions occur.
I want to catch the error output along with the return code. That works fine, but the problem I run into is that when it runs into the assertion it gives me a dialog box that just hangs there. I have to then click the assertion box be... | [
"There's not really an easy solution in general, since a program could in theory create any number of windows waiting for user input. If you have the source code for the inferior process, the easiest thing to do would be to modify it to call _set_abort_behavior(0, _CALL_REPORTFAULT) to disable the message box.\nIf... | [
1,
0
] | [] | [] | [
"assert",
"python",
"subprocess"
] | stackoverflow_0006866455_assert_python_subprocess.txt |
Q:
String replace with backslashes in Python
I'm trying to do a simple replacement of " " with "\s" (the literal \s, not some sort of backslash escape). This is what I think should happen:
>>> 'asdf hjkl'.replace(' ', '\s')
'asdf\shjkl'
I did this:
>>> 'asdf hjkl'.replace(' ', '\s')
'asdf\\shjkl'
>>> 'asdf hjkl'.rep... | String replace with backslashes in Python | I'm trying to do a simple replacement of " " with "\s" (the literal \s, not some sort of backslash escape). This is what I think should happen:
>>> 'asdf hjkl'.replace(' ', '\s')
'asdf\shjkl'
I did this:
>>> 'asdf hjkl'.replace(' ', '\s')
'asdf\\shjkl'
>>> 'asdf hjkl'.replace(' ', '\\s')
'asdf\\shjkl'
Neither returns... | [
"You're getting what you want. It just doesn't look that way in the REPL:\n>>> 'asdf hjkl'.replace(' ', '\\s')[4]\n'\\\\'\n\nAs you can see, that's one character, not two. \nTry printing it:\n>>> print 'asdf hjkl'.replace(' ', '\\s')\nasdf\\shjkl\n\n",
"The result is only displayed,\ntry the following,\na = 'asdf... | [
4,
2
] | [] | [] | [
"backslash",
"python",
"string"
] | stackoverflow_0006866696_backslash_python_string.txt |
Q:
Django Reverse One-To-One Key
Im using the DjangoBB forum system, and Im trying to add some features to it.
We have a few different models we are working with here. I will include the important parts.
User (from django.contrib.auth.models){No important code to show}
Profile and Post (from djangobb_forum.models):
... | Django Reverse One-To-One Key | Im using the DjangoBB forum system, and Im trying to add some features to it.
We have a few different models we are working with here. I will include the important parts.
User (from django.contrib.auth.models){No important code to show}
Profile and Post (from djangobb_forum.models):
class Profile(models.Model):
us... | [
"The related_name='forum_profile' changes the related name from user__profile... to user__forum_profile... \nThat's the point of the related name attribute of a foreign key or one-to-one key field.\n"
] | [
5
] | [] | [] | [
"django",
"django_models",
"django_views",
"python"
] | stackoverflow_0006866177_django_django_models_django_views_python.txt |
Q:
how to edit each member of a list in python
I am new to python and I am trying to create a capitalize function that either capitalizes all words in a string or only the first word. Here is my function
def capitalize(data, applyToAll=False):
"""depending on applyToAll it either capitalizes
all the words ... | how to edit each member of a list in python | I am new to python and I am trying to create a capitalize function that either capitalizes all words in a string or only the first word. Here is my function
def capitalize(data, applyToAll=False):
"""depending on applyToAll it either capitalizes
all the words in the string or the first word of a string"""
... | [
"The bread-and-butter way to do this is to use a list comprehension:\n>>> l = ['one', 'two', 'three']\n>>> [w.capitalize() for w in l]\n['One', 'Two', 'Three']\n\nThis creates a copy of the list, with the expression applied to each of the items. \nIf you don't want to create a copy, you could do this...\n>>> for i,... | [
5,
3
] | [] | [] | [
"for_loop",
"function",
"iteration",
"python"
] | stackoverflow_0006866712_for_loop_function_iteration_python.txt |
Q:
Tkinter Class "must be str not tuple" TypeError Python
I'm getting a problem with Tkinter for python, I have a class, application(root): root is Tk(), and when I run the class without an __init__ function, it works okay, but crashes after I quit the program. With the __init__, Tkinter tells me
Traceback (most rec... | Tkinter Class "must be str not tuple" TypeError Python | I'm getting a problem with Tkinter for python, I have a class, application(root): root is Tk(), and when I run the class without an __init__ function, it works okay, but crashes after I quit the program. With the __init__, Tkinter tells me
Traceback (most recent call last):
File "C:\stuff\Portable Python 3.2.0.1\app... | [
"root is the base class for application. You have provided an instance of Tk as the base class, rather than the class itself, ie application(Tk).\nIt would help if you could show a simple example of your failing code.\n"
] | [
1
] | [] | [] | [
"python",
"tkinter",
"types"
] | stackoverflow_0006866707_python_tkinter_types.txt |
Q:
urllib.urlretrieve is failing
I'm trying to download data using commands below.
import urllib
url = 'http://www.nse-india.com/content/historical/EQUITIES/2002/MAR/cm01MAR2002bhav.csv.zip'
urllib.urlretrieve(url, 'myzip')
What I see in the file generated file my.zip is,
You don't have permission to access "http... | urllib.urlretrieve is failing | I'm trying to download data using commands below.
import urllib
url = 'http://www.nse-india.com/content/historical/EQUITIES/2002/MAR/cm01MAR2002bhav.csv.zip'
urllib.urlretrieve(url, 'myzip')
What I see in the file generated file my.zip is,
You don't have permission to access "http://www.nse-india&#... | [
"You may need to use urllib2 and set the user-agent header to something it recognizes. It might just be blocking anything that doesn't appear to be a normal user.\n"
] | [
0
] | [] | [] | [
"python",
"urllib"
] | stackoverflow_0006866548_python_urllib.txt |
Q:
Starting game development in javascript. Where to draw the line between JS and Server Language
Im fairly proficient in php and am also learning python. I have been wanting to create a basic game for some time now and would like to create it in python. But in order to have a fancy smooth interface I need to use jav... | Starting game development in javascript. Where to draw the line between JS and Server Language | Im fairly proficient in php and am also learning python. I have been wanting to create a basic game for some time now and would like to create it in python. But in order to have a fancy smooth interface I need to use javascript (i dont much care for the flash/silverlight route). So I decided to start looking up game de... | [
"python would probably run on the server powering your web server.\nIf you want to write multiplayer client-server games then a lot of server code/logic would be in python.\nIf you want to write simpler singleplayer games then all your code is in the client (browser) and would be javascript. Python would just be th... | [
1,
1
] | [] | [] | [
"javascript",
"python"
] | stackoverflow_0006866802_javascript_python.txt |
Q:
python cpu consumption
I wrote a simple python program that looks to me like it should be cpu intensive:
for a in range(0,1500):
for b in range (0,a):
for c in range(0,b):
x = a+b+c
print x
What happens is that it takes a really long time on solving it, but ... | python cpu consumption | I wrote a simple python program that looks to me like it should be cpu intensive:
for a in range(0,1500):
for b in range (0,a):
for c in range(0,b):
x = a+b+c
print x
What happens is that it takes a really long time on solving it, but cpu consumption stays at aro... | [
"You're probably running this on a quad-core CPU. Since this code will only run on one core, it will show as taking 25% of the total, when the single core is actually at 100%.\nOn some operating systems, CPU usage will be shown as 100% per core (so that the total can go above 100%). On those operating systems your ... | [
8
] | [] | [] | [
"python"
] | stackoverflow_0006867106_python.txt |
Q:
Plotting scientific format on the axis label and different size minor formatter text size
I wrote the code below to output the figure but still need to figure out two things.
1) How do I get scientific notation on the axis for the minor tick label. Since I only have it show the 5000 I assume I could just change th... | Plotting scientific format on the axis label and different size minor formatter text size | I wrote the code below to output the figure but still need to figure out two things.
1) How do I get scientific notation on the axis for the minor tick label. Since I only have it show the 5000 I assume I could just change this in the showOnlySomeTicks function to return a string in scientific format. Is there a better... | [
"You have to use a combination of Formatter and Locator\nThe locator will tell where the tick should be placed.\nThe Formatter will return the string to be displayed at the location.\nsee: Ticker module documentation\nax.xaxis.set_minor_locator( xLocator )\nax.xaxis.set_minor_formatter( xminorFormatter )\n\n"
] | [
0
] | [] | [] | [
"matplotlib",
"numpy",
"python"
] | stackoverflow_0006828825_matplotlib_numpy_python.txt |
Q:
Benchmarking the CPU time of a python program in Windows 64-bit
I need to get the CPU run time of my python application.
How to measure execution time of command in windows command line?
I came across the above thread earlier and learned about timeit. However, according to the download website, timeit is not supp... | Benchmarking the CPU time of a python program in Windows 64-bit | I need to get the CPU run time of my python application.
How to measure execution time of command in windows command line?
I came across the above thread earlier and learned about timeit. However, according to the download website, timeit is not supported in 64-bit Windows.
http://www.microsoft.com/download/en/detail... | [
"If you're doing this just to profile or benchmark your code, don't building your own, use a built in library.\nhttp://docs.python.org/library/profile.html\n"
] | [
0
] | [] | [] | [
"benchmarking",
"python",
"windows_7"
] | stackoverflow_0006867068_benchmarking_python_windows_7.txt |
Q:
Using Django-Storages with amazon S3 and https
We have an image uploader that uploads to AWS, using django-storages. Right now it sends images over http but we want it to use https.
Googling didn't help me find a way to configure django-storages to do it. Does anyone know the best way to accomplish this, or any d... | Using Django-Storages with amazon S3 and https | We have an image uploader that uploads to AWS, using django-storages. Right now it sends images over http but we want it to use https.
Googling didn't help me find a way to configure django-storages to do it. Does anyone know the best way to accomplish this, or any documentation that would point me in the right direct... | [
"Looking at the source it appears you can enable HTTPS by setting AWS_S3_SECURE_URLS = True.\n"
] | [
20
] | [] | [] | [
"django",
"python",
"python_django_storages"
] | stackoverflow_0006866893_django_python_python_django_storages.txt |
Q:
Python - IDLE syntax error problem
I am using IDLE to learn python and I just notices something. Whenever I do a mistake, and press enter key, the program throws a syntax error. That's fine till now. But why I cannot go back, edit the lines and then re-run the code instead of writing again? I mean:
>>> def func(p... | Python - IDLE syntax error problem | I am using IDLE to learn python and I just notices something. Whenever I do a mistake, and press enter key, the program throws a syntax error. That's fine till now. But why I cannot go back, edit the lines and then re-run the code instead of writing again? I mean:
>>> def func(params):
return ";"
if 1 + 1 == 2... | [
"It's because you are entering your program into an REPL - Read, Evaluate, Print Loop. As you enter lines, they are being evaluated and the output is printed.\nYou should write your code in a file, name it MyCode.py or whatever, and then open that with IDLE. You can then call functions inside your file from within ... | [
4,
0,
0
] | [] | [] | [
"python",
"python_idle",
"syntax",
"syntax_error"
] | stackoverflow_0006843262_python_python_idle_syntax_syntax_error.txt |
Q:
Python calling mutiple URLs and pulling data from them
I'm trying to write a script that will call up a webpage (http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Tree&id=7742&lvl=3&lin=f&keep=1&srchmode=1&unlock), scan it, and then pull out the orders, families, genera, and species within each nested t... | Python calling mutiple URLs and pulling data from them | I'm trying to write a script that will call up a webpage (http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Tree&id=7742&lvl=3&lin=f&keep=1&srchmode=1&unlock), scan it, and then pull out the orders, families, genera, and species within each nested taxonomic group. However, I only want the vertebrates (a very... | [
"It isn't very clear (at least, to me) what do you exactly want to do, but, for what I understood, you need to create some sort of crawler that looks for links in the pages, navigate the site and categorize them?\nIf so, go for mechanize, that allows you to emulate a web browser, and navigate along the site, easily... | [
0
] | [] | [] | [
"call",
"genetics",
"python",
"taxonomy",
"url"
] | stackoverflow_0006867326_call_genetics_python_taxonomy_url.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.