Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
4,098,509
2010-11-04T15:51:00.000
1
1
0
0
java,c++,python,storage,simulation
4,098,941
6
false
0
0
Using D-Bus format to send the information may be to your advantage. The format is standard, binary, and D-Bus is implemented in multiple languages, and can be used to send both over the network and inter-process on the same machine.
4
2
1
I am about to start collecting large amounts of numeric data in real-time (for those interested, the bid/ask/last or 'tape' for various stocks and futures). The data will later be retrieved for analysis and simulation. That's not hard at all, but I would like to do it efficiently and that brings up a lot of questions...
Collecting, storing, and retrieving large amounts of numeric data
0.033321
0
0
2,032
4,098,509
2010-11-04T15:51:00.000
0
1
0
0
java,c++,python,storage,simulation
4,098,550
6
false
0
0
If you are just storing, then use system tools. Don't write your own. If you need to do some real-time processing of the data before it is stored, then that's something completely different.
4
2
1
I am about to start collecting large amounts of numeric data in real-time (for those interested, the bid/ask/last or 'tape' for various stocks and futures). The data will later be retrieved for analysis and simulation. That's not hard at all, but I would like to do it efficiently and that brings up a lot of questions...
Collecting, storing, and retrieving large amounts of numeric data
0
0
0
2,032
4,098,509
2010-11-04T15:51:00.000
1
1
0
0
java,c++,python,storage,simulation
4,098,613
6
false
0
0
Actually, this is quite similar to what I'm doing, which is monitoring changes players make to the world in a game. I'm currently using an sqlite database with python. At the start of the program, I load the disk database into memory, for fast writing procedures. Each change is put in to two lists. These lists are for ...
4
2
1
I am about to start collecting large amounts of numeric data in real-time (for those interested, the bid/ask/last or 'tape' for various stocks and futures). The data will later be retrieved for analysis and simulation. That's not hard at all, but I would like to do it efficiently and that brings up a lot of questions...
Collecting, storing, and retrieving large amounts of numeric data
0.033321
0
0
2,032
4,098,509
2010-11-04T15:51:00.000
3
1
0
0
java,c++,python,storage,simulation
4,098,582
6
false
0
0
Optimizing for disk space and IO speed is the same thing - these days, CPUs are so fast compared to IO that it's often overall faster to compress data before storing it (you may actually want to do that). I don't really see memory playing a big role (though you should probably use a reasonably-sized buffer to ensure yo...
4
2
1
I am about to start collecting large amounts of numeric data in real-time (for those interested, the bid/ask/last or 'tape' for various stocks and futures). The data will later be retrieved for analysis and simulation. That's not hard at all, but I would like to do it efficiently and that brings up a lot of questions...
Collecting, storing, and retrieving large amounts of numeric data
0.099668
0
0
2,032
4,099,817
2010-11-04T18:14:00.000
1
1
0
0
python,windows,excel
4,103,210
2
false
0
0
"Python functions which can be called from a number of excel worksheets" And you're not blaming Excel for randomly running Python modules? Why not? How have you proven that Excel is behaving properly?
1
3
0
We have an application based on Excel 2003 and Python 2.4 on Windows XP 32bit. The application consists of a large collection of Python functions which can be called from a number of excel worksheets. We've notcied an anomolous behavior which is that sometimes in the middle of one of these calls the python interpreter ...
Odd python search-path behavior, what's going wrong here?
0.099668
0
0
111
4,100,532
2010-11-04T19:34:00.000
1
0
1
0
python,performance,runtime
4,100,562
3
false
0
0
Two things: Code in separate modules is compiled into bytecode at first runtime and saved as a precompiled .pyc file, so it doesn't have to be recompiled at the next run as long as the source hasn't been modified since. This might result in a small performance advantage, but only at program startup. Also, Python stores...
3
1
0
I thought I once read on SO that Python will compile and run slightly more quickly if commonly called code is placed into methods or separate files. Does putting Python code in methods have an advantage over separate files or vice versa? Could someone explain why this is? I'd assume it has to do with memory allocation ...
Will Python be faster if I put commonly called code into separate methods or files?
0.066568
0
0
150
4,100,532
2010-11-04T19:34:00.000
4
0
1
0
python,performance,runtime
4,100,574
3
true
0
0
It doesn't matter. Don't structure your program around code speed; structure it around coder speed. If you write something in Python and it's too slow, find the bottleneck with cProfile and speed it up. How do you speed it up? You try things and profile them. In general, function call overhead in critical loops is high...
3
1
0
I thought I once read on SO that Python will compile and run slightly more quickly if commonly called code is placed into methods or separate files. Does putting Python code in methods have an advantage over separate files or vice versa? Could someone explain why this is? I'd assume it has to do with memory allocation ...
Will Python be faster if I put commonly called code into separate methods or files?
1.2
0
0
150
4,100,532
2010-11-04T19:34:00.000
2
0
1
0
python,performance,runtime
4,100,592
3
false
0
0
No. Regardless of where you put your code, it has to be parsed once and compiled if necessary. Distinction between putting code in methods or different files might have an insignificant performance difference, but you shouldn't worry about it. About the only language right now that you have to worry about structuring "...
3
1
0
I thought I once read on SO that Python will compile and run slightly more quickly if commonly called code is placed into methods or separate files. Does putting Python code in methods have an advantage over separate files or vice versa? Could someone explain why this is? I'd assume it has to do with memory allocation ...
Will Python be faster if I put commonly called code into separate methods or files?
0.132549
0
0
150
4,100,628
2010-11-04T19:45:00.000
6
0
0
1
python,pygtk
4,100,722
2
true
0
0
Calling urllib2 from the main thread blocks the Gtk event loop and consequently freezes the user interface. This is not specific to urllib2, but happens with any longer running function (e.g. subprocess.call). Either use the asynchronous IO facilities from glib or call urllib2 in a separate thread to avoid this issue.
2
1
0
I'm using PyGTK for a small app I've developing. The usage of URLlib2 through a proxy will freeze my GUI. Is there anyway to prevent that? My code that actually does the work is seperate from the GUI, so I was thinking may be using subprocess to call the python file. However, how would that work if I was to convert the...
urllib2 freezes GUI
1.2
0
0
310
4,100,628
2010-11-04T19:45:00.000
0
0
0
1
python,pygtk
4,101,507
2
false
0
0
I'd consider using the multiprocess module, creating a pair of Queue objects ... one for the GUI controller or other components to send requests to the urllib2 process; the other for returning the results. Just a pair of Queue objects would be sufficient for a simple design (just two processes). The urllib2 process si...
2
1
0
I'm using PyGTK for a small app I've developing. The usage of URLlib2 through a proxy will freeze my GUI. Is there anyway to prevent that? My code that actually does the work is seperate from the GUI, so I was thinking may be using subprocess to call the python file. However, how would that work if I was to convert the...
urllib2 freezes GUI
0
0
0
310
4,101,130
2010-11-04T20:36:00.000
1
0
0
1
c++,python,c,binding
4,101,176
2
false
0
0
One way would be to re-factor your command line utility so that command line handling is separated and the actual functionality is exposed as shared archive. Then you could expose those function using cython. Write your complete command line utility in python that exploits those functions. This makes distribution ha...
2
2
0
I'm interested in writing a python binding or wrapper for an existing command line utility that I use on Linux, so that I can access its features in my python programs. Is there a standard approach to doing this that someone could point me to? At the moment, I have wrapped the command line executable in a subprocess.P...
How to write Python bindings for command line applications
0.099668
0
0
510
4,101,130
2010-11-04T20:36:00.000
5
0
0
1
c++,python,c,binding
4,101,158
2
true
0
0
If you must use a command line interface, then subprocess.Popen is your best bet. Remember that you can use shell=True to let it pick the path variables, you can use os.path.join to use OS-dependent path separators etc. If, however, your command line utility has shared libraries, look at ctypes, which allows you to con...
2
2
0
I'm interested in writing a python binding or wrapper for an existing command line utility that I use on Linux, so that I can access its features in my python programs. Is there a standard approach to doing this that someone could point me to? At the moment, I have wrapped the command line executable in a subprocess.P...
How to write Python bindings for command line applications
1.2
0
0
510
4,101,815
2010-11-04T22:01:00.000
0
0
0
1
python,matlab,amazon-web-services,hadoop,mapreduce
4,101,917
2
false
0
0
The following is not exactly an answer to your Hadoop question, but I couldn't resist not asking why you don't execute your processing jobs on the Grid resources? There are proven solutions for executing compute intensive workflows on the Grid. And as far as I know matlab runtime environment is usually available on the...
1
1
1
I am writing and distributed image processing application using hadoop streaming, python, matlab, and elastic map reduce. I have compiled a binary executable of my matlab code using the matlab compiler. I am wondering how I can incorporate this into my workflow so the binary is part of the processing on Amazon's elasti...
Hadoop/Elastic Map Reduce with binary executable?
0
0
0
1,138
4,102,409
2010-11-04T23:41:00.000
0
0
0
0
java,python,database,algorithm,unique
4,102,448
8
false
0
0
If there is only one source of IDs (that is: you don't need to coordinate multiple independent sources on different machines) you can do the following: Calculate the maximum number of bits that a number may have so that it doesn't exceed the information contained in an 8-symbol string of 0-9A-Z. This would be floor(lo...
4
2
0
I've been through answers to a few similar questions asked on SO, but could not find what I was looking for. Is there a more efficient way to generate 8 character unique IDs, base 36 (0-9A-Z), than generating a unique ID and querying the DB to see if it already exists and repeating until you get a unique ID that has no...
8 Character Random Code
0
0
0
2,769
4,102,409
2010-11-04T23:41:00.000
10
0
0
0
java,python,database,algorithm,unique
4,102,438
8
false
0
0
One option is to do it the other way round: generate a huge number of them in the database whenever you need to, then either fetch a single one from the DB when you need one, or reserve a whole bunch of them for your particular process (i.e. mark them as "potentially used" in the database) and then dole them out from m...
4
2
0
I've been through answers to a few similar questions asked on SO, but could not find what I was looking for. Is there a more efficient way to generate 8 character unique IDs, base 36 (0-9A-Z), than generating a unique ID and querying the DB to see if it already exists and repeating until you get a unique ID that has no...
8 Character Random Code
1
0
0
2,769
4,102,409
2010-11-04T23:41:00.000
7
0
0
0
java,python,database,algorithm,unique
4,103,718
8
true
0
0
I question that your "inefficient" approach is actually inefficient. Consider this: There are 36^8 == 2,821,109,907,456 (2.8 Trillion) possible IDs. If you have N existing IDs, the chance of a new randomly generated ID colliding is N in ~2.8 trillion. Unless N is in the hundreds of billions, you "generate a unique ID...
4
2
0
I've been through answers to a few similar questions asked on SO, but could not find what I was looking for. Is there a more efficient way to generate 8 character unique IDs, base 36 (0-9A-Z), than generating a unique ID and querying the DB to see if it already exists and repeating until you get a unique ID that has no...
8 Character Random Code
1.2
0
0
2,769
4,102,409
2010-11-04T23:41:00.000
1
0
0
0
java,python,database,algorithm,unique
4,102,452
8
false
0
0
Unfortunately, 8 base 36 digits is a bit small. It's only 2 million million possible IDs, so if you generate 1.4 million randomly you have about a half chance of a collision. You could possibly use a PRNG with a large period, and map its current state to your ID space via some bijection. A 41 bit LFSR wouldn't be uncra...
4
2
0
I've been through answers to a few similar questions asked on SO, but could not find what I was looking for. Is there a more efficient way to generate 8 character unique IDs, base 36 (0-9A-Z), than generating a unique ID and querying the DB to see if it already exists and repeating until you get a unique ID that has no...
8 Character Random Code
0.024995
0
0
2,769
4,103,085
2010-11-05T02:15:00.000
15
1
0
1
python,notepad++,nppexec
4,106,339
2
true
0
0
Notepad++ >nppexec >follow $(current directory)
1
6
0
Using windows for the first time in quite awhile and have picked up notepad++ and am using the nppexec plugin to run python scripts. However, I noticed that notepad++ doesn't pick up the directory that my script is saved in. For example, I place "script.py" in 'My Documents' however os.getcwd() prints "Program Files \ ...
Getting NppExec to understand path of the current file in Notepad++ (for Python scripts)
1.2
0
0
4,494
4,103,107
2010-11-05T02:21:00.000
0
0
1
0
python
72,317,998
3
false
0
0
try pandas! select C# my_collection.Select(my_object => my_object.my_property) pandas my_collection['my_property'] or: C# my_collection.Select(x => x.my_property + 2) python my_collection['my_property'].apply(lambda x: x + 2) where C#: my_collection.Where(x => x.my_property == 1) pandas: my_collection[my_collection['my...
1
25
0
I'm quite new to python, and happen to have used C# for some time now. I saw that there was a filter method to use with the collections, which seems to be the equivalent of the LINQ's where clause. I wondered, is there also an equivalent for the LINQ's select statement in python? Example: my_collection.select(my_objec...
Python's equivalent of C# LINQ's select
0
0
0
15,691
4,104,202
2010-11-05T07:44:00.000
8
1
1
0
python,vim
4,104,215
1
false
0
0
vim supports scripting in various languages, Python being one of them. See :h python for more details.
1
4
0
I am going to build vim and see that it supports the pythoninterp feature by --enable-pythoninterp. What is it? Since I am a big Python fan, I'd like to know more about it. And also, what's the --with-python-config-dir=PATH for?
What is the vim feature: --enable-pythoninterp
1
0
0
3,212
4,104,751
2010-11-05T09:36:00.000
6
0
0
1
python,google-app-engine
4,105,029
1
true
1
0
Reduce the set of libraries you require in order to serve requests as much as you can. For expensive libraries that are only used in some places, put the import statement inside the function that uses them. This way, the library is only imported the first time it's needed. If your framework supports it, do just-in-time...
1
3
0
After a period of inactivity the first request takes about 5 to 10 secs to come through. Is there any best practice solutions to overcome this problem? I'm using Python version of App Engine.
Best Practice for dealing with app engine cold start problem
1.2
0
0
364
4,104,898
2010-11-05T09:59:00.000
2
1
1
0
python
4,105,223
7
false
0
0
Assuming you do have to remember their order and that the numbers are in the range of 1 to 1,000,000, it would only take 20 bits or 2½ bytes to write each one since 1,000,000 is 0xF4240 in hexadecimal. You'd have to pack them together to not waste any space with this approach, but by doing so it would only take 2.5 * 1...
4
4
0
What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc? My answer is: 1,000,000 * 3 bytes using struct module, but it seems like interviewer expected another answer... Edit. Numbers from 1 to 1,000,000 in random order (so transform like 5, 6, 7 -> 5-7 can be applied i...
Python: Write 1,000,000 ints to file
0.057081
0
0
1,746
4,104,898
2010-11-05T09:59:00.000
0
1
1
0
python
4,105,172
7
false
0
0
I would only write the start and end of the given range, in this case 1 and 1,000,000, because nowhere has the interviewer mentioned order is important.
4
4
0
What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc? My answer is: 1,000,000 * 3 bytes using struct module, but it seems like interviewer expected another answer... Edit. Numbers from 1 to 1,000,000 in random order (so transform like 5, 6, 7 -> 5-7 can be applied i...
Python: Write 1,000,000 ints to file
0
0
0
1,746
4,104,898
2010-11-05T09:59:00.000
2
1
1
0
python
4,105,217
7
true
0
0
Well, your solution takes three bytes (= 24 bits) per integer. Theoretically, 20 bits are enough (since 2^19 < 1.000.000 < 2^20). EDIT: Oops, just noticed Neil’s comment stating the same. I’m making this answer CW since it really belongs to him.
4
4
0
What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc? My answer is: 1,000,000 * 3 bytes using struct module, but it seems like interviewer expected another answer... Edit. Numbers from 1 to 1,000,000 in random order (so transform like 5, 6, 7 -> 5-7 can be applied i...
Python: Write 1,000,000 ints to file
1.2
0
0
1,746
4,104,898
2010-11-05T09:59:00.000
0
1
1
0
python
4,105,238
7
false
0
0
What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc If you interpret the 1,000,000 ints as "I didn't specify that they have to be different", you can just use a for loop to write 0 one million times.
4
4
0
What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc? My answer is: 1,000,000 * 3 bytes using struct module, but it seems like interviewer expected another answer... Edit. Numbers from 1 to 1,000,000 in random order (so transform like 5, 6, 7 -> 5-7 can be applied i...
Python: Write 1,000,000 ints to file
0
0
0
1,746
4,105,804
2010-11-05T12:25:00.000
1
1
0
0
import,ironpython
4,111,764
4
false
0
1
You can re-direct all I/O to the database using the PlatformAdaptationLayer. To do this you'll need to implement a ScriptHost which provides the PAL. Then when you create the ScriptRuntime you set the HostType to your host type and it'll be used for the runtime. On the PAL you then override OpenInputFileStream and r...
1
9
0
I am loading an IronPython script from a database and executing it. This works fine for simple scripts, but imports are a problem. How can I intercept these import calls and then load the appropriate scripts from the database? EDIT: My main application is written in C# and I'd like to intercept the calls on the C# s...
Custom IronPython import resolution
0.049958
0
0
2,738
4,106,178
2010-11-05T13:21:00.000
0
0
1
0
python,serialization
29,203,797
3
false
0
0
A program that produces some statistics, but not too much of it so that using DB is overkill. For example, benchmarking a program to choose the best algorithm. Upon completion it draws a graph. Now you might not like the way the graph is drawn. You pickle the results, then unpickle in another script (perhaps after a c...
2
1
0
In layman's terms, what is "Serialization", and why do I need it? I read the Wikipedia entry, but still don't understand it. Why do I need to convert data into a sequence of bits to store it in a file? I am specifically concerned with using Python's pickle module to do serialization. Thanks for the time!
Pickle Python Serialization
0
0
0
986
4,106,178
2010-11-05T13:21:00.000
2
0
1
0
python,serialization
4,106,205
3
true
0
0
You can save the state of a programm (of specific objects). Imagine you have a program which runs for many hours or even days. Using pickle you can save the state of the calculation, kill the programm and resume the calculation later if you want to. You could even email the saved objects to other people, who than can r...
2
1
0
In layman's terms, what is "Serialization", and why do I need it? I read the Wikipedia entry, but still don't understand it. Why do I need to convert data into a sequence of bits to store it in a file? I am specifically concerned with using Python's pickle module to do serialization. Thanks for the time!
Pickle Python Serialization
1.2
0
0
986
4,107,576
2010-11-05T15:50:00.000
1
0
0
0
javascript,python,ajax,dojo
5,576,563
2
false
1
0
My guess would be you are serving these two apps locally via 2 different ports, which is making dojo try to execute a cross-domain XHR call. You need to be able to serve the JSON URL from the same URL (protocol, hostname, & port) to make a successful XHR call. I do this by using nginx locally, and configuring it to se...
1
1
0
I have exposed a simple RESTful JSON url via CherryPy (Python web framework). I have a second application (using Pylons) which needs to reach a URL exposed by CherryPy. Both are being served via localhost. Both URLs resolve just fine when using a browser directly. But, when a DOJO script running from the initial Pylons...
DOJO AJAX Request asking for OPTIONS
0.099668
0
1
2,060
4,107,644
2010-11-05T15:57:00.000
0
0
0
0
python,django
4,107,663
2
false
1
0
Put the poll page in its own view, connect to the view via urls.py, and set up your frame or iframe to source from that URL.
1
0
0
Can you take things like the poll app from the tutorial and display them in an iframe or frameset? The tutorial is great and the app is very nice, but, how often do you go to a site with a whole page dedicated to a poll? I was trying to think about how you do it using the urls.py file, but couldn't wrap my head around ...
Django Question
0
0
0
101
4,107,888
2010-11-05T16:27:00.000
0
1
0
0
python,xml,sha1
4,233,195
1
false
0
0
Take a look at M2Crypto, it's probably the best and most complete crypto library for Python.
1
0
0
Can someone recommend a library for calculating SHA1WithRSAEncryption in Python? Context: I'm trying to do some message authentication. I've looked at PyXMLDSig, but it seemed to expect the certificates as separate files. As a first step to better understanding the problem space, I wanted to calculate the digest values...
sha1WithRSAEncryption in Python
0
0
0
378
4,108,214
2010-11-05T17:04:00.000
1
0
0
0
python,django,django-admin,django-nonrel
6,106,025
2
false
1
0
UPDATE - turn off the server, run python2.5 manage.py syncdb, and add a fresh superuser. Must already have included django.contrib.admin to INSTALLED_APPS This is not at all the answer. Completely different symptoms. I will try to remember to post here when I figure it out.
1
1
0
Bit of a strange one. I've created a super user for django admin for my app, which is just a new django nonrel project with admin enabled. I try and access the /admin whilst running the development server, but when I type in the (correct) username and password it tells me they are not correct. Deploying the project to ...
Django Nonrel - Can't log into Admin Panel on development server
0.099668
0
0
1,404
4,108,341
2010-11-05T17:19:00.000
11
0
1
0
python,list,range
4,108,362
3
false
0
0
range(10) is built in.
1
17
0
Is there a function I can call that returns a list of ascending numbers? I.e., function(10) would return [0,1,2,3,4,5,6,7,8,9]?
Generating an ascending list of numbers of arbitrary length in python
1
0
0
69,702
4,108,852
2010-11-05T18:22:00.000
4
0
0
0
python,django
4,108,925
3
true
1
0
With Django it's a bit more than introspection actually. The models use a metaclass to register themselves, I will spare you the complexities of everything involved but the admin does not introspect the models as you browse through it. Instead, the registering process creates a _meta object on the model with all the da...
1
0
0
I don't really want to know Django I am actually more interested in the administrator. The thing that interests me is how they introspect the models to create the administrator back-end. I browsed through the Django source code and found a little info but since it's such a big project I was wondering if there are small...
Django's introspecting administrator: How does it work?
1.2
0
0
91
4,109,532
2010-11-05T19:57:00.000
1
0
0
0
python,django
4,109,559
3
false
1
0
It's for any type of settings, but it's better to put local settings in a separate file so that version upgrades don't clobber them. Have the global settings file detect the presence of the local settings file and then either import everything from it or just execfile() it.
1
1
0
I'm fairly new to Python and Django, and I'm working on a webapp now that will be run on multiple servers. Each server has it's own little configuration details (commands, file paths, etc.) that I would like to just be able to store in a settings file, and then have a different copy of the file on each system. I know ...
Where should I put configuration details? [Python]
0.066568
0
0
189
4,109,848
2010-11-05T20:36:00.000
1
0
1
0
python,pickle
4,110,149
3
false
0
0
It sounds like you know you can't pickle the handle, and you're ok with that, you just want to pickle the part that can be pickled. As your object stands now, it can't be pickled because it has the handle. Do I have that right? If so, read on. The pickle module will let your class describe its own state to pickle, fo...
2
3
0
I would like to create a class that describes a file resource and then pickle it. This part is straightforward. To be concrete, let's say that I have a class "A" that has methods to operate on a file. I can pickle this object if it does not contain a file handle. I want to be able to create a file handle in order t...
Design of a python pickleable object that describes a file
0.066568
0
0
1,641
4,109,848
2010-11-05T20:36:00.000
1
0
1
0
python,pickle
4,109,958
3
false
0
0
If you open a pointer to a file, pickle it, then attempt to reconstitute is later, there is no guarantee that file will still be available for opening. To elaborate, the file pointer really represents a connection to the file. Just like a database connection, you can't "pickle" the other end of the connection, so this ...
2
3
0
I would like to create a class that describes a file resource and then pickle it. This part is straightforward. To be concrete, let's say that I have a class "A" that has methods to operate on a file. I can pickle this object if it does not contain a file handle. I want to be able to create a file handle in order t...
Design of a python pickleable object that describes a file
0.066568
0
0
1,641
4,110,992
2010-11-05T23:37:00.000
3
0
0
1
python,ubuntu,urllib2,ubuntu-10.10
4,112,300
2
true
0
0
5 seconds sounds suspiciously like the DNS resolving timeout. A hunch, It's possible that it's cycling through the DNS servers in your /etc/resolv.conf and if one of them is broken, the default timeout is 5 seconds on linux, after which it will try the next one, looping back to the top when it's tried them all. If you...
1
1
0
I am experiencing strange behavior with urllib2.urlopen() on Ubuntu 10.10. The first request to a url goes fast but the second takes a long time to connect. I think between 5 and 10 seconds. On windows this just works normal? Does anybody have an idea what could cause this issue? Thanks, Onno
Strange urllib2.urlopen() behavior on Ubuntu 10.10
1.2
0
1
427
4,111,049
2010-11-05T23:48:00.000
2
0
0
0
python,tkinter,clipboard,toolbar
4,111,218
2
false
0
1
You don't have to maintain a big framework, you can create a single binding on the root widget for <FocusIn> and put all the logic in that binding. Or, use focus_class and bind to the class all. Binding on the root will only affect children of the root, binding to all will affect all widgets in the entire app. That o...
2
0
0
I'm looking for suggestions on how one might implement a toolbar that provides edit cut, copy, paste commands using the Tkinter framework. I understand how to build a toolbar and bind the toolbar commands, but I'm confused over how the toolbar button bound commands will know which widget to apply the cut, copy, or past...
Python/Tkinter: Building a toolbar that provides edit cut, copy, paste commands
0.197375
0
0
1,053
4,111,049
2010-11-05T23:48:00.000
1
0
0
0
python,tkinter,clipboard,toolbar
4,111,334
2
true
0
1
You can tell the toolbar buttons to not take the focus; it's a configuration option and no UI guidelines I've ever seen have had toolbar buttons with focus. (Instead, the functionality is always available through some other keyboard-activatable mechanism, e.g., a hotkey combo.)
2
0
0
I'm looking for suggestions on how one might implement a toolbar that provides edit cut, copy, paste commands using the Tkinter framework. I understand how to build a toolbar and bind the toolbar commands, but I'm confused over how the toolbar button bound commands will know which widget to apply the cut, copy, or past...
Python/Tkinter: Building a toolbar that provides edit cut, copy, paste commands
1.2
0
0
1,053
4,111,244
2010-11-06T00:39:00.000
9
0
1
0
python,django,django-models
4,111,263
7
false
1
0
The list of installed applications is defined in settings.INSTALLED_APPS. It contains a tuple of strings, so you can iterate on it to access each application's name. However, I'm not sure what you mean by each application's attributes and fields.
1
48
0
In my Django website, I'm creating a class that interact dynamically with other applications installed in the website. I have to do a manipulation on each field of each application. So I want to save the name of all installed applications in a list and get the attributes of each one. There is a way to do that using an ...
Get a list of all installed applications in Django and their attributes
1
0
0
53,093
4,112,235
2010-11-06T06:46:00.000
1
0
0
1
python,google-app-engine
4,112,279
2
false
1
0
I have been handling something similar by building a custom automatic retry dispatcher on the client. Whenever an ajax call to the server fails, the client will retry it. This works very well if your page is ajaxy. If your app spits entire HTML pages then you can use a two pass process: first send an empty page contain...
2
1
0
Sometimes, with requests that do a lot, Google AppEngine returns an error. I have been handling this by some trickery: memcaching intermediate processed data and just requesting the page again. This often works because the memcached data does not have to be recalculated and the request finishes in time. However... ...
Better ways to handle AppEngine requests that time out?
0.099668
0
0
264
4,112,235
2010-11-06T06:46:00.000
1
0
0
1
python,google-app-engine
4,117,235
2
true
1
0
If interactive user requests are hitting the 30 second deadline, you have bigger problems: your user has almost certainly given up and left anyway. What you can do depends on what your code is doing. There's a lot to be optimized by batching datastore operations, or reducing them by changing how you model your data; yo...
2
1
0
Sometimes, with requests that do a lot, Google AppEngine returns an error. I have been handling this by some trickery: memcaching intermediate processed data and just requesting the page again. This often works because the memcached data does not have to be recalculated and the request finishes in time. However... ...
Better ways to handle AppEngine requests that time out?
1.2
0
0
264
4,114,055
2010-11-06T16:47:00.000
1
0
1
0
python,arguments
4,114,069
2
true
0
0
You better have two different methods if inner code is different in both cases.
1
1
0
For example, I want to have a method that, depending on the first argument passed, can take either an int or a char as the second argument. The way I thought of doing it is to have an if right after the method it calls to check what the first argument is, it can be one of 4. At this point, if it's of say, type 1 or 2 t...
What would be the proper way of handling arguments for a method that could be ints or chars in python?
1.2
0
0
103
4,114,417
2010-11-06T18:11:00.000
4
0
1
0
python,git,permissions,hook,restrict
4,114,690
2
true
0
0
I think it could be possible to use such script but it is not the right place for rights management, it should be rather done on git server side. For example in gitosis you do this configuration in gitosis-admin repository in file gitosis.conf. Security managed by a hook can be easily broken, only server can keep track...
1
3
0
I'd like to restrict write access for the master branch to only several developers, while allowing others to pull everything and push to other non-master branches. Idea is that a developer would push to some other branch and then if code passes review, reviewer would merge it into the master branch. I'm pretty sure tha...
How to write a git hook to restrict writing to branch?
1.2
0
0
5,437
4,114,722
2010-11-06T19:17:00.000
5
0
0
0
python,html,parsing
4,115,108
5
false
1
0
html5lib cannot parse half of what's "out there" That sounds extremely implausible. html5lib uses exactly the same algorithm that's also implemented in recent versions of Firefox, Safari and Chrome. If that algorithm broke half the web, I think we would have heard. If you have particular problems with it, do file bugs...
2
15
0
I'm trying to parse some html in Python. There were some methods that actually worked before... but nowadays there's nothing I can actually use without workarounds. beautifulsoup has problems after SGMLParser went away html5lib cannot parse half of what's "out there" lxml is trying to be "too correct" for typical html...
Python html parsing that actually works
0.197375
0
1
3,978
4,114,722
2010-11-06T19:17:00.000
1
0
0
0
python,html,parsing
4,114,746
5
false
1
0
I think the problem is that most HTML is ill-formed. XHTML tried to fix that, but it never really caught on enough - especially as most browsers do "intelligent workarounds" for ill-formed code. Even a few years ago I tried to parse HTML for a primitive spider-type app, and found the problems too difficult. I suspect ...
2
15
0
I'm trying to parse some html in Python. There were some methods that actually worked before... but nowadays there's nothing I can actually use without workarounds. beautifulsoup has problems after SGMLParser went away html5lib cannot parse half of what's "out there" lxml is trying to be "too correct" for typical html...
Python html parsing that actually works
0.039979
0
1
3,978
4,115,033
2010-11-06T20:34:00.000
0
0
1
0
python,thread-safety,queue
4,115,106
3
false
0
0
Why can't you just add the final step to the queue ?
2
0
0
how can i update a shared variable between different threading.Thread in python? lets say that i have 5 threads working down a Queue.Queue(). after the queue is done i want to do an other operation but i want it to happen only once. is it possible to share and update a variable betweeen the threads. so when Queue.empty...
python threading and shared variables
0
0
0
3,372
4,115,033
2010-11-06T20:34:00.000
0
0
1
0
python,thread-safety,queue
4,115,111
3
false
0
0
Have another queue where you place this event after first queue is empty. Or have special thread for this event.
2
0
0
how can i update a shared variable between different threading.Thread in python? lets say that i have 5 threads working down a Queue.Queue(). after the queue is done i want to do an other operation but i want it to happen only once. is it possible to share and update a variable betweeen the threads. so when Queue.empty...
python threading and shared variables
0
0
0
3,372
4,119,698
2010-11-07T21:07:00.000
2
0
1
0
python,optimization,linked-list,set
4,121,220
6
false
0
0
Dictionary is the collection you want in this case because it has O(1) find and delete. There is a cost you will incur, which is generating a key for each object when you want to add/remove, but it'll be significantly faster than the O(n) approach of scanning a list. Generating a key for your objects is correct in this...
4
4
0
Suppose I have profiled my program, and the vast majority of runtime is spent in method 'remove' of 'list' objects. The program manipulates a collection of collections, and the collections do not need to be ordered. What would be the most straightforward way to implement these collections in python (preferably using ...
What type of collection of mutable objects will allow me to quickly remove items in python?
0.066568
0
0
200
4,119,698
2010-11-07T21:07:00.000
2
0
1
0
python,optimization,linked-list,set
4,121,026
6
false
0
0
They suggested using a dict. This would work, but you would have to generate arbitrary id's for each item then, so it's a bit awkward. You delete them by instance? Using a dict approach, you can always use id() as their "arbitrary" ID? One dict for groups with their id() as key, inner dict for invidual's id(). And ano...
4
4
0
Suppose I have profiled my program, and the vast majority of runtime is spent in method 'remove' of 'list' objects. The program manipulates a collection of collections, and the collections do not need to be ordered. What would be the most straightforward way to implement these collections in python (preferably using ...
What type of collection of mutable objects will allow me to quickly remove items in python?
0.066568
0
0
200
4,119,698
2010-11-07T21:07:00.000
-1
0
1
0
python,optimization,linked-list,set
4,120,881
6
false
0
0
Why not have something like a master list of sets and then another set that contains the indices to the list for the set you want to keep track of? Sure it might be a little extra work, but you should be able to abstract it out into a class.
4
4
0
Suppose I have profiled my program, and the vast majority of runtime is spent in method 'remove' of 'list' objects. The program manipulates a collection of collections, and the collections do not need to be ordered. What would be the most straightforward way to implement these collections in python (preferably using ...
What type of collection of mutable objects will allow me to quickly remove items in python?
-0.033321
0
0
200
4,119,698
2010-11-07T21:07:00.000
1
0
1
0
python,optimization,linked-list,set
4,119,787
6
false
0
0
If you are spending a lot of time remove-ing elements from a list, perhaps you should consider filtering it instead? In other words. make a large initial list and then subsequent generators consuming elements in the list.
4
4
0
Suppose I have profiled my program, and the vast majority of runtime is spent in method 'remove' of 'list' objects. The program manipulates a collection of collections, and the collections do not need to be ordered. What would be the most straightforward way to implement these collections in python (preferably using ...
What type of collection of mutable objects will allow me to quickly remove items in python?
0.033321
0
0
200
4,120,169
2010-11-07T22:58:00.000
0
1
1
0
c++,visual-studio-2010,static,linker,boost-python
4,121,910
2
true
0
0
What libraries are linked depends on the settings of your project. There are two possibilities: You can build against statically dynamically linked versions of the c-runtime libs. Depending on which option is selected, the boost sends a proper #pragma to the linker. These options need to be set consistently in all pr...
2
1
0
I got a VS10 project. I want to build some C++ code so I can use it in python. I followed the boost tutorial and got it working. However VS keeps to link boost-python-vc100-mt-gd-1_44.lib but it's just a wrapper which calls boost-python-vc100-mt-gd-1_44.dll. That's why I need to copy the .dll with my .dll(.pyd) file. S...
MSVC - boost::python static linking to .dll (.pyd)
1.2
0
0
4,303
4,120,169
2010-11-07T22:58:00.000
1
1
1
0
c++,visual-studio-2010,static,linker,boost-python
4,146,530
2
false
0
0
You probably don't want to do that. Statically linked Boost python has a number of problems and quirks when there are more then one boost python based library imported. "But I only have one" you say. Can you guarantee that your users won't have another? That you might want to use another in the future? Stick with the ...
2
1
0
I got a VS10 project. I want to build some C++ code so I can use it in python. I followed the boost tutorial and got it working. However VS keeps to link boost-python-vc100-mt-gd-1_44.lib but it's just a wrapper which calls boost-python-vc100-mt-gd-1_44.dll. That's why I need to copy the .dll with my .dll(.pyd) file. S...
MSVC - boost::python static linking to .dll (.pyd)
0.099668
0
0
4,303
4,120,705
2010-11-08T01:35:00.000
-2
0
1
0
python,list,dictionary
4,120,742
7
false
0
0
I know nothing about Python, but I guess you can traverse a list and remove entries by key from the dictionary?
1
7
0
How do you remove all elements from the dictionary whose key is a element of a list?
Remove all elements from the dictionary whose key is an element of a list
-0.057081
0
0
6,938
4,121,751
2010-11-08T06:38:00.000
1
0
1
0
python,string,escaping,backslash
4,121,817
4
false
0
0
Prepending the string with r (stands for "raw") will escape all characters inside the string. For example: print r'\b\n\\' will output \b\n\\ Have I understood the question correctly?
1
1
0
I'm getting some content from Twitter API, and I have a little problem, indeed I sometimes get a tweet ending with only one backslash. More precisely, I'm using simplejson to parse Twitter stream. How can I escape this backslash ? From what I have read, such raw string shouldn't exist ... Even if I add one backslash (w...
[Python]How to deal with a string ending with one backslash?
0.049958
0
1
1,886
4,122,794
2010-11-08T10:00:00.000
34
0
0
0
python,excel,csv
4,122,980
2
true
0
0
You're using open('file.csv', 'w')--try open('file.csv', 'wb'). The Python csv module requires output files be opened in binary mode.
2
15
1
I have a csv file which contains rows from a sqlite3 database. I wrote the rows to the csv file using python. When I open the csv file with Ms Excel, a blank row appears below every row, but the file on notepad is fine(without any blanks). Does anyone know why this is happenning and how I can fix it? Edit: I used the s...
Csv blank rows problem with Excel
1.2
1
0
7,209
4,122,794
2010-11-08T10:00:00.000
0
0
0
0
python,excel,csv
4,122,816
2
false
0
0
the first that comes into my mind (just an idea) is that you might have used "\r\n" as row delimiter (which is shown as one linebrak in notepad) but excel expects to get only "\n" or only "\r" and so it interprets this as two line-breaks.
2
15
1
I have a csv file which contains rows from a sqlite3 database. I wrote the rows to the csv file using python. When I open the csv file with Ms Excel, a blank row appears below every row, but the file on notepad is fine(without any blanks). Does anyone know why this is happenning and how I can fix it? Edit: I used the s...
Csv blank rows problem with Excel
0
1
0
7,209
4,122,940
2010-11-08T10:17:00.000
1
0
0
0
python,caching,postgresql,nlp,tokenize
4,151,273
2
false
0
0
I store tokenized text in a MySQL database. While I don't always like the overhead of communication with the database, I've found that there are lots of processing tasks that I can ask the database to do for me (like search the dependency parse tree for complex syntactic patterns).
1
2
0
I have a simple question. I'm doing some light crawling so new content arrives every few days. I've written a tokenizer and would like to use it for some text mining purposes. Specifically, I'm using Mallet's topic modeling tool and one of the pipe is to tokenize the text into tokens before further processing can be do...
Storing tokenized text in the db?
0.099668
1
0
894
4,126,041
2010-11-08T16:55:00.000
4
0
0
1
python,scheduled-tasks
4,126,085
2
false
0
0
The OS provides a tool called 'cron' that's for exactly this purpose. You shouldn't need to modify your script at all to make use of it. At a terminal command prompt, type man cron for more info.
1
2
0
I run MAC OS X. So I have completed a python script that essentially parses a few sites online, and uploads a particular file to an online server. Essentially, I wish to run this script automatically from my computer about 20 times a day. Is there a solution to schedule this script to run at fixed time points everyd...
Scheduling Tasks
0.379949
0
0
1,544
4,126,247
2010-11-08T17:19:00.000
2
0
0
0
python,frameworks,zope,zope.interface
4,126,734
1
true
0
0
You can upload zope the same way you would upload anything else, but it's not suitable for deploying on many shared webhosts as many of them would not like you running the zope process due to the ammount of resources it can consume You are best off trying to find a webhost that supports zope or to use a VPS
1
0
0
Hey, I'd like to know how to upload my zope site on my ftp. I have a domain, and I like to upload it, like a upload normal files on my ftp. Thanks.
How to upload zope site on my ftp?
1.2
0
0
175
4,128,555
2010-11-08T22:07:00.000
0
1
1
0
java,c++,python,build,scons
4,129,038
2
false
0
0
I once checked out CMake (for C++), I liked it very much. It's easy to use yet powerful and quite similar to Make syntax. It also has Java support.
1
2
0
Let's say I have a bunch of small targets in different programming languages (C++, Java, Python, etc), with inter programming language dependencies (Java project depends on a C++, Python depends on C++). How can one build/compile them? I tried scons and more recently gyp. I don't remember what issues I had with scons. ...
How to build/compile C++, Java and Python projects?
0
0
0
664
4,129,658
2010-11-09T01:19:00.000
3
1
0
0
python,unicode
4,129,665
3
true
0
0
That's URL-encoded UTF-8. URL-decode it, then decode it as UTF-8.
2
0
0
What would be this encoding's name? smb://nas/music/_lib/v/voivod/voivod-rrr%C3%B6%C3%B6%C3%B6aaarrr/01%20-%20voivod%20-%20rrr%C3%B6%C3%B6%C3%B6aaarrr%20-%20korg%C3%BCll_the_exterminator.mp3 I would like to convert such string to unicode using Python. How would I do that?
unknown encoding to unicode
1.2
0
0
791
4,129,658
2010-11-09T01:19:00.000
0
1
0
0
python,unicode
4,129,716
3
false
0
0
Try urllib.unquote().
2
0
0
What would be this encoding's name? smb://nas/music/_lib/v/voivod/voivod-rrr%C3%B6%C3%B6%C3%B6aaarrr/01%20-%20voivod%20-%20rrr%C3%B6%C3%B6%C3%B6aaarrr%20-%20korg%C3%BCll_the_exterminator.mp3 I would like to convert such string to unicode using Python. How would I do that?
unknown encoding to unicode
0
0
0
791
4,129,697
2010-11-09T01:28:00.000
1
0
0
0
python,matplotlib,pyqt,vispy
4,129,787
4
false
0
1
I recommend using matplotlib in interactive mode, if you call .show once then it will pop up in its own window, if you don't then it exists only in memory and can be written to a file when you're done with it.
1
20
0
I have a complicated algorithm that updates 3 histograms that are stored in arrays. I want to debug my algorithm, so I was thinking of showing the arrays as histograms in a user interface. What is the easiest way to do this. (Rapid application development is more important than optimized code.) I have some experienc...
How do I display real-time graphs in a simple UI for a python program?
0.049958
0
0
37,324
4,129,858
2010-11-09T02:01:00.000
1
0
0
0
python,flash,html5-video,screen-capture,image-capture
4,134,375
2
false
1
0
What about capturing it inside Flash and sending it as BiteArray to the server?
1
4
0
Part of a web application I am developing requires the ability to capture still images from a Flash or HTML5 video playing with in a browser. Is there a Python library out there that could help me along with this task? UPDATE Actually, users of this web app will also have to have the ability to Draw a crop box on to...
Recommendations for a Python library that can capture still images from a Flash/HTML5 video?
0.099668
0
0
835
4,130,199
2010-11-09T03:14:00.000
0
0
1
0
python,excel,worksheet-function
7,522,661
2
false
0
0
Excel functions i dont' know, but to Excel Add-ins it's possible. Add a add-in to your excel application, and go to Visual Basic Editor, double click in add-in and use this passwords. Add-in -- Password Internet Assistant VBA -- Weezaarde!? Autosave Addin -- Wildebeest!! Analysis Toolpak ...
2
0
0
I wish to manually code VLOOKUP in python, so is it possible to see the VBA code behind VLOOKUP? I remember a presentation in my school by a guest speaker showing that the Excel Functions are just macro/vba codes. Can someone please show me the way to view the code for Excel Worksheet functions?
Accessing Vlookup Macro Code in Excel?
0
0
0
1,169
4,130,199
2010-11-09T03:14:00.000
0
0
1
0
python,excel,worksheet-function
4,131,708
2
false
0
0
I do not know of a way to view the XL code for VLOOKUP (its almost certainly written in C). The basic algorithms used in VLOOKUP are Linear Search for unsorted data, and Binary Search for sorted data. There are many examples available on the web of implementing these algorithms.
2
0
0
I wish to manually code VLOOKUP in python, so is it possible to see the VBA code behind VLOOKUP? I remember a presentation in my school by a guest speaker showing that the Excel Functions are just macro/vba codes. Can someone please show me the way to view the code for Excel Worksheet functions?
Accessing Vlookup Macro Code in Excel?
0
0
0
1,169
4,130,355
2010-11-09T03:49:00.000
0
0
0
0
python,macos,matplotlib,fink
53,662,588
11
false
0
0
Simply aliasing a new command to launch python in ~/.bash_profile will do the trick. alias vpython3=/Library/Frameworks/Python.framework/Versions/3.6(replace with your own python version)/bin/python3 then 'source ~/.bash_profile' and use vpython3 to launch python3. Explanation: Python is actually by default installed a...
3
62
1
I am getting this error: /sw/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py:235: UserWarning: Python is not installed as a framework. The MacOSX backend may not work correctly if Python is not installed as a framework. Please see the Python documentation for more information on installing Py...
python matplotlib framework under macosx?
0
0
0
25,060
4,130,355
2010-11-09T03:49:00.000
18
0
0
0
python,macos,matplotlib,fink
4,131,726
11
true
0
0
There are two ways Python can be built and installed on Mac OS X. One is as a traditional flat Unix-y shared library. The other is known as a framework install, a file layout similar to other frameworks on OS X where all of the component directories (include, lib, bin) for the product are installed as subdirectories ...
3
62
1
I am getting this error: /sw/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py:235: UserWarning: Python is not installed as a framework. The MacOSX backend may not work correctly if Python is not installed as a framework. Please see the Python documentation for more information on installing Py...
python matplotlib framework under macosx?
1.2
0
0
25,060
4,130,355
2010-11-09T03:49:00.000
31
0
0
0
python,macos,matplotlib,fink
33,873,802
11
false
0
0
Optionally you could use the Agg backend which requires no extra installation of anything. Just put backend : Agg into ~/.matplotlib/matplotlibrc
3
62
1
I am getting this error: /sw/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py:235: UserWarning: Python is not installed as a framework. The MacOSX backend may not work correctly if Python is not installed as a framework. Please see the Python documentation for more information on installing Py...
python matplotlib framework under macosx?
1
0
0
25,060
4,130,813
2010-11-09T05:36:00.000
0
1
0
1
python,google-app-engine,search,full-text-search,full-text-indexing
5,072,790
2
true
1
0
GAE has announced plans to offer full-text searching natively in the Datastore soon.
1
7
0
What should I do for fast, full-text searching on App Engine with as little work as possible (and as little Java — I’m doing Python.)?
How should I do full-text searching on App Engine?
1.2
0
0
1,246
4,131,096
2010-11-09T06:38:00.000
3
0
0
0
python,django
4,131,110
3
false
1
0
I'm partial to the #django channel on Freenode's IRC server. A few big names in the Django community hang around there. ( irc://irc.freenode.net/#django since SO's Markdown processor doesn't like irc:// in URLs)
1
1
0
Are there communities where expert Django developers (ideally looking for jobs) like to hang out? Stackoverflow excluded :)
Where are some good places to reach great Django developers?
0.197375
0
0
179
4,131,120
2010-11-09T06:42:00.000
2
0
0
0
python,django,admin
4,131,152
2
false
1
0
Let's say you create a model called Entry. IE an extremely simple blog. You write a view to show all the entries on the front page. Now how do you put those entries on the webpage? How do you edit them? Enter the admin. You register your model with the admin, create a superuser and log in to your running webapp. It's t...
2
0
0
On the website, it says this: One of the most powerful parts of Django is the automatic admin interface. It reads metadata in your model to provide a powerful and production-ready interface that content producers can immediately use to start adding content to the site. In this document, we discuss how t...
What are the best uses for the Django Admin app?
0.197375
0
0
170
4,131,120
2010-11-09T06:42:00.000
1
0
0
0
python,django,admin
4,131,237
2
false
1
0
Some of the uses I can think of - Editing data or Adding data. If you have any sort of data entry tasks, the admin app handles it like a breeze. Django’s admin especially shines when non-technical users need to be able to enter data. If you have understood above point, then this makes it possible for programmers to w...
2
0
0
On the website, it says this: One of the most powerful parts of Django is the automatic admin interface. It reads metadata in your model to provide a powerful and production-ready interface that content producers can immediately use to start adding content to the site. In this document, we discuss how t...
What are the best uses for the Django Admin app?
0.099668
0
0
170
4,131,327
2010-11-09T07:24:00.000
2
0
0
0
python,ajax,dojo,flask
4,131,349
1
true
1
0
No any special secure actions required. Consider ajax request as any other client request.
1
1
0
Hi I am trying to secure a server function being used for an Ajax request, so that the function is not accessed for any sort of malicious activity. I have done the following till now:- I am checking whether a valid session is present while the function is being called. I am using POST rather than GET I look for specif...
Handling and securing server functions in an ajax request..python
1.2
0
1
280
4,131,582
2010-11-09T08:12:00.000
5
0
1
0
python
4,153,989
3
false
0
0
Because self is just a parameter to a function, like any other parameter. For example, the following call: a = A() a.x() essentially gets converted to: a = A() A.x(a) Not making self a reserved word has had the fortunate result as well that for class methods, you can rename the first parameter to something else (no...
1
13
0
As far as I know, self is just a very powerful convention and it's not really a reserved keyword in Python. Java and C# have this as a keyword. I really find it weird that they didn't make a reserved keyword for it in Python. Is there any reason behind this?
Why is self only a convention and not a real Python keyword?
0.321513
0
0
2,989
4,131,768
2010-11-09T08:37:00.000
0
0
1
0
python,persistence,repr
4,131,799
2
false
0
0
How to get it from the database is generally uninteresting. Return the way to recreate the object from scratch, e.g. SomeModel(field1, field2, ...).
1
2
0
What would be the best way to handle the __repr__() function for an object that is made persistent? For example, one that is representing a row in a database (relational or object). According to Python docs, __repr__() should return a string that would re-create the object with eval() such that (roughly) eval(repr(obj)...
Persistent objects and __repr__
0
0
0
130
4,132,207
2010-11-09T09:37:00.000
1
0
1
0
python,set,memory-management
4,132,256
6
false
0
0
Try to use array module.
1
4
0
Setup Python 2.6 Ubuntu x64 I have a set of unique integers with values between 1 and 50 million. New integers are added at random e.g. numberset.add(random.randint(1, 50000000)). I need to be able to quickly add new integers and quickly check if an integer is already present. Problem After a while, the set grows too...
Massive Python set of integers using too much memory
0.033321
0
0
2,296
4,132,493
2010-11-09T10:09:00.000
3
1
1
1
python,performance
4,132,499
4
false
0
0
Sure. Use one of the variants that uses a JITer, such as IronPython, Jython, or PyPy.
2
2
0
There was the Unladen Swallow project that aims to get a faster python, but it seems to be stopped : Is there a way to get a faster python, I mean faster than C-Python, without the use of psyco ?
When a faster python?
0.148885
0
0
312
4,132,493
2010-11-09T10:09:00.000
1
1
1
1
python,performance
4,132,523
4
false
0
0
I saw pypy to be very fast on some tests : have a look
2
2
0
There was the Unladen Swallow project that aims to get a faster python, but it seems to be stopped : Is there a way to get a faster python, I mean faster than C-Python, without the use of psyco ?
When a faster python?
0.049958
0
0
312
4,133,327
2010-11-09T11:51:00.000
0
0
0
0
python,c,numpy,hdf5,pytables
30,009,455
3
false
0
0
HDF5 takes care of binary compatibility of structures for you. You simply have to tell it what your structs consist of (dtype) and you'll have no problems saving/reading record arrays - this is because the type system is basically 1:1 between numpy and HDF5. If you use H5py I'm confident to say the IO should be fast ...
1
2
1
when I used NumPy I stored it's data in the native format *.npy. It's very fast and gave me some benefits, like this one I could read *.npy from C code as simple binary data(I mean *.npy are binary-compatibly with C structures) Now I'm dealing with HDF5 (PyTables at this moment). As I read in the tutorial, they are u...
HDF5 : storing NumPy data
0
0
0
6,260
4,133,816
2010-11-09T12:50:00.000
7
0
1
0
python,md5,hashlib
4,133,902
2
false
0
0
Why do you think it's inefficient to make a new one? It's a small object, and objects are created and destroyed all the time. Use a new one, and don't worry about it.
1
21
0
How do you flush (or reset) and reuse an instance of hashlib.md5 in python? If I am performing multiple hashing operations in a script, it seems inefficient to use a new instance of hashlib.md5 each time, but from the python documentation I don't see any way to flush or reset the instance.
How to reuse an instance of hashlib.md5
1
0
0
8,207
4,135,836
2010-11-09T16:10:00.000
0
0
0
0
python,xml,serialization,pickle
4,136,375
2
true
0
0
So what you're looking for is a python library that spits out arbitrary XML for your objects? You don't need to control the format, so you can't be bothered to actually write something that iterates over the relevant properties of your data and generates the XML using one of the existing tools? This seems like a bad id...
1
4
0
For a while I've been using a package called "gnosis-utils" which provides an XML pickling service for Python. This class works reasonably well, however it seems to have been neglected by it's developer for the last four years. At the time we originally selected gnosis it was the only XML serization tool for Python. T...
XML object serialization in python, are there any alternatives to Gnosis?
1.2
0
1
2,017
4,136,800
2010-11-09T17:49:00.000
5
0
0
0
python,performance,sqlite
4,136,841
3
true
0
0
SQLite does not run in a separate process. So you don't actually have any extra overhead from IPC. But IPC overhead isn't that big, anyway, especially over e.g., UNIX sockets. If you need multiple writers (more than one process/thread writing to the database simultaneously), the locking overhead is probably worse, and ...
3
4
0
I noticed that a significant part of my (pure Python) code deals with tables. Of course, I have class Table which supports the basic functionality, but I end up adding more and more features to it, such as queries, validation, sorting, indexing, etc. I to wonder if it's a good idea to remove my class Table, and refacto...
Pros and cons of using sqlite3 vs custom table implementation
1.2
1
0
903
4,136,800
2010-11-09T17:49:00.000
4
0
0
0
python,performance,sqlite
4,136,876
3
false
0
0
You could try to make a sqlite wrapper with the same interface as your class Table, so that you keep your code clean and you get the sqlite performences.
3
4
0
I noticed that a significant part of my (pure Python) code deals with tables. Of course, I have class Table which supports the basic functionality, but I end up adding more and more features to it, such as queries, validation, sorting, indexing, etc. I to wonder if it's a good idea to remove my class Table, and refacto...
Pros and cons of using sqlite3 vs custom table implementation
0.26052
1
0
903
4,136,800
2010-11-09T17:49:00.000
0
0
0
0
python,performance,sqlite
4,136,862
3
false
0
0
If you're doing database work, use a database, if your not, then don't. Using tables, it sound's like you are. I'd recommend using an ORM to make it more pythonic. SQLAlchemy is the most flexible (though it's not strictly just an ORM).
3
4
0
I noticed that a significant part of my (pure Python) code deals with tables. Of course, I have class Table which supports the basic functionality, but I end up adding more and more features to it, such as queries, validation, sorting, indexing, etc. I to wonder if it's a good idea to remove my class Table, and refacto...
Pros and cons of using sqlite3 vs custom table implementation
0
1
0
903
4,137,509
2010-11-09T19:17:00.000
0
0
0
0
python-3.x,readlines
14,191,615
3
false
0
0
As it is about two years from asking the question, you probably already know the reason. Basically, Python 3 strings are Unicode strings. To make them abstract you need to tell Python what encoding is used for the file. Python 2 strings are actually byte sequences and Python feels fine to read whatever bytes from the f...
1
2
0
Python 3.1.2 (r312:79147, Nov 9 2010, 09:41:54) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> open("/home/madsc13ntist/test_file.txt", "r").readlines()[6] Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/pyth...
python3: readlines() indices issue?
0
0
0
1,413
4,137,859
2010-11-09T19:52:00.000
1
0
1
0
php,python,programming-languages
4,137,916
3
false
0
0
It is a design decision the authors of the languages chose to make. Generally spoken (and this is of course not always the case) the nicer the syntax a language has the slower it tends to be. Case in point: Ruby.
2
0
0
I don't mean for this question to be about Python vs PHP but about languages in general. I use Python and PHP as examples because I know them. In Python we can do mytoken = mystring.split(mydelimiter)[1], accessing the list returned by str.split without ever assigning it to a list. In PHP we must put the array in me...
Why are functions indexable in Python but not PHP?
0.066568
0
0
203
4,137,859
2010-11-09T19:52:00.000
1
0
1
0
php,python,programming-languages
24,936,359
3
false
0
0
This feature is now possible with PHP as of version 5.4.
2
0
0
I don't mean for this question to be about Python vs PHP but about languages in general. I use Python and PHP as examples because I know them. In Python we can do mytoken = mystring.split(mydelimiter)[1], accessing the list returned by str.split without ever assigning it to a list. In PHP we must put the array in me...
Why are functions indexable in Python but not PHP?
0.066568
0
0
203
4,137,917
2010-11-09T19:57:00.000
1
1
1
0
python
4,138,407
1
true
0
0
A quick fix to your problem should be by adding the full path of the egg to a .pth file which should exist in the sys-path (in your case site-packages).
1
0
0
I needed to make a change to a 3rd party library, so I edited the files in the egg (which is not zipped). The egg lives in site-packages in a virtualenv. Everything works fine on my dev machine, but when I copied the egg to another machine, the module can longer be found to import. I'm sure I went about this the wrong ...
Copied python egg no longer works
1.2
0
0
89
4,138,504
2010-11-09T20:52:00.000
0
0
0
1
python,mysql,permissions,configuration-files
4,139,191
2
false
0
0
Are you sure that file isn't hardcoded in some other portion of the build process? Why not just add it to you $PATH for the duration of the build? Does the script need to write that file for some reason? Does the build script use su or sudo to attempt to become some other user? Are you absolutely sure about both the pe...
2
3
0
The context: I'm working on some Python scripts on an Ubuntu server. I need to use some code written in Python 2.7 but our server has Python 2.5. We installed 2.7 as a second instance of Python so we wouldn't break anything reliant on 2.5. Now I need to install the MySQLdb package. I assume I can't do this the easy way...
Trouble installing MySQLdb for second version of Python
0
1
0
429
4,138,504
2010-11-09T20:52:00.000
2
0
0
1
python,mysql,permissions,configuration-files
4,139,563
2
false
0
0
As far as I'm aware, there is a very significant difference between "mysql_config" and "my.cnf". "mysql_config" is usually located in the "bin" folder of your MySQL install and when executed, spits out various filesystem location information about your install. "my.cnf" is a configuration script used by MySQL itself. ...
2
3
0
The context: I'm working on some Python scripts on an Ubuntu server. I need to use some code written in Python 2.7 but our server has Python 2.5. We installed 2.7 as a second instance of Python so we wouldn't break anything reliant on 2.5. Now I need to install the MySQLdb package. I assume I can't do this the easy way...
Trouble installing MySQLdb for second version of Python
0.197375
1
0
429
4,138,886
2010-11-09T21:35:00.000
4
0
0
1
python,linux,unix,cross-compiling
4,139,691
1
true
0
0
The standard freeze tool (from Tools/freeze) can be used to make fully-standalone binaries on Unix, including all extension modules and builtins (and omitting anything that is not directly or indirectly imported).
1
2
0
Anybody know how this can be done? I took a look at cx_Freeze, but it seems that it doesn't compile everything necessary into one binary (i.e., the python builtins aren't present).
How to create Unix and Linux binaries from Python code
1.2
0
0
3,222
4,139,167
2010-11-09T22:06:00.000
0
1
1
0
python,module
30,371,608
4
false
0
0
Before importing any user defined module,specify the path to the directory containg that module sys.path.append("path to your directory")
1
0
0
I'm going through the Python tutorial, and I got to the section on modules. I created a fibo.py file in Users/Me/code/Python (s Now I'm back in the interpreter and I can't seem to import the module, because I don't understand how to import a relative (or absolute) path. I'm also thoroughly confused by how and if to...
Importing a module in Python
0
0
0
6,865
4,140,396
2010-11-10T01:15:00.000
5
0
0
0
python,user-interface,listbox,tkinter,ttk
4,141,054
1
true
0
1
you cannot. The widget doesn't support that. you can't disable certain items, the widget doesn't support a state attribute. That being said, you can monitor the selection and do the appropriate thing if the user selects something that is disabled, and use the item foreground to denote disabled-ness. You will need to bi...
1
4
0
I'm studying the Tkinter Listbox widget and have been unable to find solutions for the following functionality: How can I create non-selectable horizontal separator items, eg. separators equivalent to the Tkinter Menu widget's .add_separator()? (Using chars like dashes and underscores looks awful). How can I disable ...
Tkinter: Listbox separators, disabled items, keyboard navigation?
1.2
0
0
2,343
4,140,619
2010-11-10T02:05:00.000
1
0
0
1
python,perl,bash
4,140,643
9
false
0
0
Read in the text file, create a hash with the current file name, so files['1500000704'] = 'SH103239' and so on. Then go through the files in the current directory, grab the new filename from the hash, and rename it.
1
7
0
I have a folder full of image files such as 1500000704_full.jpg 1500000705_full.jpg 1500000711_full.jpg 1500000712_full.jpg 1500000714_full.jpg 1500000744_full.jpg 1500000745_full.jpg 1500000802_full.jpg 1500000803_full.jpg I need to rename the files based on a lookup from a text file which has entries such as, SH...
Bulk renaming of files based on lookup
0.022219
0
0
5,950
4,140,656
2010-11-10T02:13:00.000
1
1
1
1
python,asynchronous,libevent,gevent
4,140,840
2
true
0
0
Biggest issue is that without threads, a block for one client will cause a block for all client. For example, if one client requests a resource (file on disk, paged-out memory, etc) that requires the OS to block the requesting process, then all clients will have to wait. A multithreaded server can block just the one cl...
2
9
0
I am writing now writing some evented code (In python using gevent) and I use the nginx as a web server and I feel both are great. I was told that there is a trade off with events but was unable to see it. Can someone please shed some light? James
Why shouldn't I use async (evented) IO
1.2
0
0
1,703
4,140,656
2010-11-10T02:13:00.000
9
1
1
1
python,asynchronous,libevent,gevent
4,291,204
2
false
0
0
The only difficulty of evented programming is that you mustn't block, ever. This can be hard to achieve if you use some libraries that were designed with threads in mind. If you don't control these libraries, a fork() + message ipc is the way to go.
2
9
0
I am writing now writing some evented code (In python using gevent) and I use the nginx as a web server and I feel both are great. I was told that there is a trade off with events but was unable to see it. Can someone please shed some light? James
Why shouldn't I use async (evented) IO
1
0
0
1,703