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 |
|---|---|---|---|---|---|---|---|
2011-05-07 11:33:19.083 | How to uninstall wxpython 2.8 on Mac OSX 10.6 | Some details of my machine and installed packages before proceeding further:
Mac OSX version: 10.6.6
Python version: Activestate Python 2.7.1
wxpython version: wxpython 2.8 (uses Carbon API hence limited to 32-bit mode arch only)
I installed wxPython2.8-osx-unicode-py2.7 from wxpython website using their .dmg installer... | If you look in the .dmg for wxPython, there is an uninstall_wxPython.py unininstall script. Just drag it to your desktop and run python ~/Desktop/uninstall_wxPython.py in a terminal. | 1 | false | 1 | 1,232 |
2011-05-07 15:29:50.840 | Load form data in JavaScript and run something client side | The original framework of my app (using Python) is below:
user key in keywords in forms.
App use the data in forms as parameter to get some results from third-party website.
The result which is from third-party website will be analyzed in my app.
Then show the result of analyze to user.
But there are some problems be... | It's very unclear what you are looking for. If the question is about server push keywords are WebSockets,Socket.io,Ajax,Comet,Bayeux to start with | 1.2 | true | 1 | 1,233 |
2011-05-08 23:06:10.787 | How do I use Python 3.0 under Apache? | I've searched for ages on how to use Python 3 under Apache. If there is a walkthrough anywhere, it's very well hidden. Thus, hopefully, one of you Python professionals could make a quick 1-2-3 on how it's done!
I'm on Windows 7 using the newest version of XAMPP. | Python 3.0 is only supported via CGI. Put your CGI script in cgi-bin\. If you're willing to look at newer versions, preliminary support is available in mod_wsgi (but you'll probably have to build it yourself). | 0.135221 | false | 1 | 1,234 |
2011-05-09 08:20:33.020 | How to call a javascript method from python on SL4A? | I am writing an Android app using Python and SL4A. The app uses a webview that I wish to refresh. I plan on doing this by utilising javascript location.replace() within a wrapping doRefresh() javascript function. The problem I have is that I do not know how to call the javascript function from within my main event loop... | You'll need to wait for a refresh event (this would be a custom event) in your JavaScript that is waiting for an event posted from your Python script. The only communication layer between JavaScript and Python is via events. | 1.2 | true | 1 | 1,235 |
2011-05-10 17:02:23.633 | Python path help | how can i run my program using test files on my desktop without typing in the specific pathname. I just want to be able to type the file name and continue on with my program. Since i want to be able to send it to a friend and not needing for him to change the path rather just read the exact same file that he has on his... | f = open(os.path.join(os.environ['USERPROFILE'], 'DESKTOP', my_filename)) | 1.2 | true | 3 | 1,236 |
2011-05-10 17:02:23.633 | Python path help | how can i run my program using test files on my desktop without typing in the specific pathname. I just want to be able to type the file name and continue on with my program. Since i want to be able to send it to a friend and not needing for him to change the path rather just read the exact same file that he has on his... | You can tell your friend to make *.py files to be executed by the interpreter. Change it from Explorer:Tools:Folder Options:File Types. | 0 | false | 3 | 1,236 |
2011-05-10 17:02:23.633 | Python path help | how can i run my program using test files on my desktop without typing in the specific pathname. I just want to be able to type the file name and continue on with my program. Since i want to be able to send it to a friend and not needing for him to change the path rather just read the exact same file that he has on his... | If you place your Python script in the same directory as the files your script is going to open, then you don't need to specify any paths. Be sure to allow the Python installer to "Register Extensions", so Python is called when you double-click on a Python script. | 0 | false | 3 | 1,236 |
2011-05-10 17:27:37.027 | Python: Read large file in chunks | Hey there, I have a rather large file that I want to process using Python and I'm kind of stuck as to how to do it.
The format of my file is like this:
0 xxx xxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx... | Why don't you just read the file char by char using file.read(1)?
Then, you could - in each iteration - check whether you arrived at the char 1. Then you have to make sure that storing the string is fast. | 0.135221 | false | 2 | 1,237 |
2011-05-10 17:27:37.027 | Python: Read large file in chunks | Hey there, I have a rather large file that I want to process using Python and I'm kind of stuck as to how to do it.
The format of my file is like this:
0 xxx xxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx... | If the format is fixed, why not just read 3 lines at a time with readline() | 0 | false | 2 | 1,237 |
2011-05-11 14:12:09.067 | Communication between PHP and Python | I'm trying to build a web interface for some python scripts. The thing is I have to use PHP (and not CGI) and some of the scripts I execute take quite some time to finish: 5-10 minutes. Is it possible for PHP to communicate with the scripts and display some sort of progress status? This should allow the user to use the... | I think you would have to use a meta refresh and maybe have the python write the status to a file and then have the php read from it.
You could use AJAX as well to make it more dynamic.
Also, probably shouldn't use exec()...that opens up a world of vulnerabilities. | 0.201295 | false | 1 | 1,238 |
2011-05-12 19:00:56.167 | asynchronous file upload with ajaxupload to a tornado web server | I'm using this javascript library (http://valums.com/ajax-upload/) to upload file to a tornado web server, but I don't know how to get the file content. The javascript library is uploading using XHR, so I assume I have to read the raw post data to get the file content. But I don't know how to do it with Tornado. Their ... | I got the answer.
I need to use self.request.body to get the raw post data.
I also need to pass in the correct _xsrf token, otherwise tornado will fire a 403 exception.
So that's about it. | 1.2 | true | 1 | 1,239 |
2011-05-13 01:51:19.343 | Linux user scheme for a Django production server | I'm currently trying to set up nginx + uWSGI server for my Django homepage. Some tutorials advice me to create specific UNIX users for certain daemons. Like nginx user for nginx daemon and so on. As I'm new to Linux administration, I thought just to create second user for running all the processes (nginx, uWSGI etc.), ... | I like having regular users on a system:
multiple admins show up in sudo logs -- there's nothing quite like asking a specific person why they made a specific change.
not all tasks require admin privileges, but admin-level mistakes can be more costly to repair
it is easier to manage the ~/.ssh/authorized_keys if each f... | 1.2 | true | 1 | 1,240 |
2011-05-14 06:32:07.553 | How to get an app name using python in django | If you are in the view and want to retrieve the app name using Python ( the app name will be used for further logic ), how would you do it ? | I believe the updated solution is view.__module__. This returns your app_name both from Django and Django Rest Framework.
My scenario was working with dynamically module or app_name from view call so that I can work with access permission check for that particular module. | 0 | false | 1 | 1,241 |
2011-05-15 05:26:20.070 | Hot deployment using mod_wsgi,python and django on Apache | I have setup an Apache server with mod_wsgi, python_sql, mysql and django.
Everything works fine, except the fact that if I make some code changes, they do not reflect immidiately, though I thing that everything is compiled on the fly when it comes to python/mod_wsgi.
I have to shut down the server and come back again ... | Just touching the wsgi file allways worked for me. | 0.545705 | false | 1 | 1,242 |
2011-05-16 06:37:39.230 | python pypdf to read pdf and get highlighted words | how to use python pypdf to read pdf and get highlighted words? I highlighted the unknown words in a pdf and I want to extract them for referencing later. | Short answer: not possible with pypdf and not with any PDF tool for Python I know. | 1.2 | true | 1 | 1,243 |
2011-05-16 16:01:33.967 | wx/wxPython: How to add a slider to a grid cell? | I need to show a slider in one column of a grid. I was able to create a custom CellEditor which displays the slider when I double click into a cell of the appropriate column so it enters the edit mode. But I don't know how to create a custom CellRenderer that displays the slider in all cell that are not in edit mode.
U... | Maybe you could use the editor to set the numeric value of the cell, then on the renderer draw a vertical bar by dividing the value by the maximum possible value and multiplying it by the width of the cell (in px, to get the proportion of the cell that the slider needs to appear at) and drawing a narrow vertical rectan... | 0.386912 | false | 1 | 1,244 |
2011-05-17 01:27:06.393 | making python interpreter open in same window | Maybe I'm being irrational but I really really hate it when a command opens a new window in emacs. I'm using emacs on Ubuntu which came with python-mode and when I start an interpreter with C-c ! it pops up in a new window.
What I want is for emacs to switch to a new buffer in the same window. So far I've tried addin... | I use python-mode 5.2.0.
I went into python-mode.el and changed the switch-to-buffer-other-window to switch-to-buffer.
I evaluated it and now the interpreter opens up in the same window (regardless of the number of other windows I have).
Did you evaluate the function when you changed the above line?
Btw, opening the in... | 0 | false | 1 | 1,245 |
2011-05-17 11:29:48.453 | How to run a code in an Amazone's EC2 instance? | I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I launched an EC2 instance.
And now I would like to execute a Python code in this instance, and I don't know how to proceed. Is it necessary to load the code somewhere in the instance? Or in Amazon's S3 and to lin... | Launch your instance through Amazon's Management Console -> Instance Actions -> Connect
(More details in the getting started guide)
Launch the Java based SSH CLient
Plugins-> SCFTP File Transfer
Upload your files
run your files in the background (with '&' at the end or use nohup)
Be sure to select an AMI with python ... | 0.3154 | false | 2 | 1,246 |
2011-05-17 11:29:48.453 | How to run a code in an Amazone's EC2 instance? | I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I launched an EC2 instance.
And now I would like to execute a Python code in this instance, and I don't know how to proceed. Is it necessary to load the code somewhere in the instance? Or in Amazon's S3 and to lin... | simply add your code to Github and take clone on EC2 instance and run that code. | 0 | false | 2 | 1,246 |
2011-05-18 06:14:19.250 | How to render DOT file using only pos attributes | I have taken an initial DOT file and modified the pos attributes of some nodes using pydot. Now I want to render an image file that shows the nodes in their new positions. The catch is, I don't want a layout program to mess with the positions! I just want to see the nodes exactly where the pos attribute indicates. I do... | dot.write_png('filename.png')? Or is there something I'm missing?
Also, the neato command-line program has a -n option for graph files that already have layout. The program description says it is for undirected graphs, but I tried it with a digraph and it produced the correct result. | 1.2 | true | 1 | 1,247 |
2011-05-18 07:42:25.913 | Python memory serialisation | I was wondering whether someone might know the answer to the following.
I'm using Python to build a character-based suffix tree. There are over 11 million nodes in the tree which fits in to approximately 3GB of memory. This was down from 7GB by using the slot class method rather than the Dict method.
When I serialise... | Do you construct your tree once and then use it without modifying it further? In that case you might want to consider using separate structures for the dynamic construction and the static usage.
Dicts and objects are very good for dynamic modification, but they are not very space efficient in a read-only scenario. I do... | 0.545705 | false | 1 | 1,248 |
2011-05-19 11:37:21.533 | Storing user and password in a database | I am creating a software with user + password. After autentification, the user can access some semi public services, but also encrypt some files that only the user can access.
The user must be stored as is, without modification, if possible. After auth, the user and the password are kept in memory as long as the softwa... | If you use a different salt for each user, you must store it somewhere (ideally in a different place). If you use the same salt for every user, you can hardcode it in your app, but it can be considered less secure.
If you don't keep the salt, you will not be able to match a given password against the one in your datab... | 0.386912 | false | 1 | 1,249 |
2011-05-19 19:46:03.587 | wx python bitmap/toggle/menu button | I need a button that has a bitmap, toggles, and to which I can add a menu (I realize this is asking a lot). I can't figure out a way to do this in wx python. Here are the things I've tried and why they don't work:
plate buttons: don't toggle
genbitmaptogglebuttons: for some reason, these buttons kill my tooltips (I p... | Per Mark's suggestion, if you have wx 2.8.12 you can use a plate button to get the toggle/bitmap/menu functionality. Since it is not easy for me to update to the newer wx at this point, I'll use a bitmap button and fake the toggle. | 0 | false | 2 | 1,250 |
2011-05-19 19:46:03.587 | wx python bitmap/toggle/menu button | I need a button that has a bitmap, toggles, and to which I can add a menu (I realize this is asking a lot). I can't figure out a way to do this in wx python. Here are the things I've tried and why they don't work:
plate buttons: don't toggle
genbitmaptogglebuttons: for some reason, these buttons kill my tooltips (I p... | I don't see a pre-built button with all those features. I would think that you can use the generic toggle button or maybe the ShapedButton for your bitmap toggle functionality and attach a right-click popup menu. I'm not really sure what you mean by a menu, so that may not work. If you're talking about a menu implement... | 0 | false | 2 | 1,250 |
2011-05-20 18:11:06.307 | Force repaint in wxPython Canvas | I've got a Canvas which manipulates objects in the mouse event handler. After modifying the objects, I want to trigger the OnPaint() event for the same Canvas to show (rerender) the changes. What is the right way to do this? It doesn't let me call OnPaint() directly. Also, is triggering an event from another event "wro... | I would just call self.Refresh() or maybe RefreshRect() and pass the area that needs to be repainted. | 1.2 | true | 1 | 1,251 |
2011-05-22 00:27:21.680 | how to upload files to PHP server with use of Python? | I was wondering is there any tutorial out there that can teach you how to push multiple files from desktop to a PHP based web server with use of Python application?
Edited
I am going to be writing this so I am wondering in general what would be the best method to push files from my desktop to web server. As read from s... | I think you're referring to a application made in php running on some website in which case thats just normal HTTP stuff.
So just look at what name the file field has on the html form generated by that php script and then do a normal post. (urllib2 or whatever you use) | 0.201295 | false | 1 | 1,252 |
2011-05-22 19:43:18.627 | python numpy array slicing | I have an 2d array, A that is 6x6. I would like to take the first 2 values (index 0,0 and 0,1) and take the average of the two and insert the average into a new array that is half the column size of A (6x3) at index 0,0. Then i would get the next two indexes at A, take average and put into the new array at 0,1.
The o... | I don't think there is a better solution, unless you have some extra information about what's in those arrays. If they're just random numbers, you have to do (n^2)/2 calculations, and your algorithm is reflecting that, running in O((n^2)/2). | 0.201295 | false | 1 | 1,253 |
2011-05-23 05:51:01.133 | Anyway to bring up suggestion box when typing python code | I'm learning wxpython right now and one thing that helps me ALOT is when I'm typing in the text editor I sometimes press the tab key to give me a hint on what I'm looking for...This is great when it works but I notice sometimes it doesn't work and I get lost looking for a syntax I can't remember...
Question is how can ... | What editor do you use??
Without knowing that there's no way we can possibly help you.
FWIW in vim I use C-x [onp] | 0 | false | 1 | 1,254 |
2011-05-24 08:55:39.530 | How do I remove south from a django project | I installed south and tried a few changes using it, which didn't exactly work out the way I wanted it to. Thankfully, my data is safe but locked into south. I want to remove south and use syncdb normally now, how do I do that without affecting my data? | What does it mean for your data to be "locked into" South? The data lives in the database, and South simply creates the schema for you and migrates it when necessary. If you remove South, the data will stay exactly the same. | 0.296905 | false | 3 | 1,255 |
2011-05-24 08:55:39.530 | How do I remove south from a django project | I installed south and tried a few changes using it, which didn't exactly work out the way I wanted it to. Thankfully, my data is safe but locked into south. I want to remove south and use syncdb normally now, how do I do that without affecting my data? | Remove 'south' from INSTALLED_APPS, remove south_migrations table from DB. | 1.2 | true | 3 | 1,255 |
2011-05-24 08:55:39.530 | How do I remove south from a django project | I installed south and tried a few changes using it, which didn't exactly work out the way I wanted it to. Thankfully, my data is safe but locked into south. I want to remove south and use syncdb normally now, how do I do that without affecting my data? | Remove 'south' from INSTALLED_APPS, remove south_migrations table from
DB.
Also, you'll need to delete the Migrations folders from your app folders. | 0.470104 | false | 3 | 1,255 |
2011-05-24 11:21:24.593 | Google App Engine Locking | just wondering if anyone of you has come across this. I'm playing around with the Python mail API on Google App Engine and I created an app that accepts a message body and address via POST, creates an entity in the datastore, then a cron job is run every minute, grabs 200 entities and sends out the emails, then deletes... | Use tasks to send the email.
Create a task that takes a key as an argument, retrieves the stored entity for that key, then sends the email.
When your handler receives the body and address, store that as you do now but then enqueue a task to do the send and pass the key of your datastore object to the task so it knows w... | 0.545705 | false | 2 | 1,256 |
2011-05-24 11:21:24.593 | Google App Engine Locking | just wondering if anyone of you has come across this. I'm playing around with the Python mail API on Google App Engine and I created an app that accepts a message body and address via POST, creates an entity in the datastore, then a cron job is run every minute, grabs 200 entities and sends out the emails, then deletes... | Instantiating an email object certainly does not count against your "recipients emailed" quota. Like other App Engine services, you consume quota when you trigger an RPC, i.e. call send().
If you intended to email 1500 recipients and App Engine says you emailed 45,000, your code has a bug. | 0.386912 | false | 2 | 1,256 |
2011-05-24 12:28:24.503 | Transferring data from a DB2 DB to a greenplum DB | My company has decided to implement a datamart using [Greenplum] and I have the task of figuring out how to go on about it. A ballpark figure of the amount of data to be transferred from the existing [DB2] DB to the Greenplum DB is about 2 TB.
I would like to know :
1) Is the Greenplum DB the same as vanilla [PostgresS... | Generally, it is really slow if you use SQL insert or merge to import big bulk data.
The recommended way is to use the external tables you define to use file-based, web-based or gpfdist protocol hosted files.
And also greenplum has a utility named gpload, which can be used to define your transferring jobs, like source,... | 0 | false | 2 | 1,257 |
2011-05-24 12:28:24.503 | Transferring data from a DB2 DB to a greenplum DB | My company has decided to implement a datamart using [Greenplum] and I have the task of figuring out how to go on about it. A ballpark figure of the amount of data to be transferred from the existing [DB2] DB to the Greenplum DB is about 2 TB.
I would like to know :
1) Is the Greenplum DB the same as vanilla [PostgresS... | Many of Greenplum's utilities are written in python and the current DBMS distribution comes with python 2.6.2 installed, including the pygresql module which you can use to work inside the GPDB.
For data transfer into greenplum, I've written python scripts that connect to the source (Oracle) DB using cx_Oracle and then ... | 0 | false | 2 | 1,257 |
2011-05-24 18:50:43.853 | Problem with reading pasted text in terminal | I'm reading text in terminal with
description = raw_input()
It works if I write the text and press enter. The problem is when I paste the text from somewhere with Ctrl+Shift+V or with right click + paste. My program immediately ends, description contains only part of the text (I can see it in database).
Do you know how... | Make sure that your pasted text doesn't contain any embedded control characters (such as a newline), which could end the input. | 0.545705 | false | 1 | 1,258 |
2011-05-25 02:55:03.843 | How to write a bash script that enters text into programs | I'm writing a bash script that fires up python and then enters some simple commands before exiting. I've got it firing up python ok, but how do I make the script simulate keyboard input in the python shell, as though a person were doing it? | Have you tried echo "Something for input" | python myPythonScript.py ? | 0.201295 | false | 1 | 1,259 |
2011-05-25 15:53:48.260 | Opencv... getting at the data in an IPLImage or CvMat | I am doing some simple programs with opencv in python. I want to write a few algorithms myself, so need to get at the 'raw' image data inside an image. I can't just do image[i,j] for example, how can I get at the numbers?
Thanks | I do not know opencv python bindings, but in C or C++ you have to get the buffer pointer stored in IplImage. This buffer is coded according to the image format (also stored in IplImage). For RGB you have a byte for R, a byte for G, a byte for B, and so on.
Look at the API of python bindings,you will find how to access ... | 0 | false | 1 | 1,260 |
2011-05-25 16:11:19.950 | python: how to know the index when you randomly select an element from a sequence with random.choice(seq) | I know very well how to select a random item from a list with random.choice(seq) but how do I know the index of that element? | If the values are unique in the sequence, you can always say: list.index(value) | 0.116092 | false | 1 | 1,261 |
2011-05-25 20:25:02.797 | python join "large" file | In python I have read in a file into a list using file.readlines() , later on after some logic, I would like to put it back together in a string using fileString = ''.join(file), for some reason, even without a print function, it prints the fileString out to the console up to a certain point, then it just stops. It doe... | You should also consider what you are going to do with the resulting string. If you just want to write the contents back to a file, there is no need to join the parts first, you can use file.writelines(strings) directly. | 0.201295 | false | 1 | 1,262 |
2011-05-28 01:47:58.247 | How to choose closest/fastest mirror in Python? | I've been thinking about how to implement mirror picking in Python. When I call on service API I get response with IP address. Now I want to take that address and check if it's close to me or not. If not, retry. I thought about pinging, as I have only ~1ms ping to the IP addresses hosted in same data center, but much h... | Call all the service API instances and use which ever responds quickest. | 0.201295 | false | 1 | 1,263 |
2011-05-28 17:04:30.517 | Turn an application or script into a shell command | When I want to run my python applications from commandline (under ubuntu) I have to be in the directory where is the source code app.py and run the application with command
python app.py
How can I make it (how is it conventionally done) to run the application from arbitrary directory with the command: app ? Similarly a... | Add a shebang: as the top line of the file: #!/usr/bin/python or #!/usr/bin/python3 (you can use the python -B to prevent generation of .pyc files, which is why I don't use /usr/bin/env)
Make it executable: You will need to do chmod +x app.py
(optional) Add directory to path, so can call it anywhere: Add a directory wi... | 0.135221 | false | 2 | 1,264 |
2011-05-28 17:04:30.517 | Turn an application or script into a shell command | When I want to run my python applications from commandline (under ubuntu) I have to be in the directory where is the source code app.py and run the application with command
python app.py
How can I make it (how is it conventionally done) to run the application from arbitrary directory with the command: app ? Similarly a... | I'm pretty sure you have to make the script executable via chmod +x and put it in the PATH variable of your system. | 0 | false | 2 | 1,264 |
2011-05-29 23:29:12.350 | How would I keep a constant piece of data updated through a socket in Python? | I have a client and a server, both written in Python 2.7.
Lets say I wanted to make a multiplayer game server (which I don't at the moment but I'm working towards it). I would need to keep the server up to date (and other clients) on my characters whereabouts, correct?
How would I do this with sockets? Send or request ... | With TCP sockets it is more typical to leave the connections open, given the teardown & rebuild cost.
Eventually when scaling you will do look into NewIO\RawIO.
If you do not, imagine that the game client might take a step & not get confirmation if sending it to the server & other players. | 0.201295 | false | 1 | 1,265 |
2011-05-30 12:44:13.693 | problem: Socket error [Address already in use] in python/selenium | I have a troublesome problem socket.error error: [Errno 10048]: Address already in use. Only one usage of each socket address (protocol/IP address/port) is normally permitted during automated tests using Selenium with Python. The problem is so interesting that it runs on one machine (Linux) works correctly, but on anot... | Maybe there is a software on your Windows that already use port 4444, can you try set Selenium to another port and try again? | 0 | false | 2 | 1,266 |
2011-05-30 12:44:13.693 | problem: Socket error [Address already in use] in python/selenium | I have a troublesome problem socket.error error: [Errno 10048]: Address already in use. Only one usage of each socket address (protocol/IP address/port) is normally permitted during automated tests using Selenium with Python. The problem is so interesting that it runs on one machine (Linux) works correctly, but on anot... | There are several possibilities. If none of your tests can listen on some port (you don't say what port) then perhaps your Windows machine is running something on a port that you previously had open; this new service may have appeared during the reinstall. If, on the other hand, it's only a problem for some tests, or i... | 0 | false | 2 | 1,266 |
2011-05-31 13:39:13.827 | pydev - call a function with only self as argument | I am new to PyDev, written scripts using mainly notepad++ and jedit where I never had these issues.
In a module, I have defined a function - get_user_inputs(self). I used the argument self as PyDev would not let me define the function othewise (and apparently it is the right thing to do).
Now my question is how do I ca... | The argument self is only necessary for class methods. It doesn't make sense for normal functions.
That means you either omitted a vital information in your question or there is a bug in PyDev. | 1.2 | true | 1 | 1,267 |
2011-05-31 14:49:09.147 | Ant simulation: it's better to create a Process/Thread for each Ant or something else? | The simple study is:
Ant life simulation
I'm creating an OO structure that see a Class for the Anthill, a Class for the Ant and a Class for the whole simulator.
Now I'm brainstorming on "how to" make Ants 'live'...
I know that there are projects like this just started but I'm brainstorming, I'm not looking for a just-r... | I agree with @delan - it seems like overkill to allocate a whole thread per Ant, especially if you are looking to scale this to a whole anthill with thousands of the critters running around.
Instead you might consider using a thread to update many ants in a single "cycle". Depending on how you write it - you need to ca... | 0.081452 | false | 2 | 1,268 |
2011-05-31 14:49:09.147 | Ant simulation: it's better to create a Process/Thread for each Ant or something else? | The simple study is:
Ant life simulation
I'm creating an OO structure that see a Class for the Anthill, a Class for the Ant and a Class for the whole simulator.
Now I'm brainstorming on "how to" make Ants 'live'...
I know that there are projects like this just started but I'm brainstorming, I'm not looking for a just-r... | I wrote an ant simulation (for finding a good TSP-solution) and a wouldnt recommend a Thread-Solution. I use a loop to calculate for each ant the next step, so my ants do not really behave concurrently (but synchronize after each step).
I don't see any reason to model those ants with Threads. Its no advantage in terms... | 0.16183 | false | 2 | 1,268 |
2011-05-31 18:06:19.590 | Notification as a cron job | I coded a python application which was running OK as a cron job. Later I added some libraries (e.g. pynotify and other *) because I wanted to be notified with the message describing what is happening, but it seems that cron can't run such an application.
Do you know some alternative how to run this application every fi... | If the cron job runs as "you", and if you set the DISPLAY var (export DISPLAY=:0) you should have no issues. | 0.101688 | false | 2 | 1,269 |
2011-05-31 18:06:19.590 | Notification as a cron job | I coded a python application which was running OK as a cron job. Later I added some libraries (e.g. pynotify and other *) because I wanted to be notified with the message describing what is happening, but it seems that cron can't run such an application.
Do you know some alternative how to run this application every fi... | I don't see any problem in cron job with pynotify? What is the error you are getting?
Can you run your python code separately to check whether your python code is working really well but only fails with cron?
Celery is distributed job queue & task manager written in Python but it may be too much for your needs.
Supervi... | 0 | false | 2 | 1,269 |
2011-06-01 22:14:58.253 | How can I automate antivirus/WSUS patch testing of my Windows driver and binary? | My (rather small) company develops a popular Windows application, but one thing we've always struggled with is testing - it frequently is only tested by the developers on a system similar to the one they developed it on, and when an update is pushed out to customers, there is a segment of our base that experiences issu... | Interesting problem. One thing to avoid is using the antivirus APIs to check to see if your application triggers them. You want a real live deployment of your application, on the expected operating system, with a real live AV install monitoring it. That way you'll trigger the heuristics monitoring as well as the simple... | 1.2 | true | 1 | 1,270 |
2011-06-02 18:59:40.373 | Repeating function over certain amount of time | I am writing a program that upload files from my nokia cell phone files to the web server which I am already done writing that. But, my program only does his job only one time and what I want is that I want to call that function for let's say every 5 mins again and again which I do not know how to do it. | You can use the time module and the sleep function. | 0.265586 | false | 1 | 1,271 |
2011-06-02 20:54:17.923 | Install python module to non default version of python on Mac | I have a couple different versions of Python installed on my Mac. The default version is 2.5, so when I install a module it gets installed to 2.5. I need to be able to install some modules to a different version of Python because I am working on projects that use different versions. Any one know how to accomplish this?... | If you're installing through setuptools (ie python setup.py), it will install to the lib directory for the python executable you use (unless it's a broken package). | 0.386912 | false | 1 | 1,272 |
2011-06-03 13:18:31.683 | Non sorted eigenvalues for finding features in Python | I am now trying some stuff with PCA but it's very important for me to know which are the features responsible for each eigenvalue.
numpy.linalg.eig gives us the diagonal matrix already sorted but I wanted this matrix with them at the original positions. Does anybody know how I can make it? | What Sven mentioned in his comments is correct. There is no "default" ordering of the eigenvalues. Each eigenvalue is associated with an eigenvector, and it is important is that the eigenvalue-eigenvector pair is matched correctly. You'll find that all languages and packages will do so.
So if R gives you eigenvalues [... | 0.201295 | false | 1 | 1,273 |
2011-06-04 12:41:22.787 | How much is the difference between html parsing and web crawling in python | I need to grab some data from websites in my django website.
Now i am confused whether i should use python parsing libraries or web crawling libraries. Does search engine libraries also fall in same category
I want to know how much is the difference between the two and if i want to use those functions inside my websit... | HTML parse will parse the page and you can collect the links present in it. These links you can add to queue and visit these pages. Combine these steps in a loop and you made a basic crawler.
Crawling libraries are the ready to use solutions which do the crawling. They provide more features like detection of recursive ... | 0.135221 | false | 1 | 1,274 |
2011-06-05 05:49:20.820 | Tree traversal in a customised way in Python? | I have two trees in python. I need to compare them in a customized way according to the following specifications. Suppose I have a tree for entity E1 and a tree for entity E2. I need to traverse both the trees starting from E1 and E2 and moving upwards till I get to a common root. (Please note that I have to start the ... | That they are trees is not even relevant to the solution. You're looking for how long it takes for two single-linked (the parent link) lists to converge into the same list.
Simply follow the links, but keep a length count for each visited node. Once you reach an already visited node, sum the previously found count and... | 0.135221 | false | 1 | 1,275 |
2011-06-07 15:06:33.680 | gdb python programming: how to write code that will set breakpoints to every method of a C++ class? | I would like to be able to set breakpoints to every method of a C++ class in gdb.
I think the easiest way to do this is probably python, since now python has complete access to gdb. I know very little python, and with gdb on top of it, it's even harder. I am wondering if anyone knows how to write a class python code ... | You can generate (for example using python) a .gdbrc file with a line containing
'break C::foo'
for every function of your class C and then start gdb. | 0 | false | 1 | 1,276 |
2011-06-07 16:36:15.707 | Could not scrape data in English, help! | I have a website that I'm trying to scrape using Python & BeautifulSoup. The site itself can be viewed in 2 languages(Thai or English); all you have to do is to click on either the Thai or UK flag on the upper right corner of the screen and the data is displayed in the selected language. When in comes to the script tho... | You haven't said what the site is so impossible to answer for sure. But a couple of suggestions. If the url does not change when you click the flag, then either:
a) The english is already in the html document, and the relevant content is being switched with javascript
b) The english content is being fetched via an ajax... | 0.386912 | false | 1 | 1,277 |
2011-06-07 17:49:27.007 | Pydev for Eclipse does not change all reference when renaming package | I would expect the pydev package to rename all references in a project when rafactoring a module name. However, this is not the case. Anyone knows how to fix this? | delete the project in eclipse and then create a new project in eclipse with the projects new name. This will automatically add the projects contents into the new project | 0 | false | 1 | 1,278 |
2011-06-08 07:02:52.850 | Can I use MonkeyRunner tool to work in mobile as application | I want to simulate touch event, keyboard event on mobile device. Can I do it with MonkeyRunner? Also, I have the impression that it only works with SDK?
I want the application to be installed on mobile, which will perform some random touch, keyboard events. Is it possible with MonkeyRunner?
If yes, please provide me he... | I want to simulate touch event, keyboard event on mobile device. Can I do it with MonkeyRunner?
From your development machine, yes. Per your question title, you cannot use MonkeyRunner on a device.
Also, I have the impression that it only works with SDK?
Yes.
I want the application to be installed on mobile, which... | 0.135221 | false | 1 | 1,279 |
2011-06-09 07:50:06.663 | programs paralyzing each other on the server (c++ with openMP and python) | I have an urgent problem because my time is running out: I let my calculations process on a server with 8 cores therefore I'm using openMP in my c++ code and it works fine. Of course I'm not the only one who is using the server, so my capacity is not always 800%CPU.
But it happened now several times that someone who s... | There can be a number of reasons for this, for example:
Increased failure rate in the branch prediction
Exhausted CPU cache
Filled up the memory bus
Too much context switching (this have an effect on many things, including all the previous points) | 0.986614 | false | 1 | 1,280 |
2011-06-09 20:25:27.347 | html post form different destinations | I am developing a django web app in which I would like to have a registration process. In this registration process I have of course a form asking for name, email and password. What I would like to do is, send the form via post to 2 different places. One of which is of course the registration database which saves the ... | You can't. There is no way to send a form to two ressources.
What you CAN do is send a HTTP request in your register script to the newsletter script, e.g. using urllib2. | 0 | false | 1 | 1,281 |
2011-06-10 20:25:35.747 | Python/Django Patching/Mocking a functions current decorator | I saw you posting around decorators. I am having a hard time finding out how to Mock a decorator. Most searches show me how to write a decorate to help tes, but to be clear, I already have decorators and when I am unittesting a function that HAS a decorator I would like to mock it so its response is not part of the tes... | You can't mock a decorator. A decorator replaces your function at compile time with the decorated function. If a function is decorated, you cannot test that function without the decorator without pulling the guts of the function out into another (non-decorated) function. | 0 | false | 1 | 1,282 |
2011-06-11 09:17:25.667 | I don't know how to change an input into integer with decimals | I've made a program that calculates the flat rate interest of a loan based on the amount borrowed, the %/year (interest), and the length of time to pay it back...
here's where my problem starts:
I let the user input the years to pay it back, BUT, if the length of time is under a year the user is forced to use a decima... | Maybe float("0.5")? that might be more suited to your problem. | 1.2 | true | 1 | 1,283 |
2011-06-12 01:31:03.800 | Apache + mod_wsgi / Lighttpd + wsgi - am I going to see differences in performance? | I'm a newbie to developing with Python and I'm piecing together the information I need to make intelligent choices in two other open questions. (This isn't a duplicate.)
I'm not developing using a framework but building a web app from scratch using the gevent library. As far as front-end web servers go, it seems I have... | That you have mentioned gevent is important. Does that mean you are specifically trying to implement a long polling application? If you are and that functionality is the bulk of the application, then you will need to put your gevent server behind a front end web server that is implemented using async techniques rather ... | 0.201295 | false | 2 | 1,284 |
2011-06-12 01:31:03.800 | Apache + mod_wsgi / Lighttpd + wsgi - am I going to see differences in performance? | I'm a newbie to developing with Python and I'm piecing together the information I need to make intelligent choices in two other open questions. (This isn't a duplicate.)
I'm not developing using a framework but building a web app from scratch using the gevent library. As far as front-end web servers go, it seems I have... | Apache...
Apache is by far the most widely used web server out there. Which is a good thing. There is so much more information on how to do stuff with it, and when something goes wrong there are a lot of people who know how to fix it. But, it is also the slowest out of the box; requring a lot of tweaking and a beefier ... | 1.2 | true | 2 | 1,284 |
2011-06-12 01:33:48.493 | Return well-formed numbers | I found this in an interview questions forum:
Write a function to return well formed
numbers of size n. A well formed
number is one in which digit i is less
than digit i+1, for example 123, 246, 349 etc
So here's how I would do it in Python:
input number of digits (x)
loop over all the numbers of x digits
for... | In my opinion, you've already lost if you're checking every number.
I'd implement this with a stack. Start by putting 1-9 on the stack. When you take a number off of the stack, add another number to it if you can following those rules. If it's n digits, then print it. If it's not n digits, put it back on the stack.
Let... | 0.135221 | false | 2 | 1,285 |
2011-06-12 01:33:48.493 | Return well-formed numbers | I found this in an interview questions forum:
Write a function to return well formed
numbers of size n. A well formed
number is one in which digit i is less
than digit i+1, for example 123, 246, 349 etc
So here's how I would do it in Python:
input number of digits (x)
loop over all the numbers of x digits
for... | 1) You are trying to return well formed numbers 'up to' n digits in your approach, that is probably not the thing they were asking for
2) Sorting each number in that range is a bit silly. You may check whether each number is a well formed one by comparing the consecutive digits, which will take O(d) time for each numbe... | 0 | false | 2 | 1,285 |
2011-06-13 01:02:59.147 | Managing Items in an Object Oriented game | Every once in a while I like to take a break from my other projects to try to make a classic adventure text-based-game (in Python, this time) as a fun project, but I always have design issues implementing the item system.
I'd like for the items in the game to descend from one base Item class, containing some attribute... | at first: i don't have any python experience, so think about this in a more general way
your item should neither know or care ... your Item should have an interface that says it is something destroyable. containers and other objects that care about things that can be destroyed, can make use of that interface
that destr... | -0.067922 | false | 3 | 1,286 |
2011-06-13 01:02:59.147 | Managing Items in an Object Oriented game | Every once in a while I like to take a break from my other projects to try to make a classic adventure text-based-game (in Python, this time) as a fun project, but I always have design issues implementing the item system.
I'd like for the items in the game to descend from one base Item class, containing some attribute... | Assuming you call a method when the item is used, you could always return a boolean value indicating whether it's broken. | 0 | false | 3 | 1,286 |
2011-06-13 01:02:59.147 | Managing Items in an Object Oriented game | Every once in a while I like to take a break from my other projects to try to make a classic adventure text-based-game (in Python, this time) as a fun project, but I always have design issues implementing the item system.
I'd like for the items in the game to descend from one base Item class, containing some attribute... | You're conflating two meanings of the "destroying" idea. The Item should get destroyed in a "gameplay" sense. Let the garbage collector worry about when to destroy it as an object.
Who has a reference to the Item? Perhaps the player has it in his inventory, or it is in a room in the game. In either case your Invent... | 0.067922 | false | 3 | 1,286 |
2011-06-13 19:53:01.430 | Python Time Problem | I'm having trouble figuring out how to do this.
I'm trying to run a python script for a set duration. And every 1/10 of the duration I need it to run something. The problem is this step can take any amount of time to complete. I cannot go over the maximum duration set at the start.
Example:
Duration 20 hours
Interval ... | Fork a subprocess to do the actual job; kill the job if it exceeds your run-time limit. | 0 | false | 1 | 1,287 |
2011-06-14 00:14:37.110 | How to use SQLAlchemy in this context | I want to do the following:
Have a software running written in Python 2.7
This software connects to a database (Currently a MySQL database)
This software listen for connections on a port X on TCP
When a connection is established, a client x request or command something, then the software use the database to store, rem... | What is the problem here? SQLAlchemy maintains a thread-local connection pool..what else do you need? | 1.2 | true | 1 | 1,288 |
2011-06-14 14:29:36.040 | Using Python to extract images and text from a word document | I would like to run a script on a folder full of word documents that reads through the documents and pulls out images and their captions (text right below the images). From the research I've done, I think pywin32 might be a viable solution. I know how to use pywin32 to find strings and pull them out, but I need help wi... | Docx files can be unzipped for extracting the images. | 0.386912 | false | 1 | 1,289 |
2011-06-15 09:09:40.343 | Formatting strings with python in django | I have a question list for a questionnaire which are stored in database but some questions has to be modified by certain parameters.
For example, if someone selects an employer name from previous page, some questions should have employer's name "Do you like to work for ........ company ?".
One solution might be savinf ... | The most flexible way - is to create custom template filter. If string needs formatting, it will do that, if it doesn't - just output it. | 1.2 | true | 1 | 1,290 |
2011-06-15 14:44:28.053 | Python Plone views call others | I have a Python function registered as a View in Plone. I need to be able to call another function from within this registered function. I'm not sure if it would be best to register this other function as a view as well and try to call that (don't know how to call other views), or if there is a better way to handle t... | Just import it and call it as any other function. You don't want to make it a view - that requires you to do a MultiAdapter lookup which is a real pain, and completely unnecessary.
[Edit - strictly using a view is a MultiAdapter lookup, but you can shortcut it via traversal, but that still isn't worth the effort] | 1.2 | true | 1 | 1,291 |
2011-06-15 21:10:55.790 | How are basic data types (strings and integers) implemented in Python and Perl | I've been wondering lately how various operations I perform on basic types like strings and integers work in terms of performance, and I figure I could get a much better idea of this if I knew how those basic types were implemented (i.e. I've heard strings and integers are immutable in Python. Does that mean any operat... | Perl strings definitely are not immutable. Each string has a buffer, the initial offset of the string in the buffer, the length of buffer, and the amount of the buffer used. Additionally, for utf8 strings, the character length is cached when it needs to be calculated. At one point, there was some caching of addition... | 0.995055 | false | 1 | 1,292 |
2011-06-16 11:30:35.540 | Python CGI how to save requested information securely? | I have a web page that uses a Python cgi script to store requested information for later retrieval by me. As an example, the web page has a text box that asks "What is your name?" When the user inputs his name and hits the submit button, the web page calls the Python cgi script which writes the user's name to mytextfil... | Definitely the wrong tool. Multiple times.
Store the file outside of the document root.
Store a key to the file in the user's session.
Use a web framework.
Use WSGI. | 1.2 | true | 2 | 1,293 |
2011-06-16 11:30:35.540 | Python CGI how to save requested information securely? | I have a web page that uses a Python cgi script to store requested information for later retrieval by me. As an example, the web page has a text box that asks "What is your name?" When the user inputs his name and hits the submit button, the web page calls the Python cgi script which writes the user's name to mytextfil... | Store it outside the document root. | 0 | false | 2 | 1,293 |
2011-06-16 14:43:07.333 | How to access linkedin from python command | I want to access my linkedin account from command prompt and then i wanted to send mails from my account using command.
Also, I need the delivery reports of the mails.
Can anyone knows how can use that? | The Member to Member API will return a 2xx status code if your message is accepted by LinkedIn. And a 4xx status code if there's an error.
This means the message was put into the LinkedIn system, not that it has been opened, read, emailed, etc. You cannot get that via the API. | 1.2 | true | 1 | 1,294 |
2011-06-17 18:49:28.007 | Matplotlib make tick labels font size smaller | In a matplotlib figure, how can I make the font size for the tick labels using ax1.set_xticklabels() smaller?
Further, how can one rotate it from horizontal to vertical? | For smaller font, I use
ax1.set_xticklabels(xticklabels, fontsize=7)
and it works! | 0.573727 | false | 2 | 1,295 |
2011-06-17 18:49:28.007 | Matplotlib make tick labels font size smaller | In a matplotlib figure, how can I make the font size for the tick labels using ax1.set_xticklabels() smaller?
Further, how can one rotate it from horizontal to vertical? | In current versions of Matplotlib, you can do axis.set_xticklabels(labels, fontsize='small'). | 0.734659 | false | 2 | 1,295 |
2011-06-18 03:13:57.857 | Split string with caret character in python | I have a huge text file, each line seems like this:
Some sort of general menu^a_sub_menu_title^^pagNumber
Notice that the first "general menu" has white spaces, the second part (a subtitle) each word is separate with "_" character and finally a number (a pag number). I want to split each line in 3 (obvious) parts, be... | It's also possible that your file is using a format that's compatible with the csv module, you could also look into that, especially if the format allows quoting, because then line.split would break. If the format doesn't use quoting and it's just delimiters and text, line.split is probably the best.
Also, for the re m... | 0 | false | 1 | 1,296 |
2011-06-21 12:08:50.077 | how to get the version of Selenium RC server | I am using selenium2 RC with the python client (selenium.py) and I need to get the version of the selenium on the server. (for example "2rc2","2rc3" etc.)
is there any command i can send to the server to get its version? | I know this was already answered but it may help someone else. Another way to get your selenium server's version is right click the selenium-server.jar, and open it was any file archiver software such as 7zip or winrar. There you should find a file called VERSION.txt which will tell you your servers version | 0.986614 | false | 1 | 1,297 |
2011-06-21 12:54:25.070 | Decoupling Domain classes from Django Model Classes | So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django.
I want to start implementing some of my domain entity classes which need persistenc... | You would not have to "rewrite your models from scratch" if you wanted a different persistence mechanism. The whole point of an activerecord-style persistence system is that it imposes minimal constraints on the model classes, and acts largely transparently.
If you're really worried, abstract out any code that relies o... | 0 | false | 4 | 1,298 |
2011-06-21 12:54:25.070 | Decoupling Domain classes from Django Model Classes | So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django.
I want to start implementing some of my domain entity classes which need persistenc... | Well, the way to go with Django is to inherit from Django's base model classes. This is the 'active record' pattern. Your django models will have all CRUD and query methods along with you business logic (if you decide to add it of course). This is seen as an anti-pattern in the java world, but the cool thing about it i... | 0.296905 | false | 4 | 1,298 |
2011-06-21 12:54:25.070 | Decoupling Domain classes from Django Model Classes | So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django.
I want to start implementing some of my domain entity classes which need persistenc... | Can you seriously envisage a possibility that you're going to just ditch the Django ORM, but keep everything else? Or that if you ditched Django totally, any of your code is still going to be applicable?
You don't complain that if you ditched Django, you'll have to rewrite all your templates. Of course you will, that's... | 0.386912 | false | 4 | 1,298 |
2011-06-21 12:54:25.070 | Decoupling Domain classes from Django Model Classes | So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django.
I want to start implementing some of my domain entity classes which need persistenc... | I think that there's no implemented solution for decoupling Django models and the domain classes, at least I haven't found any. In fact, the only ORM with such decoupling that I know exists only in Smalltalk world and it's called GLORP. It allows you to persist your domain model in a relational DB without having to mod... | 0 | false | 4 | 1,298 |
2011-06-21 21:56:45.850 | How to do weighted random sample of categories in python | Given a list of tuples where each tuple consists of a probability and an item I'd like to sample an item according to its probability. For example, give the list [ (.3, 'a'), (.4, 'b'), (.3, 'c')] I'd like to sample 'b' 40% of the time.
What's the canonical way of doing this in python?
I've looked at the random module... | I'm not sure if this is the pythonic way of doing what you ask, but you could use
random.sample(['a','a','a','b','b','b','b','c','c','c'],k)
where k is the number of samples you want.
For a more robust method, bisect the unit interval into sections based on the cumulative probability and draw from the uniform dist... | 0 | false | 2 | 1,299 |
2011-06-21 21:56:45.850 | How to do weighted random sample of categories in python | Given a list of tuples where each tuple consists of a probability and an item I'd like to sample an item according to its probability. For example, give the list [ (.3, 'a'), (.4, 'b'), (.3, 'c')] I'd like to sample 'b' 40% of the time.
What's the canonical way of doing this in python?
I've looked at the random module... | Howabout creating 3 "a", 4 "b" and 3 "c" in a list an then just randomly select one. With enough iterations you will get the desired probability. | 0.04532 | false | 2 | 1,299 |
2011-06-22 19:48:22.617 | Hijacking, redirecting, display output with Python 2.7 | I am a new programmer with little experience but I am in the process of learning Python 2.7. I use Python(x,y) or Spydar as the programs are called on Windows 7.
The main packages I'm using are numpy, pil and potentially win32gui.
I am currently trying to write a program to mine information from a 3rd-party software.... | One approach that might work would be to do something like so:
get the window handle (FindWindow() or something similar, there are a few ways to do this)
get the window dimensions (GetClientRect() or GetWindowRect())
get the device context for the window (GetWindowDC())
get the image data from the window (BitBlt() or ... | 0 | false | 1 | 1,300 |
2011-06-23 11:08:32.490 | How to properly use mysqldb in python | I'm trying to figure out how to use python's mysqldb. I can do my job with my current knownledge, but I want to use the best practices.
Should I close properly my cursor? Exiting the program isn't close it autmatically? (Shouldn't I expect the object destructor to do it anyway?)
Should I create new cursors for every qu... | Should I close properly my cursor?
Yes, you should. Explicit is better than implicit.
Should I create new cursors for every
query, or one cursor is enough for
multiple different queries in the same
DB?
This depends on how you use this cursor. For simple tasks it is enough to use one cursor. For some complex... | 1.2 | true | 1 | 1,301 |
2011-06-24 04:00:19.453 | Using python (urllib) to download a file, how to get the real filename? | So I finally managed to get my script to login to a website and download a file... however, in some instances I will have a url like "http://www.test.com/index.php?act=Attach&type=post&id=3345". Firefox finds the filename ok... so I should be able to.
I am unable to find the "Content-Disposition" header via something ... | It is the task of the remote server/Service to provide the content-disposition header.
There is nothing you can do unless the remote server/service is under your own control.. | 1.2 | true | 1 | 1,302 |
2011-06-24 12:15:16.010 | Should I use threading programming for mixing 2 audio stream? | I'd like to write a program that capture audio stream from the microphone and in the same time mix this stream with a playing audio file.
I'm lookig for library, api, etc..etc... but my concern is about the implementation, should I use threading programming? I don't know how to use a thread yet.
The operating system is... | py2.6 comes with processed-based threading as well so you don't have todo just green-threads | 0 | false | 1 | 1,303 |
2011-06-24 17:35:39.353 | Reading incoming data from barcode | I have to read incoming data from a barcode scanner using pyserial. Then I have to store the contents into a MySQL database. I have the database part but not the serial part. can someone show me examples of how to do this. I'm using a windows machine. | You will find it easier to use a USB scanner. These will decode the scan, and send it as if it were typed on the keyboard, and entered with a trailing return.
The barcode is typically written with leading and trailing * characters, but these are not sent with the scan.
Thus you print "*AB123*" using a 3 of 9 font, a... | 1.2 | true | 1 | 1,304 |
2011-06-24 21:25:31.760 | SQLAlchemy - Getting a list of tables | I couldn't find any information about this in the documentation, but how can I get a list of tables created in SQLAlchemy?
I used the class method to create the tables. | There is a method in engine object to fetch the list of tables name. engine.table_names() | 0.999999 | false | 1 | 1,305 |
2011-06-26 10:50:20.840 | How to resume program workflow at the right place after dialogue response? | The program I am writing can edit a single project at a time. This means that opening a new file/project implies closing the previous one. Now what I want to achieve is the following workflow:
User has uncommitted changes to a project he never previously saved, so the project doesn't have a file name yet.
User presses... | Would GtkDialog.run() be the method you need? You "run" the dialog, at the point where you need to ask the user, and when it returns you have your answer. | 1.2 | true | 1 | 1,306 |
2011-06-27 05:10:42.740 | python reverse proxy spawning via cgi | I need to write a cgi page which will act like a reverse proxy between the user and another page (mbean). The issue is that each mbean uses different port and I do not know ahead of time which port user will want to hit.
Therefore want I need to do is following:
A) Give user a page which will allow him to choose which... | You don't need to spawn another process, that would complicate things a lot. Here's how I would do it based on something similar in my current project :
Create a WSGI application, which can live behind a web server.
Create a request handler (or "view") that is accessible from any URL mapping as long as the user doesn... | 0.673066 | false | 1 | 1,307 |
2011-06-27 07:10:40.533 | Find file in folder without knowing the extension? | Let's say I want to search for a file name "myfile" in a folder named "myfolder", how can I do it without knowing the format of the file?
Another question: how to list all files of a folder and all the files of it's subfolders (and so on)?
Thank you. | I do not know the logic of python for this but I would do the following:
Loop through each file in the directory, get the names as strings and check to see if they begin with "myfile" by splitting the string on the "." you can compare what you are looking for with what you have. | 0 | false | 1 | 1,308 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.