content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
Python webapp - moving from testing to production
I've made a small web app using web.py that I now want to put into production. I dont anticipate this will have very high concurrent use (probably max of 5 or so users at any given time, if that).
That said, I dont want to go with the cherry.py server that comes wi... | Python webapp - moving from testing to production | I've made a small web app using web.py that I now want to put into production. I dont anticipate this will have very high concurrent use (probably max of 5 or so users at any given time, if that).
That said, I dont want to go with the cherry.py server that comes with web.py (and which i have been using for debugging), ... | [
"Available options are:\n\napache + mod_python\napache + mod_wsgi\nlighttpd + mod_fastcgi\nlighttpd + gunicorn\nnginx + gunicorn\n\nI suggest you to go for gunicorn.\n",
"CherryPy is a pretty good choice for deployment. It's a good WSGI server, and is known to work on EC2. Straightforward mapping of HTTP reques... | [
1,
0,
0
] | [] | [] | [
"nginx",
"python",
"web_applications",
"webserver"
] | stackoverflow_0003924668_nginx_python_web_applications_webserver.txt |
Q:
how to use python list comprehensions replace the function invoke inside of "for" stmt?
Sorry, I just found the
id = [conn.cursor() for x in range(100) ]
also works, so my concern will not be a problem anymore.
Thanks for all of your answer, all of you are really fast.
All,
id = [(conn.cursor(),x) for x in ra... | how to use python list comprehensions replace the function invoke inside of "for" stmt? | Sorry, I just found the
id = [conn.cursor() for x in range(100) ]
also works, so my concern will not be a problem anymore.
Thanks for all of your answer, all of you are really fast.
All,
id = [(conn.cursor(),x) for x in range(100) ]
>>> id
[(<sqlite3.Cursor object at 0x01D14DA0>, 0), (<sqlite3.Cursor object at 0x0... | [
"1.\ncursors = [ conn.cursor() for _ in xrange(100) ]\n\n2.\nresults = [ foo() for _ in xrange(100) ]\n\n",
"For the second question\nList comprehensions are used for generating another list as output of iteration over other list or lists. Since you want to run foo a numer of times, it is more elegant and less co... | [
1,
1,
1
] | [] | [] | [
"list_comprehension",
"python"
] | stackoverflow_0003966201_list_comprehension_python.txt |
Q:
Create a function in Python which creates a mySQL database
I've created a program in python and mySQL which creates a database and imports the data from text files and puts them into 4 different columns. The code works but I want to change the code and create functions.
Can anyone please help me create a function... | Create a function in Python which creates a mySQL database | I've created a program in python and mySQL which creates a database and imports the data from text files and puts them into 4 different columns. The code works but I want to change the code and create functions.
Can anyone please help me create a function that creates a mySQL database? Here is the code I have at the m... | [
"Your sql for loading data should be \nsql = '''LOAD DATA LOCAL INFILE %s INTO TABLE popularity \n FIELDS TERMINATED BY ';' \n LINES TERMINATED BY '\\\\n' \n (PersonNumber, Value, Category) \n SET Category=%s\n '''\n\n+ %s --> '%s'\n+ remove \" at the end\n\nIt should work.\nBes... | [
0
] | [] | [] | [
"mysql",
"python"
] | stackoverflow_0003965604_mysql_python.txt |
Q:
Integrating Pyjamas with Pinax+Django?
I'm going to start looking into this tomorrow when I begin my project, but could anyone point me in the right direction? (Maybe some integration code and/or a sample Pyjamas interface which uses Pinax as the backend -- all with adequate explanation, if possible? :)
Thanks!
A... | Integrating Pyjamas with Pinax+Django? | I'm going to start looking into this tomorrow when I begin my project, but could anyone point me in the right direction? (Maybe some integration code and/or a sample Pyjamas interface which uses Pinax as the backend -- all with adequate explanation, if possible? :)
Thanks!
| [
"Pinax is a collection of django applications. There's nothing specific to integrating pinax and pyjamas more than it is specific to integrating django and pyjamas. So the pyjamas book would be a good starting point.\n",
"Hope this http://code.google.com/p/pyjamas/wiki/DjangoWithPyjamas link helps you.\n"
] | [
3,
3
] | [] | [] | [
"ajax",
"django",
"pinax",
"pyjamas",
"python"
] | stackoverflow_0003965369_ajax_django_pinax_pyjamas_python.txt |
Q:
How to implement a FIFO queue that supports namespaces
I'm using the following approach to handle a FIFO queue based on Google App Engine db.Model (see this question).
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp import run_wsgi_app
class QueueItem(d... | How to implement a FIFO queue that supports namespaces | I'm using the following approach to handle a FIFO queue based on Google App Engine db.Model (see this question).
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp import run_wsgi_app
class QueueItem(db.Model):
created = db.DateTimeProperty(required=True, aut... | [
"Assuming your \"client class\" is really a request handler the client calls, you could do something like this:\nfrom google.appengine.api import users\nfrom google.appengine.api.namespace_manager import set_namespace\n\nclass ClientClass(webapp.RequestHandler):\n def get(self):\n # For this example let's assum... | [
1,
1
] | [] | [] | [
"fifo",
"google_app_engine",
"python",
"queue"
] | stackoverflow_0003963667_fifo_google_app_engine_python_queue.txt |
Q:
Minimize subqueries with IN queries on AppEngine (python)
Is there any clever way to avoid making a costly query with an IN clause in cases like the following one?
I'm using Google App Engine to build a Facebook application and at some point I (obviously) need to query the datastore to get all the entities that be... | Minimize subqueries with IN queries on AppEngine (python) | Is there any clever way to avoid making a costly query with an IN clause in cases like the following one?
I'm using Google App Engine to build a Facebook application and at some point I (obviously) need to query the datastore to get all the entities that belong to any of the facebook friends of the given user.
Suppose ... | [
"I don't think there's an elegant solution, but you could try this:\nOn the User model, use Facebook ID as the key name, and store each user's list of things in a ListProperty.\nclass Thing(db.Model):\n ...\n\nclass User(db.Model):\n things = db.ListProperty(db.Key)\n ...\n\nEntity creation would go like this:\n... | [
5,
3
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"gql",
"gquery",
"python"
] | stackoverflow_0003963010_google_app_engine_google_cloud_datastore_gql_gquery_python.txt |
Q:
How to determine when input is alphabetic?
I been trying to solve this one for a while and can't seem to make it work right.. here is my current work
while True:
guess = int(raw_input('What is your number?'))
if 100 < guess or guess < 1:
print '\ninvalid'
else:
.....continue on
Rig... | How to determine when input is alphabetic? | I been trying to solve this one for a while and can't seem to make it work right.. here is my current work
while True:
guess = int(raw_input('What is your number?'))
if 100 < guess or guess < 1:
print '\ninvalid'
else:
.....continue on
Right now I have made it so when a user input a num... | [
"You can use exception handling:\ntry:\n guess = int(raw_input('What is your number?'))\n if not (1 <= guess <= 100):\n raise ValueError\n # .....continue on\nexcept ValueError:\n print '\\ninvalid'\n\nThat way, \\ninvalid will be printed if the user either inputs a non-numeric string or inputs a... | [
6,
5
] | [] | [] | [
"python",
"user_input",
"validation"
] | stackoverflow_0003966904_python_user_input_validation.txt |
Q:
cp -r from_dir/* to_dir with python
Is there an easy way to emulate the command cp -r from_dir/* to_dir with python? shutil.copytree is not suitable because to_dir exists.
A:
Have a look at the source code of shutil.copytree, adapt it and use:
def copytree(src, dst, symlinks=False, ignore=None):
"""Recursive... | cp -r from_dir/* to_dir with python | Is there an easy way to emulate the command cp -r from_dir/* to_dir with python? shutil.copytree is not suitable because to_dir exists.
| [
"Have a look at the source code of shutil.copytree, adapt it and use:\ndef copytree(src, dst, symlinks=False, ignore=None):\n \"\"\"Recursively copy a directory tree using copy2().\n\n The destination directory must not already exist.\n If exception(s) occur, an Error is raised with a list of reasons.\n\n ... | [
7,
2,
2
] | [] | [] | [
"directory",
"python",
"shutil"
] | stackoverflow_0003966863_directory_python_shutil.txt |
Q:
How Make WebPage thumbnail on Google App Engine?
I'm using Django / Python. After saving the model I want to make a screenshot (preview) of how it looks in the template and save it on model field. Please tell me how to do it.
A:
in GAE you have limited access to external resource
outside GAE you can use webkit2p... | How Make WebPage thumbnail on Google App Engine? | I'm using Django / Python. After saving the model I want to make a screenshot (preview) of how it looks in the template and save it on model field. Please tell me how to do it.
| [
"in GAE you have limited access to external resource\noutside GAE you can use webkit2png http://www.paulhammond.org/webkit2png/\n",
"Not sure how you actually want it to work. You can however use the following links to pass a url and fetch its screenshot:\nhttp://www.websnapr.com/\nhttp://www.programmableweb.com/... | [
3,
1
] | [] | [] | [
"django",
"google_app_engine",
"python",
"screenshot",
"thumbnails"
] | stackoverflow_0003950346_django_google_app_engine_python_screenshot_thumbnails.txt |
Q:
How to update 400k rows on a production MySQL db and don't kill it
On our production server we need to split 900k images into different dirs and update 400k rows (MySQL with InnoDB engine). I wrote a python script which goes through next steps:
Select small chunk of data from db (10 rows)
Make new dirs
Copy files... | How to update 400k rows on a production MySQL db and don't kill it | On our production server we need to split 900k images into different dirs and update 400k rows (MySQL with InnoDB engine). I wrote a python script which goes through next steps:
Select small chunk of data from db (10 rows)
Make new dirs
Copy files to the created dirs and rename it
Update db (there are some triggers on... | [
"i will Add:\nWhy you create in each loop a new connexion and close it heh !!!\nAnd maybe you can use db.autocommit(False) specially for the UPDATE and do a db.commit() for each 100 rows or something ;\nand like Alin Purcaru you should do some benchmark as well.\nHope this can help :)\n",
"What I recommend. \n\nA... | [
3,
2,
1
] | [] | [] | [
"mysql",
"performance",
"python"
] | stackoverflow_0003966146_mysql_performance_python.txt |
Q:
Python+SWIG+MinGW - setup.py builds the source and the pyd file, python "cannot find the module"
I'm using MinGW to build a PythonC module using Swig. When I tell Python to load the module, it fails and complains that Python cannot find the module.
The funny thing is that the module is in the same directory that I... | Python+SWIG+MinGW - setup.py builds the source and the pyd file, python "cannot find the module" | I'm using MinGW to build a PythonC module using Swig. When I tell Python to load the module, it fails and complains that Python cannot find the module.
The funny thing is that the module is in the same directory that I'm running Python in and the module is named _mod.pyd. (I also have generated a mod.py file that uses ... | [
"This is a common problem. You probably are using the binary version of Python for Windows which is compiled with MSC not with MinGW. You can see it looking what the interpreter says when you run it from command line. If it is the case you have two choices:\n\ncompile the module with MSC or \ncompile python interpr... | [
1,
0,
0
] | [] | [] | [
"mingw",
"python",
"swig"
] | stackoverflow_0002262351_mingw_python_swig.txt |
Q:
Read python dictionary using c++
I have a python dictionary stored in a file which I need to access from a c++ program. What is the best way of doing this?
Thanks
A:
How to do this depends on the python types you've serialised. Basically, python prints something like...
{1: 'one', 2: 'two'}
...so you need code... | Read python dictionary using c++ | I have a python dictionary stored in a file which I need to access from a c++ program. What is the best way of doing this?
Thanks
| [
"How to do this depends on the python types you've serialised. Basically, python prints something like...\n{1: 'one', 2: 'two'}\n\n...so you need code to parse this. The simplest case is a flat map from one simple type to another, say int to int:\nint key, value;\nchar c;\n\nif (s >> c && c == '{')\n while (s ... | [
3,
2,
0
] | [] | [] | [
"c++",
"dictionary",
"python"
] | stackoverflow_0003966227_c++_dictionary_python.txt |
Q:
Reading text from an image
Is there a way we can read the alphabets from an image, some kind of text recognition method using python.
What I have to do is, read some images to get the text written on them.
Please suggest.
A:
See OCROPUS
EDIT:
Also after seeing the other question here (of which this question is a... | Reading text from an image | Is there a way we can read the alphabets from an image, some kind of text recognition method using python.
What I have to do is, read some images to get the text written on them.
Please suggest.
| [
"See OCROPUS\nEDIT:\nAlso after seeing the other question here (of which this question is a duplicate), pytesser is much simpler if your image only contains text and no noise (images/illustrations)\n"
] | [
14
] | [] | [] | [
"python"
] | stackoverflow_0003967548_python.txt |
Q:
Cycling a binary file in Python - Remove from beginning add to end
Could anyone point me towards a method of cycling a binary file in Python? I have a file full of 4 byte integers basically and when the file reaches a certain size, i.e. a certain number of values have been written, I want to start removing one fro... | Cycling a binary file in Python - Remove from beginning add to end | Could anyone point me towards a method of cycling a binary file in Python? I have a file full of 4 byte integers basically and when the file reaches a certain size, i.e. a certain number of values have been written, I want to start removing one from the start and adding one at the end.
I'm still reasonably new to Pytho... | [
"My idea: the first integer in the file gives you the position of the actual beginning of the data. At the start this will be 4 (assuming an integer takes 4 bytes). When the file is full, you just start overwriting data at the beginning and increase the position integer. This is basically a simple ring-buffer in fi... | [
3,
3
] | [] | [] | [
"binaryfiles",
"file_io",
"python"
] | stackoverflow_0003966969_binaryfiles_file_io_python.txt |
Q:
Difference between "grid" and "pack" geometry managers
What's the main difference between the Tkinter geometry managers grid and pack?
What do you use for your projects ?
If grid is better to align object, what the main purpose of pack?
A:
grid is used to lay out widgets in a grid. Another answer says it "overla... | Difference between "grid" and "pack" geometry managers | What's the main difference between the Tkinter geometry managers grid and pack?
What do you use for your projects ?
If grid is better to align object, what the main purpose of pack?
| [
"grid is used to lay out widgets in a grid. Another answer says it \"overlays a graph\" which is a bit of a misnomer. It doesn't overlay anything, it merely arranges widgets along row and column boundaries. It is great for creating tables and other structured types of layouts.\npack lays things out along the sides ... | [
24
] | [] | [] | [
"layout",
"python",
"python_3.x",
"tkinter"
] | stackoverflow_0003966367_layout_python_python_3.x_tkinter.txt |
Q:
Resetting all global internal state of the net-snmp library from the Python bindings
I'm trying to create automated integration tests for this hardware+software test subject which runs a SNMP agent as it's command interface. Our test setup looks like this: We're using Fitnesse as a test runner and PyFit to be able... | Resetting all global internal state of the net-snmp library from the Python bindings | I'm trying to create automated integration tests for this hardware+software test subject which runs a SNMP agent as it's command interface. Our test setup looks like this: We're using Fitnesse as a test runner and PyFit to be able to write the tests in Python. We then use netsnmp with Python bindings to send SNMP comma... | [
"The engineTime and engineBoots values are probably what is messing you up because SNMPv3 requires they not go backwards. If you have an agent that is restarting from scratch and not incrementing it's boots count (which is illegal, but under tests I could see why you'd be doing that) then you'd need to reset the i... | [
1
] | [] | [] | [
"fitnesse",
"net_snmp",
"pysnmp",
"python",
"snmp"
] | stackoverflow_0003940057_fitnesse_net_snmp_pysnmp_python_snmp.txt |
Q:
TKinter: how to change Frame width dynamically
how can I set width to a tk.Frame (post-initialization ?)
In other words, is there a member function to do it ? Sometheing like frame.setWidth()
thanks
A:
frame.config(width=100)
Be aware that if there are children in the frame that are managed by grid or pack, your... | TKinter: how to change Frame width dynamically | how can I set width to a tk.Frame (post-initialization ?)
In other words, is there a member function to do it ? Sometheing like frame.setWidth()
thanks
| [
"frame.config(width=100)\nBe aware that if there are children in the frame that are managed by grid or pack, your changes may have no effect. There are solutions to this, but it is rarely needed. Generally speaking you should let widgets be their natural size. If you do need to resize a frame that is a container of... | [
3
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0003968275_python_tkinter.txt |
Q:
Django Order By Generic Foreign Key
Hey, this is a quick one. I have two models, Post and Term and I'd like to be able to tag and categorize (taxonomy) posts as well as other (future) models. My Post model has the following fields: title, content, published (date) and my Term is declared like this:
class Term(mode... | Django Order By Generic Foreign Key | Hey, this is a quick one. I have two models, Post and Term and I'd like to be able to tag and categorize (taxonomy) posts as well as other (future) models. My Post model has the following fields: title, content, published (date) and my Term is declared like this:
class Term(models.Model):
taxonomy = models.CharFiel... | [
"Yeah, I was quite right about the simple SQL query with a join. A few joins actually. Here's what worked for me (django >= 1.2 for the raw() method)\ndata = {\n 'posts': Post._meta.db_table,\n 'relations': TermRelation._meta.db_table,\n 'terms': Term._meta.db_table,\n 'tag_id': tag.id\n}\n\nposts = Pos... | [
2,
1
] | [] | [] | [
"django",
"generics",
"python"
] | stackoverflow_0003967574_django_generics_python.txt |
Q:
how to embed C code in python program?
i want to write a program using multi-threading, raw sockets, to scan the ports in python
i have a C code for injection of raw socket. i want to perform a ACK scan so need a raw socket.
So please help me.
thank you
A:
Please check out Cython. It makes it very easy to wrap C... | how to embed C code in python program? | i want to write a program using multi-threading, raw sockets, to scan the ports in python
i have a C code for injection of raw socket. i want to perform a ACK scan so need a raw socket.
So please help me.
thank you
| [
"Please check out Cython. It makes it very easy to wrap C code.\nThis is adapted from the documentation on calling external C functions:\ncdef extern from \"math.h\":\n double sin(double)\n\ndef pysin(x):\n return sin(x)\n\nYou could then call pysin from the compiled module like a normal Python module.\n",
... | [
4,
0
] | [] | [] | [
"c",
"python",
"raw_sockets"
] | stackoverflow_0003968499_c_python_raw_sockets.txt |
Q:
delete *.pyc continuation
As a follow-up to this question, I have a new question:
What is happening internally in os.remove(module_name) and del sys.modules["module_name"]?
A:
The short answer is that os.remove(module_name) will remove a file from the filesystem. del sys.modules["module_name"] will remove a mod... | delete *.pyc continuation | As a follow-up to this question, I have a new question:
What is happening internally in os.remove(module_name) and del sys.modules["module_name"]?
| [
"The short answer is that os.remove(module_name) will remove a file from the filesystem. del sys.modules[\"module_name\"] will remove a module from the cache of previously loaded modules that the current Python interpreter is maintaining.\nIn Python, when you import a module, the interpreter checks to see if there... | [
4,
2,
1
] | [] | [] | [
"operating_system",
"python",
"sys"
] | stackoverflow_0000767920_operating_system_python_sys.txt |
Q:
stored procedures with python pymssql
I have this Stored procedure on my sql server :
[InsertRecord] @param1 varchar(10), @Param2 varchar(50),@Param3 varchar(10)=NULL,
@Param4 datetime = NULL AS BEGIN
When I update it with the following code :
connenction = pymssql.connect (host=host1,user=user1,password=p... | stored procedures with python pymssql | I have this Stored procedure on my sql server :
[InsertRecord] @param1 varchar(10), @Param2 varchar(50),@Param3 varchar(10)=NULL,
@Param4 datetime = NULL AS BEGIN
When I update it with the following code :
connenction = pymssql.connect (host=host1,user=user1,password=password1,database=database1)
curser = con... | [
"As your fiance said - you have commitment issues!\nconnection.commit()\n"
] | [
3
] | [] | [] | [
"python",
"sql_server_2005"
] | stackoverflow_0003969051_python_sql_server_2005.txt |
Q:
Python Visual Basic's CDate equivalent
I used to have this code in Visual Basic:
rpt.ParameterFields.GetItemByName("RowDate").AddCurrentValue CDate("2010-03-19")
and I cannot figure out into what I have to convert date to make eatable for COM.
Any suggestions?
A:
Ok, found solution. Bellow is python equivalent:... | Python Visual Basic's CDate equivalent | I used to have this code in Visual Basic:
rpt.ParameterFields.GetItemByName("RowDate").AddCurrentValue CDate("2010-03-19")
and I cannot figure out into what I have to convert date to make eatable for COM.
Any suggestions?
| [
"Ok, found solution. Bellow is python equivalent:\nrpt.ParameterFields.GetItemByName(\"RowDate\").AddCurrentValue(datetime.datetime.strptime('2010-03-19', \"%Y-%m-%d\").date())\n\nApproach is the same like in:\nPython date string to date object\n"
] | [
2
] | [] | [] | [
"com",
"python",
"vbscript",
"win32com"
] | stackoverflow_0003969287_com_python_vbscript_win32com.txt |
Q:
How to choose a proper Python parser generator to parse C struct definitions?
I am working on a project which contains two servers, one is written in python, the other in C. To maximize the capacity of the servers, we defined a binary proprietary protocol by which these two could talk to each other.
The protocol ... | How to choose a proper Python parser generator to parse C struct definitions? | I am working on a project which contains two servers, one is written in python, the other in C. To maximize the capacity of the servers, we defined a binary proprietary protocol by which these two could talk to each other.
The protocol is defined in a C header file in the form of C struct. Usually, I would use VIM to... | [
"As an alternative solution that might feel a bit over-ambitious from the beginning, but also might serve you very well in the long-term, is:\n\nRedefine the protocol in some higher-level language, for instance some custom XML\nGenerate both the C struct definitions and any required Python versions from the same so... | [
3,
1,
1,
0
] | [] | [] | [
"parsing",
"python"
] | stackoverflow_0003969333_parsing_python.txt |
Q:
How to pass empty argument to Popen (with shell=False)?
I have external script (sh), i would like to do something like this:
arg1 = 'some string'
arg2 = 'some string2'
arg3 = ''
cmd = ['/usr/local/bin/myscript', 'arg1', 'arg2', 'arg3']
Popen(cmd, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)
I seems, that i... | How to pass empty argument to Popen (with shell=False)? | I have external script (sh), i would like to do something like this:
arg1 = 'some string'
arg2 = 'some string2'
arg3 = ''
cmd = ['/usr/local/bin/myscript', 'arg1', 'arg2', 'arg3']
Popen(cmd, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)
I seems, that if "arg3" is empty, my script i called only with two arguments... | [
"test.py:\nimport sys\nprint(sys.argv)\n\ntest2.py:\nimport subprocess\nimport shlex\n\ncmd=\"test.py 'some string' 'some string2' '' \"\nproc=subprocess.Popen(shlex.split(cmd))\n\nRunning test2.py yields\n['test.py', 'some string', 'some string2', '']\n\n",
"Popen(cmd[0] + [ repr(x) for x in cmd[1:]], \nshell=Fa... | [
5,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0003968007_python.txt |
Q:
path to element with conditions on parent(s) attributes using xpath,lxml,python
I am working on project using lxml. here is a sample xml
<PatientsTree>
<Patient PatientID="SKU065427">
<Study StudyInstanceUID="25.2.9.2.1107.5.1.4.49339.30000006050107501192100000001">
<Series SeriesInstanceUID="2.16... | path to element with conditions on parent(s) attributes using xpath,lxml,python | I am working on project using lxml. here is a sample xml
<PatientsTree>
<Patient PatientID="SKU065427">
<Study StudyInstanceUID="25.2.9.2.1107.5.1.4.49339.30000006050107501192100000001">
<Series SeriesInstanceUID="2.16.840.1.113669.1919.1176798690"/>
<Series SeriesInstanceUID="2.16.840.1.113669.1... | [
"import lxml.etree as le\nwith open('data.xml') as f:\n doc=le.parse( f )\npatientID=\"SKU55527\"\nstudyInstanceUID=\"25.2.9.2.1107.5.1.4.49339.30000007010207164403100000013\"\nxpath='''\\\n /PatientsTree\n /Patient[@PatientID=\"{p}\"]\n /Study[@StudyInstanceUID=\"{s}\"]\n /Se... | [
3,
2,
1
] | [] | [] | [
"lxml",
"python",
"xpath"
] | stackoverflow_0003968969_lxml_python_xpath.txt |
Q:
Regex for finding date in Apache access log
I'm writing a python script to extract data out of our 2GB Apache access log. Here's one line from the log.
81.52.143.15 - - [01/Apr/2008:00:07:20 -0600] "GET /robots.txt HTTP/1.1" 200 29 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) VoilaBot BETA 1.2 (htt... | Regex for finding date in Apache access log | I'm writing a python script to extract data out of our 2GB Apache access log. Here's one line from the log.
81.52.143.15 - - [01/Apr/2008:00:07:20 -0600] "GET /robots.txt HTTP/1.1" 200 29 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) VoilaBot BETA 1.2 (http://www.voila.com/)"
I'm trying to get the date ... | [
"match() looks for a match at the beginning of the string. Use search() to look for a match anywhere in the string. More info here: http://docs.python.org/library/re.html#matching-vs-searching\n",
"Or you can use one of already available python apache log parsers like :\n\nApachelogs\nLogtools\nLogrep (Wtop packa... | [
5,
1,
0,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000883520_python_regex.txt |
Q:
ImportError when installing NumPy for Python 2.7
EDIT: after reading this http://projects.scipy.org/numpy/ticket/1322 it seems that the NumPy version I am using doesn't work with Mac OS 10.5.x. Does anyone have access to a version of NumPy that works with Mac OS 10.5? I can't get it to compile either.
Original p... | ImportError when installing NumPy for Python 2.7 | EDIT: after reading this http://projects.scipy.org/numpy/ticket/1322 it seems that the NumPy version I am using doesn't work with Mac OS 10.5.x. Does anyone have access to a version of NumPy that works with Mac OS 10.5? I can't get it to compile either.
Original post ...
I am trying to use NumPy, but I'm having diffi... | [
"You can find discussion about current problems with Mac OS on the numpy mailing list, and I would recommend to discuss installation problems there, since that's were the developers are that try to fix the problems.\nfor example\nhttp://groups.google.com/group/numpy/browse_thread/thread/a0ceb45b58feca2b#\nand this ... | [
1
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0003940523_numpy_python.txt |
Q:
Python: how to substitute and know whether it matched
I know that re.sub(pattern, repl,text) can substitute when pattern matches, and then return the substitute.
My code is:
text = re.sub(pattern, repl, text1)
I have to define another variable to check whether it is modified:
text2 = re.sub(pattern, repl, text1)... | Python: how to substitute and know whether it matched | I know that re.sub(pattern, repl,text) can substitute when pattern matches, and then return the substitute.
My code is:
text = re.sub(pattern, repl, text1)
I have to define another variable to check whether it is modified:
text2 = re.sub(pattern, repl, text1)
matches = text2 != text1
text1 = text2
It has issues, for... | [
"Use re.subn\n\nPerform the same operation as sub(), but return a tuple (new_string, number_of_subs_made).\n\nand then check the number of replacements that were made. For example:\ntext2, numReplacements = re.subn(pattern, repl, text1)\nif numReplacements:\n # did match\nelse:\n # did not match\n\n",
"The ... | [
18,
1,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0003969519_python_regex.txt |
Q:
SciPy's non-linear least square
I tried to do bundle adjustment by python. So I'm test non-linear least square module.
Then I wrote code like below. I want to get right Pmat represents camera projection matrix for three cameras. But I have an error,"ValueError: object too deep for desired array".
Anyone who can ... | SciPy's non-linear least square | I tried to do bundle adjustment by python. So I'm test non-linear least square module.
Then I wrote code like below. I want to get right Pmat represents camera projection matrix for three cameras. But I have an error,"ValueError: object too deep for desired array".
Anyone who can give clue to solve this issue?
Regar... | [
"my first guess: leastsq doesn't like matrices, \nuse arrays and np.dot, or convert np.asarray(err) before the return, And maybe convert p to matrix inside your residual function. \nMixing matrices and arrays can be a pain to keep track of.\n",
"A couple of small things: \n\nuse np.array if you can\nDo not import... | [
3,
1
] | [] | [] | [
"python",
"scipy"
] | stackoverflow_0003965995_python_scipy.txt |
Q:
download a folder of files given the http url of the files directory with python
Possible Duplicate:
Looping through a directory on the web and displaying its contents (files and other directories) via Python
hi, Guys,
If I have code files under
http://AAA/BBB/tags/revision/
how can I download these files in pyt... | download a folder of files given the http url of the files directory with python |
Possible Duplicate:
Looping through a directory on the web and displaying its contents (files and other directories) via Python
hi, Guys,
If I have code files under
http://AAA/BBB/tags/revision/
how can I download these files in python?
and If they have 600M in total, is there some efficient way to do it?
| [
"Are you using svn as your repository? It would look like this:\nfrom subprocess import Popen, PIPE\n\ndef svn_co(url):\n return run_program('svn', 'co', url)\n\ndef run_program(*args):\n popen_obj = Popen(args, stderr=PIPE)\n _, errors = popen_obj.communicate()\n if popen_obj.returncode:\n prin... | [
0
] | [] | [] | [
"download",
"python"
] | stackoverflow_0003967373_download_python.txt |
Q:
in python 2.6 how do i change a global variable within a for loop
i want to change the value of a variable within a for loop, but then have the new preserved variable changed when the loop finishes
my attempt (kinda simplified from what i'm actually doing)
SNP is a list and compar_1 is a list of lists
line_1 = emp... | in python 2.6 how do i change a global variable within a for loop | i want to change the value of a variable within a for loop, but then have the new preserved variable changed when the loop finishes
my attempt (kinda simplified from what i'm actually doing)
SNP is a list and compar_1 is a list of lists
line_1 = empty_row
for SNP1 in compar_1:
global line_1
if SNP[3] == SNP1[3]... | [
"If you had tried to just change the variable, you would have seen that it just works. Python does not have separate scope for loops.\n",
"for loops do not affect variable scope in Python (like they could in C)\nIf you were using variables inside a function, you can use global [var] to declare that when you refer... | [
3,
1,
0
] | [] | [] | [
"for_loop",
"global_variables",
"python",
"python_2.x"
] | stackoverflow_0003969136_for_loop_global_variables_python_python_2.x.txt |
Q:
Python cross platform
If I create a gui for windows using python 2.6 and Qt, and then want to running in solaris or linux world.
What do I need on both systems, I'm guessing 2.6 and Qt for both platforms.
Is this correct or would there be a better solution.
If wxpython, the same right?
A:
To run a Python appl... | Python cross platform | If I create a gui for windows using python 2.6 and Qt, and then want to running in solaris or linux world.
What do I need on both systems, I'm guessing 2.6 and Qt for both platforms.
Is this correct or would there be a better solution.
If wxpython, the same right?
| [
"To run a Python application, one obviously need to have the Python interpreter installed, usually at least the same version used for developement (but sometimes you didn't use features new to that version, so the code is backwards-compatible). A newer version should work, too - only Python 3 isn't backwards compat... | [
6
] | [] | [] | [
"cross_platform",
"python",
"qt",
"wxpython"
] | stackoverflow_0003970058_cross_platform_python_qt_wxpython.txt |
Q:
Preparing a web site for international usage
I am preparing to develop a web application that will (hopefully) be used by an audience with many different native languages.
What should I do to prepare my software project to have the user interface be almost entirely internationalized?
Are there any software sta... | Preparing a web site for international usage | I am preparing to develop a web application that will (hopefully) be used by an audience with many different native languages.
What should I do to prepare my software project to have the user interface be almost entirely internationalized?
Are there any software stacks that make this easier?
| [
"There are some resources you might want to see: \n\nhttp://docs.djangoproject.com/en/dev/topics/i18n/\nhttp://docs.djangoproject.com/en/dev/topics/i18n/internationalization/\nhttp://www.djangobook.com/en/1.0/chapter18/\n\nPython's gettext and locale module might also be useful.\n",
"One big change in your projec... | [
2,
0
] | [] | [] | [
"django",
"internationalization",
"project_planning",
"python"
] | stackoverflow_0003950851_django_internationalization_project_planning_python.txt |
Q:
Displaying log data in latest-first format
I like having log data in a last-first form (the same way most blogs and news sites organize their posts).
The languages I'm most comfortable in are C++ and Python: is there a way to output log data either to the screen (stdout) or a file with the most recent entry always... | Displaying log data in latest-first format | I like having log data in a last-first form (the same way most blogs and news sites organize their posts).
The languages I'm most comfortable in are C++ and Python: is there a way to output log data either to the screen (stdout) or a file with the most recent entry always being on top?
Or is there perhaps a way of modi... | [
"using the tac command you can also do :\nwatch \"tac file.log\"\n\nadd the -n option if you want to control the refresh time like this\nwatch -n 0.3 \"tac file.log\"\n\n",
"Terminal and console drivers are designed for displaying output in a top-down matter. You will need to resort to an external display manager... | [
4,
1
] | [] | [] | [
"c++",
"logging",
"ncurses",
"python",
"tail"
] | stackoverflow_0003970241_c++_logging_ncurses_python_tail.txt |
Q:
Anyone have a tool to detect python logger statements with an invalid number of arguments?
e.g. if you have code that does something like this somewhere in your codebase:
>>> import logging
>>> logging.basicConfig()
>>> logger = logging.getLogger(__name__)
>>> logger.critical("foo: %s", 1, 2)
Traceback (most recen... | Anyone have a tool to detect python logger statements with an invalid number of arguments? | e.g. if you have code that does something like this somewhere in your codebase:
>>> import logging
>>> logging.basicConfig()
>>> logger = logging.getLogger(__name__)
>>> logger.critical("foo: %s", 1, 2)
Traceback (most recent call last):
File "/pluto/local/lib/python2.6/logging/__init__.py", line 768, in emit
msg... | [
"One workaround would be:\n>>> import logging\n>>> logging.basicConfig()\n>>> logger = logging.getLogger(__name__)\n>>> logger.critical(\"foo: %s\" % (1, 2))\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nTypeError: not all arguments converted during string formatting\n\nOr do you wan... | [
0,
0
] | [] | [] | [
"logging",
"python"
] | stackoverflow_0003938071_logging_python.txt |
Q:
Python - List Mapping
I have several lists that I would like to map together, but I can't quite work my head around how to do it.
I am scraping a live feed of Horse Racing results. The feed only lists the course/time once and three horses and their positions (top three) OR four horses and blank (i.e. "") positions... | Python - List Mapping | I have several lists that I would like to map together, but I can't quite work my head around how to do it.
I am scraping a live feed of Horse Racing results. The feed only lists the course/time once and three horses and their positions (top three) OR four horses and blank (i.e. "") positions IF the race was abandoned.... | [
">>> class s:\n courses = [\"CourseX\", \"CourseX\", \"CourseY\"]\n times = [\"01:00\", \"02:00\", \"01:00\"]\n abandoned = [False, False, True]\n horses = [\"X1\", \"X2\", \"X3\", \"X4\", \"X5\", \"X6\", \"Y1\", \"Y2\", \"Y3\", \"Y4\"]\n positions = [\"1\",\"2\",\"3\",\"1\",\"2\",\"3\",\"\",\"\",... | [
5,
2,
2
] | [] | [] | [
"list_comprehension",
"map",
"python",
"tuples"
] | stackoverflow_0003970544_list_comprehension_map_python_tuples.txt |
Q:
python regex question
I want to match certain symbols only when they are not prefixed by specific characters. For instance, match "))))))))))" when it is not preceded by "x". Need some advices. My current expession is
(?<!x|X|:|=|\\1)([\|()\[\]])+
which does not work.
[EDIT] Rephrase my question
A:
Use complem... | python regex question | I want to match certain symbols only when they are not prefixed by specific characters. For instance, match "))))))))))" when it is not preceded by "x". Need some advices. My current expession is
(?<!x|X|:|=|\\1)([\|()\[\]])+
which does not work.
[EDIT] Rephrase my question
| [
"Use complementing character class:\n'[^x\\)](\\)+)'\nAll your specific characters which should not be prefixed will be placed with x, along with ).\n",
"re.search(r\"(?<![x)])\\)+\", text)\n\n>>> re.search(r\"(?<![x)])\\)+\", \" hello)))))\")\n<_sre.SRE_Match object at 0xb75c0c98>\n>>> _.group()\n')))))'\n>>> re... | [
1,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0003967153_python_regex.txt |
Q:
JustHost.com and Python CGI
I'm trying to get justhost.com to compile a python CGI script (helloworld.py) without much luck. The site says python works, but I can't find much.
I'm using http://webpython.codepoint.net/cgi_tutorial
Has anyone gotten it to work?
A:
Ok, I figured it out.
for justhost.com users you... | JustHost.com and Python CGI | I'm trying to get justhost.com to compile a python CGI script (helloworld.py) without much luck. The site says python works, but I can't find much.
I'm using http://webpython.codepoint.net/cgi_tutorial
Has anyone gotten it to work?
| [
"Ok, I figured it out.\nfor justhost.com users you must do a few things.\n\nset up a directory in 'public_html/'\ncalled 'scgi-bin/'\ngo to your control panel and the\n'advanced options' -> 'Apache\nHandlers' -> now add a user defined\napache handler ( handler: cgi-script,\nextenstion: .py) and 'add.'\nwrite your ... | [
3
] | [] | [] | [
"python"
] | stackoverflow_0003970178_python.txt |
Q:
Problems trying to access to a global var
I know how to use the global variables when they are defined in a class, but I have a global variable in a main.
If I want to use it inside a class, which would be the import to access it?
My main is something like this
Main.py:
from EvolutionaryAlgorithm import Evolutiona... | Problems trying to access to a global var | I know how to use the global variables when they are defined in a class, but I have a global variable in a main.
If I want to use it inside a class, which would be the import to access it?
My main is something like this
Main.py:
from EvolutionaryAlgorithm import EvolutionaryAlgorithm
initialTimeMain = 0
if __name__ ==... | [
"You have a case of circular imports, short-term solution is to move import statement inside the if clause:\ninitialTimeMain = 0\n\nif __name__ == '__main__':\n from EvolutionaryAlgorithm import EvolutionaryAlgorithm\n evolutionaryAlgorithm= EvolutionaryAlgorithm()\n\nA better, long-term solution would be to ... | [
3
] | [] | [] | [
"global_variables",
"python",
"scope"
] | stackoverflow_0003970842_global_variables_python_scope.txt |
Q:
Showing the Foreign Key value in Django template
Here is my issue. I am new to python/django (about 2 months in). I have 2 tables, Project and Status. I have a foreign key pointing from status to project, and I am looking to try to display the value of the foreign key (status) on my project template, instead of... | Showing the Foreign Key value in Django template | Here is my issue. I am new to python/django (about 2 months in). I have 2 tables, Project and Status. I have a foreign key pointing from status to project, and I am looking to try to display the value of the foreign key (status) on my project template, instead of the address of the foreign key.
Here is my models.py
... | [
"I'm guessing you mean here:\n<td>{{ p.status_set.select_related }}</td>\n\nThis doesn't do anything. select_related is an optimisation feature, it has nothing to do with actually getting or displaying the related content. If you want to do that, you will have to iterate through the result of p.status_set.all.\n",
... | [
8,
3
] | [] | [] | [
"django",
"django_models",
"django_templates",
"python"
] | stackoverflow_0003969640_django_django_models_django_templates_python.txt |
Q:
How do I return a list as a variable in Python and use in Jinja2?
I am a very young programmer and I am trying to do something in Python but I'm stuck. I have a list of users in Couchdb (using python couchdb library & Flask framework) who have a username (which is the _id) and email. I want to use the list of emai... | How do I return a list as a variable in Python and use in Jinja2? | I am a very young programmer and I am trying to do something in Python but I'm stuck. I have a list of users in Couchdb (using python couchdb library & Flask framework) who have a username (which is the _id) and email. I want to use the list of email addresses in a select box in a jinja2 template.
My first problem is h... | [
"Assuming you have a model such as:\nclass User(Document):\n email = TextField()\n\nYou can use the static method load of the User class\nusers = [User.load(db, uid) for uid in db]\n\nNow you can do this:\nfor user in users:\n print user.id, user.email \n\nBut you're using it in flask so, in your view you ca... | [
23,
3,
1
] | [] | [] | [
"flask",
"jinja2",
"python"
] | stackoverflow_0003970420_flask_jinja2_python.txt |
Q:
how to set the default value for grouped choices in django
If I have some grouped choices for a models.IntegerField, how can I set the default value to a combination of those choices
ex:
class ForumThread():
STATE_CHOICES = (
('Sticky', (
(True, 'True'),
(False, 'False') ) ... | how to set the default value for grouped choices in django | If I have some grouped choices for a models.IntegerField, how can I set the default value to a combination of those choices
ex:
class ForumThread():
STATE_CHOICES = (
('Sticky', (
(True, 'True'),
(False, 'False') ) ),
('Blocked', (
(False, 'False')
... | [
"You have misunderstood what grouped choices do. They are for presentation only - your IntegerField can only represent one single value, which in your case will be either 0 or 1 (for False or True). The only thing the groups do is provide headings within the select box. There's no way in the setup you have to have ... | [
1,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0003957489_django_django_models_python.txt |
Q:
Is TkKinter widely used to build user interfaces?
In which kind of application is Tkinter usually used?
I'm doing a project in Python in which I'm using it for the first time to build a simple user interface.
I was wondering if this is widely used for specific applications, or mobile applications.. etc
A:
As far... | Is TkKinter widely used to build user interfaces? | In which kind of application is Tkinter usually used?
I'm doing a project in Python in which I'm using it for the first time to build a simple user interface.
I was wondering if this is widely used for specific applications, or mobile applications.. etc
| [
"As far as I have seen, Tkinter is great for simple applications, teaching, or for when you don't need the features of a more comprehensive package like Qt or wxWidgets. These libraries can run several megabytes, and you may not need that. It's part of the standard library, so it's suited for this purpose. However,... | [
4,
0
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0003970255_python_tkinter.txt |
Q:
How to use FTPlib in python
i'm writing an application that is supposed to upload a file to an FTP server.
Here's the code:
try:
f = open(filename,"rb")
except:
print "error 0"
try:
ftp = FTP(str(self.ConfigUri))
print "CONNECTED!"
except:
print "CANNOT CONNE... | How to use FTPlib in python | i'm writing an application that is supposed to upload a file to an FTP server.
Here's the code:
try:
f = open(filename,"rb")
except:
print "error 0"
try:
ftp = FTP(str(self.ConfigUri))
print "CONNECTED!"
except:
print "CANNOT CONNECT"
try:
ftp = FTP(st... | [
"It could be that the filename is the full path, you should use the basename instead:\nimport os\nfolder, base = os.path.split(filename)\nftp.storbinary('STOR ' + base, f)\n\nIf not make sure your python is running at the right place:\nimport os\nprint os.getcwd()\n\n",
"What error does the following code report?... | [
1,
0,
0
] | [] | [] | [
"ftplib",
"python"
] | stackoverflow_0003971253_ftplib_python.txt |
Q:
Drag-and-drop to canvas in wxPython
Do you know if there is an easy way to drag-and-drop elements (icons or buttons) into a canvas and create different drawings on it as a result?
The idea is to have a set of objects and let the user drag them into a drawing space.
In the worst case the user could just click on th... | Drag-and-drop to canvas in wxPython | Do you know if there is an easy way to drag-and-drop elements (icons or buttons) into a canvas and create different drawings on it as a result?
The idea is to have a set of objects and let the user drag them into a drawing space.
In the worst case the user could just click on the icon/button, and then click on the canv... | [
"There is an example of something more or less like this here: http://wiki.wxpython.org/wxOGL Although it is about wxOGL, they recommend you to use either SimpleCanvas or FloatCanvas and adapt their examples.\n",
"I assume you are building a browser app? If so, the jQuery UI Droppable plugin provides most of the... | [
1,
1
] | [] | [] | [
"canvas",
"drag_and_drop",
"python",
"wxpython"
] | stackoverflow_0002328008_canvas_drag_and_drop_python_wxpython.txt |
Q:
can you flag command line inputs in python?
a lot of command-line .exe applications i use allow you flag optional inputs
e.g. program.exe -o outputfile.txt -f F
where "-o" indicates an optional output file name different to the default, and where "-F' indicates another option about the script.
so far i've been us... | can you flag command line inputs in python? | a lot of command-line .exe applications i use allow you flag optional inputs
e.g. program.exe -o outputfile.txt -f F
where "-o" indicates an optional output file name different to the default, and where "-F' indicates another option about the script.
so far i've been using the sys.arg[] variables to input file names a... | [
"If you're using Python 2.7, you want to use argparse. If you're using something older, you want the optparse module.\n",
"You could use the modules provided by python to handle command line arguments.\n\nhttp://docs.python.org/library/optparse.html (Deprecation warning)\nhttp://docs.python.org/library/argparse.h... | [
7,
2
] | [] | [] | [
"argv",
"command_line",
"flags",
"python"
] | stackoverflow_0003971528_argv_command_line_flags_python.txt |
Q:
Python-like "as" keyword (for namespacing) in Ruby
I was just over looking at this question. The first thought that popped to my head was that ruby must have some sort of "as" type keyword like Python's import to help avoid namespace pollution. I've googled a bit but it seems that it's recommended to wrap your c... | Python-like "as" keyword (for namespacing) in Ruby | I was just over looking at this question. The first thought that popped to my head was that ruby must have some sort of "as" type keyword like Python's import to help avoid namespace pollution. I've googled a bit but it seems that it's recommended to wrap your code in modules to avoid namespace problems with ruby. T... | [
"What I always do is start my modules with my company initials for work or my own initials for my personal projects.\nmodule JWG_TwitterTools\n.\n. \n.\nend\n\n",
"In ruby 2.0, there will be mix (search for mix). But now, there is nothing like that... Simply use the full constant path.\n"
] | [
2,
2
] | [] | [] | [
"module",
"python",
"ruby"
] | stackoverflow_0003969777_module_python_ruby.txt |
Q:
How to simulate POST arguments in python
I'm trying to simulate some data in to the datastore to emulate POSTs.
What I'm looking for is a way to post named arguments but as one argument. So I can use the same method as a normal POST would do.
The method I want to invoke get params in two ways.
def HandlePost(par... | How to simulate POST arguments in python | I'm trying to simulate some data in to the datastore to emulate POSTs.
What I'm looking for is a way to post named arguments but as one argument. So I can use the same method as a normal POST would do.
The method I want to invoke get params in two ways.
def HandlePost(params):
params.get('name')
params.get_al... | [
"For sure they are request objects that represents a http request. It should usually contain typical http request information like method , uri, message etc.\nTo find out what type self.request are, you could do introspection without the doc. if self.request is a instantiation of a class then you could obtain the c... | [
1,
1,
0
] | [] | [] | [
"google_app_engine",
"python",
"web_applications"
] | stackoverflow_0003966585_google_app_engine_python_web_applications.txt |
Q:
Reordering python list based on an algorithm or pattern
Here is a stumper for you math geeks out there.
I have a python list that is just a sequence that looks like this:
myList=[1,2,3,4,5,6,7,8,9,10,11,12,13,(...etc...),43]
Unfortunately, the data from which the list was generated was not zero-padded, and it s... | Reordering python list based on an algorithm or pattern | Here is a stumper for you math geeks out there.
I have a python list that is just a sequence that looks like this:
myList=[1,2,3,4,5,6,7,8,9,10,11,12,13,(...etc...),43]
Unfortunately, the data from which the list was generated was not zero-padded, and it should have been. So in reality:
1==1
2==10
3==11
4==12
5==13... | [
"Generate the list that contains the broken position, then look at the indices to find the new position.\nbrokenlist = sorted(range(1, 44), key=str)\nbrokenmap = [x[0] for x in sorted(enumerate(sorted(range(1, 44), key=str)), key=lambda x: x[1])]\nfixedlist = [brokenlist[x] for x in brokenmap]\n\n",
"I'm not quit... | [
5,
1,
0
] | [] | [] | [
"algorithm",
"list",
"math",
"python"
] | stackoverflow_0003971555_algorithm_list_math_python.txt |
Q:
How to optimize operations on large (75,000 items) sets of booleans in Python?
There's this script called svnmerge.py that I'm trying to tweak and optimize a bit. I'm completely new to Python though, so it's not easy.
The current problem seems to be related to a class called RevisionSet in the script. In essence w... | How to optimize operations on large (75,000 items) sets of booleans in Python? | There's this script called svnmerge.py that I'm trying to tweak and optimize a bit. I'm completely new to Python though, so it's not easy.
The current problem seems to be related to a class called RevisionSet in the script. In essence what it does is create a large hashtable(?) of integer-keyed boolean values. In the w... | [
"You could try doing it with numpy instead of plain python. I found it to be very fast for operations like these.\nFor example:\n# Create 1000000 numbers between 0 and 1000, takes 21ms\nx = numpy.random.randint(0, 1000, 1000000)\n\n# Get all items that are larger than 500, takes 2.58ms\ny = x > 500\n\n# Add 10 to t... | [
7,
1,
0,
0,
0
] | [] | [] | [
"large_data",
"optimization",
"python",
"python_2.6"
] | stackoverflow_0003967566_large_data_optimization_python_python_2.6.txt |
Q:
In Python, identify parts of an e-mail address
Given a list of e-mail addresses:
list = ('First Last <first@example.com>' , 'name@example.org')
some of which contain first and last name, others which just contain an e-mail address, how can I loop through the list and extract a first and last name (if they exist),... | In Python, identify parts of an e-mail address | Given a list of e-mail addresses:
list = ('First Last <first@example.com>' , 'name@example.org')
some of which contain first and last name, others which just contain an e-mail address, how can I loop through the list and extract a first and last name (if they exist), and the email address?
Thanks.
| [
"import email.utils\nmap(email.utils.parseaddr, email_list)\n\n"
] | [
9
] | [] | [] | [
"email",
"python"
] | stackoverflow_0003972128_email_python.txt |
Q:
Inheritance in Java
Consider the following code in Python:
class A(object):
CLASS_ATTRIBUTE = 42
def f(self):
return "CLASS_ATTRIBUTE: %d" % self.CLASS_ATTRIBUTE
class B(A):
CLASS_ATTRIBUTE = 44
Now A().f() and B().f() return "CLASS_ATTRIBUTE: 42" and "CLASS_ATTRIBUTE: 44" respectively.
How ... | Inheritance in Java | Consider the following code in Python:
class A(object):
CLASS_ATTRIBUTE = 42
def f(self):
return "CLASS_ATTRIBUTE: %d" % self.CLASS_ATTRIBUTE
class B(A):
CLASS_ATTRIBUTE = 44
Now A().f() and B().f() return "CLASS_ATTRIBUTE: 42" and "CLASS_ATTRIBUTE: 44" respectively.
How can I achieve a similar e... | [
"Short answer: you cant solve it like this in Java. You'll have to solve it in another way.\nIn Java you can't override or \"redeclare\" fields in subclasses, and you can't override static methods.\nIt can be solved using an ugly reflection-hack (should be avoided though):\npublic class Main {\n public static vo... | [
3,
3,
1,
0,
0
] | [] | [] | [
"inheritance",
"java",
"python"
] | stackoverflow_0003971765_inheritance_java_python.txt |
Q:
FK not populating in django form
I have a small question to ask the community. I am wondering why my foreign key will not show up when I go to my edit form. When I go to edit the information, all my data is populated except for status (which is a foreignkey that points from the status table to project table), wh... | FK not populating in django form | I have a small question to ask the community. I am wondering why my foreign key will not show up when I go to my edit form. When I go to edit the information, all my data is populated except for status (which is a foreignkey that points from the status table to project table), which is left with nothing selected. I ... | [
"I think this is because project is defined as a ForeignKey on status, and not the other way around. ForeignKey is a One-To-Many relationship. Each project can have multiple statuses connected to it.\nThat's why on the project instance you'll find: project.status_set and not project.status.\nYou'll need to add the ... | [
0
] | [] | [] | [
"django",
"django_forms",
"django_models",
"python"
] | stackoverflow_0003972236_django_django_forms_django_models_python.txt |
Q:
My dictionary has 9 items yet when iterating with for there are only eight
Here is my code:
trainingSet = {"0,0":0, "1,0":1, "2,0":1, "0,1":0, "1,1":1, "1,2":0, "2,0":0, "2,1":0, "2,2":1}
for k,expectedOutput in trainingSet.iteritems():
print 1
coordinates = k.split(",")
network.layers[0].neurons[0].v... | My dictionary has 9 items yet when iterating with for there are only eight | Here is my code:
trainingSet = {"0,0":0, "1,0":1, "2,0":1, "0,1":0, "1,1":1, "1,2":0, "2,0":0, "2,1":0, "2,2":1}
for k,expectedOutput in trainingSet.iteritems():
print 1
coordinates = k.split(",")
network.layers[0].neurons[0].value = float(coordinates[0])
network.layers[0].neurons[1].value = float(coor... | [
"You have the key \"2,0\" twice:\n... \"2,0\":1, \"0,1\":0, \"1,1\":1, \"1,2\":0, \"2,0\":0 ...\n ^^^ ^^^\n\nThe keys in a dictionary must be unique. If you want to have a key more than once with different values you need to use a different data structure. You could use for exam... | [
12
] | [] | [] | [
"python"
] | stackoverflow_0003972963_python.txt |
Q:
How to approach web app development?
I have been going through Flask and it seems that now I have a decent understanding to go ahead and build a web application. However I want to know how would I approach the problem. For eg:
I decide to build a blogging application. The first thing I do is write down all the th... | How to approach web app development? | I have been going through Flask and it seems that now I have a decent understanding to go ahead and build a web application. However I want to know how would I approach the problem. For eg:
I decide to build a blogging application. The first thing I do is write down all the things that come to my mind, from user regis... | [
"That all sounds like a lot of work. Try web2py. You get a lot of stuff, such as user registrations and updating data for a blog, for free. Then just write the code. web2py is not as freeform as flask, there is a \"one right way to do things\". But for beginners, that can be helpful until you have enough exper... | [
0
] | [] | [] | [
"python"
] | stackoverflow_0003966011_python.txt |
Q:
Sending queries to google using python
I need a code with which I can send queries to Google and get the results back for some processing. i am mostly interested in retrieving the snippets of the results. It would be nice if I can do this without installing any extra packages for Python. A pre-written api would al... | Sending queries to google using python | I need a code with which I can send queries to Google and get the results back for some processing. i am mostly interested in retrieving the snippets of the results. It would be nice if I can do this without installing any extra packages for Python. A pre-written api would also do the trick.
Thanks
| [
"A simple url based fetching technique using urllib2:\n\nWhy this request doesn't work?\n\nSee an example with google API\n\nhttp://code.google.com/apis/ajaxsearch/documentation/#fonje_snippets\nhttp://dcortesi.com/2008/05/28/google-ajax-search-api-example-python-code/\n\n"
] | [
2
] | [] | [] | [
"api",
"python",
"search"
] | stackoverflow_0003973095_api_python_search.txt |
Q:
I have a nested list in which I need to compare values
I have a list of lists composed of tuples representing blocks of military times:
[[(1405, 1525)],[(1405,1455),(1605,1655)],[(1505,1555),(1405,1455),(1305,1355)]]
I have a function to compare the times of two tuples:
def doesOverlap(tuple1, tuple2):
#tuples... | I have a nested list in which I need to compare values | I have a list of lists composed of tuples representing blocks of military times:
[[(1405, 1525)],[(1405,1455),(1605,1655)],[(1505,1555),(1405,1455),(1305,1355)]]
I have a function to compare the times of two tuples:
def doesOverlap(tuple1, tuple2):
#tuples each represent times for courses
#the 0 index for each ... | [
"Did try to understand the problem and try something.\nIt only prints if there is an overlap of time with successive data points.\nAlso I added assert to ensure that end is always greater than start, else data is erroneous.\nMade it verbose to just illustrate it well.\ndataPoints = [[(1405, 1525)],[(1405,1455),(160... | [
1,
0,
0
] | [] | [] | [
"iteration",
"python"
] | stackoverflow_0003972496_iteration_python.txt |
Q:
Multiple constructor with Python
I have a class A that can be generated from two different ways.
a = A(path_to_xml_file)
a = A(listA, listB)
The first method has file path as an input to parse from XML file to get listA, and listB. The second method is given two lists.
I can think of two ways to implement multip... | Multiple constructor with Python | I have a class A that can be generated from two different ways.
a = A(path_to_xml_file)
a = A(listA, listB)
The first method has file path as an input to parse from XML file to get listA, and listB. The second method is given two lists.
I can think of two ways to implement multiple constructor. What do you think? Wha... | [
"Make the constructor take the two lists. Write a factory classmethod that parses the XML and returns the object.\n",
"Use classmethod for second one\nclass A(object):\n @classmethod\n def from_string(cls, string):\n # ...\n\n @classmethod\n def from_lists(cls, list1, list2):\n # ...\n\n... | [
7,
3,
3,
2,
2
] | [] | [] | [
"constructor",
"python"
] | stackoverflow_0003972333_constructor_python.txt |
Q:
All possible paths from one node to another in a directed tree (igraph)
I use python binding to igraph to represent a directed tree. I would like to find all possible paths from one node in that graph to another one. Unfortunately, I couldn't find a ready to use function in igraph that performs this task?
EDIT
T... | All possible paths from one node to another in a directed tree (igraph) | I use python binding to igraph to represent a directed tree. I would like to find all possible paths from one node in that graph to another one. Unfortunately, I couldn't find a ready to use function in igraph that performs this task?
EDIT
The concerns on infinite number of paths
the graph I'm talking about is actual... | [
"You are looking for all paths between one node and another in a directed acyclic graph (DAG).\nA tree is always a DAG, but a DAG isn't always a tree. The difference is that a tree's branches are not allowed to join, only divide, while a DAG's branches can flow together, so long as no cycles are introduced.\nYour s... | [
18
] | [] | [] | [
"algorithm",
"directed_acyclic_graphs",
"igraph",
"python"
] | stackoverflow_0003971876_algorithm_directed_acyclic_graphs_igraph_python.txt |
Q:
using django-easy_thumbnails from view
easy_thumbnails is a big help when making models or views for thumbnails.
I am using the templatetag (via template, not via model) and easy_thumbnails creates sucessfully the thumbnail files.
what happen when I want to use easy_thumbnails via view, not model o templatetag (... | using django-easy_thumbnails from view | easy_thumbnails is a big help when making models or views for thumbnails.
I am using the templatetag (via template, not via model) and easy_thumbnails creates sucessfully the thumbnail files.
what happen when I want to use easy_thumbnails via view, not model o templatetag (the rendering of the images is via ajax, and... | [
"I'm not sure what you're asking about, but README file from easy_thumbnails should cover your use case. \nAnd if for some reason it doesn't and you want to use {% thumbnail %} tag directly in a view, then you can always render_to_string a template that contains just: {% thumbnail %} tag, although this looks to me ... | [
1
] | [] | [] | [
"django",
"django_apps",
"python"
] | stackoverflow_0003973166_django_django_apps_python.txt |
Q:
Django - Need some guidance on how to implement a ManyToMany database
I want the ability to let users indicate what countries they have visited.. my models.py looks something like this:
class User(models.Model):
name = models.CharField(max_length=50)
countries = models.ManyToManyField(Countries)
class... | Django - Need some guidance on how to implement a ManyToMany database | I want the ability to let users indicate what countries they have visited.. my models.py looks something like this:
class User(models.Model):
name = models.CharField(max_length=50)
countries = models.ManyToManyField(Countries)
class Countries(models.Model):
#This is where I don't know what to do.
... | [
"You would create the relationship the other way around\n class User(models.Model):\n name = models.CharField(max_length=50)\n\n class Countries(models.Model):\n user = models.ForeignKey(User)\n\nIf you are using django's built in User stuff then you only need this.\nfrom django.contrib.auth.models import U... | [
2,
1,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0003973408_django_django_models_python.txt |
Q:
Is it possible to determine which class a function is a method of?
For example, if I'm decorating a method like so
def my_decorator(fn):
# Do something based on the class that fn is a method of
def decorated_fn(*args, **kwargs):
fn(*args, **kwargs)
return decorated_fn
class MyClass(object):... | Is it possible to determine which class a function is a method of? | For example, if I'm decorating a method like so
def my_decorator(fn):
# Do something based on the class that fn is a method of
def decorated_fn(*args, **kwargs):
fn(*args, **kwargs)
return decorated_fn
class MyClass(object):
@my_decorator
def my_method(self, param):
print "foo"
... | [
"Short answer: No.\nLonger answer: You can do it by mucking about in the stack trace (see the inspect module) but it's not a great idea.\nFull answer: At the time the function gets decorated, it's still an unbound function. Try the following:\ndef my_dec(fn):\n print dir(fn) # Has \"func_code\" and \"func_name\... | [
3,
1
] | [] | [] | [
"introspection",
"methods",
"python"
] | stackoverflow_0003973496_introspection_methods_python.txt |
Q:
Yet another list comprehension question
I had this:
if Setting["Language"] == "en":
f.m_radioBox3.SetSelection(0)
elif Setting["Language"] == "pt":
f.m_radioBox3.SetSelection(1)
elif Setting["Language"] == "fr":
f.m_radioBox3.SetSelection(2)
elif Setting["Language"] == "es":... | Yet another list comprehension question | I had this:
if Setting["Language"] == "en":
f.m_radioBox3.SetSelection(0)
elif Setting["Language"] == "pt":
f.m_radioBox3.SetSelection(1)
elif Setting["Language"] == "fr":
f.m_radioBox3.SetSelection(2)
elif Setting["Language"] == "es":
f.m_radioBox3.SetSelection(3)
Then ... | [
"mapping = {\"en\" : 0, \"pt\" : 1, \"fr\" : 2, \"es\" : 3}\nif Setting[\"Language\"] in mapping:\n f.m_radioBox3.SetSelection(mapping[Setting[\"Language\"]])\n\nIf you don't need to check for the setting being one of an acceptable number of values, it becomes:\nmapping = {\"en\" : 0, \"pt\" : 1, \"fr\" : 2, \"e... | [
3,
3
] | [] | [] | [
"list_comprehension",
"python"
] | stackoverflow_0003973873_list_comprehension_python.txt |
Q:
Is Paramiko going to be ported over to Python 3.x?
Seems to be that PyCrypt is required to be ported, in order to make that happen. Is it hard to do yourself?
A:
You can try using 2to3, which comes with Python 2.7, to convert the source of projects to Python 3 compliant code. Then, just run some tests on the pa... | Is Paramiko going to be ported over to Python 3.x? | Seems to be that PyCrypt is required to be ported, in order to make that happen. Is it hard to do yourself?
| [
"You can try using 2to3, which comes with Python 2.7, to convert the source of projects to Python 3 compliant code. Then, just run some tests on the packages you converted and see if they work.\nMost of the major work will be done by 2to3, and after that you can make fine-tuned adjustments if you need to to make ev... | [
3
] | [] | [] | [
"paramiko",
"python",
"python_3.x",
"ssh"
] | stackoverflow_0003973947_paramiko_python_python_3.x_ssh.txt |
Q:
Could a bored AWK master kindly convert this Python program?
I love Python but do not really care for AWK. For purposes of comparison (and to see how a Python-to-AWK master would do this), could someone rewrite the following Python program in AWK? Considering how short it is, some would think that the rewrite woul... | Could a bored AWK master kindly convert this Python program? | I love Python but do not really care for AWK. For purposes of comparison (and to see how a Python-to-AWK master would do this), could someone rewrite the following Python program in AWK? Considering how short it is, some would think that the rewrite would be simple and easy for anyone with a little time.
import os
ROO... | [
"Why awk?\nThis looks like a simple grep command to me; something like:\negrep -w '628251|173511|223401|138276|673278|698450|629138|449040|901575' /Users/Zero/Documents/MyProgram.app/Contents/TempFiles/*.log*\n\n\nupdate: or use find+grep, as suggested in some of the comments, if a recursive search is intended\n",
... | [
6,
4
] | [] | [] | [
"awk",
"comparison",
"lazy_evaluation",
"python"
] | stackoverflow_0003974142_awk_comparison_lazy_evaluation_python.txt |
Q:
SHA-256 password generator
i saw a javascript implementation of sha-256.
i waana ask if it is safe (pros/cons wathever) to use sha-256 (using javascript implementation or maybe python standard modules) alogrithm as a password generator:
i remember one password, put it in followed(etc) by the website address and us... | SHA-256 password generator | i saw a javascript implementation of sha-256.
i waana ask if it is safe (pros/cons wathever) to use sha-256 (using javascript implementation or maybe python standard modules) alogrithm as a password generator:
i remember one password, put it in followed(etc) by the website address and use the generated text as the pass... | [
"I think you are describing the approach used by SuperGenPass:\nTake a master password (same for every site), concatenate it with the site's domain name, and then hash the thing.\nYes, SHA-256 would be secure for that, likely more secure than when SuperGenPass uses. However, you will end up with very long passwords... | [
1,
0
] | [] | [] | [
"javascript",
"python",
"sha256"
] | stackoverflow_0003974211_javascript_python_sha256.txt |
Q:
django compressor and clevercss with absolute url paths
When using django, compressor, and clevercss, I set my css url to an absolute path. Clevercss is then passed the path of the .ccss file without the COMPRESS_ROOT prefixed (the absolute path). When I set my css url to a relative path, clevercss processes the c... | django compressor and clevercss with absolute url paths | When using django, compressor, and clevercss, I set my css url to an absolute path. Clevercss is then passed the path of the .ccss file without the COMPRESS_ROOT prefixed (the absolute path). When I set my css url to a relative path, clevercss processes the ccss files, but the browser then correctly looks for relativel... | [
"I can't speak to django-compressor specifically; but I have been dealing with finding a good automatic compression solution for the CSS and JS files of my Django-powered web applications. I'm currently using django-static. It's been really easy to set up and use, IMO. I was running into some issues running django-... | [
2
] | [] | [] | [
"clevercss",
"css",
"django",
"django_compressor",
"python"
] | stackoverflow_0003849835_clevercss_css_django_django_compressor_python.txt |
Q:
Polymorphism in Python
class File(object):
def __init__(self, filename):
if os.path.isfile(filename):
self.filename = filename
self.file = open(filename, 'rb')
self.__read()
else:
raise Exception('...')
def __read(self):
raise NotImpl... | Polymorphism in Python | class File(object):
def __init__(self, filename):
if os.path.isfile(filename):
self.filename = filename
self.file = open(filename, 'rb')
self.__read()
else:
raise Exception('...')
def __read(self):
raise NotImplementedError('Abstract metho... | [
"Prefixing an attribute with double underscores doesn't make the attribute private, it simply makes polymorphism impossible because the attribute name gets mangled with the current class name. Change it to a single underscore prefix instead.\n",
"You can also leave the method undefined in the base class to achiev... | [
7,
1
] | [] | [] | [
"methods",
"polymorphism",
"python"
] | stackoverflow_0003964929_methods_polymorphism_python.txt |
Q:
String splitting issue problem with multiword expressions
I have a series of strings like:
'i would like a blood orange'
I also have a list of strings like:
["blood orange", "loan shark"]
Operating on the string, I want the following list:
["i", "would", "like", "a", "blood orange"]
What is the best way to get ... | String splitting issue problem with multiword expressions | I have a series of strings like:
'i would like a blood orange'
I also have a list of strings like:
["blood orange", "loan shark"]
Operating on the string, I want the following list:
["i", "would", "like", "a", "blood orange"]
What is the best way to get the above list? I've been using re throughout my code, but I'm ... | [
"This is a fairly straightforward generator implementation: split the string into words, group together words which form phrases, and yield the results.\n(There may be a cleaner way to handle skip, but for some reason I'm drawing a blank.)\ndef split_with_phrases(sentence, phrase_list):\n words = sentence.split(... | [
4,
1,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0003974363_python_regex.txt |
Q:
Getting unique value when the same tag is in children's tree in XML with Python
I have getElementText as follows which works pretty well with [0] as the XML that I'm working on doesn't have the duplicate tag.
from xml.dom import minidom
def getElementText(element, tagName):
return str(element.getElementsByTa... | Getting unique value when the same tag is in children's tree in XML with Python | I have getElementText as follows which works pretty well with [0] as the XML that I'm working on doesn't have the duplicate tag.
from xml.dom import minidom
def getElementText(element, tagName):
return str(element.getElementsByTagName(tagName)[0].firstChild.data)
doc = minidom.parse("/Users/smcho/Desktop/hello.x... | [
"If lxml is an option (it's much nicer than minidomyou) can do:\nfrom lxml import etree\n\ndoc = etree.fromstring(xml)\n\nnode = doc.find('Number')\nprint node.text # 0\n\nnode = doc.xpath('//ConnectedTerminal/Number')[0]\nprint node.text # 1\n\nAlso see the xpath tutorial.\n",
"There's not a direct DOM method to... | [
3,
0
] | [] | [] | [
"python",
"xml"
] | stackoverflow_0003974464_python_xml.txt |
Q:
How do I pass/catch/respond to Python's KeyboardInterrupt in C++?
I have a simple library written in C++ which I'm creating a Python wrapper for using boost.python. Some functions take a long time to execute (over 30 seconds), and I would like to make it interruptible so that when I hit ctrl-d to trigger KeyboardI... | How do I pass/catch/respond to Python's KeyboardInterrupt in C++? | I have a simple library written in C++ which I'm creating a Python wrapper for using boost.python. Some functions take a long time to execute (over 30 seconds), and I would like to make it interruptible so that when I hit ctrl-d to trigger KeyboardInterrupt in the python interpreter, I'm somehow able to respond to that... | [
"Call PyErr_CheckSignals() every so often.\n"
] | [
5
] | [] | [] | [
"boost_python",
"c++",
"interrupt",
"python"
] | stackoverflow_0003974646_boost_python_c++_interrupt_python.txt |
Q:
How can I convert SQLite 2 to SQLite3 using Python on Windows?
I'm trying to convert a SQLite 2 file to SQLite3 using Python on Windows. On Linux, I'd just pipe a dump from sqlite to sqlite3:
os.system("sqlite db.sqlite .dump | sqlite3 db3.sqlite")
On Windows, I have no such convenient means of transferring the ... | How can I convert SQLite 2 to SQLite3 using Python on Windows? | I'm trying to convert a SQLite 2 file to SQLite3 using Python on Windows. On Linux, I'd just pipe a dump from sqlite to sqlite3:
os.system("sqlite db.sqlite .dump | sqlite3 db3.sqlite")
On Windows, I have no such convenient means of transferring the dump. Here's what I'm doing:
sqlite_dump = os.popen('sqlite %s .dum... | [
"Why can't you pipe it similarly on Windows? What goes wrong when you do it?\n"
] | [
3
] | [] | [] | [
"python",
"sqlite",
"sqlite2",
"windows"
] | stackoverflow_0003974692_python_sqlite_sqlite2_windows.txt |
Q:
Python: How to generate the code on the fly?
I've got a problem, I have to generate program on the fly and then execute it.
How could we do this?
A:
You can use the eval() function to execute code from a string
An example would be:
import math
test=r"dir(math)"
eval(test)
Output
['__doc__', '__name__', '__pa... | Python: How to generate the code on the fly? | I've got a problem, I have to generate program on the fly and then execute it.
How could we do this?
| [
"You can use the eval() function to execute code from a string \nAn example would be:\nimport math\n\ntest=r\"dir(math)\"\n\neval(test)\n\nOutput\n['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'exp', 'fabs', 'fac... | [
8,
4,
3,
2
] | [] | [] | [
"python"
] | stackoverflow_0003974554_python.txt |
Q:
How to enumerate unique paths reaching top right (h8) square starting from bottom left (a1) square of a chess board given some move rules?
I was asked a few weeks ago, to find all the different and unique ways to reach the top right of a chess board, with x, y > 3, starting from (0, 0), knowing that you can only i... | How to enumerate unique paths reaching top right (h8) square starting from bottom left (a1) square of a chess board given some move rules? | I was asked a few weeks ago, to find all the different and unique ways to reach the top right of a chess board, with x, y > 3, starting from (0, 0), knowing that you can only increase x and y by +1.
I still haven't been able to find algorithms that would explain how to navigate over a chessboard, so I was wondering if ... | [
"I'd suggest you look into depth-first search and breadth-first search. Your search is successful when x & y are both greater than 3, and each successful search path down the tree would be a valid path.\n",
"Yes, as was mentioned by Bryan, use DFS.\nIn this case, you don't need to keep a stack to record the ways ... | [
2,
1,
1,
0
] | [] | [] | [
"algorithm",
"python"
] | stackoverflow_0003929268_algorithm_python.txt |
Q:
Why can't python infer types like scala?
Possible Duplicate:
How to deal with Python ~ static typing?
I'm basically a Java programmer with little knowledge of python.I really like the syntax of python and the ease with which a programmer is able to express his idea's but also I'm aware that python is dynamically... | Why can't python infer types like scala? |
Possible Duplicate:
How to deal with Python ~ static typing?
I'm basically a Java programmer with little knowledge of python.I really like the syntax of python and the ease with which a programmer is able to express his idea's but also I'm aware that python is dynamically typed and thus is not as fast as Java.My que... | [
"It is not that Python can't, but it doesn't. The difference is in the type systems that the designers of the languages choose to follow.\nPython uses duck typing and has typed objects but untyped variable names. Type constraints are not checked at compile time; rather, operations on an object may fail, signifying ... | [
27,
3
] | [
"Python is dynamically-typed, whereas type inference is only possible in statically typed languages. Static typing would be impossible to implement without dropping support for features such as lists of arbitrary objects.\n"
] | [
-2
] | [
"python",
"type_inference"
] | stackoverflow_0003975422_python_type_inference.txt |
Q:
Can I gzip JavaScript and CSS files in Django?
I tried profiling my web application and one of the bottlenecks reported was the lack of gzip compression. I proceeded to install the gzip middleware in Django and got a bit of a boost but a new report shows that it is only gzipping the HTML files i.e. any content pro... | Can I gzip JavaScript and CSS files in Django? | I tried profiling my web application and one of the bottlenecks reported was the lack of gzip compression. I proceeded to install the gzip middleware in Django and got a bit of a boost but a new report shows that it is only gzipping the HTML files i.e. any content processed by Django. Is there a way I could kludge/hack... | [
"Your CSS and JS should not be going through Django on your production system. You need to configure Apache (or Nginx, or whatever) to serve these, and when you do so you'll be able to set up gzip compression there, rather than in Django.\nAnd no, compressing and minifying are not the same thing. GZip compression i... | [
16,
4,
2,
2
] | [] | [] | [
"compression",
"django",
"gzip",
"python",
"static_files"
] | stackoverflow_0003968650_compression_django_gzip_python_static_files.txt |
Q:
How to update mongodb collections
My collection structure is:
col1 = {'class':'12', 'roll':[1, 2, 3, 4]}
Now, I want to update the collection col1 to
col1 = {'class':'12', 'roll':[1, 2, 3, 4, 5]}
I added another roll number here, How to update this collection in pymongo.
A:
db.col1.update( { class : 12}, { $... | How to update mongodb collections | My collection structure is:
col1 = {'class':'12', 'roll':[1, 2, 3, 4]}
Now, I want to update the collection col1 to
col1 = {'class':'12', 'roll':[1, 2, 3, 4, 5]}
I added another roll number here, How to update this collection in pymongo.
| [
" db.col1.update( { class : 12}, { $push : { roll : 5 } } )\n\n"
] | [
3
] | [] | [] | [
"mongodb",
"pymongo",
"python"
] | stackoverflow_0003976070_mongodb_pymongo_python.txt |
Q:
How many times different letters appear in different words?
How to know how many times strings s , t and n appear in each of the following words to have an output like this:
descriptions: s 2 , t 1 , n 1
statements s 2 , t 3 , n 1
The words are not known in advance.The first thing came to my mind was to make a d... | How many times different letters appear in different words? | How to know how many times strings s , t and n appear in each of the following words to have an output like this:
descriptions: s 2 , t 1 , n 1
statements s 2 , t 3 , n 1
The words are not known in advance.The first thing came to my mind was to make a dictionary, but for dictionaries we can only have two unknowns, so... | [
"In Python ≥2.7 and ≥3.1 you could use collections.Counter.\n>>> from collections import Counter\n>>> Counter(\"descriptions\")\nCounter({'i': 2, 's': 2, 'c': 1, 'e': 1, 'd': 1, 'o': 1, 'n': 1, 'p': 1, 'r': 1, 't': 1})\n\n(For Python ≥2.5 there is an implementation in http://code.activestate.com/recipes/576611/.)\n... | [
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0003976401_python.txt |
Q:
How to make this random text generator more efficient in Python?
I'm working on a random text generator -without using Markov chains- and currently it works without too many problems. Firstly, here is my code flow:
Enter a sentence as input -this is called trigger string, is assigned to a variable-
Get longest wo... | How to make this random text generator more efficient in Python? | I'm working on a random text generator -without using Markov chains- and currently it works without too many problems. Firstly, here is my code flow:
Enter a sentence as input -this is called trigger string, is assigned to a variable-
Get longest word in trigger string
Search all Project Gutenberg database for sentenc... | [
"Some suggested improvements:\n\nThe while loop will run forever, you should probably remove it.\nUse max and generator expressions to generate the longest word in a memory-efficient manner.\nYou should generate a list of sentences with a length greater than 40 characters that include longestWord with a list compre... | [
1,
1
] | [] | [] | [
"nltk",
"python",
"random",
"text",
"word"
] | stackoverflow_0003595877_nltk_python_random_text_word.txt |
Q:
Python urllib2.urlopen bug: timeout error brings down my Internet connection?
I don't know if I'm doing something wrong, but I'm 100% sure it's the python script brings down my Internet connection.
I wrote a python script to scrape thousands of files header info, mainly for Content-Length to get the exact size of ... | Python urllib2.urlopen bug: timeout error brings down my Internet connection? | I don't know if I'm doing something wrong, but I'm 100% sure it's the python script brings down my Internet connection.
I wrote a python script to scrape thousands of files header info, mainly for Content-Length to get the exact size of each file, using HEAD request.
Sample code:
class HeadRequest(urllib2.Request):
... | [
"I'd guess that either your ISP or VPN provider is limiting you because of high-volume suspicious traffic, or your router or VPN tunnel is getting clogged up with half-open connections. Consumer internet is REALLY not intended for spider-type activities. \n",
"\n\"the script starts to throw out urlopen error time... | [
0,
0
] | [] | [] | [
"python",
"urllib2",
"urlopen"
] | stackoverflow_0003974452_python_urllib2_urlopen.txt |
Q:
CSVWriter not saving data to file the moment I write it
Python newbie getting a bit frustrated with the csv module. At this rate, it would have been easier if I wrote the file parser myself, but I want to do things the Pythonic way ....
I have written a little python script that should save my data into a CSV file... | CSVWriter not saving data to file the moment I write it | Python newbie getting a bit frustrated with the csv module. At this rate, it would have been easier if I wrote the file parser myself, but I want to do things the Pythonic way ....
I have written a little python script that should save my data into a CSV file.
Here is a snippet of my code:
import csv
wrtr = csv.writer... | [
"Use\nwith open('myfile.csv','wb') as myfile:\n wrtr = csv.writer(myfile, delimiter=',', quotechar='\"')\n for row in rows:\n wrtr.writerow([row.field1,row.field2,row.field3])\n myfile.flush() # whenever you want\n\nor \nmyfile = open('myfile.csv','wb')\nwrtr = csv.writer(myfile, delimiter=',', ... | [
100,
9
] | [] | [] | [
"csv",
"python"
] | stackoverflow_0003976711_csv_python.txt |
Q:
App Engine Version, Memcache
I am developing an App Engine App that uses memcache. Since there is only a single memcache shared among all versions of your app I am potentially sending bad data from a new version to the production version memcache. To prevent this, I think I may append the app version to the memc... | App Engine Version, Memcache | I am developing an App Engine App that uses memcache. Since there is only a single memcache shared among all versions of your app I am potentially sending bad data from a new version to the production version memcache. To prevent this, I think I may append the app version to the memcache key string to allow various v... | [
"The os.environ variable contains a key called CURRENT_VERSION_ID that you can use. It's value is composed of the version from app.yaml concatenated together with a period and what I suspect is the api_version. If I set version to 42 it gives me the value of 42.1. You should have no problems extracting the version ... | [
12
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0003976772_google_app_engine_python.txt |
Q:
Efficiently computing size of filtered list
I would like to efficiently compute the size of a filtered list, i.e., I don't want to keep the whole filtered list in memory, I just want to get its size. Is there a more "pythonic" way than computing the size using a for-loop?
For example:
my_list = [1,2,3,4]
# this l... | Efficiently computing size of filtered list | I would like to efficiently compute the size of a filtered list, i.e., I don't want to keep the whole filtered list in memory, I just want to get its size. Is there a more "pythonic" way than computing the size using a for-loop?
For example:
my_list = [1,2,3,4]
# this loads the entire **filtered** list in memory
size_... | [
"size_of_filtered_list = sum(1 for item in my_list if item % 2 == 0)\n\n",
"size_of_filtered_list = sum(item%2==0 for item in my_list)\n\n"
] | [
6,
2
] | [] | [] | [
"list_comprehension",
"python"
] | stackoverflow_0003976795_list_comprehension_python.txt |
Q:
Python imports-Need someone to check this please
Ok yes it is a very silly question, but just that I am getting a little confused.
I have a file structure which looks like this:-
-Mainapplication
-models.py
-Helpingmodules
-Folder1
-module1.py
Now I have to import models into module1. So in module1.py ... | Python imports-Need someone to check this please | Ok yes it is a very silly question, but just that I am getting a little confused.
I have a file structure which looks like this:-
-Mainapplication
-models.py
-Helpingmodules
-Folder1
-module1.py
Now I have to import models into module1. So in module1.py I just did:-
from Mainapplication import models
Now ... | [
"There's nothing wrong with the import, but if the names of your packages are accurate, this looks like a design flaw in that you're destroying code reusability; I'd expect a package of \"helping modules\" to be independent of the application they're helping (although in the case the package name is so vague that I... | [
2,
1
] | [] | [] | [
"import",
"python"
] | stackoverflow_0003976952_import_python.txt |
Q:
Django model instance specific code
in one of my Django models I have to add specific code for each model instance. Now, I wonder what would be a good way to implement this. My current attempt results in a big, hard to read if statement.
Consider the following model:
class Foo(models.Model):
name = models.Char... | Django model instance specific code | in one of my Django models I have to add specific code for each model instance. Now, I wonder what would be a good way to implement this. My current attempt results in a big, hard to read if statement.
Consider the following model:
class Foo(models.Model):
name = models.CharField(max_length=255)
def do_instanc... | [
"I would add another field to your model, vendor. Then add per-vendor methods to your model, and invoke them with getattr:\nclass Foo(models.Model):\n name = models.CharField(max_length=255)\n vendor = models.CharField(max_length=50)\n\n def vendor_fedex(self, arg):\n blah blah\n\n def vendor_up... | [
3,
1
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0003975909_django_django_models_python.txt |
Q:
Python: Executing an application to install a program
I am using a python script to execute an application to install a program. Using os.system('dir\\application.exe') works. However the installer has 2 installation parts and after completing the first one, it will hang there. The second one will only execute wh... | Python: Executing an application to install a program | I am using a python script to execute an application to install a program. Using os.system('dir\\application.exe') works. However the installer has 2 installation parts and after completing the first one, it will hang there. The second one will only execute when I exit the python script. How can I get the whole instal... | [
"from what you provided it is not clear why the installer is hanging. I've ran installers here and it works fine. Which installer are you running? Is it public available?\nAs a sidenote, don't use os.system to run your application. It needlessy invokes the shell -- use subprocess module instead:\nsubprocess.call(['... | [
0
] | [] | [] | [
"python",
"windows_installer",
"windows_xp"
] | stackoverflow_0003976530_python_windows_installer_windows_xp.txt |
Q:
Buttons in vizard
I am developing a GUI in Vizard in which i am using radio buttons to select correct options, but I have a problem that I cannot solve.
In every group of radio buttons the 1st button always appears to be selected, but is actually not selected. The only way to select it is by choosing another butto... | Buttons in vizard | I am developing a GUI in Vizard in which i am using radio buttons to select correct options, but I have a problem that I cannot solve.
In every group of radio buttons the 1st button always appears to be selected, but is actually not selected. The only way to select it is by choosing another button and then choosing the... | [
"I don't know Vizard but radio buttons probably have a method or another way of deselecting them similar to radiobutton.deselect() method of Tkinter. Have you looked at their documentation?\nAlso someone have done this trick, may be you should try it:\nCreate another radio button in that group, let it be selected b... | [
2
] | [] | [] | [
"python",
"radio_button",
"vizard"
] | stackoverflow_0003977007_python_radio_button_vizard.txt |
Q:
Time actions in Python
I want to run a part of my loop for a certain time: 60 seconds. Afterwards I set a boolean flag and continue at another point. Does Python have something like a stopwatch? Maybe this is OS specific: it's targeted against a Linux env.
Sleeping a couple of seconds is easy... no question. ;) I ... | Time actions in Python | I want to run a part of my loop for a certain time: 60 seconds. Afterwards I set a boolean flag and continue at another point. Does Python have something like a stopwatch? Maybe this is OS specific: it's targeted against a Linux env.
Sleeping a couple of seconds is easy... no question. ;) I want the opposite.
| [
"You could use the time.time() method:\nimport time\nendtime = time.time() + 60\nwhile time.time() < endtime:\n # do something\n\nNote - you probably don't want to use time.clock() as this measures CPU time rather than wall time.\n",
"You could use time.time() to set the begin of the loop, and later check if t... | [
2,
0
] | [] | [] | [
"python",
"timer"
] | stackoverflow_0003977272_python_timer.txt |
Q:
Eliminating duplicates - shall I use a set?
I need to read through a log file, extracting all paths, and return a sorted list of the paths containing no duplicates. What's the best way to do it? Using a set?
I thought about something like this:
def geturls(filename)
f = open(filename)
s = set() # creates an em... | Eliminating duplicates - shall I use a set? | I need to read through a log file, extracting all paths, and return a sorted list of the paths containing no duplicates. What's the best way to do it? Using a set?
I thought about something like this:
def geturls(filename)
f = open(filename)
s = set() # creates an empty set?
for line in f:
# see if the line ... | [
"def sorted_paths(filename):\n with open(filename) as f:\n gen = (matches(line) for line in f)\n s = set(match.group(1) for match in gen if match)\n return sorted(s)\n\n",
"This is a good way of doing it, both in terms of performance and in terms of conciseness.\n",
"Only if the order doesn't ... | [
4,
3,
2,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0003977128_python.txt |
Q:
Sorting a dictionary (with date keys) in Python
I have a dictionary. The keys are dates (datetime). I need to sort the dictionary so that the values in the dictionary are sorted by date - so that by iterating through the dictionary, I am processing items in the desired chronological (i.e. date/time) order.
How may... | Sorting a dictionary (with date keys) in Python | I have a dictionary. The keys are dates (datetime). I need to sort the dictionary so that the values in the dictionary are sorted by date - so that by iterating through the dictionary, I am processing items in the desired chronological (i.e. date/time) order.
How may I sort such a dictionary by date?
Example:
mydict = ... | [
"If you're using Python 2.7+ or 3.1+ you could create an OrderedDict from collections from a sort of your dictionary and then iterate through that.\nfrom collections import OrderedDict\n\nordered = OrderedDict(sorted(mydict.items(), key=lambda t: t[0]))\n\nHowever, depending on what you want to do it's probably eas... | [
22,
6,
5,
2,
0,
0
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0003977310_dictionary_python.txt |
Q:
Python: num to bytes
I want to have a byte representation of some numbers. For example, a byte array whose first byte has a meaning (0-255), the second byte another (0-255) and so on. Since string are byte arrays i can easily represent it as "aB" if I want to store 97 and 66.
Now, if i want the third and forth byt... | Python: num to bytes | I want to have a byte representation of some numbers. For example, a byte array whose first byte has a meaning (0-255), the second byte another (0-255) and so on. Since string are byte arrays i can easily represent it as "aB" if I want to store 97 and 66.
Now, if i want the third and forth bytes to represent a number b... | [
"You want struct.\n>>> import struct\n>>> struct.pack('<HBB', 12345, 97, 66)\n'90aB'\n\n",
"(You'll have a bit of difficulty if you want to represent 0-65536, so I'll assume you meant 0-65535.)\nSimply store x>>8 in the one byte, and x&0xff in the other byte. You can also use Python's struct module to pack differ... | [
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0003977403_python.txt |
Q:
What are the benefits of using Elixir
... vs declarative sqlalchemy ?
A:
I have started a list here on practical (technical) differences / advantages of elixir vs. sqlalchmey, but I don't know if my claims are right because my knowledge about sqlalchemy is very restricted (I use a very small portion of elixir an... | What are the benefits of using Elixir | ... vs declarative sqlalchemy ?
| [
"I have started a list here on practical (technical) differences / advantages of elixir vs. sqlalchmey, but I don't know if my claims are right because my knowledge about sqlalchemy is very restricted (I use a very small portion of elixir and sqla).\nIt would be very proof-wise that answers show a code example in s... | [
5,
2,
1
] | [] | [] | [
"python",
"python_elixir",
"sqlalchemy"
] | stackoverflow_0003957938_python_python_elixir_sqlalchemy.txt |
Q:
Translate Java to Python -- signing strings with PEM certificate files
I'm trying to translate the follow Java into its Python equivalent.
// certificate is contents of https://fps.sandbox.amazonaws.com/certs/090909/PKICert.pem
// signature is a string that I need to verify.
CertificateFactory factory = Certifi... | Translate Java to Python -- signing strings with PEM certificate files | I'm trying to translate the follow Java into its Python equivalent.
// certificate is contents of https://fps.sandbox.amazonaws.com/certs/090909/PKICert.pem
// signature is a string that I need to verify.
CertificateFactory factory = CertificateFactory.getInstance("X.509");
X509Certificate x509Certificate =
... | [
"I looked into doing this with pyCrypto and keyczar but the problem is neither have the ability to parse X509 certificates (keyczar has keyczar.util.ParseX509() but it is limited and doesn't work for the AWS cert or I'm guessing any real world cert).\nI believe M2Crypto works though. See the following code snippet,... | [
2,
0,
0
] | [] | [] | [
"frame_rate",
"java",
"pem",
"python",
"x509certificate"
] | stackoverflow_0002642451_frame_rate_java_pem_python_x509certificate.txt |
Q:
import media does not work in Python
I am reading a book about python. There is a sample. The first line is:
import media
I am trying to do the same, but the error like below
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import media
ImportError: No module named media
I want to... | import media does not work in Python | I am reading a book about python. There is a sample. The first line is:
import media
I am trying to do the same, but the error like below
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import media
ImportError: No module named media
I want to know, is the media a default library?
Bes... | [
"Looks like you're using this book (mentioning it specifically would have made it easier to identify than just saying \"a book\", BTW;-). Per this thread, you need to install some modules as documented here, and possibly the pygraphics package. Doesn't the book itself explain that, in an introduction or maybe in ... | [
4,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0003126503_python.txt |
Q:
tuple inside list for finding values
I am list of tuple as:
mylist = [ (user1, 23, 32), (user1, 23, 34), (user3, 34, 34), (user2, 34, 45), (user1, 45,23),(user2, 56, 56), (user5, 4,4)]
I need to find out average time for each user.
My problem is I dont know how many user are there and values.
So i cannot do
for ... | tuple inside list for finding values | I am list of tuple as:
mylist = [ (user1, 23, 32), (user1, 23, 34), (user3, 34, 34), (user2, 34, 45), (user1, 45,23),(user2, 56, 56), (user5, 4,4)]
I need to find out average time for each user.
My problem is I dont know how many user are there and values.
So i cannot do
for item in mylist:
if item[0] == 'user1':... | [
">>> from collections import defaultdict \n>>> d = defaultdict(list)\n>>> for user, *items in mylist:\n d[user] += items,\n\n\n>>> d\ndefaultdict(<class 'list'>, {'user5': [[4, 4]], 'user2': [[34, 45], [56, 56]], 'user3': [[34, 34]], 'user1': [[23, 32], [23, 34], [45, 23]]})\n\n",
"You obviously need a dict... | [
4,
2,
0,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0003977635_python.txt |
Q:
How to add data to the end of a CSV file (Python)
I need to be able to periodically add data to the end of a CSV file. Ideally, I would like to do this without reading the entire file into memory.
Is there a way where I can append data to the end of a file?. One solution that occured to me was to simply shell a pi... | How to add data to the end of a CSV file (Python) | I need to be able to periodically add data to the end of a CSV file. Ideally, I would like to do this without reading the entire file into memory.
Is there a way where I can append data to the end of a file?. One solution that occured to me was to simply shell a pipe command from Python, but that seemed too much of an ... | [
"Actually, there are two approaches. First, you can just open(filename, 'ab'), which will open the file for appending in binary mode. The second is using seek:\nimport os\nmy_file = open(\"data.csv\", \"ab\")\nmy_file.seek(0, os.SEEK_END)\n\n(I threw that second one in there mainly so I wasn't just ripping off S. L... | [
2
] | [] | [] | [
"csv",
"python"
] | stackoverflow_0003977365_csv_python.txt |
Q:
google checkout with appengine
I am trying to get my website to have a simple checkout flow where the person is able to create an account and pay for the product. I want to record this in the datastore so that the account gets created only when the payment has gone through and the person should be able to get back... | google checkout with appengine | I am trying to get my website to have a simple checkout flow where the person is able to create an account and pay for the product. I want to record this in the datastore so that the account gets created only when the payment has gone through and the person should be able to get back to the profile/personal page once d... | [
"We based our version on the google checkout from this project http://code.google.com/p/chippysshop/\nthere is a listener and it creates the order when it receives a confirmation back from Google\nworks fine for us.\n"
] | [
2
] | [] | [] | [
"google_app_engine",
"google_checkout",
"python"
] | stackoverflow_0003947492_google_app_engine_google_checkout_python.txt |
Q:
Redirect RuntimeError to log instead of console in wxPython?
How do I redirect RuntimeError to log instead of the console?
In the code below, the 'Hello' is printed to console, which is redirected to the wx.TextCtrl. The RuntimeError raised OnClose is printed to the terminal however. How do I redirect the RuntimeE... | Redirect RuntimeError to log instead of console in wxPython? | How do I redirect RuntimeError to log instead of the console?
In the code below, the 'Hello' is printed to console, which is redirected to the wx.TextCtrl. The RuntimeError raised OnClose is printed to the terminal however. How do I redirect the RuntimeError to see same log as the 'Hello'?
import sys
import wx
class R... | [
"I'd assume you just have to assign your log to sys.stderr.\n"
] | [
0
] | [] | [] | [
"python",
"redirect",
"runtime_error",
"wxpython"
] | stackoverflow_0003977902_python_redirect_runtime_error_wxpython.txt |
Q:
Python command isn't reading a .txt file
Trying to follow the guide here, but it's not working as expected. I'm sure I'm missing something.
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files
file = open("C:/Test.txt", "r");
print file
file.read()
file.read()
file.read()
file.read()
file.rea... | Python command isn't reading a .txt file | Trying to follow the guide here, but it's not working as expected. I'm sure I'm missing something.
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files
file = open("C:/Test.txt", "r");
print file
file.read()
file.read()
file.read()
file.read()
file.read()
file.read()
Using the readline() method g... | [
"Nothing's wrong there. file is an object, which you are printing.\nTry this:\nfile = open('C:/Test.txt', 'r')\nfor line in file.readlines(): print line,\n\n",
"print file invokes the file object's __repr__() function, which in this case is defined to return just what is printed. To print the file's contents, you... | [
7,
2,
1,
0
] | [] | [] | [
"python",
"text"
] | stackoverflow_0003977949_python_text.txt |
Q:
Access files on WM6 phone using USB connection
Windows XP shows my Windows Mobile 6 phone (HP iPAQ 514) as "Mobile Device" in "My computer". Using Windows explorer, I can copy files from/to the device and its storage card.
Which possibilities are there to access these files programmatically? Any way to access them... | Access files on WM6 phone using USB connection | Windows XP shows my Windows Mobile 6 phone (HP iPAQ 514) as "Mobile Device" in "My computer". Using Windows explorer, I can copy files from/to the device and its storage card.
Which possibilities are there to access these files programmatically? Any way to access them using normal filenames or special paths?
Note that ... | [
"The \"special paths\" you're looking for exist at Shell level, not the kernel. Therefore, you shouldn't be using paths from the Win32 kernel namespace (which you linked to), but PIDL 's\n",
"To answer the question how you actually do the reading, you'd be looking at the \"RAPI\" component of Windows - it's an in... | [
0,
0
] | [] | [] | [
"file",
"python",
"usb",
"windows_mobile_6"
] | stackoverflow_0003977758_file_python_usb_windows_mobile_6.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.