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
9,241,091
2012-02-11T14:48:00.000
4
1
0
0
php,python,ruby-on-rails,ruby,go
9,241,134
2
true
0
0
Alas, I'd love to have 1 asset that I could use for all conditions but it's just not available in the world of computing. You're going to have to learn 2 or more. PHP is very widely used, so you might as well stick with it. If you can create decent webapps using it, go for it. I would suggest learning C/C++ too so you ...
1
2
0
I have learned in my University time Pascal and C and RedHat Linux/Unix . To get quickly one job, i started learning Microsoft Visual Basic 6.0 for speed in development etc. In that time, with C its like more time consuming and i was not confident to use it for job purpose, where most of the companies demand fast/rapi...
Stick with PHP or learn Go-lang?
1.2
0
0
8,545
9,242,713
2012-02-11T18:13:00.000
0
1
0
1
python,unix,sandbox
9,242,880
2
false
0
0
Create a new user account "student". Run your students' scripts as "student". Worst case, the script will destroy this special user account. If this happens, just delete user "student" and start over.
1
1
0
I have to run some student-made code that they made as homework, I'm running this on my own computer (Mac OS), and I'm not entirely certain they won't accidentally "rm -rf /" my machine. Is there an easy way to run their python scripts with reduced permissions, so that e.g. they can access only a certain directory? Is ...
Run python script with reduced permissions
0
0
0
224
9,242,989
2012-02-11T18:46:00.000
0
1
0
1
python,c,sudo,suid
9,243,141
1
false
0
0
You don't want to use a shebang at all, on any file - you want to use a binary which invokes the Python interpreter, then tells it to start the script file for which you asked. It needs to do three things: Start a Python interpreter (from a trusted path, breaking chroot jails and so on). I suggest statically linking l...
1
3
0
(Note: I’ve Linux in mind, but the problem may apply on other platforms.) Problem: Linux doesn’t do suid on #! scripts nor does it activate “Linux capabilities” on them. Why dow we have this problem? Because during the kernel interpreter setup to run the script, an attacker may have replaced that file. How? The formerl...
Is this a safe suid/capability wrapper for (Python) scripts?
0
0
0
2,470
9,244,255
2012-02-11T21:35:00.000
0
0
1
0
python,xml,parsing,exe
9,244,785
1
false
0
0
I can not post comments currently, but if you are using py2exe, make sure you are ONLY importing modules from your python path. If you are not, you might want to check if your module goes into the same path your program specifies. Py2exe (if assuming you have it) creates two directories when it compiles (by default) an...
1
0
0
I'm somewhat new to Python, and am trying to build a standalone parser. The actual parser works when executed through python, but I get an error when I try to run it after it's been converted into an exe file. I need it to be able to run without any third-party software. The error says that there is no module named xml...
XML Parsing using Python converted to an exe file
0
0
1
292
9,245,466
2012-02-12T00:51:00.000
0
0
0
0
python,numpy,statistics
9,245,481
3
false
0
0
How many grids are there? One option would be to create a 3D array that is 100x100xnumGrids and compute the median across the 3rd dimension.
1
1
1
I have many 100x100 grids, is there an efficient way using numpy to calculate the median for every grid point and return just one 100x100 grid with the median values? Presently, I'm using a for loop to run through each grid point, calculating the median and then combining them into one grid at the end. I'm sure there's...
Efficient two dimensional numpy array statistics
0
0
0
1,689
9,245,656
2012-02-12T01:32:00.000
6
0
1
1
python,parallel-processing,multiprocessing,celery
9,246,968
2
true
0
0
I have actually never used Celery, but I have used multiprocessing. Celery seems to have several ways to pass messages (tasks) around, including ways that you should be able to run workers on different machines. So a downside might be that message passing could be slower than with multiprocessing, but on the other hand...
1
26
0
I'm having a bit of trouble deciding whatever to use python multiprocessing or celery or pp for my application. My app is very CPU heavy but currently uses only one cpu so, I need to spread it across all available cpus(which caused me to look at python's multiprocessing library) but I read that this library doesn't s...
Is Celery as efficient on a local system as python multiprocessing is?
1.2
0
0
8,882
9,245,719
2012-02-12T01:45:00.000
1
0
1
0
python,eclipse
9,245,979
1
true
0
0
The projects for the current workspace are shown in the "Package Explorer" view, which displays them as in a "Windows Explorer" fashion. Using this view you can open/close and manage your projects for a given workspace. If you currently don't have Package Explorer open, you can go to Window->Show View->Package Explorer...
1
2
0
I'm brand new to Eclipse (learning Python). I'm really confused about the terminology within Eclipse. I had previously created a "hello world" project and exited Eclipse. I've restarted Eclipse, but how do I list all of the projects in the current workspace? Is there a way to do that? If not how do I open a projec...
How do you view/list projects within a workspace within Eclipse?
1.2
0
0
144
9,246,204
2012-02-12T03:35:00.000
5
0
0
0
windows,python-3.x,pyqt4
9,246,252
1
true
0
1
Use the python extension .pyw. E.g program.pyw This causes your program to be run with pythonw.exe instead of python.exe which suppresses the terminal.
1
2
0
I have a Python program that is mostly complete, and there is one thing that I'd like to change, which may or may not be possible. This program uses PyQT to display a GUI and I have it pretty much pinned up so I was wondering if I can make Python not open up a termianl when I open the program. I am using Windows XP rig...
How to make a Python PyQT program not open the command line in Windows
1.2
0
0
1,931
9,246,353
2012-02-12T04:06:00.000
1
0
1
0
python,uninstallation,downgrade
37,056,225
5
false
0
0
You could install PyCharm or another Python IDE. It allows you to change which version of python you use to interpret your code. This will also identify syntax errors as you are writing and will notify you of them - in case you have code that works in 3.x but not 2.x. Ecker00 is right, installing 2.7 in a separate dire...
3
10
0
I am trying to uninstall Python 3.2 and go back to 2.7, I do not have much experience with Python, and as I am learning now, it is becoming increasingly difficult to manage all of the work arounds needed to work with the newest version, and I require 2.7 for a college course. I tried using the Windows 7 add/remove prog...
How Can I Downgrade from Python 3.2 to 2.7?
0.039979
0
0
65,345
9,246,353
2012-02-12T04:06:00.000
2
0
1
0
python,uninstallation,downgrade
9,248,312
5
false
0
0
Python 3.x is not backward compatible with Python 2.x, which was the purpose of the release. To clean up Python2.x without worrying about backward compatibility. You can have as many python installations as you want on your computer, as they do not interact with each other. The python installations have it's own folder...
3
10
0
I am trying to uninstall Python 3.2 and go back to 2.7, I do not have much experience with Python, and as I am learning now, it is becoming increasingly difficult to manage all of the work arounds needed to work with the newest version, and I require 2.7 for a college course. I tried using the Windows 7 add/remove prog...
How Can I Downgrade from Python 3.2 to 2.7?
0.07983
0
0
65,345
9,246,353
2012-02-12T04:06:00.000
-1
0
1
0
python,uninstallation,downgrade
39,293,962
5
false
0
0
Use the following steps to get it fixed. //Check current Python pointer ls -l python //Check available Python versions ls -l python* //Unlink current python version sudo unlink python //Select required python version and lin to python command sudo ln -s /usr/bin/python2.7 python //Confirm change in pointer ls ...
3
10
0
I am trying to uninstall Python 3.2 and go back to 2.7, I do not have much experience with Python, and as I am learning now, it is becoming increasingly difficult to manage all of the work arounds needed to work with the newest version, and I require 2.7 for a college course. I tried using the Windows 7 add/remove prog...
How Can I Downgrade from Python 3.2 to 2.7?
-0.039979
0
0
65,345
9,246,720
2012-02-12T05:39:00.000
0
0
1
0
python,string,bucket,data-partitioning
12,116,596
2
false
0
0
A hash by definition doesn't preserve any order. And I don't think there is any pythonic way to do this. You could just create dictionaries (which are basically hashing functions) and keep adding a string to each round-robin style, but it wouldn't preserve any order.
2
1
0
I have N strings that I want to divide lexicographic into M even-sized buckets (+/- 1 string). Also, N>>M. The direct way would be to sort all the strings and split the resulting list into the M buckets. I would like to instead approximate this by routing each string as it is created to a bucket, before the full list i...
Grouping strings lexicographically (python)
0
0
0
360
9,246,720
2012-02-12T05:39:00.000
0
0
1
0
python,string,bucket,data-partitioning
9,574,315
2
true
0
0
You can sort by first two chars of a string, or something of this sort. Let's say that M=100, so you should divide the characters into sqrt(M) regions, and each should point to another sqrt(M) regions, then for each string you get, you can compare the first char to decide which region to direct the string to and again ...
2
1
0
I have N strings that I want to divide lexicographic into M even-sized buckets (+/- 1 string). Also, N>>M. The direct way would be to sort all the strings and split the resulting list into the M buckets. I would like to instead approximate this by routing each string as it is created to a bucket, before the full list i...
Grouping strings lexicographically (python)
1.2
0
0
360
9,248,821
2012-02-12T12:37:00.000
1
0
0
0
python,linear-algebra,sparse-matrix,matrix-inverse
9,248,907
1
false
0
0
In general the inverse of a sparse matrix is not sparse which is why you won't find sparse matrix inverters in linear algebra libraries. Since D is diagonal, D^(-1/2) is trivial and the Laplacian matrix calculation is thus trivial to write down. L has the same sparsity pattern as A but each value A_{ij} is multiplied b...
1
3
1
I have two sparse matrix A (affinity matrix) and D (Diagonal matrix) with dimension 100000*100000. I have to compute the Laplacian matrix L = D^(-1/2)*A*D^(-1/2). I am using scipy CSR format for sparse matrix. I didnt find any method to find inverse of sparse matrix. How to find L and inverse of sparse matrix? Also sug...
Python Sparse matrix inverse and laplacian calculation
0.197375
0
0
1,503
9,248,933
2012-02-12T12:53:00.000
1
0
1
0
python
9,248,957
3
false
0
0
just access the list[0][0] for 19 and [0][1] for 0.97471237. its a list of tuples.
1
1
0
I have python list with one item like this - [(19, 0.97471237)] Now i need to split it into 19 and 0.97471237 How do i do that ?
How to split list item?
0.066568
0
0
220
9,249,219
2012-02-12T13:42:00.000
2
0
0
0
python
9,253,503
2
false
0
0
This is a problem that people usually solve using sax. If your huge file is basically a bunch of XML documents aggregated inside and overall XML envelope, then I would suggest using sax (or plain string parsing) to break it up into a series of individual documents that you can then process using lxml.etree.
1
7
0
I have a very large XML file with 40,000 tag elements. When i am using element tree to parse this file it's giving errors due to memory. So is there any module in python that can read the xml file in data chunks without loading the entire xml into memory?And How i can implement that module?
How to parse XML file in chunks
0.197375
0
1
3,249
9,249,995
2012-02-12T15:33:00.000
5
0
1
0
python,eclipse,pydev
9,286,199
3
true
0
0
When you set the PYTHONPATH for a project, pydev will create a .pydevproject file in the root of your project. Make sure that file is being properly written (it could be that your project is read-only or something like that which could prevent PyDev from writing that file where the settings are persisted). If that's no...
2
6
0
I can setup a working PYTHONPATH using project properties, but it seems like after every reboot, I have to manually reset it. Is there a good way to persist the PYTHONPATH associated with a project?
How to persist PYTHONPATH setting of an Eclipse Pydev project?
1.2
0
0
13,492
9,249,995
2012-02-12T15:33:00.000
0
0
1
0
python,eclipse,pydev
9,250,104
3
false
0
0
Then you create new pydev project you can select option like "Add project to your python path". If you want you can customize python's intepreter and associated libs.
2
6
0
I can setup a working PYTHONPATH using project properties, but it seems like after every reboot, I have to manually reset it. Is there a good way to persist the PYTHONPATH associated with a project?
How to persist PYTHONPATH setting of an Eclipse Pydev project?
0
0
0
13,492
9,250,624
2012-02-12T16:53:00.000
0
0
1
0
python,tkinter
9,252,989
3
false
0
1
A GUI program is always waiting for some action to occur. When actions do occur, the event code corresponding to that action is executed. Therefore, there is no need to call sleep(). All you need to do is set it up so that the third program is executed from the appropriate event.
2
2
0
This is quite an essential part of my program and I need to have sorted out as soon as possible so anything would be a massive help. My program consists of three modules which are imported to each other. One module consists of my user interface for which I am using tkinter. The user inputs data on a canvas which is sen...
stop tkinter window from freezing while program is sleeping
0
0
0
4,892
9,250,624
2012-02-12T16:53:00.000
1
0
1
0
python,tkinter
9,265,601
3
false
0
1
H.E.P - The traditional way to do this does indeed involve using a separate thread and co-ordinating the work between the "worker" thread and the GUI thread using some sort of polling or eventing mechanism. But, as Thomas K. points out, that can get very complex and tricky, especially regarding Python's use of the Glo...
2
2
0
This is quite an essential part of my program and I need to have sorted out as soon as possible so anything would be a massive help. My program consists of three modules which are imported to each other. One module consists of my user interface for which I am using tkinter. The user inputs data on a canvas which is sen...
stop tkinter window from freezing while program is sleeping
0.066568
0
0
4,892
9,252,986
2012-02-12T21:43:00.000
3
0
0
0
python,django
9,253,022
4
true
1
0
You need to build mod_wsgi against python 2.7 and load this module into apache instead of the current mod_wsgi version you are using that links against python 2.4. This requires root access to the machine.
3
1
0
The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] I can't update Python 2.4 because CentOS depends on that versio...
How do set Python path to run Django with WSGI and Apache?
1.2
0
0
1,793
9,252,986
2012-02-12T21:43:00.000
0
0
0
0
python,django
9,253,191
4
false
1
0
"You got peanut butter on my chocolate!" "You got chocolate in my peanut butter!" Two great tastes that go together. As Thiefmaster says, you need to use the correct version of wsgi. As Alex says, you need to run in a virtualenv for the later python so that you don't mess up everything else. Install all your python stu...
3
1
0
The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] I can't update Python 2.4 because CentOS depends on that versio...
How do set Python path to run Django with WSGI and Apache?
0
0
0
1,793
9,252,986
2012-02-12T21:43:00.000
0
0
0
0
python,django
9,253,152
4
false
1
0
You can run Django 1.3 in Python 2.4 without problems. I think it's the best choice for CentOS, and you won't have to upgrade Python. I've installed django on Centos 5 with Apache+mod_wsgi and Cherokee+uwsgi (I prefer the last one)
3
1
0
The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] I can't update Python 2.4 because CentOS depends on that versio...
How do set Python path to run Django with WSGI and Apache?
0
0
0
1,793
9,254,671
2012-02-13T01:53:00.000
1
0
0
0
python,waveform
9,254,885
2
false
0
0
An MP3 file is an encoded version of a waveform. Before you can work with the waveform, you must first decode the MP3 data into a PCM waveform. Once you have PCM data, each sample represents the waveform's amplitude at the point in time. If we assume an MP3 decoder outputs signed, 16-bit values, your amplitudes will ra...
1
2
1
I'm trying to build something in python that can analyze an uploaded mp3 and generate the necessary data to build a waveform graphic. Everything I've found is much more complex than I need. Ultimately, I'm trying to build something like you'd see on SoundCloud. I've been looking into numpy and fft's, but it all seem mo...
Generate volume curve from mp3
0.099668
0
0
1,275
9,255,761
2012-02-13T04:52:00.000
3
0
0
1
python,google-app-engine,cron
9,257,522
2
true
0
0
You could tell the bot to add the new schedule in your datastore instead. Then create a single "master" cron job with 1 minute schedule that checks the schedules that you had set in the datastore. The cron job would then determine whether on the current time the handler for an associated schedule need to be invoked or ...
2
2
0
I need to make a bot who can automatically add a cron job for itself,but I don't think I could access the cron.yaml file on GAE server.What can I do with this?
How to make my program add a cron job automatically with GAE?
1.2
0
0
296
9,255,761
2012-02-13T04:52:00.000
0
0
0
1
python,google-app-engine,cron
9,256,920
2
false
0
0
It's true that a lot of dev environments don't give you access to the cron.yaml files, however, you can run a Python script locally that communicates with your deployed program, edits your local copy of cron.yaml and pushes up the changes.
2
2
0
I need to make a bot who can automatically add a cron job for itself,but I don't think I could access the cron.yaml file on GAE server.What can I do with this?
How to make my program add a cron job automatically with GAE?
0
0
0
296
9,255,776
2012-02-13T04:55:00.000
-2
0
0
0
python,database,django,rest
9,451,170
3
false
1
0
I'm facing a similar obstacle with a new ecommerce project. The project is a front end to a full-fledged store management software (CMS+ERP+CRM). It needs to use the master product database, but have its own entries for product reviews, ratings and so on. The initial thought was to make a cached copy of the master data...
1
8
0
I have a Django web front-end that consumes data from a REST API backend. Even the users are made and created on the backend. My Problem : How to use 3rd party apps within this system, that heavily depend on django models/ORM ? Is there something that can provide some bridge between the REST API resources and the ORM?...
Django : Project consuming data from REST API, How to use external apps in this system?
-0.132549
0
0
2,102
9,255,930
2012-02-13T05:19:00.000
0
0
0
0
python,django,directory-structure
19,614,229
3
false
1
0
Virtualenv and pip are fantastic for working on multiple django projects on one machine. However, if you only have one project that you are editing, it is not necessary to use virtualenv.
1
2
0
I have a django project that uses a lot of 3rd party apps, so wanted to decide out of the two approaches to manage my situation : I can use [ virtualenv + pip ] along with pip freeze as requirements file to manage my project dependencies. I don't have to worry about the apps, but can't have that committed with my co...
Django : Which approach is better [ virtualenv + pip ] vs [manually carrying packages in svn]?
0
0
0
699
9,258,461
2012-02-13T09:52:00.000
1
0
1
0
python,compiler-construction,llvm
9,410,206
1
false
0
0
You could recompile python bytecode, then you can keep python syntax. i.e. language frontend as it is. If you wanted great improvement, you may have to change libpython. Look at pyastra and pymite projects, they do a subset of python and native execution. Cython can be useful as half-way between python and compilation....
1
6
0
I'm new to compiler design. I know the basics of compiler design. I want to develop a frond end which take a python program as input and using LLVM libraries and LLVM JIT compiler produces an output. Can some one please point me in right direction or provide some link for reading? What are the basic blocks I have to co...
What thing I will need for creating a front end for Python based on LLVM architecture?
0.197375
0
0
1,055
9,259,531
2012-02-13T11:16:00.000
0
0
0
1
python,hadoop,amazon-ec2
9,377,499
1
true
0
0
Its possible to download data onto hadoop on ec2. Hadoop has a distributed File system (HDFS) which takes care of placing blocks of data onto the slaves, and also honors the replication factor specified in configurations. The slaves in ec2 have different ip addresses.
1
0
0
I am thinking of launching a hadoop cluster on amazon ec2 to download a few tens of thousands of files and later do some processing of them but before putting to much work to it I would like to know if anyone more experienced with hadoop than me thinks that it is possible? I have some doubts about being able to downloa...
Downloading many large files through Amazon EC2 Hadoop
1.2
0
1
157
9,260,249
2012-02-13T12:07:00.000
7
0
0
0
python,html,django,json
9,260,320
1
true
1
0
Use different URLs for the JSON and HTML versions. I suggest that your JSON version be available on a url like r'normal/api(?P<json_flag>/json/?)$', and have a parameter in your view to receive the json flag. You can then serve appropriately. Naturally, your view will have to use different logic to generate HTML and J...
1
3
0
I have a django app which has html templates and I also have a command line python api which can do GET and POST requests to the django app on the server. The api can pretty much do everything that the django app can do. How do I make it such that when I access the django app through the browser it returns html but whe...
Django return json and html depending on client python
1.2
0
0
3,193
9,260,561
2012-02-13T12:31:00.000
0
0
0
0
wxpython,client,web
9,261,900
1
false
0
1
You should be able to use httplib or similar to communicate with your website and use wxPython as the front-end. When you hit you're Submit button or whatever, you would call httplib or a similar library to post the data to your website. You might need to use threads to keep the GUI responsive.
1
0
0
I am currently working on a GUI for a science experiment. I am using wxPython. I have done the design part and also the data logging in an SQLite database. Is it possible for the GUI to behave as a web-client and write data onto a website. I have a Kodingen account. Can this GUI write to my homepage everytime I run it?
wxPython GUI as a web-client
0
0
0
260
9,265,551
2012-02-13T18:06:00.000
0
0
0
1
python,matlab,operating-system,subprocess,matlab-deployment
9,265,849
2
false
0
0
Possible issues: You did not install MCR. Not running as administrator Running from network drive
1
2
0
I want to run my Matlab function (test.m) from Python. I converted the function to an exe file test.exe using mcc -m command of Matlab; and I can run it test.exe from command prompt of windows. On the other side, when I run exe files using os.system and subprocess.call by Python, it works well: subprocess.call('C:\Pro...
Running Matlab M-function from Python
0
0
0
1,156
9,268,611
2012-02-13T21:53:00.000
1
1
1
1
python,tcl
9,268,696
2
true
0
0
Tcl is not really very similar to Python. It has some surface similarities I guess, as it is a mostly procedural language, but its philosophy is rather different. Whereas Python takes the approach that everything is an object, Tcl's approach is sometimes described as "everything is (or can be) a string." There are some...
2
2
0
Right now, I'm learning Python and Javascript, and someone recently suggested to me that I learn tcl. Being a relative noob to programming, I have no idea what tcl is, and if it is similar to Python. As i love python, I'm wondering how similar the two are so I can see if I want to start it.
Similarities between tcl and Python
1.2
0
0
3,587
9,268,611
2012-02-13T21:53:00.000
5
1
1
1
python,tcl
9,268,859
2
false
0
0
While this question will obviously be closed as inconstructive in a short time, I'll leave my answer here anyway. Joe, you appear to be greatly confused about what should drive a person who count himself a programmer to learn another programming language: in fact, one should have a natural desire to learn different lan...
2
2
0
Right now, I'm learning Python and Javascript, and someone recently suggested to me that I learn tcl. Being a relative noob to programming, I have no idea what tcl is, and if it is similar to Python. As i love python, I'm wondering how similar the two are so I can see if I want to start it.
Similarities between tcl and Python
0.462117
0
0
3,587
9,268,916
2012-02-13T22:21:00.000
17
0
1
0
python,exception-handling,gevent,greenlets
9,273,337
4
true
0
0
The traceback is intentionally not saved when the Greenlet dies. If it was saved, it would keep a lot of objects alive that are expected to be deleted, which matters especially if the object manages some resource (open file or socket). If you want to save the traceback you have to do it yourself.
1
6
0
I've spawned a Greenlet and linked it to a callable. Some time later, the Greenlet fails with an Exception. The linked callable gets called. That's all great! Here's the issue: The traceback for the Exception appears on my console, as you'd expect. But I want do things with that traceback within the linked callable. Ho...
how to capture a traceback in gevent
1.2
0
0
3,158
9,269,902
2012-02-13T23:59:00.000
1
1
1
0
python,class,singleton,subclass,subclassing
9,269,944
3
false
0
0
When I hear "creating subclasses on the fly" I understand "create objects that behave differently on the fly", which is really a question of configuration. Is there anything you need that you can't get by just reading in some data and creating an object that decides how it is going to behave based on what it reads? Her...
1
11
0
I'm creating a game in which I have a somewhat complex method for creating entities. When a level is loaded, the loading code reads a bunch of YAML files that contain attributes of all the different possible units. Using the YAML file, it creates a so-called EntityResource object. This EntityResource object serves as...
Is there a way to create subclasses on-the-fly?
0.066568
0
0
9,225
9,271,525
2012-02-14T04:04:00.000
-1
0
0
0
python,windows
9,271,567
4
false
1
0
You simply need to leave your program running! Please google "python daemon" and see how to implement a persistent background process in Python. Now, you cannot know when a website changes unless you poll it. If the website is well designed, the page you are trying to poll will have a "Last-Modified" header, you can ma...
2
5
0
I had a program that Scraped certain data from certain Web-Pages, and when the Web-Pages changed, acted accordingly. How would one set up the program so it continues to run in the background? I don't need any specifics I'm just really confused on this concept and would appreciate whatever help anybody has to offer.
Python: Running Daemon Processes in Windows7
-0.049958
0
0
8,604
9,271,525
2012-02-14T04:04:00.000
10
0
0
0
python,windows
9,274,957
4
false
1
0
start path-to-pythonw.exe your-code.py pythonw means without console. start means start on background. if your python is installed system-wide, you can probably start your-code.pyw .pyw is associated with pythonw.exe remember you cannot use print (to stdout) in this case.
2
5
0
I had a program that Scraped certain data from certain Web-Pages, and when the Web-Pages changed, acted accordingly. How would one set up the program so it continues to run in the background? I don't need any specifics I'm just really confused on this concept and would appreciate whatever help anybody has to offer.
Python: Running Daemon Processes in Windows7
1
0
0
8,604
9,272,332
2012-02-14T05:50:00.000
19
0
1
0
c#,multithreading,ironpython,abort
9,279,021
2
false
0
0
What is a safe way to stop a running thread? Put the thread in its own process. When you want it to stop, kill the process. That is the only safe way to kill a thread. Aborting a thread can severely destabilize a process and lose user data. There's no way to avoid the "lose user data" scenario if you really, truly nee...
1
10
0
I have a thread which contains execution of an IronPython script. For some reason I may need to stop this thread at any time, including script execution. How to achieve this? The first idea is Thread.Abort(), but it's known to be evil...
What is a safe way to stop a running thread?
1
0
0
32,297
9,272,710
2012-02-14T06:35:00.000
0
0
0
0
php,python,django,templates,include
9,272,857
1
true
1
0
Depending on your use case a few options: Use a separate base template for all pages that need the widget; in that base add the required js/css files. For all views that need the widget, inherit from the modified base. Using javascript implement conditional includes.
1
0
0
I have a reusable google-maps widget that can be plugged into any page that might want to use it. Widget has : Google maps specific js includes. Map specific css to style the map. Problem: Widget code gets included as server-side include. Widget specific js and css has to included with the widget code. Therefore, if...
How to include plug-n-play widget statics [CSS/JS] without repetition?
1.2
0
0
162
9,277,875
2012-02-14T13:40:00.000
17
0
0
0
wxpython
9,294,892
3
false
0
1
As mentioned by the other fellow, make sure you have a 64-bit Python AND a 64-bit wxPython version downloaded. If one or the other is 32-bit, it won't work. Personally, I have never had any problems installing wxPython on Windows.
2
18
0
import wx Traceback (most recent call last): File "", line 1, in import wx File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.py", line 45, in from wx._core import * File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 4, in import _core_ ImportError: DLL load ...
DLL load failed: 1% is not valid win32 application
1
0
0
20,396
9,277,875
2012-02-14T13:40:00.000
2
0
0
0
wxpython
18,842,884
3
false
0
1
I had this problem in windows 7 with Python2.7 as I have installed 32bit wx version earlier. Try installing 64bit and it will work fine.If you are in 64 bit system and trying to install 32bit wx you will get some error at the beginning. So try 64bit wx.
2
18
0
import wx Traceback (most recent call last): File "", line 1, in import wx File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.py", line 45, in from wx._core import * File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 4, in import _core_ ImportError: DLL load ...
DLL load failed: 1% is not valid win32 application
0.132549
0
0
20,396
9,280,171
2012-02-14T16:06:00.000
52
0
0
0
python,matplotlib
9,280,538
5
false
0
0
I think that using show(block=True) should fix your problem.
1
55
1
I have a simple python script which plots some graphs in the same figure. All graphs are created by the draw() and in the end I call the show() function to block. The script used to work with Python 2.6.6, Matplotlib 0.99.3, and Ubuntu 11.04. Tried to run it under Python 2.7.2, Matplotlib 1.0.1, and Ubuntu 11.10 but t...
Matplotlib python show() returns immediately
1
0
0
84,640
9,280,488
2012-02-14T16:27:00.000
1
0
0
0
python,numpy
9,280,574
4
false
0
0
If you want to access the results by name, then you could use a python nested dictionary instead of ndarray, and serialize it in a .JSON text file using json module.
1
5
1
I have a scientific model which I am running in Python which produces a lookup table as output. That is, it produces a many-dimensional 'table' where each dimension is a parameter in the model and the value in each cell is the output of the model. My question is how best to store this lookup table in Python. I am runni...
How to store numerical lookup table in Python (with labels)
0.049958
0
0
1,600
9,281,907
2012-02-14T18:05:00.000
0
0
0
0
python,dropbox,dropbox-api
9,281,952
1
true
0
0
I don't think you can change this yourself(unless there's an api avail for it) but the settings for notifications is in the dropbox preferences. I believe the user would have to go there and turn it off globally since any change within dropbox will be reported to the end user based on the global preference settings. I...
1
1
0
I have not tried anything since I don't know from where to start. How can I implement code so that I don't get anything which shows that dropbox is syncing or updating. In other words, I want to create an application which works stealthly and automatically updates dropbox without the user even noticing anything?
Dropbox in stealth mode
1.2
0
0
295
9,282,100
2012-02-14T18:19:00.000
1
0
1
1
python,windows
9,282,142
2
false
0
0
Assuming Python is installed, it is usually placed in a folder prefixed with "Python" and the major/minor version. E.g. C:\Python26
1
0
0
I have always used a mac to write and run python scripts. However, I have a bunch of files on a PC that I need to run a script on. I have never really used a PC and don't know how to run the script. If I go to the command program on the PC and type in python, nothing happens. How do I find where the python path is in ...
Run a python script in windows
0.099668
0
0
2,860
9,283,788
2012-02-14T20:34:00.000
0
0
0
0
python,exe,hex-editors
9,284,042
2
false
0
1
You may find this next to impossible to do this way, since there could be thousands of characters like this in the exe. You'd probably be better off first searching for a less common item in your dropdown to give you a better chance of finding the "area" where it may be occurring. Then do a more localized search near...
1
0
0
I am trying to modify an exe (of mine) with a hex editor. It was originally written in Python using wx and turned into an exe via py2exe. I lost the source code (ugh) and need to change one of the items in a dropdown menu. It's a simple one character change, from a "6" to a "9". (Makes me think of Jimi Hendrix) I ha...
Hexedit of ASCII in exe not changing in app
0
0
0
411
9,288,221
2012-02-15T05:16:00.000
1
0
0
0
python,classification,nltk,probability
9,300,400
2
true
0
0
I am not sure about the NLTK implementation of Naive Bayes, but the Naive Bayes algorithm outputs probabilities of class membership. However, they are horribly calibrated. If you want good measures of certainty, you should use a different classification algorithm. Logistic regression will do a decent job at producing...
2
1
1
In NLTK, if I write a NaiveBayes classifier for say movie reviews (determining if positive or negative), how can I determine the classifier "certainty" when classify a particular review? That is, I know how to run an 'accuracy' test on a given test set to see the general accuracy of the classifier. But is there anyway ...
NLTK certainty measure?
1.2
0
0
524
9,288,221
2012-02-15T05:16:00.000
1
0
0
0
python,classification,nltk,probability
9,300,932
2
false
0
0
nltk.classify.util.log_likelihood. For this problem, you can also try measuring the results by precision, recall, F-score at the token level, that is, scores for positive and negative respectively.
2
1
1
In NLTK, if I write a NaiveBayes classifier for say movie reviews (determining if positive or negative), how can I determine the classifier "certainty" when classify a particular review? That is, I know how to run an 'accuracy' test on a given test set to see the general accuracy of the classifier. But is there anyway ...
NLTK certainty measure?
0.099668
0
0
524
9,288,747
2012-02-15T06:16:00.000
13
0
0
0
python,flask,werkzeug
9,288,773
1
true
1
0
Flask and Werkzeug are different things. Flask contains Werkzeug as one of the things in it, but also has much more (which might be unwanted). Flask is a web microframework. Werkzeug is a WSGI middleware.
1
9
0
I am just curious to know as why should we use werkzeug when flask is there. Any specific reason to consider werkzeug over flask.
Why use werkzeug when there is flask
1.2
0
0
3,175
9,289,427
2012-02-15T07:27:00.000
8
0
1
0
python,slice
9,289,467
3
true
0
0
No. Both result in slice(None, None, None). Positive strides go forwards. Negative strides go backwards. Zero strides go... nowhere? How exactly would that work? An infinite sequence of a single value?
2
4
0
Is there any difference between mylist[:] and mylist[::]? What's the rationale for mylist[::0] to raise an error since negative steps are allowed?
About slices in Python
1.2
0
0
5,495
9,289,427
2012-02-15T07:27:00.000
0
0
1
0
python,slice
9,289,485
3
false
0
0
Third element is for steps. When you write mylist[:] it will assume step will be 1 which is same case in mylist[::]. If you write mylist[::0] then it will raise error because steps can be +ve or -ve not 0
2
4
0
Is there any difference between mylist[:] and mylist[::]? What's the rationale for mylist[::0] to raise an error since negative steps are allowed?
About slices in Python
0
0
0
5,495
9,290,018
2012-02-15T08:27:00.000
1
1
1
1
python,linux
9,290,219
2
false
0
0
Regarding the script in /usr/bin, if you execute your script as a user that doesn't have permissions to write in /usr/bin, then the .pyc files won't be created and, as far as I know, there isn't any other caching mechanism. This means that your file will be byte compiled by the interpreter every time so, yes, there wil...
2
3
0
If I place my project in /usr/bin/ will my python interpreter generate bytecode? If so where does it put them as the files do not have write permission in that folder. Does it cache them in a temp file? If not, is there a performance loss for me putting the project there? I have packaged this up as a .deb file that i...
Out of home folder .pyc files?
0.099668
0
0
738
9,290,018
2012-02-15T08:27:00.000
1
1
1
1
python,linux
9,290,322
2
false
0
0
.pyc/.pyo files are not generated for scripts that are run directly. Python modules placed where Python modules are normally expected and packaged up have the .pyc/.pyo files generated at either build time or install time, and so aren't the end user's problem.
2
3
0
If I place my project in /usr/bin/ will my python interpreter generate bytecode? If so where does it put them as the files do not have write permission in that folder. Does it cache them in a temp file? If not, is there a performance loss for me putting the project there? I have packaged this up as a .deb file that i...
Out of home folder .pyc files?
0.099668
0
0
738
9,296,393
2012-02-15T15:42:00.000
1
0
0
0
python,wxpython,twisted
9,319,541
2
false
0
1
I'm using wxPython with Twisted on Linux, Mac and Windows without any crazy things happening.
1
1
0
Am wondering does twisted framework work well with wxPython GUI framework. From the docs its seems like twisted does not support wxPython well. The example given seems to be a bit shy on the details. If not, what is the best way of using twisted with wxPython? Which other non-blocking event-driven networking framework...
Does Python Twisted work with wxPython?
0.099668
0
0
762
9,297,679
2012-02-15T16:57:00.000
0
0
0
0
python,random,trigonometry,hypotenuse
9,297,835
2
false
0
0
If you have a hypotenuse in the form of a line segment, then you have two points. From two points in the form P0 = (x0, y0) P1 = (x1, y1) you can get the x and y displacements by subtracting x0 from x1 and y0 from y1. If your hypotenuse is actually a vector in a polar coordinate plane, then yes, you'll have to take the...
2
1
1
I'm writing a simple 2d brownian motion simulator in Python. It's obviously easy to draw values for x displacement and y displacement from a distribution, but I have to set it up so that the 2d displacement (ie hypotenuse) is drawn from a distribution, and then translate this to new x and y coordinates. This is probabl...
2d random walk in python - drawing hypotenuse from distribution
0
0
0
996
9,297,679
2012-02-15T16:57:00.000
1
0
0
0
python,random,trigonometry,hypotenuse
9,298,238
2
true
0
0
This is best done by using polar coordinates (r, theta) for your distributions (where r is your "hypotenuse")), and then converting the result to (x, y), using x = r cos(theta) and y = r sin(theta). That is, select r from whatever distribution you like, and then select a theta, usually from a flat, 0 to 360 deg, distr...
2
1
1
I'm writing a simple 2d brownian motion simulator in Python. It's obviously easy to draw values for x displacement and y displacement from a distribution, but I have to set it up so that the 2d displacement (ie hypotenuse) is drawn from a distribution, and then translate this to new x and y coordinates. This is probabl...
2d random walk in python - drawing hypotenuse from distribution
1.2
0
0
996
9,299,399
2012-02-15T18:51:00.000
5
0
1
0
python,datetime
9,299,593
3
false
0
0
Normally, a server application will do all its time storage and calculations in UTC. Times would also be transmitted to the client in UTC. Then, you do the conversion to local time at the client side (in Javascript, if it's a web application). It's very difficult for a server to get the time zone right for every client...
2
5
0
In a Python application I need to know the current day. datetime.date.today() works well. The problem is that when I deploy the program to my server located in the USA, my user base (that is Italian) is presented a date that may not be the correct one (since the server is 6 time zones away). How can I construct a date ...
Time zones in Python
0.321513
0
0
1,049
9,299,399
2012-02-15T18:51:00.000
-2
0
1
0
python,datetime
9,299,444
3
false
0
0
access the class, create an instance, set your own time, access that object everytime you want the time.
2
5
0
In a Python application I need to know the current day. datetime.date.today() works well. The problem is that when I deploy the program to my server located in the USA, my user base (that is Italian) is presented a date that may not be the correct one (since the server is 6 time zones away). How can I construct a date ...
Time zones in Python
-0.132549
0
0
1,049
9,299,872
2012-02-15T19:24:00.000
1
0
0
1
python,twisted
9,301,329
1
true
0
0
Just use callFromThread directly as your queue. The reactor is already synchronizing on and monitoring it. Anywhere you want to call foo.sendString() from a non-reactor thread, just do reactor.callFromThread(foo.sendString). Building additional infrastructure to do this (your own custom synchronized queues, for exam...
1
0
0
I'm working on TCP client-server application using the IntNReceiver protocol. Server is accepting multiple TCP connections from client. I would like to let other threads use the protocol's sendString method, on both client and the server. I tried to use synchronized queue, monitored in separate thread and reactor.callF...
How to ensure that send method of the protocol is thread safe
1.2
0
0
168
9,299,934
2012-02-15T19:28:00.000
3
0
0
0
python,user-interface,gtk,pygtk,glade
9,302,750
1
true
0
1
Given that the number and name of the columns to display isn't known beforehand, you could just create a gtk.TreeView widget in glade and modify it as you need in the application code. This widget could be updated to use a new model using gtk.TreeView.set_model and the columns could be adapted to match the information ...
1
3
0
I'm building a database front-end with python and glade. I need to present SQL query results in the form of database tables inside my app's window (schema followed by tuples/records). Both the schema and the database entries are dynamic because the schema could be that of a join operation or in general altered and the ...
GUI for database tables with pygtk and glade
1.2
1
0
2,104
9,302,039
2012-02-15T21:52:00.000
-1
0
1
0
python
9,302,069
2
false
0
0
Google appengine doesn't support json. On top of that simplejson is more updated than json
1
2
0
The reason in the past used to be that simplejson was way faster than the included json but now they are pretty similar in speed. Do I get any benefits sticking with simplejson anymore or should I switch all my code over to the included json now?
Any reason to continue using simplejson over the included json in Python 2.7?
-0.099668
0
0
254
9,305,751
2012-02-16T04:54:00.000
1
0
1
0
python,class,variables
9,323,525
8
false
0
0
You can do it exactly as you say you said you would do it in C++; make assignment to them go through a setter method, and have the setter method check the type. The concepts of "private state" and "public interfaces" in Python are done with documentation and convention, and it's pretty much impossible to force anyone t...
1
65
0
How do I restrict a class member variable to be a specific type in Python? Longer version: I have a class that has several member variables which are set externally to the class. Due to the way they're used, they must be of specific types, either int or list. If this was C++, I would simply make them private and do ty...
How to force/ensure class attributes are a specific type?
0.024995
0
0
128,021
9,305,817
2012-02-16T05:02:00.000
6
0
1
0
python,multithreading
9,305,840
1
true
0
0
Python's interpreter uses global state, and as such you can only have one interpreter per process. You can try using multiprocessing to run multiple processes, each with their own interpreter, but I'm not sure how well that would play with embedding.
1
2
0
I have a multi-threaded program. I want to embed a python interpreter. I don't want to use Python's threading; I want to have multiple copies of the Python interpreter running. Can I do this? (That is, does Python have global variables, or is everything done with a single Python interpreter object?) Is there an examp...
Can I embed multiple copies of the Python interpreter in a multi-threaded program?
1.2
0
0
438
9,306,460
2012-02-16T06:16:00.000
0
0
0
0
java,javascript,python,django,web-applications
9,307,042
4
false
1
0
"Scanning" a client from a server may be possible if you break their security or get them to break it for you through some extension (see windows udate, for example). Either way, it's evil.
4
1
0
I would like to write a web application (in django) which scans the client/remote computers (assumption is windows) and retrieve the list of software's(mainly browsers) installed. Looking for suggestions to implement it. Is this possible without asking the user to download any scritps/exe's? If so, is it possible via ...
Retrieve a list of browsers/agents installed in client system
0
0
0
300
9,306,460
2012-02-16T06:16:00.000
3
0
0
0
java,javascript,python,django,web-applications
9,306,601
4
true
1
0
Short answer: No, it is not possible Long answer: This is something that any sane (operating) system designer / administrator would try to prevent - scanning of local system by a web page. However, you could use a plug-in component, such as a java applet, to do so - but in practice you probably would need to handle ea...
4
1
0
I would like to write a web application (in django) which scans the client/remote computers (assumption is windows) and retrieve the list of software's(mainly browsers) installed. Looking for suggestions to implement it. Is this possible without asking the user to download any scritps/exe's? If so, is it possible via ...
Retrieve a list of browsers/agents installed in client system
1.2
0
0
300
9,306,460
2012-02-16T06:16:00.000
1
0
0
0
java,javascript,python,django,web-applications
9,307,607
4
false
1
0
You want to access the data from the client side so from the conceptual/logically its not good to access the client system. You have to use some medium which run on client side on behalf of server. JavaScript and JavaApplet is good in this. You can get the data by JavaScript or Applet and in backend you can send data ...
4
1
0
I would like to write a web application (in django) which scans the client/remote computers (assumption is windows) and retrieve the list of software's(mainly browsers) installed. Looking for suggestions to implement it. Is this possible without asking the user to download any scritps/exe's? If so, is it possible via ...
Retrieve a list of browsers/agents installed in client system
0.049958
0
0
300
9,306,460
2012-02-16T06:16:00.000
0
0
0
0
java,javascript,python,django,web-applications
9,306,570
4
false
1
0
You cannot do this unless you have some signed control installed on the client computer; or have them download a program which runs (separate from a browser) and sends the information to your server, where your django app can access it. This is not possible using javascript (as it runs in a sandbox).
4
1
0
I would like to write a web application (in django) which scans the client/remote computers (assumption is windows) and retrieve the list of software's(mainly browsers) installed. Looking for suggestions to implement it. Is this possible without asking the user to download any scritps/exe's? If so, is it possible via ...
Retrieve a list of browsers/agents installed in client system
0
0
0
300
9,308,629
2012-02-16T09:29:00.000
1
0
0
0
python,multithreading,web-services,soap
9,310,348
3
false
0
0
Excuse me, may be I didn't understand you right. I think that you want your server to process HTTP requests in parallel, but then you don't need to think about your code/library. Parallelizing should be done by Apache httpd and mod_wsgi/mod_python module. Just set up httpd.conf with 'MaxClients 100' for example and 'WS...
1
1
0
I'm looking for a python library for easily creating a server which exposes web services (SOAP), and can process multiple requests simultaneously. I've tried using ZSI and rcplib, but with no success. Update: Thanks for your answers. Both ZSI and rcplib (the successor of soaplib) implement their own Http server. How do...
Python library for a SOAP server that handles multiple requests simultaneously?
0.066568
0
1
1,184
9,311,905
2012-02-16T13:14:00.000
1
0
1
0
python,version,project,distutils,python-sphinx
9,332,590
2
false
0
0
This is a favorite question on Python distutils mailing lists. You can import your module from setup.py as well as from conf.py and get module.version. This may not work depending on your imports, your use of 2to3 or other factors, in which case you can move your version to a text file and open that from your module,...
1
8
0
I have a Python project which has Sphinx documentation and distutils for publishing to Pip. Both of these functions require a version (e.g., 0.4b3) Is there a best practice for automatically maintaining a consistent version number across the various utilities which require version numbers? As a bonus, is there anything...
Consistent versioning in Python project
0.099668
0
0
756
9,313,152
2012-02-16T14:36:00.000
0
0
1
0
python,py2exe,importerror
9,550,608
1
true
0
0
I still dont know what is the problem in py2exe, so I tried pyinstaller instead and its works
1
3
0
I read the py2exe tutorial and successfully convert my python code to a running exectuable. But when i tried to run it on another computer that dont have python installed , i get the following error: Traceback (most recent call last): File "C:\Program_Files\Pyton2_7_2\lib\site-packages\py2exe\boot_common.py", line...
py2exe ImportError
1.2
0
0
1,365
9,314,824
2012-02-16T16:14:00.000
1
0
1
0
python,file,dictionary,external
9,314,985
6
false
0
0
I highly discourage using eval though. It may result in security issues if you don't have full control on the input file. Just import your dictionary and save them by using the json or pickle module.
1
31
0
I'd like to create a dictionary from a text file that I have, who's contents are in a 'dictionary' format. Here's a sample of what the file contains: {'fawn': [1], 'sermersheim': [3], 'sonji': [2], 'scheuring': [2]} It's exactly this except it contains 125,000 entries. I am able to read in the text file using read(),...
Python: Create Dictionary from Text/File that's in Dictionary Format
0.033321
0
0
71,443
9,317,168
2012-02-16T18:44:00.000
4
0
1
0
python,web-services,scalability,flask
9,317,857
1
false
1
0
It's not really a scalability issue, rather it can make it more difficult to maintain a complex code-base. This is because thread locals are used as a global data store, to avoid passing state via function arguments, which makes it harder to follow what's going on. Speed-wise, thread locals are not particularly slow, b...
1
9
0
I am evaluating python frameworks to build a REST API. I have gone through many frameworks including flask and found Flask pretty interesting and easy to use with all the features needed to build a REST web service. One thing i don get is in flask docs it is mentioned that it uses "thread local and has issues with scal...
What does thread local mean in Flask framework?
0.664037
0
0
1,559
9,318,347
2012-02-16T20:09:00.000
16
0
0
0
python,mysql,session,caching,wsgi
9,318,495
2
true
0
0
MySQL defaults to the isolation level "REPEATABLE READ" which means you will not see any changes in your transaction that were done after the transaction started - even if those (other) changes were committed. If you issue a COMMIT or ROLLBACK in those sessions, you should see the changed data (because that will end t...
1
9
0
I'm having a problem with the sessions in my python/wsgi web app. There is a different, persistent mysqldb connection for each thread in each of 2 wsgi daemon processes. Sometimes, after deleting old sessions and creating a new one, some connections still fetch the old sessions in a select, which means they fail to val...
Why are some mysql connections selecting old data the mysql database after a delete + insert?
1.2
1
0
5,316
9,318,574
2012-02-16T20:29:00.000
9
0
1
0
python,unicode,repr
9,318,611
4
true
0
0
repr(x).decode("utf-8") and unicode(repr(x), "utf-8") should work.
2
8
0
I call a __repr__() function on object x as follows: val = x.__repr__() and then I want to store val string to SQLite database. The problem is that val should be unicode. I tried this with no success: val = x.__repr__().encode("utf-8") and val = unicode(x.__repr__()) Do you know how to correct this? I'm using Python 2....
How to make __repr__ to return unicode string
1.2
0
0
11,366
9,318,574
2012-02-16T20:29:00.000
16
0
1
0
python,unicode,repr
9,319,359
4
false
0
0
The representation of an object should not be Unicode. Define the __unicode__ method and pass the object to unicode().
2
8
0
I call a __repr__() function on object x as follows: val = x.__repr__() and then I want to store val string to SQLite database. The problem is that val should be unicode. I tried this with no success: val = x.__repr__().encode("utf-8") and val = unicode(x.__repr__()) Do you know how to correct this? I'm using Python 2....
How to make __repr__ to return unicode string
1
0
0
11,366
9,319,122
2012-02-16T21:10:00.000
4
1
0
1
python,windows,linux
9,319,169
2
false
0
0
What you probably should do is to just try to make the link and if it fails, copy. It'll give you the advantage that you'll automatically support all file systems with soft links without having to do advanced detection or keeping an updated list of supported file systems.
1
1
0
I am making a python script that in the case of EXT filesystem, will create symbolic links of some stuff, otherwise it will move the files. How can I know the type of the filesystem of a directory?
Finding out if the current filesystem supports symbolic links
0.379949
0
0
168
9,319,878
2012-02-16T22:11:00.000
1
0
1
0
python,user-interface,pyqt
9,319,895
5
false
0
1
The C++ docs for QT are actually a pretty good reference for PyQT. Last time I used PyQT (> 5 years ago), they were actually the best available reference.
1
20
0
I'm starting getting into PyQt. Therefore I would need some good tutorials. I searched a bit but didn't find any good. Most tutorials only post "full" applications but don't go into detail. Can you advise me some? Currently im programming in Notepad++. Are there better lightweight editors or simple IDEs for python in c...
Good PyQt tutorial needed
0.039979
0
0
28,223
9,321,335
2012-02-17T00:38:00.000
2
1
0
0
python,apache,wsgi
9,321,430
2
false
1
0
Put the WSGI app in daemon mode and tell it to use a single process. Note that this could have a detrimental effect on performance.
1
0
0
I have a python web application that I have configured in apache as: WSGIScriptAlias /firetalk /scripts/firetalkServer2 When I access this from javascript using XMLHttpRequest, WSGI/Apache end up launching multiple instances which breaks what I am trying to accomplish. So, is there any way to limit WSGI/Apache to a...
How to keep WSGI from launching multiple instances
0.197375
0
0
676
9,321,875
2012-02-17T01:54:00.000
1
1
1
0
python,assembly
9,338,218
2
false
0
0
Your friend is wrong. Most programs don't get demonstrably faster when written in assembly. What makes assembly code fast is that assembly code programmers generally worry a lot about speed and size, and so that's the focus of their efforts. Most compilers can do a much better job of creating fast programs than an o...
1
0
0
My friend told me that I should use assembly to get my code to run faster, but it's really hard to program in and I don't know where to begin. Are there any programs that can generate assembly from an easier language like python??
need an assembly code generator
0.099668
0
0
945
9,322,042
2012-02-17T02:19:00.000
3
1
0
1
python,perl,scripting,lua,cgi
9,323,660
5
false
0
0
One idea that comes to my mind is to create a chroot'ed env for each of your user and run the user's script in that chroot'ed env.
1
2
0
I want my users to write code and run it inside a controlled environment, like for example Lua or Perl. My site runs on Perl CGI's. Is there a way to run an isolated perl/Lua/python/etc script without access to the filesystem and returns data via stdout to be saved in a database? What i need is a secure environment, ho...
How to run a script that can only write to STDOUT and read from STDIN?
0.119427
0
0
303
9,322,401
2012-02-17T03:18:00.000
0
0
0
1
python,ssh,subprocess
10,684,894
4
false
0
0
Try using pexpect module. It allows opening and maintaining ssh sessions, which you can reuse to send in multiple commands. You can send in any commands and expect particular outputs based on which you can perform other logical operations.
2
4
0
Once my program has been launched, it opens any number of ssh sessions (user defined) and runs specific commands on the servers indefinitely (while true loop) or until the user quits. For efficiency reasons I want to create each session only once, then be able to run the commands until the user quits. How can I do this...
Create and maintain several ssh sessions in Python
0
0
0
3,383
9,322,401
2012-02-17T03:18:00.000
-1
0
0
1
python,ssh,subprocess
9,323,101
4
false
0
0
Tried mixing it up with multithreading?
2
4
0
Once my program has been launched, it opens any number of ssh sessions (user defined) and runs specific commands on the servers indefinitely (while true loop) or until the user quits. For efficiency reasons I want to create each session only once, then be able to run the commands until the user quits. How can I do this...
Create and maintain several ssh sessions in Python
-0.049958
0
0
3,383
9,322,410
2012-02-17T03:18:00.000
1
1
0
1
python,unicode,python-3.x,cgi
9,322,497
7
false
0
0
Your best bet is to explicitly encode your Unicode strings into bytes using the encoding you want to use. Relying on the implicit conversion will lead to troubles like this. BTW: If the error is really UnicodeDecodeError, then it isn't happening on output, it's trying to decode a byte stream into Unicode, which would ...
3
23
0
When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. It seems that open() and print() use the return value of locale.getpreferredencoding() to know what encoding to use by default. When running on the command line, that va...
Set encoding in Python 3 CGI scripts
0.028564
0
0
7,021
9,322,410
2012-02-17T03:18:00.000
4
1
0
1
python,unicode,python-3.x,cgi
9,337,200
7
false
0
0
You shouldn't read your IO streams as strings for CGI/WSGI; they aren't Unicode strings, they're explicitly byte sequences. (Consider that Content-Length is measured in bytes and not characters; imagine trying to read a multipart/form-data binary file upload submission crunched into UTF-8-decoded strings, or return a b...
3
23
0
When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. It seems that open() and print() use the return value of locale.getpreferredencoding() to know what encoding to use by default. When running on the command line, that va...
Set encoding in Python 3 CGI scripts
0.113791
0
0
7,021
9,322,410
2012-02-17T03:18:00.000
3
1
0
1
python,unicode,python-3.x,cgi
44,271,683
7
false
0
0
Summarizing @cercatrova 's answer: Add PassEnv LANG line to the end of your /etc/apache2/apache2.conf or .htaccess. Uncomment . /etc/default/locale line in /etc/apache2/envvars. Make sure line similar to LANG="en_US.UTF-8" is present in /etc/default/locale. sudo service apache2 restart
3
23
0
When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. It seems that open() and print() use the return value of locale.getpreferredencoding() to know what encoding to use by default. When running on the command line, that va...
Set encoding in Python 3 CGI scripts
0.085505
0
0
7,021
9,322,523
2012-02-17T03:37:00.000
3
0
0
0
iphone,python,mysql,objective-c,database
9,322,806
2
false
0
0
The maximum load is going to vary based on the design of your application and the power of the hardware that you put it on. A well designed application on reasonable hardware will far outperform what you need to get the project off the ground. If you are unexpectedly successful, you will have money to put into real ...
1
4
0
I am looking to store information in a database table that will be constantly receiving and sending data back and forth to an iPhone App/Python Socket. The problem is, if I were to have my own servers, what is the maximum queries I can sustain? The reason I'm asking is because if I were to have thousands of people usin...
How many SQL queries can be run at a time?
0.291313
1
0
1,960
9,323,749
2012-02-17T06:15:00.000
24
0
1
0
python,dictionary,filter,subset
11,924,754
18
false
0
0
for keys and values check use: set(d1.items()).issubset(set(d2.items())) if you need to check only keys: set(d1).issubset(set(d2))
1
151
0
I'm trying to write a custom filter method that takes an arbitrary number of kwargs and returns a list containing the elements of a database-like list that contain those kwargs. For example, suppose d1 = {'a':'2', 'b':'3'} and d2 = the same thing. d1 == d2 results in True. But suppose d2 = the same thing plus a bunch o...
How to check if one dictionary is a subset of another larger dictionary?
1
0
0
80,097
9,324,802
2012-02-17T08:04:00.000
4
1
0
1
python,emacs
9,325,028
6
false
0
0
I don't know about canonical, but if I needed to interact with a script I'd do M-xshellRET and run the script from there. There's also M-xterminal-emulator for more serious terminal emulation, not just shell stuff.
1
8
0
I am a fairly proficient vim user, but friends of mine told me so much good stuff about emacs that I decided to give it a try -- especially after finding about the aptly-named evil mode... Anyways, I am currently working on a python script that requires user input (a subclass of cmd.Cmd). In vim, if I wanted to try it...
Running interactive python script from emacs
0.132549
0
0
10,228
9,327,602
2012-02-17T11:40:00.000
5
0
1
1
python,setuptools,egg,software-packaging
9,369,738
4
true
0
0
You can use a single package if: The package does not use functions/classes that are not available on all your target platforms (see e.g. chapters 36-39 of the Python standard library reference for version 2.7.2 for stuff that you shouldn't use in that case) You are not using extensions written in C/C++ that need to b...
2
7
0
Ours is a python shop. We have different python packages developed inhouse and will be deployed onto customers' environments(machines). This is how our development and release cycle happens. Once developers complete "testing" of a package, a distribution(egg file) of the package is prepared and pushed to a central arch...
What are the best practices for creating Python Distributions(eggs) on(and for) Multiple Operating Systems
1.2
0
0
1,167
9,327,602
2012-02-17T11:40:00.000
1
0
1
1
python,setuptools,egg,software-packaging
9,421,037
4
false
0
0
Platform-specific eggs are only intended for distributing packages containing C code; otherwise the egg files themselves are platform-independent and you only need to distribute one, platform-independent egg. If you are using automated installation tools or pkg_resources' runtime APIs for finding libraries and plugins,...
2
7
0
Ours is a python shop. We have different python packages developed inhouse and will be deployed onto customers' environments(machines). This is how our development and release cycle happens. Once developers complete "testing" of a package, a distribution(egg file) of the package is prepared and pushed to a central arch...
What are the best practices for creating Python Distributions(eggs) on(and for) Multiple Operating Systems
0.049958
0
0
1,167
9,327,606
2012-02-17T11:41:00.000
3
1
1
0
import,module,ironpython
9,332,166
1
true
0
1
Taking 4-5 seconds to do imports, especially for large modules, is not unexpected for IronPython 2.7.1. I would pyc.py to improve it, but I also think that it isn't as useful as it once was - IronPython's imports are a lot faster than they used to be, so pyc.py is less useful. The thing is, IronPython does a lot more t...
1
1
0
(first question on StackOverflow, glad to be there :)) I am using IronPython 2.7.1 and C# .net 4.0. I use C# to launch my python script. I have about 20 personal modules that are imported a lots of time. E.g : If I have module1.py, module2.py, module3.py, module4.py and main_script.py. main_script.py imports module1 an...
Import module in IronPython 2.7.1 very slow
1.2
0
0
1,258
9,330,955
2012-02-17T15:28:00.000
-1
0
1
0
python
9,332,354
1
false
0
0
After installing mingw32 compiler you'll need to set the PATH Windows environment variable to include the directory of the mingw/bin so it can find the gcc executable. Note that you'll have to open a new cmd window to pick up the new PATH setting.
1
0
0
setup.py install build --compiler=mingw32 gcc: error /Z1: No such file or directory error: command 'gcc' failed with exit status 1 Any suggestions? Thanks!
python 2.7 windows 7 installing mysqllib mingw32
-0.197375
0
0
497
9,335,190
2012-02-17T20:49:00.000
5
0
1
0
python,osx-lion,virtualenv,install-name-tool
9,335,485
1
false
0
0
If you're using Xcode 4.3, you'll have to install the Command Line Tools package, available under the Downloads tab in the preferences.
1
4
0
When I try to run mkvirtualenv with python 2.6, I get the error: Could not call install_name_tool -- you must have Apple's development tools installed I've installed Xcode. (It's actually installed, not just downloaded and waiting to be installed). The command: which install_name_tool yields me nothing. Why can't I ca...
install_name_tool error when running virtualenv on Mac OSX Lion (with Xcode)
0.761594
0
0
909
9,336,053
2012-02-17T22:00:00.000
1
0
1
0
python,com,vb6,activex
9,358,941
1
true
0
0
The parameter that should be in Dispatch is a string called the ProgID (Program ID). This is of the form <projectname>.<classname> . So for instance, if your VB6 project was called BusinessLib, and it contained a Public class called Formulae, the string would be BusinessLib.Formulae.
1
0
0
I created a VB6 DLL and it is registered on my PC. I have pywin32 and python2.7 installed. I ran makepy in the win32com\client dir and chose the appropriate DLL. I am now at a loss as to how to use this DLL in my Python program...examples on the Web show win32com.client.Dispatch(X), but what do I use for X? How do I us...
How to use VB6 DLL (Active X/COM) in Python?
1.2
0
0
819
9,337,149
2012-02-18T00:03:00.000
50
0
0
0
python,django,deployment
9,337,514
6
true
1
0
I would do it that way if you ever think you'll run more than one project on the webserver. As soon as you have two projects you run the risk of a future upgrade of any python package breaking the other site.
4
80
0
I have always been using virtualenv for testing my app in localhost since I have isolated environment and can safely test new release of packages. Now It comes the time when I have to deploy my app to a production server. I am wondering if I should also use virtualenv for production server or just normal installation s...
Is virtualenv recommended for django production server?
1.2
0
0
20,184
9,337,149
2012-02-18T00:03:00.000
0
0
0
0
python,django,deployment
41,409,586
6
false
1
0
Using Docker containers for both development and production deployment is pretty popular now, so if you're considering following this trend, you won't need virtualenv anymore.
4
80
0
I have always been using virtualenv for testing my app in localhost since I have isolated environment and can safely test new release of packages. Now It comes the time when I have to deploy my app to a production server. I am wondering if I should also use virtualenv for production server or just normal installation s...
Is virtualenv recommended for django production server?
0
0
0
20,184
9,337,149
2012-02-18T00:03:00.000
3
0
0
0
python,django,deployment
9,340,145
6
false
1
0
In most cases I would agree it is best to have a virtualenv even if it doesn't seem like you need it when you first set up the server. That said if you are using some kind of cloud service and spinning up servers for a specific task for a short time then I don't see the point of using a virtualenv.
4
80
0
I have always been using virtualenv for testing my app in localhost since I have isolated environment and can safely test new release of packages. Now It comes the time when I have to deploy my app to a production server. I am wondering if I should also use virtualenv for production server or just normal installation s...
Is virtualenv recommended for django production server?
0.099668
0
0
20,184
9,337,149
2012-02-18T00:03:00.000
15
0
0
0
python,django,deployment
9,339,816
6
false
1
0
Is virtualenv recommended for django production server? Yes, it makes your project not depend on certain aspects of the system environment and also it allows you to make the deployment process more clear and configurable. I use fabric, pip and virtualenv to deploy all my Django projects.
4
80
0
I have always been using virtualenv for testing my app in localhost since I have isolated environment and can safely test new release of packages. Now It comes the time when I have to deploy my app to a production server. I am wondering if I should also use virtualenv for production server or just normal installation s...
Is virtualenv recommended for django production server?
1
0
0
20,184