Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2012-11-27 22:00:30.547 | Command Prompt: Set up for Python 2.7 by default | My command prompt is currently running Python 3.2 by default how do I set it up to run Python 2.7 by default, I have changed the PATH variable to point towards Python 2.7, but that did not work.
UPDATE:
It still does not work. :(
Still running python3 - to be specific it runs python3 when I am trying to install flask ... | Changing your PATH environment variable should do the trick. Some troubleshooting tips:
Make sure you didn't just change the local, but rather the system variable to reflect the new location
Make sure you restarted your CL window (aka close "cmd" or command prompt and reopen it). This will refresh the system variabl... | 0.101688 | false | 1 | 2,235 |
2012-11-28 13:47:53.260 | Python not getting IP if cable connected after script has started | I hope this doesn't cross into superuser territory.
So I have an embedded linux, where system processes are naturally quite stripped. I'm not quite sure which system process monitors to physical layer and starts a dhcp client when network cable is plugged in, but i made one myself.
¨
The problem is, that if i have a p... | After alot more research, the glibc problem jedwards suggested, seemed to be the problem. I did not find a solution, but made workaround for my usecase.
Considering I only use one URL, I added my own "resolv.file" .
A small daemon gets the IP address of the URL when PHY reports cable connected. This IP is saved to "m... | 0 | false | 1 | 2,236 |
2012-11-28 16:38:03.607 | Tracking online status? | I am quite new to web development and am working on this social networking site.
Now I want to add functionality to show if a person is online.
Now one of the ways I figure out doing this is by keeping online status bit in the database.
My question is how to do it dynamically. Say the page is loaded and a user (say c... | Create a new model with a last_activity DateTimeField and a OneToOneField to User. Alternatively, if you are subclassing User, using a custom User in django 1.5, or using a user profile, just add the field to that model.
Write a custom middleware that automatically updates the last_activity field for each user on every... | 0.201295 | false | 2 | 2,237 |
2012-11-28 16:38:03.607 | Tracking online status? | I am quite new to web development and am working on this social networking site.
Now I want to add functionality to show if a person is online.
Now one of the ways I figure out doing this is by keeping online status bit in the database.
My question is how to do it dynamically. Say the page is loaded and a user (say c... | As Sanjay says, prefer using memory solutions (online statuses have a quite brief use) like the Django cache (Redis or Memcache).
If you want a simple way of updating the online status of an user on an already loaded web page, use any lib like jQuery, AJAX-poll an URL giving the status of an user, and then update the t... | 0 | false | 2 | 2,237 |
2012-11-28 17:38:01.940 | Creating a haar classifier using opencv_traincascade | I am having a little bit of trouble creating a haar classifier. I need to build up a classifier to detect cars. At the moment I made a program in python that reads in an image, I draw a rectangle around the area the object is in, Once the rectangle is drawn, it outputs the image name, the top left and bottom right coor... | This looks like you need to determine what features you would like to train your classifier on first, as using the haar classifier it benefits from those extra features. From there you will need to train the classifier, this requires you to get a lot of images that have cars and those that do not have cars in them and ... | 1.2 | true | 1 | 2,238 |
2012-11-29 04:55:31.533 | Virtualenv and python - how to work outside the terminal? | When I enter my virtual environment (source django_venv/bin/activate), how do I make that environment transfer to apps run outside the terminal, such as Eclipse or even Idle? Even if I run Idle from the virtualenv terminal window command line (by typing idle), none of my pip installed frameworks are available within I... | Tell Eclipse or Idle that the python interpreter is django_venv/bin/python instead of /usr/bin/python | 1.2 | true | 1 | 2,239 |
2012-11-29 09:45:15.053 | Transactions in Web2Py over Google App Engine | I'm making a room reservation system in Web2Py over Google App Engine.
When a user is booking a Room the system must be sure that this room is really available and no one else have reserved it just a moment before.
To be sure I make a query to see if the room is available, then I make the reservation. The problem is ... | Mutual exclusion is already built into DBMS so we just have to use that. Lets take an example.
First, your table in the model should be defined in such a way that your room number should be unique (use UNIQUE constraint).
When User1 and User2 both query for a room, they should get a response saying the room is vacant. ... | 0.386912 | false | 1 | 2,240 |
2012-11-29 14:42:08.573 | How to use browser cookies programmatically | I have a crawler that automates the login and crawling for a website, but since the login was changed it is not working anymore.
I am wondering, can I feed the browser cookie (aka, I manually log-in) to my HTTP request? Is there anything particularly wrong in principle that wouldn't make this work? How do I find the b... | When you send the login information (and usually in response to many other requests) the server will set some cookies to the client, you must keep track of them and send them back to the server for each subsequent request.
A full implementation would also keep track of the time they are supposed to be stored. | 1.2 | true | 1 | 2,241 |
2012-11-30 22:29:36.167 | How to make Python get the username in windows and then implement it in a script | I know that using
getpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python to find the username and then implement it in the following script itself.
Script: os.path.join('..','Documents and Settings','USERNAME','Desktop'))
(Python Version 2... | you can try the following as well:
import os
print (os.environ['USERPROFILE'])
The advantage of this is that you directly get an output like:
C:\\Users\\user_name | 0.081452 | false | 3 | 2,242 |
2012-11-30 22:29:36.167 | How to make Python get the username in windows and then implement it in a script | I know that using
getpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python to find the username and then implement it in the following script itself.
Script: os.path.join('..','Documents and Settings','USERNAME','Desktop'))
(Python Version 2... | os.getlogin() did not exist for me. I had success with os.getenv('username') however. | 0.999798 | false | 3 | 2,242 |
2012-11-30 22:29:36.167 | How to make Python get the username in windows and then implement it in a script | I know that using
getpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python to find the username and then implement it in the following script itself.
Script: os.path.join('..','Documents and Settings','USERNAME','Desktop'))
(Python Version 2... | os.getlogin() return the user that is executing the, so it can be:
path = os.path.join('..','Documents and Settings',os.getlogin(),'Desktop')
or, using getpass.getuser()
path = os.path.join('..','Documents and Settings',getpass.getuser(),'Desktop')
If I understand what you asked. | 1.2 | true | 3 | 2,242 |
2012-12-01 00:34:49.430 | How do I manage a dynamic, changing main menu in wxPython? | I'm writing a document based application in wxPython, by which I mean that the user can have open multiple documents at once in multiple windows or tabs. There are multiple kinds of documents, and the documents can all be in different "states", meaning that there should be different menu options available in the main m... | Probably the only way to do it with the standard wx.Menu is to destroy and recreate the entire menubar. You might be able to Hide it though. Either way, I think it would be easiest to just put together a set of methods that creates each menubar on demand. Then you can destroy one and create the other.
You might also ta... | 0 | false | 1 | 2,243 |
2012-12-01 05:34:46.397 | When a web backend does more than simply reply to requests, how should my application be structured? | I'm creating a website that allows players to queue to find similarly skilled players for a multiplayer video game. Simple web backends only modify a database and create a response using a template, but in addition to that, my backend has to:
Communicate with players in real-time (via gevent-socketio) while they queue... | My first thought is that you could use a service oriented architecture to separate these tasks. Each of these services could run a Flask app on a separate port (or machine (or pool of machines)) and communicate to each other using simple HTTP. The breakdown might go something like this:
GameService: Handles incoming... | 0.386912 | false | 1 | 2,244 |
2012-12-01 18:30:02.920 | Multithreading or how to avoid blocking in a Python-application | I'm developing a Python-application that "talks" to the user, and performs tasks based on what the user says(e.g. User:"Do I have any new facebook-messages?", answer:"Yes, you have 2 new messages. Would you like to see them?"). Functionality like integration with facebook or twitter is provided by plugins. Based on pre... | i didn't really understand what sort of application its going to be, but i tried to anwser your questions
create a thread that query's, and then sleeps for a while
create a thread for each user, and close it when the user is gone
create a thread that download's and stops
after all, there ain't going to be 500 threads... | 0 | false | 1 | 2,245 |
2012-12-01 23:34:07.400 | How can I test if my Tic Tac Toe A.I. is perfect? | I made a tic tac toe A.I. Given each board state, my A.I. will return 1 exact place to move. (Even if moves are equally correct, it chooses same one every time, it does not pick a random one)
I also made a function that loops though all possible plays made with the A.I.
So it's a recursive function that lets the A.I. m... | You could actually brute force the game, and prove that every time there is a winning strategy, your A.I. picks the correct move. Then, you could prove that for every position, your A.I. picks the move which maximizes the chances of having a winning strategy, assuming the other player is playing randomly. There are not... | 0 | false | 2 | 2,246 |
2012-12-01 23:34:07.400 | How can I test if my Tic Tac Toe A.I. is perfect? | I made a tic tac toe A.I. Given each board state, my A.I. will return 1 exact place to move. (Even if moves are equally correct, it chooses same one every time, it does not pick a random one)
I also made a function that loops though all possible plays made with the A.I.
So it's a recursive function that lets the A.I. m... | One issue with akaRem's answer is that an optimal player shouldn't look like the overall distribution. For example, a player that I just wrote wins about 90% of the time against someone playing randomly and ties 10% of the time. You should only expect akaRem's statistics to match if you have two players against each ot... | 0 | false | 2 | 2,246 |
2012-12-02 08:33:00.150 | Adding PyMongo to Python IDE | I am a python newbie - I want to use the pymongo library to access mongoDb using some convenient IDE, and after looking through the web i decided to use WING.
Can some one point how to add the pymongo library to the WING ide (or to any other IDE for that matter)? i want to get the auto-completion for commands.
Thanks | If you are in windows platform just install the pymongo.exe file and it will install in python directory. Then you will be able to access it in any IDE such PyCharm by typing:
import pymongo | 0 | false | 1 | 2,247 |
2012-12-03 00:05:56.417 | How to utilize OpenBSD, Nginx, Python and NoSQL | I'm familiar with LAMP systems and have been programming mostly in PHP for the past 4 years. I'm learning Python and playing around with Nginx a little bit.
We're working on a project website which will handle a lot of http handle requests, stream videos(mostly from a provider like youtube or vimeo). My colleague has e... | My advice - if you don't know how to use these technologies - don't do it. Few servers will cost you less than the time spent mastering technologies you don't know. If you want to try them out - do it. One by one, not everything at once. There is no magic solution on how to use them. | 0.673066 | false | 2 | 2,248 |
2012-12-03 00:05:56.417 | How to utilize OpenBSD, Nginx, Python and NoSQL | I'm familiar with LAMP systems and have been programming mostly in PHP for the past 4 years. I'm learning Python and playing around with Nginx a little bit.
We're working on a project website which will handle a lot of http handle requests, stream videos(mostly from a provider like youtube or vimeo). My colleague has e... | I agree with wdev, the time it takes to learn this is not worth the money you will save. First of all, MySQL databases are not hard to scale. WordPress utilizes MySQL databases, and some of the world's largest websites use MySQL (google for a list). I can also say the same of linux and PHP.
If you design your site usi... | 0.201295 | false | 2 | 2,248 |
2012-12-04 11:42:20.873 | windows 8 incompatibility? | I cannot get my code to run on my win8 laptop. I am working with a combination of:
Stackless Python 2.7.2
Qt 4.8.4
PySide 1.1.2
Eclipse/Pydev and WingIDE
This works well on my Win7 PC, but now i have bought a demo laptop with windows 8. As far as I know all is installed the same way as on my PC.
When i run my program... | I had the same problem with Pyside 1.1.2 and Qt 4.8.4. The solution for me was to set the compatibility mode of the Python executable to Windows 7 via right click on the executable -> Properties -> Compatiblity -> Run this program in compatibility mode for: Windows 7
Hope that helps. | 0.201295 | false | 2 | 2,249 |
2012-12-04 11:42:20.873 | windows 8 incompatibility? | I cannot get my code to run on my win8 laptop. I am working with a combination of:
Stackless Python 2.7.2
Qt 4.8.4
PySide 1.1.2
Eclipse/Pydev and WingIDE
This works well on my Win7 PC, but now i have bought a demo laptop with windows 8. As far as I know all is installed the same way as on my PC.
When i run my program... | try using Hyper-V however Hyper-V is not installed by default in Windows 8. You need to go "Turn Windows features on or off." | 0 | false | 2 | 2,249 |
2012-12-04 20:56:20.807 | changing python windows command line | I try to save a python script as a shortcut that I want to run. It opens it but then closes right away.
I know why it is doing this, it is opening my windows command line in python3.2 the script is in python 2.7
I need both version on my PC, my question is how to I change the cmd default.
I have tried to "open with" sh... | Install both pythons, and change the path in Windows, by default both Pythons will be PATH=c:\python\python 2.7 and PATH=c:\python\python 3.2 Or something like that. What and since windows stops as soon as it finds the first python, what you could do is have one called PATH=c:\python27\ and another PATH=c:\python32\ th... | 0 | false | 1 | 2,250 |
2012-12-05 11:57:12.377 | How to reduce errors in dynamic language such as python, and improve my code quality? | I've always have trouble with dynamic language like Python.
Several troubles:
Typo error, I can use pylint to reduce some of these errors. But there's still some errors that pylint can not figure out.
Object type error, I often forgot what type of the parameter is, int? str? some object? Also, forgot the type of some ... | Unit testing is the best way to handle this. If you think the testing is taking too much time, ask yourself how much time you are loosing on defects - identifying, diagnosing and rectifying - after you have released the code.
In effect, you are testing in production, and there's plenty of evidence to show that defects ... | 0.673066 | false | 1 | 2,251 |
2012-12-05 16:54:15.010 | Can I use Z3Py withouth doing a system-wide install? | I'm trying to use Z3 from its python interface, but I would prefer not to do a system-wide install (i.e. sudo make install). I tried doing a local install with a --prefix, but the Makefile is hard-coded to install into the system's python directory.
Best case, I would like run z3 directly from the build directly, in t... | Yes, you can do it by including the build directory in your LD_LIBRARY_PATH and PYTHONPATH environment variables. | 1.2 | true | 1 | 2,252 |
2012-12-06 03:07:13.897 | Understanding an element of the main loop | I'm just starting out with Python. And I need help understanding how to do the main loop of my program.
I have a source file with two columns of data, temperature & time. This file gets updated every 60 seconds by a bash script.
I successfully wrote these three separate programs;
1. A program that can read the last 144... | The simplest solution is to add a variable outside of the loop which stores the last time the data size was checked. Every time through your loop you can compare the current time vs the last time every time through the loop and check if more than X time has elapsed. | 0.386912 | false | 1 | 2,253 |
2012-12-06 16:33:23.693 | Django session race condition? | Summary: is there a race condition in Django sessions, and how do I prevent it?
I have an interesting problem with Django sessions which I think involves a race condition due to simultaneous requests by the same user.
It has occured in a script for uploading several files at the same time, being tested on localhost. I ... | Yes, it is possible for a request to start before another has finished. You can check this by printing something at the start and end of a view and launch a bunch of request at the same time.
Indeed the session is loaded before the view and saved after the view. You can reload the session using request.session = engine... | 1.2 | true | 1 | 2,254 |
2012-12-07 23:52:45.663 | Plotting data using Flot and MySQL | So I am trying to create a realtime plot of data that is being recorded to a SQL server. The format is as follows:
Database: testDB
Table: sensors
First record contains 3 records. The first column is an auto incremented ID starting at 1. The second column is the time in epoch format. The third column is my sensor d... | Install a httpd server
Install php
Write a php script to fetch the data from the database and render it
as a webpage.
This is fairly elaborate request, with relatively little details given. More information will allow us to give better answers. | 0 | false | 1 | 2,255 |
2012-12-08 11:20:38.903 | Multiple processes reading&deleting files in the same directory | I have a directory with thousands of files and each of them has to be processed (by a python script) and subsequently deleted.
I would like to write a bash script that reads a file in the folder, processes it, deletes it and moves onto another file - the order is not important. There will be n running instances of thi... | The only sure way that no two scripts will act on the same file at the same time is to employ some kind of file locking mechanism. A simple way to do this could be to rename the file before beginning work, by appending some known string to the file name. The work is then done and the file deleted. Each script tests the... | 0.135221 | false | 1 | 2,256 |
2012-12-08 18:52:20.000 | Django - how to set up asynchronous longtime background data processing task? | Newb quesion about Django app design:
Im building reporting engine for my web-site. And I have a big (and getting bigger with time) amounts of data, and some algorithm which must be applied to it. Calculations promise to be heavy on resources, and it would be stupid if they are performed by requests of users. So, I thi... | Why don't you have a url or python script that triggers whatever sort of calculation you need to have done everytime it's run and then fetch that url or run that script via a cronjob on the server? From what your question was it doesn't seem like you need a whole lot more than that. | 0 | false | 1 | 2,257 |
2012-12-08 23:33:16.087 | Finding the indices of the top three values via argmin() or min() in python/numpy without mutation of list? | So I have this list called sumErrors that's 16000 rows and 1 column, and this list is already presorted into 5 different clusters. And what I'm doing is slicing the list for each cluster and finding the index of the minimum value in each slice.
However, I can only find the first minimum index using argmin(). I don't th... | numpy.argpartition(cluster, 3) would be much more effective. | 0.673066 | false | 1 | 2,258 |
2012-12-09 03:52:24.113 | Programmatically setting a process to execute at startup (runlevel 2)? | I would like to find out how to write Python code which sets up a process to run on startup, in this case level two.
I have done some reading, yet it has left me unclear as to which method is most reliable on different systems. I originally thought I would just edit /etc/inittab with pythons fileIO, but then I found ou... | I may as well answer my own question with my findings.
On Debian,Ubuntu,CentOS systems there is a file named /etc/rc.local. If you use pythons' FileIO to edit that file, you can put a command that will be run at the end of all the multi-user boot levels. This facility is still present on systems that use upstart.
On BS... | 1.2 | true | 1 | 2,259 |
2012-12-10 09:53:55.893 | uPnP pushing video to Smart TV/Samsung TV on OSX/Mac | I would like to make a simple script to push a movie to a Smart TV.
I have already install miniupnp or ushare, but I don't want to go in a folder by the TV Smart Apps, i want to push the movie to the TV, to win time and in future why not make the same directly from a NAS.
Can anyone have an idea how to do this ? This a... | You will still need a DLNA server to host your videos on. Via UPnP you only hand the URL to the TV, not the video directly. Once you have it hosted on a DLNA server, you can find out the URL to a video by playing it in Windows Media Player (which has DLNA-support) or by using UPnP Inspector (which I recommend anyways, ... | 1.2 | true | 1 | 2,260 |
2012-12-10 14:51:36.877 | PyCuda and Eclipse | I have installed PyCuda without any difficulty but am having trouble linking it to my eclipse environment. Does anyone know how I can link pycuda and eclipse IDE? Thanks in Adanced | You can use NetBeans 6.5 IDE its provide python support. | 0 | false | 1 | 2,261 |
2012-12-11 15:52:06.567 | Elastic search client for Python: advice? | I'm writing some scripts for our sales people to query an index with elastic search through python. (Eventually the script will update lead info in our Salesforce DB.)
I have been using the urllib2 module, with simplejson, to pull results. The problem is that this seems to be a not-so-good approach, evidenced by script... | It sounds like you have an issue unrelated to the client. If you can pare down what's being sent to ES and represent it in a simple curl command it will make what's actually running slowly more apparent. I suspect we just need to tweak your query to make sure it's optimal for your context. | 0 | false | 2 | 2,262 |
2012-12-11 15:52:06.567 | Elastic search client for Python: advice? | I'm writing some scripts for our sales people to query an index with elastic search through python. (Eventually the script will update lead info in our Salesforce DB.)
I have been using the urllib2 module, with simplejson, to pull results. The problem is that this seems to be a not-so-good approach, evidenced by script... | We use pyes. And its pretty neat. You can there go with the thrift protocol which is faster then the rest service. | 1.2 | true | 2 | 2,262 |
2012-12-11 23:36:19.927 | Change variable permanently | I'm writing a small program that helps you keep track of what page you're on in your books. I'm not a fan of bookmarks, so I thought "What if I could create a program that would take user input, and then display the number or string of text that they wrote, which in this case would be the page number they're on, and al... | You need to store it on disk. Unless you want to be really fancy, you can just use something like CSV, JSON, or YAML to make structured data easier.
Also check out the python pickle module. | 0.135221 | false | 1 | 2,263 |
2012-12-12 02:59:37.603 | PYTHON - Search a directory | Is it possible for the user to input a specific directory on their computer, and for Python to write the all of the file/folder names to a text document? And if so, how?
The reason I ask is because, if you haven't seen my previous posts, I'm learning Python, and I want to write a little program that tracks how many fil... | While the approach of @Makato is certainly right, for your 'diff' like application you want to capture the inode 'stat()' information of the files in your directory and pickle that python object from day-to-day looking for updates; this is one way to do it - overkill maybe - but more suitable than save/parse-load from ... | 0.135221 | false | 1 | 2,264 |
2012-12-12 18:22:17.063 | Strange co_filename for file from .egg during tracing in Python 2.7 | When tracing(using sys.settrace) python .egg execution by Python 2.7 interpreter frame.f_code.co_filename instead of <path-to-egg>/<path-inside-egg> eqauls to something like build/bdist.linux-x86_64/egg/<path-inside-egg>
Is it a bug? And how to reveal real path to egg?
In Python 2.6 and Python 3 everything works as ... | No, that is not a bug. Eggs, when being created, have their bytecode compiled in a build/bdist.<platform>/egg/ path, and you see that reflected in the co_filename variable. The bdist stands for binary distribution. | 1.2 | true | 1 | 2,265 |
2012-12-13 11:22:29.483 | How to step through Python expression evaluation process? | I want to build a visual debugger, which helps programming students to see how expression evaluation takes place (how subexpressions get evaluated and "replaced" by their values, something like expression evaluation visualizer in Excel).
Looks like you can't step through this process with Python's pdb, as its finest st... | Using pdb, any function call can be stepped into. For any other statement, pdb can print the values of the relevant names in the line. What additional functionality are you looking for that isn't covered?
If you're trying to 'step into' things like a list comprehension, that won't work from a pure Python perspective b... | 0.101688 | false | 1 | 2,266 |
2012-12-13 11:44:21.643 | python html parser which doesn't modify actual markup? | I want to parse html code in python and tried beautiful soup and pyquery already. The problem is that those parsers modify original code e.g insert some tag or etc. Is there any parser out there that do not change the code?
I tried HTMLParser but no success! :(
It doesn't modify the code and just tells me where tags a... | No, to this moment there is no such HTML parser and every parser has it's own limitations. | 1.2 | true | 1 | 2,267 |
2012-12-14 18:37:09.450 | Redirecting audio output from one function to another function in python | Suppose I have two functions drawn from two different APIs, function A and B.
By default, function A outputs audio data to a wav file.
By default, function B takes audio input from a wav file and process it.
Is it possible to stream the data from function A to B? If so, how do I do this? I work on lubuntu if that is r... | The answer is highly platform dependent and more details are required. Different Operating Systems have different ways of handling Interprocess Communication, or IPC.
If you're using a UNIXlike environment, there are a rich set of IPC primitives to work with. Pipes, SYS V Message Queues, shared memory, sockets, etc. In... | 0.386912 | false | 1 | 2,268 |
2012-12-15 03:39:30.717 | Run an external command and get the amount of CPU it consumed | Pretty simple, I'd like to run an external command/program from within a Python script, once it is finished I would also want to know how much CPU time it consumed.
Hard mode: running multiple commands in parallel won't cause inaccuracies in the CPU consumed result. | You can do timings within Python, but if you want to know the overall CPU consumption of your program, that is kind of silly to do. The best thing to do is to just use the GNU time program. It even comes standard in most operating systems. | 0.240117 | false | 1 | 2,269 |
2012-12-15 12:20:34.350 | given a URL in python, how can i check if URL has RSS feed? | am trying to find a way to detect if a given URL has an RSS feed or not. Any suggestions? | Each RSS have some format.
See what Content-Type the server returns for the given URL. However, this may not be specific and a server may not necessarily return the correct header.
Try to parse the content of the URL as RSS and see if it is successful - this is likely the only definitive proof that a given URL is a RS... | 0.999988 | false | 1 | 2,270 |
2012-12-16 08:46:52.957 | pip install web2py | I tried to install Web2py with pip. The installation is completed successfully. But after that I don't know how to start the server. I know there are three apps which are 'w2p_clone', 'w2p_apps' and 'w2p_run'. I don't know how to use these three apps. And also I did not set up my virtual env for Web2py, however even I ... | I think I can give my answer to my own question: we don't need to install web2py, just download it and python it. | 1.2 | true | 1 | 2,271 |
2012-12-16 23:50:46.180 | Storing large python object in RAM for later use | Is it possible to store python (or C++) data in RAM for latter use and how can this be achieved?
Background:
I have written a program that finds which lines in the input table match the given regular expression. I can find all the lines in roughly one second or less. However the problem is that i process the input tabl... | Your problem description is kind of vague and can be read in several different ways.
One way in which I read this is that you have some kind of ASCII representation of a data structure on disk. You read this representation into memory, and then grep through it one or more times looking for things that match a given reg... | 0 | false | 3 | 2,272 |
2012-12-16 23:50:46.180 | Storing large python object in RAM for later use | Is it possible to store python (or C++) data in RAM for latter use and how can this be achieved?
Background:
I have written a program that finds which lines in the input table match the given regular expression. I can find all the lines in roughly one second or less. However the problem is that i process the input tabl... | We regularly load and store much larger chunks of memory than 2 Gb in no time (seconds). We can get 350 Mb/s from our 3 year old SAN.
The bottlenecks /overheads seem to involve mainly python object management. I find that using marshal is much faster than cPickle. Allied with the use of data structures which involve mi... | 0.201295 | false | 3 | 2,272 |
2012-12-16 23:50:46.180 | Storing large python object in RAM for later use | Is it possible to store python (or C++) data in RAM for latter use and how can this be achieved?
Background:
I have written a program that finds which lines in the input table match the given regular expression. I can find all the lines in roughly one second or less. However the problem is that i process the input tabl... | You could try pickling your object and saving it to a file, so that each time the program runs it just has to deserialise the object instead of recalculating it. Hopefully the server's disk cache will keep the file hot if necessary. | 0.201295 | false | 3 | 2,272 |
2012-12-17 08:23:01.957 | Find out how many uncommitted items are in the session | I developed an application which parses a lot of data, but if I commit the data after parsing all the data, it will consume too much memory. However, I cannot commit it each time, because it costs too much hard disk I/O.
Therefore, my question is how can I know how many uncommitted items are in the session? | This is a classic case of buffering. Try a reasonably large chunk and reduce it if there's too much disk I/O (or you don't like it causing long pauses, etc) or increase it if your profile shows too much CPU time in I/O calls.
To implement, use an array, each "write" you append an item to the array. Have a separate "flu... | 0 | false | 1 | 2,273 |
2012-12-17 19:19:56.580 | idea/solution how to edit PBL (PowerBuilder Library) files? | I want to get the content of DataWindow from PBL (PowerBuilder Library) file and edit it in place. The idea is to read the pbl file, and access individual DataWindows to modify source code. Somehow, I have managed to do the first part with PblReader .NET library using IronPython. It allows me to read PBL files, and acc... | A PowerBuilder application can load a DataWindow from a PBL (doesn't have to be in the library path), modify it, and save it back to the PBL. I've written a couple of tools that do that. PowerBuilder will allow you to modify the DataWindow according to its object model using the modify method. I don't know why anyone w... | 1.2 | true | 1 | 2,274 |
2012-12-18 15:47:38.247 | copy netcdf file using python | I would like to make a copy of netcdf file using Python.
There are very nice examples of how to read or write netcdf-file, but perhaps there is also a good way how to make the input and then output of the variables to another file.
A good-simple method would be nice, in order to get the dimensions and dimension variab... | If you want to only use the netCDF-4 API to copy any netCDF-4 file, even those with variables that use arbitrary user-defined types, that's a difficult problem. The netCDF4 module at netcdf4-python.googlecode.com currently lacks support for compound types that have variable-length members or variable-length types of a... | 0.386912 | false | 1 | 2,275 |
2012-12-18 18:07:56.053 | Rapid number updates on a website | I wonder how to update fast numbers on a website.
I have a machine that generates a lot of output, and I need to show it on line. However my problem is the update frequency is high, and therefore I am not sure how to handle it.
It would be nice to show the last N numbers, say ten. The numbers are updated at 30Hz. That ... | a) WebSockets in conjuction with ajax to update only parts of the site would work, disadvantage: the clients infrastructure (proxies) must support those (which is currently not the case 99% of time).
b) With existing infrastructure the approach is Long Polling. You make an XmlHttpRequest using javascript. In case no da... | 0.265586 | false | 1 | 2,276 |
2012-12-18 19:52:29.320 | Streaming audio in Python with TideSDK | Iam trying to stream audio in my TideSDK application, but it seems to be quite difficult. The HTML5 audio does not work for me, neither does video tags. The player simply keeps loading. I've tested and confirmed that my code worked in many other browsers.
My next attemp was VLC via Python bindings. But without any conf... | The current version has very old webkit so because of that the HTML5 support is lacking. Audio and video tags are currently not supported in windows because underlying webkit implementation (wincairo) does not support it. Wa are working on the first part to use the latest webkit. once completed we are also planning to ... | 0.673066 | false | 1 | 2,277 |
2012-12-20 04:37:42.657 | Can I parse xpath using python, selenium and lxml? | So I have been trying to figure our how to use BeautifulSoup and did a quick search and found lxml can parse the xpath of an html page. I would LOVE if I could do that but the tutorial isnt that intuitive.
I know how to use Firebug to grab the xpath and was curious if anyone has use lxml and can explain how I can use i... | I prefer to use lxml. Because the efficiency of lxml is more higher than selenium for large elements extraction. You can use selenium to get source of webpages and parse the source with lxml's xpath instead of the native find_elements_with_xpath in selenium. | 0 | false | 1 | 2,278 |
2012-12-22 04:07:26.413 | PyQt - Automatically refresh a custom view when the model is updated? | By default, the built-in views in PyQt can auto-refresh itself when its model has been updated. I wrote my own chart view, but I don't know how to do it, I have to manually update it for many times.
Which signal should I use? | You need to connect your view to the dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ) signal of the model:
This signal is emitted whenever the data in an existing item changes.
If the items are of the same parent, the affected ones are those
between topLeft and bottomRight inclusive. If t... | 1.2 | true | 1 | 2,279 |
2012-12-22 04:34:14.467 | How do you find the negative index of a position if you know the index? | I have a string of variable length and I know the index position is 25. As it's variable in his length (>= 25), I need a way to locate the negative index of that same position for easier data manipulation.
Do you have any idea how this can be done? | Lets use a 'list' with following values:
'1', '2', '3','4', '5', '6'
Steps to get the negative index of any value:
Step1. Get the 'normal_index' of the value. For example the normal index of value '4' is 3.
Step2. Get the 'count' of the 'list'. In our example the 'list_count' is 5.
Step3. Get Negative index of the requ... | 0.201295 | false | 1 | 2,280 |
2012-12-22 13:51:15.650 | File path encoding in Windows | I'm writing a small application which saves file paths to a database (using django). I assumed file paths are utf-8 encoded, but I ran into the following file name: C:\FXG™.nfo which is apparently not encoded in utf-8.
When I do filepath.decode('utf-8') I get the following error:
UnicodeDecodeError: 'utf8' codec can't... | Use sys.getfilesystemencoding().
That should allow you to convert all paths that look ok.
However, there can always be illegally-encoded files or folders, you have to think how to deal with those in the framework of your application.
Some apps may ignore such files, others keep name as a binary blob. | 0.386912 | false | 1 | 2,281 |
2012-12-22 17:13:04.503 | nodelay() causes python curses program to exit | I've written a curses program in python. It runs fine. However, when I use nodelay(), the program exits straight away after starting in the terminal, with nothing shown at all (just a new prompt).
EDIT
This code will reproduce the bug:
sc = curses.initscr()
sc.nodelay(1) # But removing this line allows the program t... | While I didn't use curses in python, I am currently working with it in C99, compiled using clang on Mac OS Catalina. It seems that nodelay()` does not work unless you slow down the program step at least to 1/10 of a second, eg. usleep(100000). I suppose that buffering/buffer reading is not fast enough, and getch() or w... | 0.135221 | false | 2 | 2,282 |
2012-12-22 17:13:04.503 | nodelay() causes python curses program to exit | I've written a curses program in python. It runs fine. However, when I use nodelay(), the program exits straight away after starting in the terminal, with nothing shown at all (just a new prompt).
EDIT
This code will reproduce the bug:
sc = curses.initscr()
sc.nodelay(1) # But removing this line allows the program t... | I see no difference when running your small test program with or without the sc.nodelay() line.
Neither case prints anything on the screen... | 0 | false | 2 | 2,282 |
2012-12-23 02:46:16.277 | Storing MySQL Passwords | So, a friend and I are currently writing a panel (in python/django) for managing gameservers.
Each client also gets a MySQL server with their game server. What we are stuck on at the moment is how clients will find out their MySQL password and how it will be 'stored'.
The passwords would be generated randomly and prese... | Your question embodies a contradiction in terms. Either you don't want reversibility or you do. You will have to choose.
The usual technique is to hash the passwords and to provide a way for the user to reset his own password on sufficient alternative proof of identity. You should never display a password to anybody, f... | 0.201295 | false | 2 | 2,283 |
2012-12-23 02:46:16.277 | Storing MySQL Passwords | So, a friend and I are currently writing a panel (in python/django) for managing gameservers.
Each client also gets a MySQL server with their game server. What we are stuck on at the moment is how clients will find out their MySQL password and how it will be 'stored'.
The passwords would be generated randomly and prese... | Though this is not the answer you were looking for, you only have three possibilities
store the passwords plaintext (ugh!)
store with a reversible encryption, e.g. RSA (http://stackoverflow.com/questions/4484246/encrypt-and-decrypt-text-with-rsa-in-php)
do not store it; clients can only reset password, not view it
Th... | 1.2 | true | 2 | 2,283 |
2012-12-23 17:49:22.527 | synchronizing file names across servers | I have a development & production server and some large video files. The large files need to be renamed. I don't know how to automatically change the file names in the production environment when I change their name in the development environment. I think using git is very inefficient for large files.
On the developmen... | If the names on the development and production server are the same, then record the rename commands in a shell-script.
You can run that on both the development and the production server... | 0 | false | 1 | 2,284 |
2012-12-25 06:09:36.257 | python lists copying is it deep copy or Shallow copy and how is it done? | How is Deep copy being done in python for lists?
I am a little confused for copying of lists. Is it using shallow copy or deep copy?
Also, what is the syntax for sublists? is it g=a[:]? | The new list is a copy of references. g[0] and a[0] both reference the same object. Thus this is a shallow copy. You can see the copy module's deepcopy method for recursively copying containers, but this isn't a common operation in my experience.
Stylistically, I prefer the more explicit g = list(a) to create a copy of... | 0.545705 | false | 1 | 2,285 |
2012-12-25 08:57:30.693 | How dynamic arrays store different datatypes? | How does the language know how much space to reserve for each element? Or does it reserve the maximum space possible required for a datatype? (Talk about large floating point numbers). In that case isn't it a bit inefficient? | Arrays in Python are done via the array module. They do not store different datatypes, they store arrays of specific numerical values.
I think you mean the list type. It doesn't contain values, it just contains references to objects, which can be any type of object at all.
None of these reserves any space for any eleme... | 0.101688 | false | 3 | 2,286 |
2012-12-25 08:57:30.693 | How dynamic arrays store different datatypes? | How does the language know how much space to reserve for each element? Or does it reserve the maximum space possible required for a datatype? (Talk about large floating point numbers). In that case isn't it a bit inefficient? | Python reserves only enough space in a list for a reference to the various objects; it is up to the objects' allocators to reserve enough space for them when they are instantiated. | 0.101688 | false | 3 | 2,286 |
2012-12-25 08:57:30.693 | How dynamic arrays store different datatypes? | How does the language know how much space to reserve for each element? Or does it reserve the maximum space possible required for a datatype? (Talk about large floating point numbers). In that case isn't it a bit inefficient? | In C language terms, a Python list is like a PyObject *mylist[100], except it's dynamically allocated. It's a contiguous chunk of memory storing references to Python objects. | 0 | false | 3 | 2,286 |
2012-12-25 17:04:55.777 | Python data structure sort list alphabetically | I am a bit confused regarding data structure in python; (),[], and {}. I am trying to sort a simple list, probably since I cannot identify the type of data I am failing to sort it.
My list is simple: ['Stem', 'constitute', 'Sedge', 'Eflux', 'Whim', 'Intrigue']
My question is what type of data this is, and how to sort ... | ListName.sort() will sort it alphabetically. You can add reverse=False/True in the brackets to reverse the order of items: ListName.sort(reverse=False) | 0.327599 | false | 1 | 2,287 |
2012-12-25 22:21:24.347 | Permanent cookies with QWebKit -- where to get the QNetworkAccessManager? | I need to store cookies persistently in an application that uses QWebKit. I understand that I have to create a subclass of QNetworkCookieJar and attach it to a QNetworkAccessManager. But how do I attach this QNetworkAccessManager to my QWebView or get the QNetworkAccessManager used by it?
I use Python 3 and PyQt if tha... | You can get/set the cookie jar through QWebView.page().networkAccessManager().cookieJar()/setCookieJar().
The Browser demo included with Qt (in C++) shows how to read and write cookies to disk. | 1.2 | true | 1 | 2,288 |
2012-12-26 06:00:12.617 | Does uwsgi server read the paths in the environment variable PYTHONPATH? | Its weird because, when I run a normal python script on the server, it runs but when I run it via uWSGI, it cant import certain modules.
there is a bash script that starts uwsgi, and passes a path via --pythonpath option.
Is this an additional path or all the paths have to be given here ?
If yes, how do I separate mult... | you can specify multiple --pythonpath options, but PYTHONPATH should be honoured (just be sure it is correctly set by your init script, you can try setting it from the command line and running uwsgi in the same shell session) | 0 | false | 1 | 2,289 |
2012-12-26 16:05:37.923 | Downloading a Blob by Filename in Google App Engine (Python) | I know that I can grab a blob by BlobKey, but how do I get the blobkey associated with a given filename?
In short, I want to implement "get file by filename"
I can't seem to find any built-in functionality for this. | Every blob you upload, creates a new version of that blob (with that filename) in the blobstore. Ofcourse you can delete the old version(s) of the blob, if you uploaded a new version. But to make sure you have the latest version of a blob (of a filename) you have to store the filename in the datastore and make a refere... | 0.201295 | false | 1 | 2,290 |
2012-12-27 03:31:41.547 | Is declaring [almost] everything with self. alright (Python)? | I have a habit to declare new variables with self. in front to make it available to all methods. This is because sometimes I thought I don't need the variable in other methods. But halfway through I realized that I need it to be accessible in other methods. Then I have to add self. in front of all that variable.
So my ... | It's not really allright. self makes your variable available to global object-scope. That way you need to make sure that names of your variables are unique throughout complete object, rather than in localized scopes, amongst other side-effects that might or might not be unwanted.
In your particular case it might be not... | 0.545705 | false | 2 | 2,291 |
2012-12-27 03:31:41.547 | Is declaring [almost] everything with self. alright (Python)? | I have a habit to declare new variables with self. in front to make it available to all methods. This is because sometimes I thought I don't need the variable in other methods. But halfway through I realized that I need it to be accessible in other methods. Then I have to add self. in front of all that variable.
So my ... | Set a property on self only when the value is part of the overall object state. If it's only part of the method state, then it should be method-local, and should not be a property of self. | 1.2 | true | 2 | 2,291 |
2012-12-27 07:57:38.660 | how to disable pypy assert statement? | $ ./pypy -O
Python 2.7.2 (a3e1b12d1d01, Dec 04 2012, 13:33:26)
[PyPy 1.9.1-dev0 with GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: `` amd64 and ppc are only
available in enterprise version''
>>>> assert 1==2
Traceback (most recent... | PyPy does silently ignore -O. The reasoning behind it is that we believe -O that changes semantics is seriously broken, but well, I guess it's illegal. Feel free to post a bug (that's also where such reports belong, on bugs.pypy.org) | 1.2 | true | 2 | 2,292 |
2012-12-27 07:57:38.660 | how to disable pypy assert statement? | $ ./pypy -O
Python 2.7.2 (a3e1b12d1d01, Dec 04 2012, 13:33:26)
[PyPy 1.9.1-dev0 with GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: `` amd64 and ppc are only
available in enterprise version''
>>>> assert 1==2
Traceback (most recent... | For anyone coming here in the future, Oct 3 2021 pypy3 does accept the -O flag and turn off assertion statements | 0 | false | 2 | 2,292 |
2012-12-27 08:42:01.773 | How to check if pdf printing is finished on linux command line | I have a bunch of files that I need to print via PDF printer and after it is printed I need to perform additional tasks, but only when it is finally completed.
So to do this from my python script i call command "lpr path/to/file.doc -P PDF"
But this command immediately returns 0 and I have no way to track when printin... | You can check the state of the printer using the lpstat command (man lpstat). To wait for a process to finish, get the PID of the process and pass it wait command as argument | 0.201295 | false | 1 | 2,293 |
2012-12-28 19:40:03.950 | Make python configobj to not put a space before and after the '=' | Simple question. It is possible to make configobj to not put a space before and after the '=' in a configuration entry ?
I'm using configobj to read and write a file that is later processed by a bash script, so putting an antry like:
VARIABLE = "value"
breaks the bash script, it needs to always be:
VARIABLE="value"
Or... | Configobj is for reading and writing ini-style config files. You are apparently trying to use it to write bash scripts. That's not something that is likely to work.
Just write the bash-script like you want it to be, perhaps using a template or something instead.
To make ConfigParses not write the spaces around the = pr... | 0.067922 | false | 1 | 2,294 |
2012-12-29 07:13:59.600 | How to determine whether the number is 32-bit or 64-bit integer in Python? | I want to differentiate between 32-bit and 64-bit integers in Python. In C it's very easy as we can declare variables using int_64 and int_32. But in Python how do we differentiate between 32-bit integers and 64-bit integers? | There's no need. The interpreter handles allocation behind the scenes, effectively promoting from one type to another as needed without you doing anything explicit. | 0.613357 | false | 1 | 2,295 |
2012-12-31 11:36:58.317 | C# GUI automation using PyWinAuto | I was working with GUI automation for visual studio C# desktop application.
There I have DataGridView and inside the grid I have combo box and check boxes.
I tried to automate these using pywinauto, I can get only grid layout control only
and internal things I cant able to get the controls
(I tried with print _control_... | The short answer is that there's no good way to automate sub-controls of a DataGridView using PyWinAuto.
If you want to read data out of a DataGridView (e.g. read the text contents of a cell, or determine whether a checkbox is checked), you are completely out of luck. If you want to control a DataGridView, there are t... | 0.545705 | false | 1 | 2,296 |
2013-01-01 20:23:12.477 | How to execute a python command line utility from the terminal in any directory | I have just written a python script to do some batch file operations. I was wondering how i could keep it in some common path like rest of the command line utilities like cd, ls, grep etc.
What i expect is something like this to be done from any directory -
$ script.py arg1 arg2 | Add the directory it is stored in to your PATH variable? From your prompt, I'm guessing you're using an sh-like shell and from your tags, I'm further assuming OS X. Go into your .bashrc and make the necessary changes. | 0 | false | 2 | 2,297 |
2013-01-01 20:23:12.477 | How to execute a python command line utility from the terminal in any directory | I have just written a python script to do some batch file operations. I was wondering how i could keep it in some common path like rest of the command line utilities like cd, ls, grep etc.
What i expect is something like this to be done from any directory -
$ script.py arg1 arg2 | Just put the script directory into the PATH environment variable, or alternatively put the script in a location that is already in the PATH. On Unix systems, you usually use /home/<nick>/bin for your own scripts and add that to the PATH. | 1.2 | true | 2 | 2,297 |
2013-01-02 10:02:56.867 | Python-controllable command line audio player for Linux | I want to build use my Raspberry Pi as a media station. It should be able to play songs via commands over the network. These commands should be handled by a server written in Python. Therefor, I need a way to control audio playback via Python.
I decided to use a command line music player for linux since those should of... | mpd should be perfect for you. It is a daemon and can be controlled by various clients, ranging from GUI-less command-line clients like mpc to GUI command-line clients like ncmpc and ncmpcpp up to several full-featured desktop clients.
mpd + mpc should do the job for you as mpc can be easily controlled via the command ... | 1.2 | true | 1 | 2,298 |
2013-01-02 22:09:55.833 | Creating an Image model | I am developing Image recognition software that will detect letters. I was wondering how I could create a model of a letter ("J" for example) so that when I take a picture with the letter "J" on it, the software will compare the image to the model and detect the letter "J".
How would I create the model? | You can use OpenCv library for java , this library contain Template Matching Model already implemented
but the better thing for image recognition is using learning machine or neural network | 0 | false | 3 | 2,299 |
2013-01-02 22:09:55.833 | Creating an Image model | I am developing Image recognition software that will detect letters. I was wondering how I could create a model of a letter ("J" for example) so that when I take a picture with the letter "J" on it, the software will compare the image to the model and detect the letter "J".
How would I create the model? | If I were going to do this, I would use normalized floats.
The letter A would be:
[(0.0,0.0),(0.5,1.0),(1.0,0.0),(0.1,0.5)(0.9,0.5)]
Update (further explanation)
So my thought is that you should be able to uniquely identify a letter with an array of normalized points. Points would be at important features of the let... | 0 | false | 3 | 2,299 |
2013-01-02 22:09:55.833 | Creating an Image model | I am developing Image recognition software that will detect letters. I was wondering how I could create a model of a letter ("J" for example) so that when I take a picture with the letter "J" on it, the software will compare the image to the model and detect the letter "J".
How would I create the model? | It seems you want to do OCR (Optical Character Recognition).
If this is only part of a larger project, try OpenCV. Even if you are making a commercial product, it has a permissive BSD license.
If you have set out to make a library of your own, read some of the papers available through any good search engine. There are ... | 0.265586 | false | 3 | 2,299 |
2013-01-03 12:54:47.767 | Cross-platform deployment and easy installation | EDIT
One option I contemplated but don't know enough about is to e.g. for windows write a batch script to:
Search for a Python installation, download one and install if not present
Then install the bundled package using distutils to also handle dependencies.
It seems like this could be a relatively elegant and simpl... | I would recommend using py2exe for the windows side, and then BuildApplet for the mac side. This will allow you to make a simple app you double click for your less savvy users. | 0 | false | 2 | 2,300 |
2013-01-03 12:54:47.767 | Cross-platform deployment and easy installation | EDIT
One option I contemplated but don't know enough about is to e.g. for windows write a batch script to:
Search for a Python installation, download one and install if not present
Then install the bundled package using distutils to also handle dependencies.
It seems like this could be a relatively elegant and simpl... | py2exe works pretty well, I guess you just have to setup a Windows box (or VM) to be able to build packages with it. | 0.265586 | false | 2 | 2,300 |
2013-01-04 06:55:53.620 | can one python script run both with python 2.x and python 3.x | i have thousands of servers(linux), some only has python 2.x and some only has python 3.x, i want to write one script check.py can run on all servers just as $./check.py without use $python check.py or $python3 check.py, is there any way to do this?
my question is how the script check.py find the Interpreter no matter ... | Considering that Python 3.x is not entirely backwards compatible with Python 2.x, you would have to ensure that the script was compatible with both versions. This can be done with some help from the 2to3 tool, but may ultimately mean running two distinct Python scripts. | 0 | false | 2 | 2,301 |
2013-01-04 06:55:53.620 | can one python script run both with python 2.x and python 3.x | i have thousands of servers(linux), some only has python 2.x and some only has python 3.x, i want to write one script check.py can run on all servers just as $./check.py without use $python check.py or $python3 check.py, is there any way to do this?
my question is how the script check.py find the Interpreter no matter ... | In the general case, no; many Python 2 scripts will not run on Python 3, and vice versa. They are two different languages.
Having said that, if you are careful, you can write a script which will run correctly under both. Some authors take extra care to make sure their scripts will be compatible across both versions, co... | 0 | false | 2 | 2,301 |
2013-01-04 08:57:55.073 | How can I see emails sent with Python's smtplib in my Outlook Sent Items folder? | I am using hosted exchange Microsoft Office 365 email and I have a Python script that sends email with smtplib. It is working very well. But there is one issue, how can I get the emails to show up in my Outlook Sent Items? | You can send a copy of that email to yourself, with some header that tag the email was sent by yourself, then get another script (using IMAP library maybe) to move the email to the Outlook Sent folder | 0.673066 | false | 1 | 2,302 |
2013-01-04 17:45:26.820 | PyRun_InteractiveLoop globals/locals | I am trying to set local/globals variables in PyRun_InteractiveLoop call.
Cant figure out how to do it, since, unlike exec counterparts, loop doesn't accept global/local args.
What am I missing? | If what you want is a C API version of exec, maybe try PyRun_File and its ilk? Not sure exactly what you're trying to accomplish though. | 0 | false | 1 | 2,303 |
2013-01-05 23:11:16.263 | Get publicly accessible contents of S3 bucket without AWS credentials | Given a bucket with publicly accessible contents, how can I get a listing of all those publicly accessible contents? I know boto can do this, but boto requires AWS credentials. Also, boto doesn't work in Python3, which is what I'm working with. | Using AWS CLI,
aws s3 ls s3://*bucketname* --region *bucket-region* --no-sign-request | 0 | false | 2 | 2,304 |
2013-01-05 23:11:16.263 | Get publicly accessible contents of S3 bucket without AWS credentials | Given a bucket with publicly accessible contents, how can I get a listing of all those publicly accessible contents? I know boto can do this, but boto requires AWS credentials. Also, boto doesn't work in Python3, which is what I'm working with. | If the bucket's permissions allow Everyone to list it, you can just do a simple HTTP GET request to http://s3.amazonaws.com/bucketname with no credentials. The response will be XML with everything in it, whether those objects are accessible by Everyone or not. I don't know if boto has an option to make this request wit... | 0.673066 | false | 2 | 2,304 |
2013-01-07 06:34:29.080 | python project setting for production and developement | I'm building project with Django, I can make two setting files for Django: production_setting.py and development_setting.py, however, I need some configure file for my project and I'm using ConfigParser to parse that files. e.g.
[Section]
name = "development"
version = "1.0"
how to split this configure file to produc... | What we usually do in our Django projects is create versions of all configuration files for each platform (dev, prod, etc...) and use symlinks to select the correct one. Now that Windows supports links properly, this solution fits everybody.
If you insist on another configuration file, try making it a Python file that ... | 1.2 | true | 1 | 2,305 |
2013-01-07 07:12:44.863 | How can I assign a variant of POINTER(c_char) type to a string? | I call foreign c library in my program using ctypes, I don't know how to assign a POINTER(c_char) variant to a string. | The question is vague, but I guess you should use c_char_p instead of POINTER(c_char). | 0 | false | 1 | 2,306 |
2013-01-07 18:08:53.097 | Need more than 32 USB sound cards on my system | I'm working on an educative multiseat project where we need to connect 36 keyboards and 36 USB sound cards to a single computer. We're running Ubuntu Linux 12.04 with the 3.6.3-030603-generic kernel.
So far we've managed to get the input from the 36 keyboards, and recognized the 36 sound cards without getting a kernel ... | The sound card limit is defined as the symbol SNDRV_CARDS in include/sound/core.h.
When I increased this seven years ago, I did not go beyond 32 because the card index is used as a bit index for the variable snd_cards_lock in sound/core/init.c, and I did not want to change more than necessary.
If you make snd_cards_loc... | 0.545705 | false | 1 | 2,307 |
2013-01-09 17:18:16.087 | use / load new python module without installation | I am totally new to Python, and I have to use some modules in my code, like numpy and scipy, but I have no permission on my hosting to install new modules using easy-install or pip ( and of course I don't know how to install new modules in a directory where I have permission [ I have SSH access ] ).
I have downloaded n... | Use the --user option to easy_install or setup.py to indicate where the installation is to take place. It should point to a directory where you have write access.
Once the module has been built and installed, you then need to set the environmental variable PYTHONPATH to point to that location. When you next run the pyt... | 0 | false | 1 | 2,308 |
2013-01-09 18:41:35.587 | colorbar with a slider using wxpython | I haven't seen an example of this but I wanted to know if any knows how to implement a colorbar with an adjustable slider using wxpython. Basically the slider should change the levels of the colorbar and as such adjust the colormap.
If anyone has an idea of how to do and possible some example code it would be much app... | I think you're looking for one of the following widgets:
ColourDialog, ColourSelect, PyColourChooser or CubeColourDialog
They all let you choose colors in different ways and they have a slider to help adjust the colours too.
You can see each of them in action in the wxPython demo (downloadable from the wxPython web pag... | 1.2 | true | 1 | 2,309 |
2013-01-10 09:08:22.983 | Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn | I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: "Registered online", "Accepts email notifications" etc) and continuous data (ex: "Age",... | You will need the following steps:
Calculate the probability from the categorical variables (using predict_proba method from BernoulliNB)
Calculate the probability from the continuous variables (using predict_proba method from GaussianNB)
Multiply 1. and 2. AND
Divide by the prior (either from BernoulliNB or from Gaus... | 0 | false | 3 | 2,310 |
2013-01-10 09:08:22.983 | Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn | I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: "Registered online", "Accepts email notifications" etc) and continuous data (ex: "Age",... | The simple answer: multiply result!! it's the same.
Naive Bayes based on applying Bayes’ theorem with the “naive” assumption of independence between every pair of features - meaning you calculate the Bayes probability dependent on a specific feature without holding the others - which means that the algorithm multiply e... | 0.986614 | false | 3 | 2,310 |
2013-01-10 09:08:22.983 | Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn | I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: "Registered online", "Accepts email notifications" etc) and continuous data (ex: "Age",... | You have at least two options:
Transform all your data into a categorical representation by computing percentiles for each continuous variables and then binning the continuous variables using the percentiles as bin boundaries. For instance for the height of a person create the following bins: "very small", "small", "r... | 1.2 | true | 3 | 2,310 |
2013-01-10 10:08:08.487 | Twisted: ReconnectingClientFactory connection to different servers | I have a twisted ReconnectingClientFactory and i can successfully connect to given ip and port couple with this factory. And it works well.
reactor.connectTCP(ip, port, myHandsomeReconnectingClientFactory)
In this situation, when the server is gone, myHandsomeReconnectingClientFactory tries to connect same ip and por... | ReconnectingClientFactory doesn't have this capability. You can build your own factory which implements this kind of reconnection logic, mostly by hooking into the clientConnectionFailed factory method. When this is called and the reason seems to you like that justifies switching servers (eg, twisted.internet.error.C... | 0.386912 | false | 1 | 2,311 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.