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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
11,161,747 | 2012-06-22T18:03:00.000 | -4 | 0 | 1 | 0 | python,mtp | 46,545,449 | 3 | false | 0 | 0 | Simply connecting a USB cable between the phone and computer should work.
It may be necessary to enable MTP transfers in the settings menu on your phone. The menu selection location is likely to be different on different versions of android and different phone models. Try a google search for "galaxy nexus enable mtp".... | 2 | 25 | 0 | How can I read from and write to my Galaxy Nexus phone, using MTP over a USB cable in python?
I'm on a windows 7 computer. | How to access an MTP USB device with python | -1 | 0 | 1 | 15,627 |
11,161,747 | 2012-06-22T18:03:00.000 | 5 | 0 | 1 | 0 | python,mtp | 11,254,179 | 3 | true | 0 | 0 | One way to do this would be to install ADB (android debugging bridge, part of the SDK) and launch it as a child process from python. ADB can be used to, among other things, read from or write to, an android device. | 2 | 25 | 0 | How can I read from and write to my Galaxy Nexus phone, using MTP over a USB cable in python?
I'm on a windows 7 computer. | How to access an MTP USB device with python | 1.2 | 0 | 1 | 15,627 |
11,161,776 | 2012-06-22T18:05:00.000 | 0 | 0 | 1 | 1 | python,centos,pip,python-module | 42,556,424 | 2 | false | 0 | 0 | If executing pip with sudo, you may want sudo's -H flag
-H, --set-home set HOME variable to target user's home dir
e.g
sudo -H pip install virtualenv | 2 | 16 | 0 | When installing a package via sudo pip-python (CentOS 6 package: python-pip-0.8-1.el6.noarch), I sometimes get permission issues with the installed packages being readable only by root.
Re-installing again one or two times usually fixes the problem. Has anyone experienced this? Or can anyone suggest any troubleshooting... | pip: inconsistent permissions issues | 0 | 0 | 0 | 11,217 |
11,161,776 | 2012-06-22T18:05:00.000 | 13 | 0 | 1 | 1 | python,centos,pip,python-module | 11,169,137 | 2 | false | 0 | 0 | When you run a command using sudo, it will preserve the users umask. pip just installs files, it doesn't change access rights, so you'll end up with the files having the access rights set conforming to the current user's umask, which may be owner-readable only (0077) and therefore readable by root only.
That means you ... | 2 | 16 | 0 | When installing a package via sudo pip-python (CentOS 6 package: python-pip-0.8-1.el6.noarch), I sometimes get permission issues with the installed packages being readable only by root.
Re-installing again one or two times usually fixes the problem. Has anyone experienced this? Or can anyone suggest any troubleshooting... | pip: inconsistent permissions issues | 1 | 0 | 0 | 11,217 |
11,161,901 | 2012-06-22T18:14:00.000 | 1 | 0 | 1 | 0 | python,blender | 44,329,972 | 5 | false | 0 | 0 | If you are on Windows you can just do python setup.py install as usual using the python interpreter given by blender. So for example, 'c:/Program Files/Blender Foundation/Blender/2.78/python/bin/python.exe' setup.py install.
On Linux, I think the native python3 interpreter is used so there is no problem of this kind. | 1 | 9 | 0 | I've been trying to install pyserial for blender, but I can only install it to python32 on my C drive, is there anything i can do to have it install to blender or have blender import from python32 | How to install python modules in blender | 0.039979 | 0 | 0 | 18,980 |
11,162,214 | 2012-06-22T18:39:00.000 | 0 | 0 | 1 | 1 | python,fabric | 11,497,518 | 2 | false | 0 | 0 | You could always use the new execute() and wrap that in a try/except or just look at the return codes from your run()s. | 1 | 5 | 0 | In the eventuality that Fabric exits cleanly or not, I need to execute a bunch of clean-up tasks (mostly delete temp files and folders).
How can I achieve this with Fabric? | Fabric equivalent of try finally | 0 | 0 | 0 | 1,088 |
11,164,176 | 2012-06-22T21:10:00.000 | 2 | 1 | 0 | 0 | python,process,communication,iostream | 11,164,681 | 4 | true | 0 | 0 | On unix systems; the usual way to open a subprocess is with fork(), which will leave any open file descriptors (small integers representing open files or sockets) available in both the child, and the parent, and then exec(), which also allows the new executable to use the file descriptors that were open in the old proc... | 2 | 0 | 0 | A python program opens a new process of the C++ program and is reading the processes stdout.
No problem so far.
But is it possible to have multiple streams like this for communication? I can get two if I misuse stderr too, but not more. Easy way to hack this would be using temporary files. Is there something more eleg... | C++ to python communication. Multiple io streams? | 1.2 | 0 | 0 | 270 |
11,164,176 | 2012-06-22T21:10:00.000 | 0 | 1 | 0 | 0 | python,process,communication,iostream | 11,165,324 | 4 | false | 0 | 0 | assuming windows machine.
you could try using the clipboard for exchanging information between python processes and C++.
assign some unique process id followed by your information and write it to clipboard on python side.....now just parse the string on C++ side.
its akin to using temporary files but all done in memory... | 2 | 0 | 0 | A python program opens a new process of the C++ program and is reading the processes stdout.
No problem so far.
But is it possible to have multiple streams like this for communication? I can get two if I misuse stderr too, but not more. Easy way to hack this would be using temporary files. Is there something more eleg... | C++ to python communication. Multiple io streams? | 0 | 0 | 0 | 270 |
11,164,651 | 2012-06-22T21:55:00.000 | 1 | 0 | 1 | 1 | linux,python-2.7 | 11,170,901 | 1 | false | 0 | 0 | You are asking for a number that is nearly impossible to calculate and has very little value.
Any Linux system that is running for an amount of time will have hardly any 'free' ram available. Just cat /proc/meminfo - the MemFree entry is usually in order of just a few megabytes.
So, where did that memory go?
The kernel... | 1 | 0 | 0 | So, the title describes almost all the necessary to answer me. Just one more thing: please, just reply about libraries installed with Python by default, as the app which I'm developing is part of the Ubuntu App Showdown.
Running Python 2.7, Ubuntu 12.04. | How can I detect my RAM free and total space in Python? | 0.197375 | 0 | 0 | 186 |
11,165,937 | 2012-06-23T01:02:00.000 | 1 | 0 | 1 | 0 | python,python-2.7 | 11,165,954 | 1 | true | 0 | 0 | Put the directory containing your module (let's call it functions.py) into the PYTHONPATH environment variable. Then you'll be able to use import functions to get your functions.
Pip also seems to have support for this: pip install -e src/mycheckout for exxample, but I don't quite understand the ramifications of that... | 1 | 0 | 0 | I'm building a personal module of functions, generic functions for my scientific work.
It's not finished so I would like to keep it in it's development folder for the time being without installing it like you install every other modules with pip, etc.
Now, I also need to work on other non-related projects but still nee... | Importing unfinished modules | 1.2 | 0 | 0 | 56 |
11,166,014 | 2012-06-23T01:15:00.000 | 5 | 0 | 1 | 0 | python,django,installation,duplicates | 11,166,438 | 3 | false | 1 | 0 | Check out virtualenv and virtualenvwrapper | 2 | 7 | 0 | In the process of trying to install django, I had a series of failures. I followed many different tutorials online and ended up trying to install it several times. I think I may have installed it twice (which the website said was not a good thing), so how do I tell if I actually have multiple versions installed? I have... | How to tell if you have multiple Django's installed | 0.321513 | 0 | 0 | 2,635 |
11,166,014 | 2012-06-23T01:15:00.000 | 9 | 0 | 1 | 0 | python,django,installation,duplicates | 11,166,539 | 3 | true | 1 | 0 | open terminal and type python then type import django then type django and it will tell you the path to the django you are importing. Goto that folder [it should look something like this: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/] and look for more than one instance of django(if the... | 2 | 7 | 0 | In the process of trying to install django, I had a series of failures. I followed many different tutorials online and ended up trying to install it several times. I think I may have installed it twice (which the website said was not a good thing), so how do I tell if I actually have multiple versions installed? I have... | How to tell if you have multiple Django's installed | 1.2 | 0 | 0 | 2,635 |
11,166,890 | 2012-06-23T04:37:00.000 | 1 | 0 | 1 | 0 | python,plone | 11,255,794 | 1 | false | 0 | 0 | Plone can, with appropriate tuning, handle this kind of load, but as Martijn points out above, Plone is not really a document management or versioning solution for large archives of binary files--it is a web content management system first and foremost. I would consider looking at something like Alfresco. | 1 | 0 | 0 | How scalable is plone/zope in terms of importing terabytes of existing data on a file system? I am using Plone 4.1 and wish to import existing files/images etc on the file system in linux debian. | How scalable is plone/zope in terms of importing terabytes of existing data on a file system? | 0.197375 | 0 | 0 | 208 |
11,167,328 | 2012-06-23T06:08:00.000 | 0 | 0 | 1 | 0 | python | 11,167,357 | 6 | false | 0 | 0 | You may want to try something like an array of dictionaries or objects. Arrays are ordered. The text for the menu item would be in some field of the array or object. | 1 | 4 | 0 | Can I expect the keys() to remain in the same order?
I plan to use them for a dropdown box and I dont want them to shift if I add or delete items from the dictionary. | Order of list obtained by dictionary's keys() | 0 | 0 | 0 | 129 |
11,167,518 | 2012-06-23T06:47:00.000 | 4 | 0 | 0 | 0 | python,sqlalchemy,flask,flask-sqlalchemy | 11,210,290 | 3 | false | 1 | 0 | At the time you execute create_all, models.py has never been imported, so no class is declared. Thus, create_all does not create any table.
To solve this problem, import models before running create_all or, even better, don't separate the db object from the model declaration. | 1 | 1 | 0 | Trying to set up Flask and SQLAlchemy on Windows but I've been running into issues.
I've been using Flask-SQLAlchemy along with PostgreSQL 9.1.4 (32 bit) and the Psycopg2 package. Here are the relevant bits of code, I created a basic User model just to test that my DB is connecting, and committing.
The three bits of co... | Setting up Flask-SQLAlchemy | 0.26052 | 1 | 0 | 7,080 |
11,167,771 | 2012-06-23T07:40:00.000 | 1 | 0 | 0 | 0 | python,google-app-engine,jinja2 | 11,167,788 | 2 | true | 1 | 0 | What you are thinking about, and moving toward (whether you know it or not) is called a content management system.
Most of them store content in a database and provide a user interface to allow editing it, just as you're designing.
Perhaps you could use off-the-shelf parts? I don't know exactly which ones are appengine... | 1 | 1 | 0 | So I have a python webapp on Google App Engine and am using the jinja2 template engine. I have a lot of text on the site that I want to update regularly, such as news sections and updates about the site.
What is the most efficient way to go about doing this? Clearly the simplest short-term solution and what I am curr... | update text within html | 1.2 | 0 | 0 | 119 |
11,168,747 | 2012-06-23T10:23:00.000 | 1 | 1 | 0 | 1 | python,django,web-hosting,cpanel | 11,169,154 | 2 | true | 1 | 0 | You could try to put them in your PYTHONPATH. Usually, your current working directory is in your PYTHONPATH. If that changes, you might need to add a path to it (maybe in each file, you should check, or one common file which is always included), and put the libraries there. You can do this with import sys;sys.path.appe... | 2 | 0 | 0 | I am using heliohost's free service to test my django apps. But Heliohost does not provide me shell access. Is there anyway to install python libraries on the host machine? | python libraries in cpanel | 1.2 | 0 | 0 | 1,172 |
11,168,747 | 2012-06-23T10:23:00.000 | 0 | 1 | 0 | 1 | python,django,web-hosting,cpanel | 45,138,203 | 2 | false | 1 | 0 | You should inform the support of heliohost.this server has very good support that help you or install any package you want | 2 | 0 | 0 | I am using heliohost's free service to test my django apps. But Heliohost does not provide me shell access. Is there anyway to install python libraries on the host machine? | python libraries in cpanel | 0 | 0 | 0 | 1,172 |
11,169,418 | 2012-06-23T12:15:00.000 | 4 | 0 | 0 | 0 | c++,arrays,python-3.x,numpy,dynamic-arrays | 57,324,664 | 13 | false | 0 | 0 | Use LibTorch (PyTorch frontend for C++) and be happy. | 1 | 104 | 1 | Are there any C++ (or C) libs that have NumPy-like arrays with support for slicing, vectorized operations, adding and subtracting contents element-by-element, etc.? | NumPy style arrays for C++? | 0.061461 | 0 | 0 | 81,916 |
11,170,120 | 2012-06-23T14:07:00.000 | 1 | 0 | 1 | 0 | python,object-oriented-analysis | 11,170,301 | 2 | false | 0 | 0 | I would say that all values are objects anyway. Let's say that instead of transaction class instance, you would have a dictionary {'transaction name':[123,'GBP','12/12/12',1234,'in']}. Now this dictionary is again an object and the difference is that it wasn't your own class. Everything is an object anyway. The fact th... | 1 | 7 | 0 | I'm thinking about a situation where I have an object "Transaction", that has quite a few properties to it like account, amount, date, currency, type, etc.
I never plan to mutate these data points, and calculation logic will live in other classes. My question is, is it poor Python design to instantiate thousands of obj... | Objects With No Behavior | 0.099668 | 0 | 0 | 168 |
11,170,599 | 2012-06-23T15:15:00.000 | 2 | 0 | 1 | 0 | python,memory-leaks | 11,170,635 | 1 | true | 0 | 0 | It's not possible in native Python to obtain this information from an object after it's been created, but you can override the __new__() method on a base class to record it somewhere on the object (getting it from the inspect module). | 1 | 1 | 0 | Is there a way to find out where a Python object was instantiated the first time? Like the line number or even the full traceback at the creation?
For memory profiling I'd like to examine all objects after the run. (I'm aware of memory profiling tools, but they are hard to install or don't do this task). | Find out where Python object was created | 1.2 | 0 | 0 | 157 |
11,170,827 | 2012-06-23T15:46:00.000 | -1 | 0 | 1 | 0 | python,version,virtualenv | 60,839,180 | 8 | false | 0 | 0 | I had this problem and just decided to rename one of the programs from python.exe to python2.7.exe. Now I can specify on command prompt which program to run easily without introducing any scripts or changing environmental paths.
So i have two programs: python2.7 and python (the latter which is v.3.8 aka default). | 3 | 95 | 0 | How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that?
Bonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program a... | How do I tell a Python script to use a particular version | -0.024995 | 0 | 0 | 224,173 |
11,170,827 | 2012-06-23T15:46:00.000 | -1 | 0 | 1 | 0 | python,version,virtualenv | 56,130,973 | 8 | false | 0 | 0 | While working with different versions of Python on Windows,
I am using this method to switch between versions.
I think it is better than messing with shebangs and virtualenvs
1) install python versions you desire
2) go to Environment Variables > PATH
(i assume that paths of python versions are already added to Env.Var... | 3 | 95 | 0 | How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that?
Bonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program a... | How do I tell a Python script to use a particular version | -0.024995 | 0 | 0 | 224,173 |
11,170,827 | 2012-06-23T15:46:00.000 | 0 | 0 | 1 | 0 | python,version,virtualenv | 11,170,838 | 8 | false | 0 | 0 | You can't do this within the Python program, because the shell decides which version to use if you a shebang line.
If you aren't using a shell with a shebang line and just type python myprogram.py it uses the default version unless you decide specifically which Python version when you type pythonXXX myprogram.py which... | 3 | 95 | 0 | How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that?
Bonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program a... | How do I tell a Python script to use a particular version | 0 | 0 | 0 | 224,173 |
11,170,949 | 2012-06-23T15:59:00.000 | 1 | 0 | 0 | 0 | python,python-c-extension | 11,171,590 | 4 | false | 0 | 0 | Physically copy the socket module to socket_monkey and go from there? I don't feel you need any "clever" work-around... but I might well be over simplifying! | 1 | 39 | 0 | I need to make a copy of a socket module to be able to use it and to have one more socket module monkey-patched and use it differently.
Is this possible?
I mean to really copy a module, namely to get the same result at runtime as if I've copied socketmodule.c, changed the initsocket() function to initmy_socket(), and i... | How to make a copy of a python module at runtime? | 0.049958 | 0 | 1 | 7,543 |
11,172,215 | 2012-06-23T19:07:00.000 | 0 | 1 | 0 | 0 | python-c-extension,python-extensions | 20,085,116 | 2 | false | 0 | 1 | I had a similar problem and resolved it by:
Adding the Modules\ directory (from your Python source) to the C/C++ Additional Include Directories.
#include "socketmodule.h"
Don't know if this is the best solution, but it worked for me! | 1 | 1 | 0 | I'd like to invoke PySocketModule_ImportModuleAndAPI function defined in socketmodule.h in my Python C-extension. | Is it possible to include socketmodule.h in Python C extensions? | 0 | 0 | 1 | 142 |
11,174,324 | 2012-06-24T01:20:00.000 | 0 | 0 | 0 | 0 | python,deployment,fixtures | 11,174,357 | 1 | false | 0 | 0 | You have to give the user that loads the fixture the privileges to write on the database regardless which way you are going to load the data.
With Postgres you can give login permission without password to specific users and eliminate the problem of a shared password or you can store the password in the pgpass file wit... | 1 | 1 | 0 | I need to load fixtures into the system when a new VM is up. I have dumped MongoDB and Postgres. But I can't just sit in front of the PC whenever a new machine is up. I want to be able to just "issue" a command or the script automatically does it.
But a command like pg_dump to dump PostgreSQL will require a password. T... | Security concerns while loading fixtures | 0 | 1 | 0 | 70 |
11,174,713 | 2012-06-24T03:21:00.000 | 0 | 0 | 1 | 0 | java,python,image-processing,wolfram-mathematica,image-stitching | 11,219,818 | 6 | false | 0 | 0 | In Mathematica, you can use ImageCorrespondingPoints within the overlap region, and then FindGeometricTransform to compute an affine transformation that takes one image into the other. Note that the size of the images and and overlap regions influence the accuracy of the transformation. If you are doing something compl... | 2 | 6 | 0 | I have a bunch of images in a folder that are effectively just pieces of one image that was broken into overlapping parts. How can I quickly and programmatically recombine these images to create the original image?
I would prefer a solution that uses python or mathematica (or is an existing application), but I am open... | Stitch together images with exactly matching (pixel to pixel) overlaps | 0 | 0 | 0 | 3,573 |
11,174,713 | 2012-06-24T03:21:00.000 | 0 | 0 | 1 | 0 | java,python,image-processing,wolfram-mathematica,image-stitching | 11,174,812 | 6 | false | 0 | 0 | What you want is a tool for creating panoramas. There are various tools sold to do this with various features. Things to think about are:
matching position vertically and horizontally
varying brightness between images
correcting for camera rotation and angle | 2 | 6 | 0 | I have a bunch of images in a folder that are effectively just pieces of one image that was broken into overlapping parts. How can I quickly and programmatically recombine these images to create the original image?
I would prefer a solution that uses python or mathematica (or is an existing application), but I am open... | Stitch together images with exactly matching (pixel to pixel) overlaps | 0 | 0 | 0 | 3,573 |
11,175,645 | 2012-06-24T07:14:00.000 | 0 | 1 | 1 | 0 | python | 11,175,666 | 10 | false | 0 | 0 | You have only two values, so you know in advance the precise structure of the output: it will be divided into two regions of varying lengths. | 1 | 2 | 0 | What is the most efficient way to sort a list, [0,0,1,0,1,1,0] whose elements are only 0 & 1, without using any builtin sort() or sorted() or count() function. O(n) or less than that | Sort a list efficiently which contains only 0 and 1 without using any builtin python sort function? | 0 | 0 | 0 | 1,534 |
11,176,273 | 2012-06-24T09:15:00.000 | 2 | 1 | 0 | 0 | python,caching,memcached | 11,176,318 | 1 | false | 1 | 0 | There's no way to do it that's guaranteed to work. The only way I found is the way you'll find on google, but there's a restriction: Only 1 MB will be returned - it may not be all keys. And it will probably be quite slow..
If you really, really has to have all those keys you'd probably have to hack the source code.
I w... | 1 | 2 | 0 | I know this question has been asked many times and it's also covered in official memcached FAQ. But my case is - I want to use it just for admin panel purposes. I want to see keys with values in my admin page so it doesn't matter if it's slow and against the best practices. Please advise, if it's possible. | List all memcached keys/values | 0.379949 | 0 | 0 | 839 |
11,177,018 | 2012-06-24T11:21:00.000 | 0 | 0 | 0 | 0 | python,multithreading,sockets | 11,177,059 | 4 | false | 0 | 0 | I don't know of a way to prioritize at the Python level.
So I'd suggest using 2 processes, not threads, and prioritize at the OS level. On Unix you can use os.nice() to do that.
You'd need to use 2 sockets then, and your sharing problem would be solved at the same time. | 3 | 14 | 0 | I have a design problem:
I have two threads, a heartbeat/control thread and a messagehandler thread.
Both are sharing the same socket, however the messageHandler thread only sends out messages and never receives. The heartbeat thread sends and receives (receives messages and reacts on heartbeats).
The problem is I'm n... | Python: Socket and threads? | 0 | 0 | 1 | 22,734 |
11,177,018 | 2012-06-24T11:21:00.000 | 0 | 0 | 0 | 0 | python,multithreading,sockets | 11,177,130 | 4 | false | 0 | 0 | If both threads are client threads, it is a good idea to open two client sockets one to the server for heart beat and another for communication. | 3 | 14 | 0 | I have a design problem:
I have two threads, a heartbeat/control thread and a messagehandler thread.
Both are sharing the same socket, however the messageHandler thread only sends out messages and never receives. The heartbeat thread sends and receives (receives messages and reacts on heartbeats).
The problem is I'm n... | Python: Socket and threads? | 0 | 0 | 1 | 22,734 |
11,177,018 | 2012-06-24T11:21:00.000 | 10 | 0 | 0 | 0 | python,multithreading,sockets | 11,177,260 | 4 | true | 0 | 0 | Unfortunately,The socket shared by multi-thread is not thread safe.Think about buffer two threads operate on with no lock.
The normal way to implement is with two socket,just like what ftp does.cmd socket and msg socket.
If you wanna implement this by one socket,you can put different type msgs into different queues,and... | 3 | 14 | 0 | I have a design problem:
I have two threads, a heartbeat/control thread and a messagehandler thread.
Both are sharing the same socket, however the messageHandler thread only sends out messages and never receives. The heartbeat thread sends and receives (receives messages and reacts on heartbeats).
The problem is I'm n... | Python: Socket and threads? | 1.2 | 0 | 1 | 22,734 |
11,178,136 | 2012-06-24T14:09:00.000 | 3 | 0 | 1 | 0 | python,random,python-3.x | 11,178,180 | 5 | false | 0 | 0 | Make a wrapper function that increments the count and then makes the call and returns the result.
If you consider that "manual", then yes. | 1 | 3 | 0 | I have a Python application in which I would like to monitor the number of calls to functions in the standard random module, at runtime; is there any nice way to do this, or do I have to "manually" do it? | Counting number of calls to random in Python? | 0.119427 | 0 | 0 | 340 |
11,178,243 | 2012-06-24T14:24:00.000 | 5 | 1 | 1 | 0 | java,python,jython | 11,178,285 | 2 | false | 1 | 0 | The point of using Jython is that you can write Python code and have it run on the JVM. Don't ruin that by making your Python into Java.
If -- if -- it turns out that your data structure is too slow, you can drop-in replace it with a Java version. But that's for the optimisation stage of programming, which comes later... | 2 | 6 | 0 | I'm trying to understand whether and under what circs one should use Python classes and/or Java ones.
If making a specialist dictionary/Map kind of class, should one subclass from Python's dict, or from Java's HashMap or TreeMap, etc.?
It is tempting to use the Python ones just because they are simpler and sexier. B... | Jython - is it faster to use Python data structures or Java ones? | 0.462117 | 0 | 0 | 418 |
11,178,243 | 2012-06-24T14:24:00.000 | 4 | 1 | 1 | 0 | java,python,jython | 11,179,152 | 2 | true | 1 | 0 | Generally, the decision shouldn't be one of speed - the Python classes will be implemented in terms of Java classes anyway, even if they don't inherit from them. So, the speed should be roughly comparable, and at most you would save a couple of method calls per operation.
The bigger question is what you plan on doing ... | 2 | 6 | 0 | I'm trying to understand whether and under what circs one should use Python classes and/or Java ones.
If making a specialist dictionary/Map kind of class, should one subclass from Python's dict, or from Java's HashMap or TreeMap, etc.?
It is tempting to use the Python ones just because they are simpler and sexier. B... | Jython - is it faster to use Python data structures or Java ones? | 1.2 | 0 | 0 | 418 |
11,181,195 | 2012-06-24T21:07:00.000 | 2 | 0 | 1 | 0 | python | 11,181,226 | 4 | false | 0 | 0 | I would create a separated module called random_words, or something like that, hiding the list inside it and encapsulating the choice(word_list) inside an interface function.
As to load them from a file, well, since I would need to type them anyway, and a python file is just a text file in the end, I would type them ri... | 2 | 0 | 0 | I am writing a game in python in which I must periodically pull a random word from a list of words. When I prototyped my game I declared a word_list = ['cat','dog','rat','house'] of ten words at the top of one of my modules. I then use choice(word_list) to get a random word. However, I must must change this temporary h... | Where should I declare a list of 5,000+ words? | 0.099668 | 0 | 0 | 290 |
11,181,195 | 2012-06-24T21:07:00.000 | 3 | 0 | 1 | 0 | python | 11,181,204 | 4 | false | 0 | 0 | Read the words from the file at startup (or at least the line indexes), and use as required. | 2 | 0 | 0 | I am writing a game in python in which I must periodically pull a random word from a list of words. When I prototyped my game I declared a word_list = ['cat','dog','rat','house'] of ten words at the top of one of my modules. I then use choice(word_list) to get a random word. However, I must must change this temporary h... | Where should I declare a list of 5,000+ words? | 0.148885 | 0 | 0 | 290 |
11,182,558 | 2012-06-25T01:29:00.000 | 3 | 0 | 1 | 0 | python,iteration,combinations | 11,182,603 | 4 | false | 0 | 0 | The main issue with this problem, is that not all letters can be translated to symbols or numbers. You have to create a dictionary where the key is a lower case letter and the value is a list of all possible replacement of that letter:
{'a':['a','A','@'],...,'s':['s','S','5'],...,}
Once your dictionary is built, the re... | 1 | 0 | 0 | I hope it's Monday-itis kicking in at the moment, but something I feel should be quite easy - or at least elegant - is giving me a brain fart. The use case is this:
Find all possible combinations of a specific word, where letters can be any case or replaced with letters. For instance:
Word: 'Password'
Combinations: 'PA... | Find all combinations (upper and lower and symbols) of a word in python | 0.148885 | 0 | 0 | 1,263 |
11,182,825 | 2012-06-25T02:24:00.000 | 4 | 0 | 0 | 0 | python,html,parsing,text,web | 11,182,855 | 1 | false | 0 | 0 | I won't write code, but I'll give you the process I'd go through for solving this problem:
Retrieve the source of the page
Replace out all of the parts
of the page that we don't care to monitor
Calculate an md5 or
sha1 hash of the source after replacements are made
Compare the
hash with the stored hash, see if it's di... | 1 | 1 | 0 | What would be the simplest way to check a web page for changes? I want to scan a web page every so often, and compare it to an older scan. One problem is I also need the scan to ignore certain changes, such as the time of day, etc. I only want to check for relevant updates. | Detecting web page updates with python | 0.664037 | 0 | 1 | 2,212 |
11,186,600 | 2012-06-25T09:25:00.000 | 1 | 0 | 1 | 0 | python,on-the-fly | 11,186,714 | 2 | false | 0 | 0 | If the program saves its state or its results from time to time, you could add a logic which skips the steps which have already executed.
Otherwise, I don't see a way to change this. | 2 | 10 | 0 | I launched a python program with many nested loops, and the program will take days. I just realized that one of the loops values is wrong and makes a infinite loop.
I don't want to restart the program from zero, is there a way to interrupt the current program and modify the loop range so it will work properly and also... | modify a running python program | 0.099668 | 0 | 0 | 1,132 |
11,186,600 | 2012-06-25T09:25:00.000 | 0 | 0 | 1 | 0 | python,on-the-fly | 15,535,463 | 2 | false | 0 | 0 | I guess pretty old article but just came across now. In case you still want to try you could do the following:
Make your script run under pdb as:
python -m pdb
This will run it under pdb. After entering pdb just enter command 'c' (continue). This will begin your program.
When you encounter a infinite loop just do a ... | 2 | 10 | 0 | I launched a python program with many nested loops, and the program will take days. I just realized that one of the loops values is wrong and makes a infinite loop.
I don't want to restart the program from zero, is there a way to interrupt the current program and modify the loop range so it will work properly and also... | modify a running python program | 0 | 0 | 0 | 1,132 |
11,187,086 | 2012-06-25T09:57:00.000 | 3 | 0 | 0 | 0 | python,export-to-excel,openerp,export-to-csv | 11,187,374 | 2 | false | 0 | 0 | Why not to use Open ERP client it self.
you can go for xlwt if you really require to write a python program to generate it. | 1 | 0 | 1 | Which is the best to way to export openerp data to csv/xls file using python so that i can schedule it in openerp( i cant use the client side exporting)?
using csv python package
using xlwt python package
or any other package?
And also how can I dynamically provide the path and name to save this newly created csv fi... | The best way to export openerp data to csv file using python | 0.291313 | 0 | 0 | 4,385 |
11,188,725 | 2012-06-25T11:43:00.000 | 0 | 1 | 0 | 0 | python,django,http | 11,188,777 | 2 | false | 0 | 0 | In terms of security, you should store it in session. If it's in cookie, the client can modify your url to whatever he wants. | 2 | 0 | 0 | I need a url for using that for a template. Now there are two ways of storing the url and use that again in python I guess...
One is using session to store that URL and get it later whenever we need it...
or
Second is using cookies to store that URL and get it later..
So which method is more appropriate in terms of se... | Storing URL into cookies or session? | 0 | 0 | 1 | 276 |
11,188,725 | 2012-06-25T11:43:00.000 | 0 | 1 | 0 | 0 | python,django,http | 11,188,963 | 2 | true | 0 | 0 | I don't think "session hijacking" means what you think it means. The only thing someone can do with session hijacking is impersonate a user. The actual session data is stored on the back end (eg in the database), so if you don't give the user access to that particular data then they can't change it, whether they're the... | 2 | 0 | 0 | I need a url for using that for a template. Now there are two ways of storing the url and use that again in python I guess...
One is using session to store that URL and get it later whenever we need it...
or
Second is using cookies to store that URL and get it later..
So which method is more appropriate in terms of se... | Storing URL into cookies or session? | 1.2 | 0 | 1 | 276 |
11,190,243 | 2012-06-25T13:24:00.000 | 0 | 0 | 0 | 0 | python,sockets,ssh-tunnel,graphite | 11,214,979 | 1 | false | 0 | 0 | It's hard to answer this correctly without a code sample. However, it sounds like you might be trying to reuse a closed socket, which is not possible.
If the socket has been closed (or has experienced an error), you must re-create a new connection using a new socket object. For this to work, the remote server must be... | 1 | 0 | 0 | I am running a Graphite server to monitor instruments at remote locations. I have a "perpetual" ssh tunnel to the machines from my server (loving autossh) to map their local ports to my server's local port. This works well, data comes through with no hasstles. However we use a flaky satellite connection to the sites, w... | python - can't restart socket connection from client if server becomes unavailable temporarily | 0 | 0 | 1 | 1,295 |
11,194,380 | 2012-06-25T17:37:00.000 | 0 | 0 | 1 | 1 | python,command-line,path,pypy | 11,194,517 | 2 | false | 0 | 0 | to add to your path just open your start menu
right click on "Computer"
select "Properties"
click option for "Advanced System Settings"
click option for "environmental Variables"
change the one named "PATH" to include the folder that you need | 1 | 0 | 0 | So, I have installed the pypy pre-built interpreter to my home folder in windows; however, it only allows me to execute python scripts through the interpreters interface (similar to IDLE). I would like to extend this functionality to the cmd line in windows by putting something referencing the pypy interpreter to my sy... | Running Python Scripts from Command Line with Pypy Interpreter | 0 | 0 | 0 | 1,249 |
11,196,258 | 2012-06-25T19:44:00.000 | 4 | 1 | 0 | 0 | python,cython,pypy,pytables,psyco | 11,196,841 | 2 | true | 0 | 0 | There is some support numpy. Running pypy 1.9 I get the following message on importing numpy:
ImportError: The 'numpy' module of PyPy is in-development and not
complete. To try it out anyway, you can either import from 'numpypy',
or just write 'import numpypy' first in your program and then import
from 'numpy' a... | 1 | 1 | 0 | And if it doesn't, is there anyway to speed up my python code for accessing pytables on a 64-bit system (so no psyco)? | Does Pypy Support PyTables and Numpy? | 1.2 | 0 | 0 | 589 |
11,196,367 | 2012-06-25T19:54:00.000 | -1 | 0 | 1 | 0 | python,multithreading,multiprocessing | 11,196,583 | 3 | false | 0 | 0 | well break the single big file into multiple smaller files and have each of them processed in separate threads. | 1 | 86 | 0 | I have a single big text file in which I want to process each line ( do some operations ) and store them in a database. Since a single simple program is taking too long, I want it to be done via multiple processes or threads.
Each thread/process should read the DIFFERENT data(different lines) from that single file and... | Processing single file from multiple processes | -0.066568 | 0 | 0 | 61,124 |
11,198,288 | 2012-06-25T22:29:00.000 | 1 | 0 | 0 | 0 | python,netlogo,pycuda,agent-based-modeling,mayavi | 11,198,804 | 2 | true | 0 | 0 | You almost certainly do not want to use CUDA unless you are running into a significant performance problem. In general CUDA is best used for solving floating point linear algebra problems. If you are looking for a framework built around parallel computations, I'd look towards OpenCL which can take advantage of GPUs if ... | 1 | 2 | 1 | sorry if this all seem nooby and unclear, but I'm currently learning Netlogo to model agent-based collective behavior and would love to hear some advice on alternative software choices. My main thing is that I'd very much like to take advantage of PyCuda since, from what I understand, it enables parallel computation. H... | ABM under python with advanced visualization | 1.2 | 0 | 0 | 1,399 |
11,199,767 | 2012-06-26T01:49:00.000 | 1 | 0 | 1 | 0 | python,ipython | 11,199,881 | 2 | true | 0 | 0 | Usually when there is an error, it shows error message and get out. That is why you are seeing the flash.
Run the executable from command line and you can check out what that error is. | 1 | 2 | 0 | Just got a fresh 64bit box running windows vista, installed Python 2.7.3 and IPython 0.12.1, but IPython didn't seem to create any program folders.
Even if I run the .exe file from C:\Python27\Scripts, the terminal just flashes for a moment.
Any thoughts? | IPython won't launch after install | 1.2 | 0 | 0 | 940 |
11,199,797 | 2012-06-26T01:53:00.000 | 2 | 0 | 1 | 0 | python,django,import,settings | 11,202,467 | 2 | true | 1 | 0 | No. Use from ... import * or execfile() in settings/__init__.py to load the appropriate files. | 1 | 0 | 0 | I have a file layout like this:
settings/
----__init__.py
----common.py
----configs/
--------constants1.py
--------constants2.py
----debug/
--------include1&2.py
--------include1.py
--------include2.py
and when I import settings.debug.include1, I would like the settings file to execute/import common.py then override t... | How can I resolve this python and django settings import idiosyncrasy? | 1.2 | 0 | 0 | 116 |
11,199,978 | 2012-06-26T02:20:00.000 | 3 | 0 | 1 | 0 | python,python-2.7 | 11,200,000 | 3 | false | 0 | 0 | Strings sort naturally. Use list.sort (in-place) or built-in sorted (copying).
Both accept a boolean parameter named reverse which defaults to False; set to True fr reverse order. | 1 | 1 | 0 | Suppose I have a list of dates in the string format, 'YYYYMMDD.' How do I sort the list in regular and reverse order? | What is the most efficient way to sort a list of dates in string format in Python? | 0.197375 | 0 | 0 | 241 |
11,202,713 | 2012-06-26T07:37:00.000 | 3 | 1 | 0 | 0 | python,pyserial | 11,202,829 | 1 | true | 0 | 0 | A Serial port has no real concept of "cable connected" or not connected.
Depending on the equipment you are using you could try to poll the DSR or CTS lines, and decide there is no device connected when those stay low over a certain time.
From wikipedia:
DTR and DSR are usually on all the time and, per the RS-232 stan... | 1 | 1 | 0 | I am working on a multi threaded server application for processing serial/USB ports.
The issue is that if a cable gets unplugged, pyserial keeps reporting that the port is open and available. When reading I only receive Empty exceptions (due to read timeout).
How do I find out that a port has been disconnected so that ... | How to find out if serial port is closed? | 1.2 | 0 | 0 | 2,182 |
11,204,002 | 2012-06-26T09:05:00.000 | 0 | 0 | 0 | 0 | python,django,python-imaging-library,importerror | 11,204,486 | 1 | true | 1 | 0 | Oh, installing lcms from macports and reinstalling PIL helped. | 1 | 1 | 0 | Today i've tried to test a django project on my macbook, but whenever i try to start it, i get the same error: "Error: No module named _imagingcms".
Seems like something is missng from PIL. I've tried to reinstall PIL, but it does not help.
What should i do? | No module named _imagingcms on OSX | 1.2 | 0 | 0 | 550 |
11,206,884 | 2012-06-26T12:00:00.000 | 12 | 0 | 1 | 0 | python,sorting | 11,207,560 | 7 | false | 0 | 0 | I think the docs are incomplete. I interpret the word "primarily" to mean that there are still reasons to use cmp_to_key, and this is one of them. cmp was removed because it was an "attractive nuisance:" people would gravitate to it, even though key was a better choice.
But your case is clearly better as a cmp functi... | 1 | 36 | 0 | The move in recent versions of Python to passing a key function to sort() from the previous cmp function is making it trickier for me to perform complex sorts on certain objects.
For example, I want to sort a set of objects from newest to oldest, with a set of string tie-breaker fields. So I want the dates in reverse o... | How to write sort key functions for descending values? | 1 | 0 | 0 | 15,471 |
11,209,054 | 2012-06-26T14:01:00.000 | 1 | 0 | 1 | 0 | python,utf-8,io | 11,210,051 | 2 | false | 0 | 0 | Some experimentation with utf-8 encodings (repeated seeking and printing of .read(1) methods in a file with lots of multi-byte characters) revealed that yes, .seek() and .read() do behave differently in utf-8 files... they don't deal with single bytes, but single characters. This consisted of several simple re-writings... | 1 | 4 | 0 | For input text files, I know that .seek and .tell both operate with bytes, usually - that is, .seek seeks a certain number of bytes in relation to a point specified by its given arguments, and .tell returns the number of bytes since the beginning of the file.
My question is: does this work the same way when using other... | How does file reading work in utf-8 encoding? | 0.099668 | 0 | 0 | 646 |
11,211,228 | 2012-06-26T15:54:00.000 | 2 | 0 | 1 | 0 | java,php,c++,python,ruby | 11,211,502 | 1 | true | 1 | 0 | Perhaps I am missing something ....
Its appears you want to keep the data in 5 min buckets, but you can't be sure you have all the data for a bucket for up to 10 sec after it has rolled over.
This means for each instrument you need to keep the current bucket and the previous bucket. When its 10 seconds past the 5 min b... | 1 | 1 | 0 | Alright so this problem has been breaking my brain all day today.
The Problem: I am currently receiving stock tick data at an extremely high rate through multicasts. I have already parsed this data and am receiving it in the following form.
-StockID: Int-64
-TimeStamp: Microseconds from Epoch
-Price: Int
-Quantity: Int... | Interesting Stock Tick Data Scenario | 1.2 | 0 | 0 | 441 |
11,214,241 | 2012-06-26T19:01:00.000 | 2 | 0 | 1 | 0 | python,dictionary | 11,214,297 | 2 | false | 0 | 0 | The only drawback is performance. Larger keys mean longer times to hash.
Simply put, the only requirement of keys in a python dict is that they be immutable and hashable. For tuples (which are immutable), this means that you just need to combine the hashes of the sub-objects (which themselves must be immutable and ha... | 2 | 1 | 0 | Seems like there should be...
Right now it just seems like magic that you can hash multidimensionally to the same table, without any negative effects. | Any Drawback to Using Tuples as Dictionary Keys in Python? | 0.197375 | 0 | 0 | 1,117 |
11,214,241 | 2012-06-26T19:01:00.000 | 4 | 0 | 1 | 0 | python,dictionary | 11,214,300 | 2 | true | 0 | 0 | From the dictionary's perspective, there's not a single thing multi-dimensional about it. The dictionary has no idea that you are interpreting the keys as describing an n-space.
You could, for example, cleverly pack your vector into a string which would seem less magical, be more complicated to get right, and yet be fu... | 2 | 1 | 0 | Seems like there should be...
Right now it just seems like magic that you can hash multidimensionally to the same table, without any negative effects. | Any Drawback to Using Tuples as Dictionary Keys in Python? | 1.2 | 0 | 0 | 1,117 |
11,214,620 | 2012-06-26T19:28:00.000 | 2 | 0 | 1 | 1 | python,macos,osx-lion,virtualenv,homebrew | 11,214,702 | 2 | true | 0 | 0 | Homebrew is just a package manager for Mac, like pip for Python. Of course you never need a package manager, you can just get all the programs, or libraries in case of pip and Pypi yourself. The point of package managers however is to ease this process and give you a simple interface to install the software, and also t... | 1 | 1 | 0 | Being fairly new to programming, I am having trouble understanding exactly what Homebrew does... or rather - why it is needed. I know it contains pip for package management, but so does Virtualenv and I'm planning on installing this in due course.
Does Homebrew install another version of python that is not the system ... | Do I need to install Homebrew if I am planning to install Virtualenv? | 1.2 | 0 | 0 | 680 |
11,215,535 | 2012-06-26T20:38:00.000 | 1 | 0 | 0 | 0 | python,database,sqlite,error-handling | 11,215,911 | 1 | true | 1 | 0 | Your gut feeling is right. There is no way to add robustness to the application without reviewing each database access point separately.
You still have a lot of important choice at how the application should react on errors that depends on factors like,
Is it attended, or sometimes completely unattended?
Is delay OK,... | 1 | 2 | 0 | I have a desktop app that has 65 modules, about half of which read from or write to an SQLite database. I've found that there are 3 ways that the database can throw an SQliteDatabaseError:
SQL logic error or missing database (happens unpredictably every now and then)
Database is locked (if it's being edited by anoth... | Efficient approach to catching database errors | 1.2 | 1 | 0 | 237 |
11,216,401 | 2012-06-26T21:43:00.000 | 1 | 1 | 0 | 0 | c#,python,visa,gpib | 15,514,499 | 3 | false | 0 | 0 | There should be a clear command (something like "*CLS?", but dont quote me on that). I always run that when i first connect to a device. Then make sure you have a good timeout duration. I found for my device around 1 second works. Less then 1 second makes it so I miss the read after a write. Most of the time, a timeout... | 1 | 2 | 0 | I have a GPIB device that I'm communicating with using a National Instruments USB to GPIB. the USB to GPIB works great.
I am wondering what can cause a GPIB device to be unresponsive? If I Turn off the device and turn it back on it will respond, but when I run my program it will respond at first. It then cuts off ... | What can cause a GPIB to be unresponsive | 0.066568 | 0 | 0 | 2,223 |
11,217,855 | 2012-06-27T00:39:00.000 | 1 | 0 | 0 | 0 | python,math,geometry,gis | 11,217,921 | 2 | false | 0 | 0 | You could recursively split the quad in half on the long sides until the resulting area is small enough. | 1 | 1 | 1 | It is pretty easy to split a rectangle/square into smaller regions and enforce a maximum area of each sub-region. You can just divide the region into regions with sides length sqrt(max_area) and treat the leftovers with some care.
With a quadrilateral however I am stumped. Let's assume I don't know the angle of any o... | Split quadrilateral into sub-regions of a maximum area | 0.099668 | 0 | 0 | 1,141 |
11,218,393 | 2012-06-27T01:59:00.000 | 0 | 0 | 0 | 0 | python,django,django-file-upload | 11,218,464 | 2 | false | 1 | 0 | try: models.FileField(upload_to = '...') | 1 | 0 | 0 | Is it possible to upload a file in django using django's model.FileField() to a location that's not relative to /media ?. In my case upload an .html file to myproject/templates. | django upload file to custom location | 0 | 0 | 0 | 303 |
11,219,060 | 2012-06-27T03:37:00.000 | 6 | 0 | 0 | 0 | python,mysql,ruby,utf-8 | 11,219,610 | 2 | false | 0 | 0 | Once upon a time there was no unicode or UTF-8, and disparate encoding schemes were in use throughout the world.
It wasn't until back in 1988 that the initial unicode proposal was issued, with the goal of encoding all the worlds characters in a common encoding.
The first release in 1991 covered many character repre... | 2 | 8 | 0 | I'm just curious that there are modern systems out there that default to something other than UTF-8. I've had a person block for an entire day on the multiple locations that a mysql system can have different encoding. Very frustrating.
Is there any good reason not to use utf-8 as a default (and storage space seems lik... | why doesn't EVERYTHING default to UTF-8? | 1 | 1 | 0 | 519 |
11,219,060 | 2012-06-27T03:37:00.000 | -1 | 0 | 0 | 0 | python,mysql,ruby,utf-8 | 11,219,088 | 2 | false | 0 | 0 | Some encodings have different byte orders (little and big endian) | 2 | 8 | 0 | I'm just curious that there are modern systems out there that default to something other than UTF-8. I've had a person block for an entire day on the multiple locations that a mysql system can have different encoding. Very frustrating.
Is there any good reason not to use utf-8 as a default (and storage space seems lik... | why doesn't EVERYTHING default to UTF-8? | -0.099668 | 1 | 0 | 519 |
11,219,319 | 2012-06-27T04:16:00.000 | 1 | 0 | 0 | 1 | python,apache,cgi,nltk,appdata | 11,246,816 | 3 | false | 1 | 0 | %APPDATA% is a special variable that expands to the "Application Data" directory of the user who expands the variable (i.e., who runs a script). Apache is not running as you, so it has no business knowing about your APPDATA directory.
You should either hard-code the relevant path into your script, or replace it with a... | 1 | 1 | 0 | I'm using Python with the NLTK toolkit in Apache via CGI. The toolkit need to know the APPDATA directory, but when executed in the server, the os.environ not lists theAPPDATA.
When I execute a simple print os.envrion in console, APPDATA is present, but not when executed via CGI in the web server.
What is going on? How ... | APPDATA is not returned in Python executed via CGI | 0.066568 | 0 | 0 | 496 |
11,221,544 | 2012-06-27T07:43:00.000 | 5 | 0 | 0 | 0 | python,django,file-upload | 11,221,675 | 1 | true | 1 | 0 | how long will this file be retained in memory?
Are you talking about the temporary file on the filesystem? In that case, on a Unix platform, usually until you reboot. If you're talking about uploaded files in RAM, it probably stays in there at least until the request/response cycle is done. But that shouldn't really m... | 1 | 2 | 0 | "if an uploaded file is too large, Django will write the uploaded file to a temporary file stored in your system's temporary directory. On a Unix-like platform this means you can expect Django to generate a file called something like /tmp/tmpzfp6I6.upload. If an upload is large enough, you can watch this file grow in s... | how long will django store temporary files? | 1.2 | 0 | 0 | 457 |
11,223,147 | 2012-06-27T09:27:00.000 | 1 | 0 | 0 | 0 | python,sqlite | 11,224,222 | 4 | false | 0 | 0 | If you're not after just parameter substitution, but full construction of the SQL, you have to do that using string operations on your end. The ? replacement always just stands for a value. Internally, the SQL string is compiled to SQLite's own bytecode (you can find out what it generates with EXPLAIN thesql) and ? rep... | 3 | 0 | 0 | I'm trying to create a python script that constructs valid sqlite queries. I want to avoid SQL Injection, so I cannot use '%s'. I've found how to execute queries, cursor.execute('sql ?', (param)), but I want how to get the parsed sql param. It's not a problem if I have to execute the query first in order to obtain the ... | Python + Sqlite 3. How to construct queries? | 0.049958 | 1 | 0 | 1,125 |
11,223,147 | 2012-06-27T09:27:00.000 | 1 | 0 | 0 | 0 | python,sqlite | 11,224,475 | 4 | true | 0 | 0 | If you're trying to transmit changes to the database to another computer, why do they have to be expressed as SQL strings? Why not pickle the query string and the parameters as a tuple, and have the other machine also use SQLite parameterization to query its database? | 3 | 0 | 0 | I'm trying to create a python script that constructs valid sqlite queries. I want to avoid SQL Injection, so I cannot use '%s'. I've found how to execute queries, cursor.execute('sql ?', (param)), but I want how to get the parsed sql param. It's not a problem if I have to execute the query first in order to obtain the ... | Python + Sqlite 3. How to construct queries? | 1.2 | 1 | 0 | 1,125 |
11,223,147 | 2012-06-27T09:27:00.000 | 0 | 0 | 0 | 0 | python,sqlite | 11,224,003 | 4 | false | 0 | 0 | I want how to get the parsed 'sql param'.
It's all open source so you have full access to the code doing the parsing / sanitization. Why not just reading this code and find out how it works and if there's some (possibly undocumented) implementation that you can reuse ? | 3 | 0 | 0 | I'm trying to create a python script that constructs valid sqlite queries. I want to avoid SQL Injection, so I cannot use '%s'. I've found how to execute queries, cursor.execute('sql ?', (param)), but I want how to get the parsed sql param. It's not a problem if I have to execute the query first in order to obtain the ... | Python + Sqlite 3. How to construct queries? | 0 | 1 | 0 | 1,125 |
11,224,299 | 2012-06-27T10:36:00.000 | 0 | 0 | 1 | 0 | python,unicode | 11,244,398 | 2 | false | 0 | 0 | I ended up using pattern ff(fd|\d\w|\w\d) and removed all but only a few errors.
Some errors such as ff07 and ff50 are not removed which is strange since they should have been removed by the re pattern, but that little amount of errors is within my tolerance. | 1 | 0 | 0 | I have a Chinese document, but in the document there are a lot of error strings left due to error in decoding, they all look like fffd , ff10 or something.
Now I need to remove all the occurrence of those error strings, so I need to know the pattern for them, but I can't find useful information. All I SEEM TO know now ... | How to detect coding error strings? | 0 | 0 | 0 | 81 |
11,224,517 | 2012-06-27T10:49:00.000 | 1 | 1 | 0 | 1 | python,centos | 11,251,911 | 1 | true | 0 | 0 | If python2.7 is available on Yum, you should use that: the package management on large distros (redhat, ubuntu, debian, fedora ) takes care of maintaining parallel Python installs for you which won't conflict with each other.
This option should keep your system "/usr/bin/python¬ file pointing to Python2.4 and give you... | 1 | 0 | 0 | I have a CentOS 5.8 server and am planning to install a later version of python (presumably 2.7). I have heard a lot of mention that CentOS relies quite heavily on 2.4 for many admin features etc. I'm trying to determine exactly what these features are (and whether I would actually be using them) so that I can decide w... | CentOS 5.8 dependencies on Python 2.4? | 1.2 | 0 | 0 | 1,419 |
11,227,579 | 2012-06-27T13:40:00.000 | 2 | 0 | 0 | 1 | python,macos,mount | 11,228,033 | 1 | true | 0 | 0 | Have a look at the diskutil(8) and hdiutil(1) tools. | 1 | 1 | 0 | Is there a way in which I can get some information about the mounts I have in the folder /Volumes in OSX?
I want to be able to tell the difference between disk images like dmgs and other types, like hard disks or network mounts.
I tried parsing the output of mount -v and looking if read-only is in the line but I doubt ... | Getting mount type information in python on OSX | 1.2 | 0 | 0 | 813 |
11,228,645 | 2012-06-27T14:35:00.000 | 2 | 0 | 1 | 1 | python,windows | 11,228,733 | 3 | false | 0 | 0 | On Linux, it is common to store the configuration file in the users home directory, for instance ~/.myprogramrc. On windows Vista and up, users have a home directory as well (/Users/username) and a would recommend storing your settings there in a subfolder (/Users/useranem/myprogram). Storing the settings in the applic... | 1 | 10 | 0 | I have a python program that must work on Windows and Linux. There are some configuration options I normally store in a file, in a subdirectory of the program's directory.
For Windows, I converted it to exe and created an Installer for it. And now I have the problem of dealing with the config file.
What is the best pla... | Where to store the configuration files of python applications on Windows | 0.132549 | 0 | 0 | 4,707 |
11,228,878 | 2012-06-27T14:45:00.000 | 1 | 0 | 0 | 0 | python,html | 11,229,283 | 2 | true | 1 | 0 | If you are just trying to execute your application from the web application you would like to create, then you can go for anything from bare cgi scripts (in say ... Perl) through PHP script and even Django (Python based web framework). It all depend on what you like to do :)
If your intention is to integrate your Pytho... | 1 | 0 | 0 | I want to take HTML form data and handle the submited data(string for example) with my python application.
The html file with the form will be stored locally and values will be entered from a browser.
I then want to take the submited values to my python application.
How do I do with the form action and link it to my ap... | Take HTML form data to python | 1.2 | 0 | 0 | 600 |
11,230,979 | 2012-06-27T16:31:00.000 | 1 | 0 | 1 | 0 | python,django,pycharm | 11,231,045 | 3 | true | 1 | 0 | If your site loads, you should put the import the models into one of your Django views.
In a view you can do whatever you like with the models. | 1 | 1 | 0 | So I have a chunk of code that declares some classes, creates data, uses django to actually save them to the database. My question is how do I actually execute it?
I am using PyCharm and have the file open. But I have no clue how to actually execute it. I can execute line by line in Django Console, but if it's more tha... | How to run a file that uses django models (large block of code) in Pycharm | 1.2 | 0 | 0 | 1,138 |
11,231,244 | 2012-06-27T16:48:00.000 | 1 | 0 | 0 | 0 | python,ipv6,urllib,ipv4 | 11,231,476 | 1 | false | 0 | 0 | I had a look into the source code. Unfortunately, urllib.urlopen() seems to use httplib.HTTP(), which doesn't even allow setting a source address.
urllib2.urlopen() uses httplib.HTTPConnection() which you could inherit from and create a class which by default sets a source address '0.0.0.0' instead of ''. Then you coul... | 1 | 2 | 0 | What is the way to do urlopen in python such that even if the underlying machine has ipv6 networking enabled, the request is sent via ipv4 instead of ipv6? | how to do urlopen over ipv4 by default | 0.197375 | 0 | 1 | 2,773 |
11,232,351 | 2012-06-27T18:03:00.000 | 4 | 0 | 0 | 0 | python,iframe,tornado | 11,232,414 | 1 | true | 1 | 0 | Javascript has access to the browser context but a templating system will only have access to the request object.
If you control the creation of the iframe in question, for instance if that is happening on another part of your site, you might be able to pass get parameters in to the templating system or something... B... | 1 | 0 | 0 | In Tornado, you can do if statements in the HTML such as {% if true %} do stuff {% end %}. I'd like to check if the page is within an iframe.
In Javascript, it would be something like: if (top === self) { not in a frame } else { in a frame }
How can I do this in with Tornado? | Test iFrame "top === self" in Python Tornado | 1.2 | 0 | 0 | 152 |
11,232,958 | 2012-06-27T18:42:00.000 | 2 | 0 | 1 | 0 | python,data-structures,foreign-keys,relationship | 11,236,244 | 1 | false | 0 | 0 | Use sqlite. No server to install, and you get foreign key constraints for free. If this was a question of a single pair of tables you could hard-code the checking, but as you've discovered, it gets out of hand when you have to re-implement so much of what a DBMS is designed for. | 1 | 0 | 0 | I'm looking for a way to manage a set of Python data structures which would nicely fit into a relational schema, but without the overhead of having a real database or parsing SQL. The amount of data can be assumed to be small enough to fit conveniently into memory (say, no structure contains more than a million element... | Foreign key constrains for Python data structures without using real databases | 0.379949 | 0 | 0 | 192 |
11,233,140 | 2012-06-27T18:54:00.000 | 2 | 0 | 0 | 0 | python,excel,openpyxl | 11,233,362 | 1 | true | 0 | 0 | A workbook doesn't really have a name - normally you'd just consider it to be the basename of the file it's saved as... slight update - yep, even in VB WorkBook.Name just returns "file on disk.xls" | 1 | 3 | 0 | There is a worksheet.title method but not workbook.title method. Looking in the documentation there is no explicit way to find it, I wasn't sure if anyone knew a workaround or trick to get it. | Is there a way to get the name of a workbook in openpyxl | 1.2 | 1 | 0 | 10,098 |
11,233,863 | 2012-06-27T19:49:00.000 | 7 | 0 | 1 | 0 | python,python-2.7 | 11,233,915 | 4 | true | 0 | 0 | Use an OrderedDict from the collections module if you simply need to access the last item entered. If, however, you need to maintain continuous sorting, you need to use a different data structure entirely, or at least an auxiliary one for the purposes of indexing.
Edit: I would add that, if accessing the final element ... | 1 | 2 | 0 | I have a default dict of dicts whose primary key is a timestamp in the string form 'YYYYMMDD HH:MM:SS.' The keys are entered sequentially. How do I access the last entered key or the key with the latest timestamp? | What is the best way to access the last entered key in a default dict in Python? | 1.2 | 0 | 0 | 179 |
11,234,197 | 2012-06-27T20:16:00.000 | 3 | 0 | 0 | 0 | python,networking,interface,simulation | 11,315,321 | 2 | true | 0 | 0 | The massive number of answers people posted encouraged me to think outside of the box.
My approach will be to use Dummynet, a truly amazing and versatile tool. Unfortunately the Dummynet Windows and Linux ports are not well-maintained, which means I'll be running *BSD.
But this simplifies things, since a *BSD image ca... | 1 | 6 | 0 | I'm making a simulator for a digital radio using Python. The radio relays over RF one each of an RS-232 port and an Ethernet port, with a pair of radios making seamless pipes. Thus, the simulator will be used in pairs, with pipes between them simulating the RF link, permitting users to connect to each end using physi... | Network interface simulation in Python? | 1.2 | 0 | 1 | 2,780 |
11,239,467 | 2012-06-28T06:55:00.000 | 1 | 0 | 1 | 1 | python | 11,239,806 | 1 | true | 0 | 0 | Most of the code written in Ubuntu is written in Python. One should avoid removing system dependencies at any time.
You can do sudo apt-get install python but rest of the programs are probably gone; even though you install them manually, you can experience random bugs, system failures. I think you should just re-instal... | 1 | 0 | 0 | I removed python from my computer to be reinstalled. However after removing it, many services has gone from my Ubuntu 10.04. (e.g. mozilla, Ubuntu Software Center and many applications from System tab.) How can I get back all of them? Thanks a lot.. | Removing python | 1.2 | 0 | 0 | 289 |
11,241,781 | 2012-06-28T09:33:00.000 | 20 | 1 | 0 | 0 | python,unit-testing,jenkins,junit,xunit | 11,463,624 | 6 | false | 0 | 0 | I would second using nose. Basic XML reporting is now built in. Just use the --with-xunit command line option and it will produce a nosetests.xml file. For example:
nosetests --with-xunit
Then add a "Publish JUnit test result report" post build action, and fill in the "Test report XMLs" field with nosetests.xml (a... | 2 | 150 | 0 | How do you get Jenkins to execute python unittest cases?
Is it possible to JUnit style XML output from the builtin unittest package? | Python unittests in Jenkins? | 1 | 0 | 0 | 104,678 |
11,241,781 | 2012-06-28T09:33:00.000 | 4 | 1 | 0 | 0 | python,unit-testing,jenkins,junit,xunit | 11,241,965 | 6 | false | 0 | 0 | I used nosetests. There are addons to output the XML for Jenkins | 2 | 150 | 0 | How do you get Jenkins to execute python unittest cases?
Is it possible to JUnit style XML output from the builtin unittest package? | Python unittests in Jenkins? | 0.132549 | 0 | 0 | 104,678 |
11,242,387 | 2012-06-28T10:12:00.000 | 1 | 0 | 0 | 0 | python,database,design-patterns,simulation | 11,244,121 | 3 | false | 1 | 0 | It sounds like you need to record more or less the same kinds of information for each case, so a relational database sounds like a good fit-- why do you think it's "not the proper way"?
If your data fits in a collection of CSV files, you're most of the way to a relational database already! Just store in database table... | 2 | 7 | 0 | I am working with some network simulator. After making some extensions to it, I need to make a lot of different simulations and tests. I need to record:
simulation scenario configurations
values of some parameters (e.g. buffer sizes, signal qualities, position) per devices per time unit t
final results computed from t... | Preferred (or recommended) way to store large amounts of simulation configurations, runs values and final results | 0.066568 | 0 | 0 | 2,845 |
11,242,387 | 2012-06-28T10:12:00.000 | 1 | 0 | 0 | 0 | python,database,design-patterns,simulation | 11,244,431 | 3 | false | 1 | 0 | If your data structures are well-known and stable AND you need some of the SQL querying / computation features then a light-weight relational DB like SQLite might be the way to go (just make sure it can handle your eventual 3+GB data).
Else - ie, each simulation scenario might need a dedicated data structure to store ... | 2 | 7 | 0 | I am working with some network simulator. After making some extensions to it, I need to make a lot of different simulations and tests. I need to record:
simulation scenario configurations
values of some parameters (e.g. buffer sizes, signal qualities, position) per devices per time unit t
final results computed from t... | Preferred (or recommended) way to store large amounts of simulation configurations, runs values and final results | 0.066568 | 0 | 0 | 2,845 |
11,243,256 | 2012-06-28T11:04:00.000 | 0 | 0 | 0 | 0 | python,web.py | 11,488,215 | 1 | false | 1 | 0 | Not sure, but I'd switch to WSGI anyway, its faster and easy to use. Do you get that error when running the built in webserver? | 1 | 1 | 0 | when uploading a file with web.py, there's a exception " SystemError: error return without exception set" raised.
here's traceback
...
File "../web/template.py", line 882, in __call__
return BaseTemplate.__call__(self, *a, **kw)
File "../web/template.py", line 809, in __call__
return self... | what's wrong with web.py? SystemError: error return without exception set | 0 | 0 | 0 | 363 |
11,244,049 | 2012-06-28T11:53:00.000 | 1 | 1 | 0 | 0 | java,python,jsp | 11,244,145 | 3 | false | 1 | 0 | It would be neater to expose your python API as RESTful services, that JSP can access using Ajax and display data in the page. I'm specifically suggesting this because you said 'JSP' not 'Java'. | 1 | 1 | 0 | I want to create a UI which invokes my python script. Can i do it using JSP? If so, can you please explain how ? Or can i do it using some other language. I have gone through many posts related to it but could not find much? please help me out? Explanations using examples would be more helpful.
Thanks In Advance.. | Is it possible to invoke a python script from jsp? | 0.066568 | 0 | 0 | 8,657 |
11,245,439 | 2012-06-28T13:11:00.000 | 20 | 0 | 1 | 0 | shell,ipython,undo | 11,245,499 | 2 | true | 0 | 0 | Ctrl-_ (underscore) or Ctrl-x Ctrl-u
If you deleted something with ctrl-w/ctrl-k and so on
you can just paste it back with ctrl-y.
See readline(1) for additional hotkeys. | 1 | 9 | 0 | Is there a keyboard command for undoing typing in iPython? Note: I am not talking about undoing the result of a command you've executed.
Suppose I copied and pasted a few variable names as arguments into a long function call, and then realized they are the wrong arguments. Can I do an equivalent of ctrl-z or something ... | How to undo typing (not command output) in iPython shell | 1.2 | 0 | 0 | 5,481 |
11,248,073 | 2012-06-28T15:36:00.000 | 0 | 0 | 1 | 0 | python,pip,virtualenv,python-packaging | 65,819,257 | 30 | false | 0 | 0 | I simply wanted to remove packages installed by the project, and not other packages I've installed (things like neovim, mypy and pudb which I use for local dev but are not included in the app requirements). So I did:
cat requirements.txt| sed 's/=.*//g' | xargs pip uninstall -y
which worked well for me. | 3 | 971 | 0 | I'm trying to fix up one of my virtualenvs - I'd like to reset all of the installed libraries back to the ones that match production.
Is there a quick and easy way to do this with pip? | What is the easiest way to remove all packages installed by pip? | 0 | 0 | 0 | 859,222 |
11,248,073 | 2012-06-28T15:36:00.000 | 0 | 0 | 1 | 0 | python,pip,virtualenv,python-packaging | 47,974,813 | 30 | false | 0 | 0 | In Command Shell of Windows, the command pip freeze | xargs pip uninstall -y won't work. So for those of you using Windows, I've figured out an alternative way to do so.
Copy all the names of the installed packages of pip from the pip freeze command to a .txt file.
Then, go the location of your .txt file and run the ... | 3 | 971 | 0 | I'm trying to fix up one of my virtualenvs - I'd like to reset all of the installed libraries back to the ones that match production.
Is there a quick and easy way to do this with pip? | What is the easiest way to remove all packages installed by pip? | 0 | 0 | 0 | 859,222 |
11,248,073 | 2012-06-28T15:36:00.000 | 0 | 0 | 1 | 0 | python,pip,virtualenv,python-packaging | 70,313,854 | 30 | false | 0 | 0 | Select Libraries To Delete From This Folder:
C:\Users\User\AppData\Local\Programs\Python\Python310\Lib\site-packages | 3 | 971 | 0 | I'm trying to fix up one of my virtualenvs - I'd like to reset all of the installed libraries back to the ones that match production.
Is there a quick and easy way to do this with pip? | What is the easiest way to remove all packages installed by pip? | 0 | 0 | 0 | 859,222 |
11,249,313 | 2012-06-28T16:47:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,cookies,openid | 11,249,560 | 1 | true | 1 | 0 | users.get_current_user() is actually reading the cookies so you don't need to do anything more to optimize it (you can easily verify it by deleting your cookies and then refreshing the page). Unless you want to store more information and have access to them without accessing the datastore on every request. | 1 | 0 | 0 | I am using OpenID as a login system for a google appengine website and I right now for every website I am just passing the user info to every page using user = users.get_current_user()
Would using a cookie to do this be more efficient? (I know if would be easier that putting that in every single webpage) and is these ... | store openid user in cookie google appengine | 1.2 | 0 | 0 | 191 |
11,252,864 | 2012-06-28T21:04:00.000 | 2 | 1 | 1 | 0 | python,git,packaging | 11,253,601 | 1 | true | 0 | 0 | Personally, I only set files I intend to be executed as scripts as executable. Using a least permissive model is a smart, if not ideal, design choice when it comes to security. If you don't need the permissions, don't use them.
I don't see any reason why omitting the shebang is a bad idea, other than if someone else w... | 1 | 0 | 0 | I am starting an open source Python library that my company expects will be used by all of our customers. Since I am a sucker for proper presentation and practices, I have a question about file modes as saved by git. However, I want to avoid turning this into a best-practice type of discussion discouraged by StackOverf... | Is there a reason to not set Python files' modes as executable in an open source git repository? | 1.2 | 0 | 0 | 95 |
11,258,057 | 2012-06-29T07:52:00.000 | 1 | 0 | 1 | 0 | python,class,tkinter | 11,258,706 | 1 | true | 0 | 1 | I figured it out.
I used frame_table.grid_size() and have the columns and rows (7, 3).
Sorry for the dull question! | 1 | 0 | 0 | Just a quick question..
Following opening a text file in a separate definition (no classes used) I have a 'table' (i.e a frame) that has n rows (depending on what is in the text file).
As this number could be any number, is it possible to retrieve the number of rows afterwards since I have been given the task where I'm... | Obtaining number of rows Tkinter | 1.2 | 0 | 0 | 72 |
11,258,710 | 2012-06-29T08:48:00.000 | 1 | 0 | 1 | 1 | python,multithreading,google-app-engine,python-2.7 | 11,259,344 | 2 | false | 0 | 0 | You can't have "some thread safe and some not thread safe". That's impossible. If some code is not thread safe, then none of the code is thread safe. That's just how thread safety works. | 1 | 0 | 0 | Please help how it is possible to detect if python27 runtime is run in thread safe mode or not for code?
For example to notify that module is not compatible or apply threading code if required.
I want to port some code to python27 as thread safe and some as not thread safe but not understand how it works in Google App ... | How to check if Google App Engine python27 runs thread safe mode or not? | 0.099668 | 0 | 0 | 268 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.