Q_Id
int64 337
49.3M
| CreationDate
stringlengths 23
23
| Users Score
int64 -42
1.15k
| Other
int64 0
1
| Python Basics and Environment
int64 0
1
| System Administration and DevOps
int64 0
1
| Tags
stringlengths 6
105
| A_Id
int64 518
72.5M
| AnswerCount
int64 1
64
| is_accepted
bool 2
classes | Web Development
int64 0
1
| GUI and Desktop Applications
int64 0
1
| Answer
stringlengths 6
11.6k
| Available Count
int64 1
31
| Q_Score
int64 0
6.79k
| Data Science and Machine Learning
int64 0
1
| Question
stringlengths 15
29k
| Title
stringlengths 11
150
| Score
float64 -1
1.2
| Database and SQL
int64 0
1
| Networking and APIs
int64 0
1
| ViewCount
int64 8
6.81M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
20,406,998 | 2013-12-05T17:44:00.000 | 2 | 1 | 0 | 0 | php,python,ruby | 20,409,383 | 1 | true | 1 | 0 | Language is irrelevant.
Just put "short" operation in function (object, if it is complex) and use it from 2 places:
web-code which needs "preview" will call it once and get its piece of data
long-running background process will call it iteratively as much as needed and will store result of function in DB instead of returning it to user immediately
Can be easily done in PHP. Long-running processeses are not a problem since 5.3 | 1 | 0 | 0 | I have a web frontend which uses data from a task that must be run frequently in bulk (which takes more time than I'd like to use PHP for). The data can be stored in a database so I was planning on writing a Java application to run the task and use the database as a middleman to get the results of this task accessible to the web.
Problem is, a "preview" of this data is needed occasionally. IE, sometimes the user needs to request a sample of the data (which can be computed quickly) to be generated on cue.
This presents a real problem for me, this preview IS more suited for a language like PHP even though it's essentially the same task. It's just two cases, in case A there are real jobs from many users to be done so the task takes a sufficiently long time to complete (longer than a PHP request can hold), in case B it's a baby job for just one user ran on the spot which could be completed in PHP without issue.
I don't want to write this code twice, it would make maintenance a nightmare so I kind of need to pick a language and stick with it. The frontend is designed but not implemented so I have an oppertunity to write the site in PHP, Ruby or Python if need be. I know PHP, so I would only consider switching to Python or Ruby if one of those languages offered a solution to this problem. but I know so little about these languages that I really cannot begin to know if they offer a solution without learning them (which I don't have the time for atm).
In short, is there a non-hackish way to write short, quick event-driven code AND long-running repetitive code with Ruby on Rails or Python? If not do you have any ideas how to satifsy these two cases with either PHP or Java? | PHP / Python / Ruby - Long running tasks with short previews | 1.2 | 0 | 0 | 81 |
20,411,315 | 2013-12-05T21:38:00.000 | 0 | 0 | 0 | 0 | python,qt,pyqt4 | 20,411,550 | 1 | false | 0 | 1 | In the handler of the button-click in the first window, instantiate the second window and invoke its show-method, and then close (emit the close-signal to) the first window. | 1 | 0 | 0 | I have two pyqt files that I made in qt4 designer. I put them both in a directory and created a file outside the directory, which I imported them with. The first file is a window with a button, that when clicked, should close the first window, and open the second window.
I can import them, and launch them both at the same time, but I can't figure out how to have the button in the first window affect the other, yet alone have it close itself and spawn the other. | How to tie two windows together in pyqt4 | 0 | 0 | 0 | 150 |
20,411,647 | 2013-12-05T21:57:00.000 | 0 | 0 | 0 | 0 | python,file,module,tree,wxpython | 20,411,707 | 1 | true | 0 | 1 | treeCtrl.Unbind(wx.EVT_KEY_DOWN)
I think would work :P | 1 | 0 | 0 | I am currently using CustomTreeCtrl instead of the regular TreeCtrl because it allows me to have checkbox / radio button with the tree nodes.
However, I realize the control itself catches event EVT_KEY_DOWN (whenever any key is pressed) to look for any matching tree nodes. I need the event EVT_KEY_DOWN for other purposes, so is there a way to disable the tree control from recognizing EVT_KEY_DOWN?
Or would it work if I create my own CustomTreeCtrl that does not have self.Bind(wx.EVT_KEY_DOWN, self.onKeyDown) inside? How would I locate that Python file then (wx.lib.agw.customtreectrl) on Linux? | wxPython: CustomTreeCtrl disable checking for event EVT_KEY_DOWN | 1.2 | 0 | 0 | 230 |
20,415,414 | 2013-12-06T03:29:00.000 | 5 | 0 | 0 | 0 | python,pandas,dataframe | 20,415,698 | 5 | false | 0 | 0 | What have you tried? You could sort with s.sort() and then call s.head(3).index and s.tail(3).index. | 1 | 4 | 1 | How can I find the index of the 3 smallest and 3 largest values in a column in my pandas dataframe? I saw ways to find max and min, but none to get the 3. | python pandas 3 smallest & 3 largest values | 0.197375 | 0 | 0 | 7,247 |
20,420,020 | 2013-12-06T09:10:00.000 | 5 | 0 | 1 | 0 | python,linux | 20,420,190 | 3 | true | 0 | 0 | There is no easy way to determine if someone else has made a link to a given "hard" directory. You can only check if a given directory is a symlink to another directory.
This means that you need to traverse your entire directory structure, look for symlinks, and then check if they point to the directory in question.
A symlink is a special file which points to another file/directory, somewhere in your directory structure. Symlinks can point to other filesystems as well. Creating a symlink does not change the inode of the destination file/folder (as opposed to hard links), so you can't tell by looking at the target, only at the link itself. | 1 | 2 | 0 | I am trying to remove a set of directories, excluding those that are in used and symlinked to elsewhere.
What is the most effective way to determine if a given directory is symlinked to?
I've tried os.stat(dir).mt_nlink, but it returns 3 even for directories I want to remove.
EDIT:
By symlinked to I mean this directory is a target of some symlink. | How can I determine if a given directory is `symlink`ed to in Python? | 1.2 | 0 | 0 | 1,730 |
20,421,001 | 2013-12-06T09:59:00.000 | 1 | 0 | 0 | 0 | python,cherrypy | 20,422,180 | 2 | false | 1 | 0 | Try <img src="/page_first/my_image.png"/> | 2 | 2 | 0 | I do a simple web application written in Python using cherrypy and Mako. So, my question is also simple.
I have one page with URL http://1.2.3.4/a/page_first. Also there is an image that available on URL http://1.2.3.4/a/page_first/my_image.png. And I want to locate my_image.png on the page_first.
I added a tag <img src="my_image.png"/>, but it is not shown. I looked at web developer tools->Network and saw that request URL for image was http://1.2.3.4/a/my_image.png, instead of http://1.2.3.4/a/page_first/my_image.png.
Why does it happen?
Thanks. | Using relative URL's | 0.099668 | 0 | 1 | 195 |
20,421,001 | 2013-12-06T09:59:00.000 | 2 | 0 | 0 | 0 | python,cherrypy | 20,422,773 | 2 | true | 1 | 0 | The page address needs to be http://1.2.3.4/a/page_first/ (with trailing slash).
ADDED:
You don't seem to understand relative URLs, so let me explain. When you reference an image like this <img src="my_image.png"/>, the image URL in the tag doesn't have any host/path info, so path is taken from the address of the HTML page that refers to the image. Since path is everything up to the last slash, in your case it is http://1.2.3.4/a/. So the full image URL that the browser will request becomes http://1.2.3.4/a/my_image.png.
You want it to be http://1.2.3.4/a/page_first/my_image.png, so the path part of the HTML page must be /a/page_first/.
Note that the browser will not assume page_first is "a directory" just because it doesn't have an "extension", and will not add the trailing slash automatically. When you access a server publishing static dirs and files and specify a directory name for the path and omit the trailing slash (e. g. http://www.example.com/some/path/here), the server is able to determine that you actually request a directory, and it adds the slash (and usually also a default/index file name) for you. It's not generally the case with dynamic web sites where URLs are programmed.
So basically you need to explicitly include the trailing slash in your page path: dispatcher.connect('page','/a/:number_of_page/', controller=self, action='page_method') and always refer to it with the trailing slash (http://1.2.3.4/a/page_first/), otherwise the route will not be matched.
As a side note, usually you put the images and other static files into a dedicated dir and serve them either with CherryPy's static dir tool, or, if it's a high load site, with a dedicated server. | 2 | 2 | 0 | I do a simple web application written in Python using cherrypy and Mako. So, my question is also simple.
I have one page with URL http://1.2.3.4/a/page_first. Also there is an image that available on URL http://1.2.3.4/a/page_first/my_image.png. And I want to locate my_image.png on the page_first.
I added a tag <img src="my_image.png"/>, but it is not shown. I looked at web developer tools->Network and saw that request URL for image was http://1.2.3.4/a/my_image.png, instead of http://1.2.3.4/a/page_first/my_image.png.
Why does it happen?
Thanks. | Using relative URL's | 1.2 | 0 | 1 | 195 |
20,421,648 | 2013-12-06T10:30:00.000 | 0 | 0 | 0 | 0 | wxpython,wxwidgets | 20,425,632 | 1 | false | 0 | 1 | The problem with Alt-N not having any effect seems to be a wxWidgets bug, so I don't think you can work around it in wxPython. Perhaps you could try to catch EVT_CHAR for them in the wizard itself and see if you get the event there.
As for disabling some keys when some specific control has focus, you definitely should be able to catch EVT_KEY_DOWN in this control. Although I don't really understand why would you want to do this. | 1 | 1 | 0 | The wizard in wxpython automatically responds to keyboard accelerators for the buttons on the page (for example "Alt-N" to activate the next button). I want this but ...
It only does this if there is at least one interactive widget on the visible wizard page. If the page only has static text then accelerator keystrokes don't do anything.
The wizard also responds to keys that shouldn't do anything at all, eg "C" or "c" activates the cancel button whenever the focus is on an image button (note that it doesn't do that if the focus is on a text entry widget - in that case the corresponding character is entered into the text box).
How can I change the behaviour of the wxpython wizard so that:
"Alt-N" and "Alt-C" should activate the next and cancel buttons even on pages that only have static text controls
"N" and "C" should NOT activate the next and cancel buttons regardless of which widget has the current focus. | How to make wx wizard respond to keyboard accelerators like a normal Microsoft Windows application | 0 | 0 | 0 | 117 |
20,421,825 | 2013-12-06T10:38:00.000 | 3 | 0 | 1 | 1 | python,py2exe | 20,421,890 | 1 | true | 0 | 0 | Yes, trivially. Py2exe just creates a zip of the .pyc files with an executable wrapper, and those files are easily uncompilable with eg uncompyle.
The way to sell commercial software in Python is not to worry about whether people can see the code, but to license it appropriately. | 1 | 1 | 0 | I would like to distribute a .exe program that I made with Python and py2exe.
My program may be commercial (not sure). If so, I don't want people to recover easily the sourcecode. (Of course reverse engineering or complex decompiling can always be done, but...)
So : is it possible to recover the original sourecode from an executable produced by py2exe? | Can human-readable source code be recovered from a py2exe executable? | 1.2 | 0 | 0 | 598 |
20,421,965 | 2013-12-06T10:47:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,blob,google-cloud-datastore | 20,424,484 | 1 | false | 1 | 0 | Datastore has a limit on the size of objects stored there, thats why all examples and documentation say to use the blobstore or cloud storage. Do that. | 1 | 0 | 0 | Just wondering how to store files in the google app engine datastore.
There are lots of examples on the internet, but they are using blobstore
I have tried importing db.BlobProperty, but when i put() the data
it shows up as a <Blob> i think. It appears like there is no data
Similar to None for a string
Are there any examples of using the Datastore to store files
Or can anyone point me in the right direction
I am new to programming, so not to complex, but I have a good
hang of Python, just not an expert yet.
Thanks for any help | How do I store files in googleappengine datastore | 0 | 1 | 0 | 71 |
20,423,546 | 2013-12-06T12:08:00.000 | 21 | 0 | 1 | 0 | ipython,background-color,spyder | 20,436,610 | 1 | true | 0 | 0 | (Spyder dev here) You need to update Spyder to 2.3.0beta1, which has this option under:
Tools > Preferences > IPython console > Background color > Dark background | 1 | 12 | 0 | I'm new to Spyder(version 2.3.0dev6) and I want to change the background color of my IPython console(version 1.1.0). I can change the background color of console but not the IPython console. I also tried in the "Run configuration", "general settings", "command line options": --color=linux, but nothing happened. | Spyder IPython background color | 1.2 | 0 | 0 | 25,229 |
20,426,690 | 2013-12-06T14:43:00.000 | 0 | 0 | 1 | 0 | python,numpy,windows64,pyfits | 20,436,137 | 2 | true | 0 | 0 | This is a problem importing numpy, not pyfits. You can tell because the traceback ended upon trying to import the numpy multiarray module.
This error suggests that the numpy you have installed was not built for the same architecture as your Python installation. | 1 | 0 | 1 | I am using windows 7 home basic 64 bit. I wanted to work with FITS file in python 3.3 so downloaded pyfits and numpy for 64 bit. When I import pyfits I get the following error:
Traceback (most recent call last): File "", line 1, in
import pyfits as py File
"C:\Python33\lib\site-packages\pyfits__init__.py", line 26, in
import pyfits.core File
"C:\Python33\lib\site-packages\pyfits\core.py", line 38, in
import pyfits.py3compat File
"C:\Python33\lib\site-packages\pyfits\py3compat.py", line 12, in
import pyfits.util File
"C:\Python33\lib\site-packages\pyfits\util.py", line 29, in
import numpy as np File
"C:\Python33\lib\site-packages\numpy__init__.py", line 168, in
from . import add_newdocs File
"C:\Python33\lib\site-packages\numpy\add_newdocs.py", line 13, in
from numpy.lib import add_newdoc File
"C:\Python33\lib\site-packages\numpy\lib__init__.py", line 8, in
from .type_check import * File
"C:\Python33\lib\site-packages\numpy\lib\type_check.py", line 11, in
import numpy.core.numeric as _nx File
"C:\Python33\lib\site-packages\numpy\core__init__.py", line 6, in
from . import multiarray ImportError: DLL load failed: %1
is not a valid Win32 application. | pyfits not working for windows 64 bit | 1.2 | 0 | 0 | 718 |
20,427,217 | 2013-12-06T15:09:00.000 | 1 | 1 | 0 | 0 | python,web2py | 20,437,241 | 1 | true | 1 | 0 | Look at section 4.17.1 of the web2py manual (or Google "web2py cron").
You can run a script on startup of web2py by registering it in the crontab file as:
"@reboot web2py *scripts/myscript.py"
web2py should be the username that it will run as, which should be the same as what web2py runs as. In my setup I have a user named 'web2py' to run the app.
The asterix before scripts/myscript.py indicates that you want to run the script in the web2py environment.
Keep in mind that you run the risk of locking issues if your script is trying to use the database at the same time as the normal web2py process. | 1 | 0 | 0 | I need a launch script which has access to "db" and other web2py modules. This script must be running constantly. I know that Web2py has launch parameters from which you can run python files in the web2py enviroment, but i don't know how that works. Can this parameter solve my problem and if so, how do I go about it? Thanks! | Web2py launch script | 1.2 | 0 | 0 | 1,158 |
20,428,414 | 2013-12-06T16:06:00.000 | 0 | 1 | 0 | 0 | php,python,sockets | 20,429,263 | 5 | false | 0 | 0 | If the same machine, you can use file with command. Create a file cmd.txt , python will read it in loop every sec, Php script will write a command in file cmd.txt , python will do the job and erase the command from cmd.txt | 1 | 2 | 0 | Here is my problem, I have a Python script that will be running indefinitely in a while(1) loop. I want some PHP script to somehow interact with the Python script, and when it does, the script needs to perform a function with the data submitted to the script.
Any ideas would be appreciated! | Sending data to Python Script from PHP | 0 | 0 | 0 | 4,830 |
20,428,732 | 2013-12-06T16:22:00.000 | 5 | 0 | 0 | 0 | python,selenium | 59,528,985 | 4 | false | 0 | 0 | You can try:
pip list
conda list
or for example on MAC:
brew list
And then check if and what version is in your installed package list.
For conda you might have different environments. Change it by conda activate myenv where myenv is the name of your second or more test environments. | 2 | 16 | 0 | The title says it all, I want to programmatically get the version of Selenium I have installed on my Python environment. | How do I retrieve the version of Selenium currently installed, from Python | 0.244919 | 0 | 1 | 48,042 |
20,428,732 | 2013-12-06T16:22:00.000 | 3 | 0 | 0 | 0 | python,selenium | 66,284,498 | 4 | false | 0 | 0 | Try using pip show selenium, that worked for me | 2 | 16 | 0 | The title says it all, I want to programmatically get the version of Selenium I have installed on my Python environment. | How do I retrieve the version of Selenium currently installed, from Python | 0.148885 | 0 | 1 | 48,042 |
20,433,712 | 2013-12-06T21:16:00.000 | 0 | 0 | 0 | 1 | python,development-environment,vagrant | 21,195,137 | 1 | false | 0 | 0 | In most IDE you can add "library" path which are outside the project so that your code completion etc works. About the traceback, I'm unfamiliar with python but this sounds like issue that are resolved by "mapping" paths between servers and dev machine. This is generally the reason why #2 is often the way to go (Except when you have a team willing to do #1). | 1 | 5 | 0 | I'm investigating ways to add vagrant to my development environment. I do most of my web development in python, and I'm interested in python-related specifics, however the question is more general.
I like the idea of having all development-related stuff isolated in virtual machine, but I haven't yet discovered an effective way to work with it. Basically, I see 3 ways to set it up:
Have all services (such as database server, MQ, etc) as well as an application under development to run in VM. Developer would ssh to VM and edit sources there, run app, tests, etc, all in an ssh terminal.
Same as 1), but edit sources on host machine in mapped directory with normal GUI editor. Run application and tests on vagrant via ssh. This seems to be most popular way to use vagrant.
Host only external services in VM. Install app dependencies into virtualenv on host machine and run app and tests from there.
All of these approaches have their own flaws:
Developing in text console is just too inconvenient, and this is the show-stopper for me. While I'm experienced ViM user and could live with it, I can't recommend this approach to anyone used to work in any graphical IDE.
You can develop with your familiar tools, but you cannot use autocompletion, since all python libs are installed in VM. Your tracebacks will point to non-local files. You will not be able to open library sources in your editor, ctags will not work.
Losing most of "isolation" feature: you have to install all compilers, *-dev libraries yourself to install python dependencies and run an app. It is pretty easy on linux, but it might be much harder to set them all up on OSX and on Windows it is next to impossible I guess.
So, the question is: is there any remedy for problems of 2nd and 3rd approaches? More specifically, how is it possible to create an isolated and easily replicatable environment, and yet enjoy all the comfort of development on host machine? | Using vagrant as part of development environment | 0 | 0 | 0 | 1,504 |
20,437,735 | 2013-12-07T04:49:00.000 | 5 | 1 | 0 | 0 | python,performance,serial-port,baud-rate | 20,437,926 | 1 | true | 1 | 0 | You're going to give up some time when the direction of communication is reversed. So there's some "dead time" between when one side receives the last stop bit and when it loads the first response byte into the UART transmitter and starts driving the first start bit.
I'm calculating that this dead time is 5 ms (almost 5 bit times, i.e. half a byte counting framing overhead) per two-way run, or 0.495 seconds of your 2.895 total seconds. This isn't bad, but it could be a little better. However, I'm not sure you'll get much improvement without writing your own UART driver.
(This all assumes, of course, that the clocks both computers are using are crystal accurate. This isn't always true, since UARTs at 8N1 can tolerate up to about 2% clock difference between each end.)
In embedded land, if we wanted to do this with absolute minimum bandwidth loss, we'd write the driver as a standard two-way full-duplex driver, with some way to know when to switch directions (e.g. on packet bounds). This driver would then only push bytes in the correct direction, leaving the other queue unused.
At the user (application) level, we'd have to make sure those queues were never starved. That means that, in your example, the 13-byte response packet would need to be ready to go before the 10-byte incoming packet is fully received. The other end would need to do the same.
With larger machines, the usual practice is to "coalesce" several packets in each direction and transmit them consecutively, so as to minimize the number of times that you have to change direction. This increases latency, though, and requires more memory, which could be a problem with a small microcontroller with only a couple kB of RAM.
IMHO, given your small packets, frequent direction reversals, and lack of driver-level optimizations, that bandwidth looks about right. | 1 | 3 | 0 | I am developing an application in Python that communicates to a device over RS-485 two wire, half-duplex.
I have enough of the application working that I can perform some performance tests.
I am using a laptop with a USB to 485 converter. The communications is setup as 9600,N,8,1.
For my speed test I send a message with a total length of 10 bytes including the check byte. Then I wait for the reply of 13 bytes. I decode the reply as it is coming in. When the response is complete. I then send the next message. I repeat this 100 times as fast as possible. This takes 2.895 seconds.
From this I calculate that I am transmitting/receiving 23 bytes * 100 iterations / 2.895 seconds = 794 bytes/s.
If I understand it correctly serial port communication of 9600 N-8-1 has 1 start bit, 8 data bits and 1 stop bit. This means that it has a 2 bit overhead. So the actual theoretical transmission rate is (9600 bits / s) * (8 data bits / 10 transmission bits) * (1 Byte / 8 bits) = 960 bytes / s.
My program is transmitting/receiving at a combined rate of 794 bytes/s out of a possible 960 bytes / s = 82.7%.
Should I be able to achieve near 100% of the 960 bytes/s. Or is it typical to have this much bandwidth un-utilized? | RS-485 Serial Port Baud Rate Performance Efficiency | 1.2 | 0 | 0 | 1,777 |
20,439,604 | 2013-12-07T09:06:00.000 | 3 | 0 | 1 | 0 | python | 20,439,634 | 2 | false | 0 | 0 | Rather than leaving in the syntax errors, explicitly raise NotImplementedError from your unfinished function. Or move the constants to a separate module. | 1 | 0 | 0 | I have a module A.py, that holds some constants, and a class. The class is not ready yet, so meny of it's functions implementations are NOT IMPLEMENTED YET - that is, I want if anyone calls this function, python to fail with syntactic error.
However, now I am doing from A import constants and python is failing with the error within the function within the class.
How can I resolve this? | From a module with errors, import valid entities | 0.291313 | 0 | 0 | 36 |
20,440,320 | 2013-12-07T10:36:00.000 | 3 | 1 | 0 | 0 | python,linux,disk | 20,441,124 | 1 | false | 0 | 0 | Get libatasmart which is a C library, and invoke it from Python via ctypes or cffi. | 1 | 0 | 0 | Is there a way to do this without using smartmontools? I'd like to try to see how far I get with just Python if possible. A google search does not seem to yield too much. | Accessing SMART attributes in Linux with only Python? | 0.53705 | 0 | 0 | 167 |
20,440,581 | 2013-12-07T11:07:00.000 | 0 | 1 | 0 | 0 | javascript,php,python,vbscript,cloud9-ide | 20,442,855 | 1 | false | 1 | 0 | You could possibly make a temporary file in your system, and in an iframe, open the file.
Important Note
This could be insecure as they could get the URL and execute code to delete ../../../ or something, which could harm your files. | 1 | 0 | 0 | I am using ACE to allow people to code freely on my website. How would I run this code.
I would like a run button in the bottom left corner (I can do that in css), but how would I run it, as it is python. I have added extra tags, as you can write these languages in the ace editor. When I mean, a run button, I mean like on codecademy, where you write some code, then it is submitted. | How do I try and run code that I have written in ACE Cloud 9? | 0 | 0 | 0 | 530 |
20,441,270 | 2013-12-07T12:17:00.000 | 0 | 0 | 0 | 0 | python,csv,python-3.x,urllib | 20,441,410 | 4 | false | 0 | 0 | You are probably not going to be able to top that speed without either a) a faster internet connection both for you and the provider or b) getting the provider to provide a zip or tar.gz format of the files that you need.
The other possibility would be to use a cloud service such as Amazon to get the files to your cloud location, zip or compress them there and then download the zip file to your local machine. As the cloud service is on the internet backbone it should have faster service than you. The downside is you may end up having to pay for this depending on the service you use. | 2 | 8 | 0 | I need to download a thousand csv files size: 20KB - 350KB. Here is my code so far:
Im using urllib.request.urlretrieve. And with it i download thousand files with size of all of them together: 250MB, for over an hour.
So my question is:
How can I download thousand csv files faster then one hour?
Thank you! | Fastest way to download thousand files using python? | 0 | 0 | 1 | 5,698 |
20,441,270 | 2013-12-07T12:17:00.000 | 1 | 0 | 0 | 0 | python,csv,python-3.x,urllib | 20,441,497 | 4 | false | 0 | 0 | The issue is very unlikely to be bandwidth (connection speed) because any network connection can maintain that bandwidth. The issue is latency - the time it takes to establish a connection and set up your transfers. I know nothing about Python, but would suggest you split your list and run the queries in parallel if possible, on multiple threads or processes - since the issue is almost certainly neither CPU, nor bandwidth-bound. So, I am saying fire off multiple requests in parallel so a bunch of setups can all be proceeding at the same time and the time each takes is masked behind another.
By the way, if your thousand files amount to 5MB, then they are around 5kB each, rather than the 20kB to 350kB you say. | 2 | 8 | 0 | I need to download a thousand csv files size: 20KB - 350KB. Here is my code so far:
Im using urllib.request.urlretrieve. And with it i download thousand files with size of all of them together: 250MB, for over an hour.
So my question is:
How can I download thousand csv files faster then one hour?
Thank you! | Fastest way to download thousand files using python? | 0.049958 | 0 | 1 | 5,698 |
20,442,022 | 2013-12-07T13:41:00.000 | 1 | 0 | 0 | 0 | python,pygame | 20,443,462 | 1 | false | 0 | 1 | An event can be made with the command pygame.event.Event(type, dict). The type will be what you want it to return when the event.type() command is used on it. The dict will include every other attribute.
An example: pygame.event.Event(pygame.MOUSEBUTTONDOWN, {'button':1}) would return a MOUSEBUTTONDOWN event with an attribute button of 1. | 1 | 0 | 0 | Is it possible to define an event object in pygame?
What I am trying to do is loop through all the keyboard events in a method, I then want to call that method with an event as a parameter, but I first need to define it. Is this possible?
Im using Pygame 3.3 and python 3. | Pygame event object | 0.197375 | 0 | 0 | 198 |
20,446,892 | 2013-12-07T21:28:00.000 | 2 | 0 | 1 | 0 | python | 20,446,961 | 1 | true | 0 | 0 | First you would have to define the meaning of the hash of three bits. The hashes in hashlib (and standard hashes in general) are defined with an input which is a sequence of bytes, so if you have less than one byte there's no standard definition.
For example, you might define that the hash of '001' should be equal to the hash of a single byte equal to 1 -- that is to say fill the other 5 bits with 0. I'm not saying that's a "correct" definition, just that it makes sense. There must be some reason why you don't want the hash of the 3 bytes '001', that you've chosen not to share. That reason might tell you the "correct" definition.
If you do make that definition, you can get the byte to hash using chr(int('001', 2)) in Python2 or int('001',2).to_bytes("big", 1) in Python3. There might be a better way in 3. | 1 | 0 | 0 | Is there a way to send a raw bitstring like '001' and hash that using Python's hashlib? Using the literal string '001' hashes the binary representation of the string which is 24 bits in length. | Use Python's hashlib to find the hash of something that isn't a complete byte | 1.2 | 0 | 0 | 77 |
20,447,826 | 2013-12-07T23:08:00.000 | 0 | 0 | 0 | 0 | python,sockets,python-3.x,port | 20,447,877 | 1 | false | 0 | 0 | Use a firewall for example?
On linux there is the iptables. It's easy to use and powerful. | 1 | 0 | 0 | For example, if I have my minecraft server running on port 25565, I want to have a python script close the port so that all connections will be dropped and no further connections will be made without having to shutdown the service.
I have tried binding a new socket to the same port number and then closing the socket, but it does not have any effect on the server.
I am working in Python 3.3. | How do I force close a port being used by an independent service? | 0 | 0 | 1 | 148 |
20,449,398 | 2013-12-08T03:03:00.000 | 21 | 0 | 1 | 0 | python,generics | 20,449,414 | 2 | false | 0 | 0 | No. Python is not a statically typed language, so there is no need for them. Java generics only provide compile time type safety; they don't do anything at runtime. Python doesn't have any compile time type safety, so it wouldn't make sense to add generics to beef up the compile time type checks Python doesn't have.
A list, for example, is an untyped collection. There is no equivalent of distinguishing between List<Integer> and List<String> because a Python list can store any type of object. | 1 | 9 | 0 | Does python have generic methods like Java? If so could you refer to a site that explains it. | Does python have generic methods? | 1 | 0 | 0 | 13,573 |
20,452,189 | 2013-12-08T10:11:00.000 | 2 | 0 | 1 | 0 | python,python-3.x,floating-point,int | 20,452,362 | 4 | false | 0 | 0 | There are four reasons which I can currently think of (and I'm sure there are more):
Memory. Choosing wisely data types can dramatically affect the memory requirements (large databases, for example).
Speed. Hardware implementation of integer arithmetic is much faster (and simpler) than floating point arithmetic.
Programming practices. Having data types enforces better programming practices, as the programmer must be aware of kind of data each variable stores. This also allows early errors detection (compile time vs runtime).
History. Memory used to be expensive (and still is on some systems for some applications). | 3 | 7 | 0 | I'm preparing for a class lesson (I'm teaching) and I'm trying to predict any possible questions from the students and I ran into one that I can't answer:
If we have floats, why do we ever use ints at all? What's the point?
I know (or at least I think) that floats take more memory because they have more accuracy, but surely the difference is nearly negligible as far as memory usage goes for most non-embedded applications.
And I realize in many cases we actually don't need a float, but honestly, why do we have ints in the first place? What's the point? There's nothing an int can do that a float can't.
So why are they there at all?
Edit: You could argue they're easier to write (3 vs. 3.0) but you could just make all numbers default to float, so 3 would be treated the same as 3.0. Why make it a different type? | Why should I use ints instead of floats? | 0.099668 | 0 | 0 | 9,918 |
20,452,189 | 2013-12-08T10:11:00.000 | 9 | 0 | 1 | 0 | python,python-3.x,floating-point,int | 20,452,910 | 4 | false | 0 | 0 | There are various historical reasons that apply to most languages:
A philosophy of "don't use what you don't need". A lot of programs have no need for non-integer values but use integer values a lot, so an integer type reflects the problem domain.
Floating point arithmetic used to be far more expensive than integer. It's still somewhat more expensive, but in a lot of cases in Python you'd hardly notice the difference.
A 32 bit IEEE float can only represent all integers up to 2**24 then loses precision. A 16 bit float ("half precision") only represents all integers to 2048. So for 16 and 32 bit computing, when register sizes impose a serious trade-off between performance and value range, float-for-everything makes that trade-off even more serious.
An 8-bit integer type (or whatever byte size exists on the platform), is very useful for low-level programming because it exactly maps to any data representable in memory. Same goes for a register-sized integer type with some efficiency advantage to working in words rather than bytes. These are the (signed and unsigned) char and int types in C.
There is an additional reason specifically for Python:
The int type automatically promotes to long when a computation goes beyond its range, thereby retaining precision. float doesn't get bigger to remain precise. Both behaviours are useful in different circumstances.
Note that Javascript doesn't provide an integer type. The only built-in numbers in Javascript are 64 bit floating-point. So for any reason why an integer type is beneficial, it's instructive to consider how Javascript gets on without it. | 3 | 7 | 0 | I'm preparing for a class lesson (I'm teaching) and I'm trying to predict any possible questions from the students and I ran into one that I can't answer:
If we have floats, why do we ever use ints at all? What's the point?
I know (or at least I think) that floats take more memory because they have more accuracy, but surely the difference is nearly negligible as far as memory usage goes for most non-embedded applications.
And I realize in many cases we actually don't need a float, but honestly, why do we have ints in the first place? What's the point? There's nothing an int can do that a float can't.
So why are they there at all?
Edit: You could argue they're easier to write (3 vs. 3.0) but you could just make all numbers default to float, so 3 would be treated the same as 3.0. Why make it a different type? | Why should I use ints instead of floats? | 1 | 0 | 0 | 9,918 |
20,452,189 | 2013-12-08T10:11:00.000 | 9 | 0 | 1 | 0 | python,python-3.x,floating-point,int | 20,452,305 | 4 | false | 0 | 0 | It's important to use data types that are the best fit for the task they are used for. A data type may not fit in different ways. For instance, a single byte is a bad fit for a population count because you cannot count more than 255 individuals. On the other hand a float is a bad fit because many possible floating point values have no meaning. For example, 1.5 is a floating point value that has no meaning as a count. So, using an appropriately sized integer type gives us the best fit. No need to perform sanity checks to weed out meaningless values.
Another reason to favour integers over floats is performance and efficiency. Integer arithmetic is faster. And for a given range integers consume less memory because integers don't need to represent non-integer values.
Another reason is to show intent. When a reader of the code sees that you used an integer, that reader can infer that the quantity is only meant to take integer values. | 3 | 7 | 0 | I'm preparing for a class lesson (I'm teaching) and I'm trying to predict any possible questions from the students and I ran into one that I can't answer:
If we have floats, why do we ever use ints at all? What's the point?
I know (or at least I think) that floats take more memory because they have more accuracy, but surely the difference is nearly negligible as far as memory usage goes for most non-embedded applications.
And I realize in many cases we actually don't need a float, but honestly, why do we have ints in the first place? What's the point? There's nothing an int can do that a float can't.
So why are they there at all?
Edit: You could argue they're easier to write (3 vs. 3.0) but you could just make all numbers default to float, so 3 would be treated the same as 3.0. Why make it a different type? | Why should I use ints instead of floats? | 1 | 0 | 0 | 9,918 |
20,452,796 | 2013-12-08T11:17:00.000 | 2 | 0 | 0 | 0 | python,mysql | 20,452,854 | 1 | true | 0 | 0 | Your design is poorly suited for a relational database such as MySQL. The best way to go about it is to either redesign your storage layout to a form that a relational database works well with (eg. make each row a (hashtag, hour) pair), or use something other than a relational database to store it. | 1 | 0 | 0 | I'm using a python script to run hourly scrapes of a website that publishes the most popular hashtags for a social media platform. They're to be stored in a database (MYSQL), with each row being a hashtag and then a column for each hour that it appears in the top 20, where the number of uses within that past hour is listed.
So, the amount of rows as well as columns will constantly increase, as new hashtags appear and ones that have previously appeared resurface into the top 20.
Is there a best way to go about this? | Best way to handle a database with lots of dynamically added columns? | 1.2 | 1 | 0 | 48 |
20,455,129 | 2013-12-08T15:29:00.000 | 1 | 0 | 0 | 0 | python,mysql,latitude-longitude | 20,455,724 | 1 | true | 0 | 0 | Load B into a python list and for each calculate maxlat, minlat, maxlong, minlong that everything outside of the box is definitely outside of your radius, if your radius is in nautical miles and lat/long in degrees. You can then raise an SQL query for points meeting criteria of minlat < lat < maxlat and minlong < long < maxlong. The resulting points can then be checked for exact distance and added to the in range list if they are in range.
I would suggest doing this in multiple processes. | 1 | 0 | 0 | Problem
I have a list of ~5000 locations with latitude and longitude coordinates called A, and a separate subset of this list called B. I want to find all locations from A that are within n miles of any of the locations in B.
Structure
All of this data is stored in a mysql database, and requested via a python script.
Approach
My current approach is to iterate through all locations in B, and request locations within n miles of each location, adding them to the list if they don't exist yet.
This works, but in the worst case, it takes a significant amount of time, and is quite inefficient. I feel like there has to be a better way, but I am at a loss as for how to do it.
Ideas
Load all locations into a list in python, and calculate distances there. This would reduce the number of mysql queries, and likely speed up the operation. It would still be slow though. | Finding Locations with n Miles of Existing Locations | 1.2 | 1 | 0 | 71 |
20,456,893 | 2013-12-08T18:00:00.000 | 0 | 0 | 0 | 1 | python,sockets,networking,io,network-programming | 20,457,117 | 1 | true | 0 | 0 | From the python select documentation:
This module provides access to the select() and poll() functions
available in most operating systems, epoll() available on Linux 2.5+
and kqueue() available on most BSD. Note that on Windows, it only
works for sockets; on other operating systems, it also works for other
file types (in particular, on Unix, it works on pipes). It cannot be
used on regular files to determine whether a file has grown since it
was last read. | 1 | 0 | 0 | I was trying to use the poll() function on Windows when I realized that only the select() function is supported on windows, and I believe poll() is supported on Linux.
Could anyone help me out as to what functions of the select module are supported on what operating systems?
Thanks | On what operating systems are the different functions of the select module in Python, like select(), poll(), epoll() available? | 1.2 | 0 | 0 | 57 |
20,456,992 | 2013-12-08T18:09:00.000 | 2 | 0 | 1 | 0 | python | 20,457,050 | 3 | false | 0 | 0 | From the error, it seems that r is assigned to a function by mistake. I'm guessing you're calling your function with something like this: generateNumber(float). Or the argument is one of your own functions, but you forgot to add parentheses: generateNumber(myOwnFunction) instead of the correct generateNumber(myOwnFunction()). | 1 | 0 | 0 | I am trying to calculate the value of 10^r in python. I started with pow(10, r), but I was told that I had a TypeError and needed a float. I tried using (10**r) and pow(10, float(r)), but nothing is working. In the first, I got a "TypeError - unsupported operand type(s) for ** or pow(): 'int' and 'builtin_function_or_method'." In the second, I was told that float() needed a string or number argument. Any tips will be appreciated. Thank you. | Python math.pow function needs float() | 0.132549 | 0 | 0 | 1,536 |
20,458,011 | 2013-12-08T19:35:00.000 | 5 | 0 | 1 | 0 | python,python-2.7,python-3.3,python-2to3 | 47,106,899 | 9 | false | 0 | 0 | To convert all python 2 files in a directory to 3, you simply could run $ C:\Program Files\Python\Tools\Scripts\2to3.py -w -n. inside the directory that you want to translate. It would skip all the non .py files anyway, and convert the rest.
note: remove the -n flag, if you want the backup file too. | 3 | 69 | 0 | I have some code in python 2.7 and I want to convert it all into python 3.3 code. I know 2to3 can be used but I am not sure exactly how to use it. | How to use 2to3 properly for python? | 0.110656 | 0 | 0 | 73,248 |
20,458,011 | 2013-12-08T19:35:00.000 | 1 | 0 | 1 | 0 | python,python-2.7,python-3.3,python-2to3 | 65,057,406 | 9 | false | 0 | 0 | Running it is very simple! I am going to consider you already have it installed and explain step-by-step how to proceed after that:
Open terminal (or cmd for win users) inside the main folder containing the files you want to convert
e.g.
C:\Users\{your_username}\Desktop\python2folder
Type
python {your_2to3.py_install_directory} -w .\
e.g. in my case (win10) it would be:
python C:"\Program Files"\Python39\Tools\scripts\2to3.py -w .\
This is going to make the program scan the entire directory (and sub directories as well) and automatically convert everything that is written in Python2 to Python3.
-w flag makes the script apply the changes creating new converted files. So remove this you'd like to just scan and see what needs conversion (but without actually doing anything)
If you'd like to convert just one file instead of entire folders simply substitute .\ for python2_file_name.py:
e.g. python {your_2to3.py directory} -w python2_file_name.py
Also, by default it creates a .bak file for everything it converts. It is highly advised to keep it this way since any conversion is prone to errors but if you'd like to disable the automatic backup you could also add the -n flag.
e.g. python C:"\Program Files"\Python39\Tools\scripts\2to3.py -w -n python2_file_name.py
3.Done! | 3 | 69 | 0 | I have some code in python 2.7 and I want to convert it all into python 3.3 code. I know 2to3 can be used but I am not sure exactly how to use it. | How to use 2to3 properly for python? | 0.022219 | 0 | 0 | 73,248 |
20,458,011 | 2013-12-08T19:35:00.000 | -2 | 0 | 1 | 0 | python,python-2.7,python-3.3,python-2to3 | 48,277,515 | 9 | false | 0 | 0 | The python 2to3.py file is mostly found in the directory C:/Program Files/Python/Tools/scripts if you already have python installed. I have python 3.6 and 2to3 is in the directory C:/Program Files/Python36/Tools/scripts.
To convert a certain python 2 code to python 3, go to your command promt, change the directory to C:/Program Files/Python36/Tools/scripts where the 2to3 file is found. Then add the following command:
python 2to3.py -w (directory to your script).
eg. C:\Program Files\Python36\Tools\scripts> python 2to3.py -w C:Users\Iykes\desktop\test.py.
the '-w' here ensures a backup file for your file is created. | 3 | 69 | 0 | I have some code in python 2.7 and I want to convert it all into python 3.3 code. I know 2to3 can be used but I am not sure exactly how to use it. | How to use 2to3 properly for python? | -0.044415 | 0 | 0 | 73,248 |
20,458,503 | 2013-12-08T20:16:00.000 | 1 | 1 | 1 | 0 | python,unicode,python-3.3 | 20,459,315 | 1 | false | 0 | 0 | As @Jongware and @SimeonVisser pointed out, "Unicode is basically just a big lookup table," so there's secret sauce along the lines of what I was looking for.
Marking as answered--hopefully the directness here will help someone with a similar question in the future. | 1 | 1 | 0 | I'm working on string manipulation in Python (v3.3), and I'm wondering if there's a predictable way to detect the addition of diacritical markings on a given character.
So for instance is there some relationship between 'α' # ord('α') = 945) (Greek unmarked alpha) and 'ᾶ' # ord('ᾶ') = 8118 (Greek alpha with a circumflex) and 'ω' # ord('ω') = 969 (Greek unmarked omega) and 'ῶ' # ord('ῶ') = 8182 (Greek omega with a circumflex)?
Are there any manipulations that can be done to clear the diacritics? Or to add a diacritic, for example when marking a long vowel: 'ᾱ' # ord('ᾱ') = 8113?
Thanks!
Edit: I've played around with both the unidecode package and unicodedata. I'm not looking simply to normalize strings; I'm interested in resources for understanding the byte manipulations that happen behind the scenes to add, say, a circumflex or a macron to a standard alpha. Another way of asking that question is how does chr(945) # 'α' become or relate to chr(8113) # 'ᾱ' at a very low level? Maybe I'm thinking of this (text) in completely the wrong way, and I'd be interested in learning that too.
This question doesn't actually have so much to do with Python as it does with text encoding in general, but I mention Python just in case any of its peculiarities come into play.
Edit 2: I should also add that I'm more interested in how something like unidecode works than in actually using it at the moment. unidecode('ῶ') and unidecode('ὄ') # that's an omicron, not an 'o' both return 'o', and that return value isn't as helpful to me at the moment as a higher-level understanding of how the unidecode module arrives at that return value. | Unicode and (Greek) Diacritics in Python | 0.197375 | 0 | 0 | 581 |
20,460,867 | 2013-12-09T00:00:00.000 | 14 | 0 | 0 | 0 | python,kivy | 20,470,745 | 1 | true | 0 | 1 | A widget keeps a reference to its parent in self.parent. So you can just so self.parent.size or self.parent.pos or whatever.
Depending on what you're doing, it may be necessary or useful to make sure you check if self.parent is None first, so that your code doesn't fail for widgets with no parent. | 1 | 11 | 0 | Im learning Kivy and would like to center an object inside of a parent object. I know I can access an object's own properties with the self keyword in the kv language, but is there a shortcut for accessing a parent widget's, say, size and position properties? Both root.size and parent.size are failing for me. | Accessing the parent object's size parameters in kivy widgets | 1.2 | 0 | 0 | 5,845 |
20,461,790 | 2013-12-09T01:53:00.000 | 5 | 1 | 0 | 0 | python,installation,xlrd | 20,462,021 | 4 | false | 0 | 0 | If windows this should work.
Browser to "folder with python"\scripts Open cmd here (shift + right click and and it should be an option in the context menu.)
type inn: easy_install.exe xlrd
It should download and install if for you. | 2 | 8 | 0 | Can someone give me a guide for morons? I am somewhat out of my depth here. So far I have downloaded xlrd 0.9.2 and tried to follow the readme, but neither I nor ctrl-f can find the installer mentioned. | I'm having a lot of trouble installing xlrd 0.9.2 for python | 0.244919 | 0 | 0 | 43,595 |
20,461,790 | 2013-12-09T01:53:00.000 | 1 | 1 | 0 | 0 | python,installation,xlrd | 52,548,713 | 4 | false | 0 | 0 | If you have installed pip which is available with python installation file; then just do the following steps:
Open Command Line
Type "pip install xlrd"
Hope it will work | 2 | 8 | 0 | Can someone give me a guide for morons? I am somewhat out of my depth here. So far I have downloaded xlrd 0.9.2 and tried to follow the readme, but neither I nor ctrl-f can find the installer mentioned. | I'm having a lot of trouble installing xlrd 0.9.2 for python | 0.049958 | 0 | 0 | 43,595 |
20,463,104 | 2013-12-09T04:21:00.000 | 0 | 0 | 0 | 0 | android,python,mobile | 20,463,265 | 1 | false | 0 | 1 | From what I can tell, neither of the projects you mention is meant for building native Android apps. If you were really knowledgeable in Jython and Android, maybe you could finagle Jython to make native apps, but since you mention that you've never used Java, that's unlikely. Unfortunately, the only project that attempted to do it is dead (and turned into SL4A, maybe?).
So TL;DR, if you want completely native, I-can't-believe-it's-not-Java experience, you have no choice. If not, you should specify what exactly you wan't to accomplish, maybe Python is good enough. | 1 | 4 | 0 | I primarily program in Python and have always tried to steer clear of Java (no particular reason, really). Now I find myself in a position where I have to build an app for Android.
My question is, is there any inherent difference in terms of speed, resource-consumption, access to hardware features etc if I build the app in Python, using SL4A or Kivy or some other platform(I still need to explore those options in detail)? Or should I Download the SDK Bundle and go about learning to build apps for Android exclusively? | Building apps for Android using Python | 0 | 0 | 0 | 6,207 |
20,464,887 | 2013-12-09T06:57:00.000 | 0 | 0 | 1 | 0 | python,excel,xlrd | 21,302,801 | 3 | false | 0 | 0 | Excel dates are represented as pywintypes.Time type objects. So in order to e.g. assign the current timestamp to a cell you do:
workbook.Worksheets(1).Cells(1,1).Value = pywintypes.Time(datetime.datetime.now()) | 1 | 2 | 0 | I can convert date read from excel to a proper date using xldate_as_tuple function. Is there any function which can do the reverse i.e. convert proper date to float which is stored as date in excel ? | How to convert current date to float which is stored in excel as date? | 0 | 1 | 0 | 1,405 |
20,465,269 | 2013-12-09T07:23:00.000 | 4 | 1 | 0 | 0 | python,twitter,twython | 20,511,726 | 2 | true | 0 | 0 | What I ended up doing was .show_user(user_id=twitter_id) which returns (among other things) the followers count via ['followers_count'] | 1 | 0 | 0 | Is there an easy way to get the number of followers an account has without having to loop through cursors? I'm looking for a simple function call which will return to me just the number of followers the use with a given Twitter ID has.
Just looking for the physical number not access to anything else | Twython get followers count | 1.2 | 0 | 1 | 907 |
20,466,573 | 2013-12-09T08:51:00.000 | 1 | 0 | 0 | 0 | python,sockets,networking,select,network-programming | 20,466,700 | 2 | false | 0 | 0 | Note that select with a timeout of 0 is basically the same as a poll but the biggest problem for cross system programming is that the support for both select and poll is mixed and inconsistent - personally I tend to opt for a blocking listener in a separate thread that once a complete frame, message, etc., has been received raises an event with the data attached - this seems to work well cross systems. | 1 | 0 | 0 | I am writing an application in Python that involves socket programming. I have understood that it's better to use the non-blocking sockets, and thus write an event-driven server. I am not sure as to why and how I should prefer one of these two methods that I want to use: select() and poll() for checking activity in any of the sockets. Could anyone help me out if there's anything in either of these methods that makes it a better choice that the other?
I mean, why would I choose one over the other? | How can I choose between select.select() and select.poll() methods in the select module in Python? | 0.099668 | 0 | 1 | 805 |
20,467,107 | 2013-12-09T09:23:00.000 | 1 | 0 | 1 | 0 | python,urllib2,urllib,urllib3 | 20,467,364 | 3 | false | 0 | 0 | Personally I avoid to use third-party library when possible, so I can reduce the dependencies' list and improve portability.
urllib and urllib2 are not mutually exclusive and are often mixed in the same project. | 2 | 9 | 0 | as we know, python has two built-in url lib:
urllib
urllib2
and a third-party lib:
urllib3
if my requirement is only to request a API by GET method, assume it return a JSON string.
which lib I should use? do they have some duplicated functions?
if the urllib can implement my require, but after if my requirements get more and more complicated, the urllib can not fit my function, I should import another lib at that time, but I really want to import only one lib, because I think import all of them can make me confused, I think the method between them are totally different.
so now I am confused which lib I should use, I prefer urllib3, I think it can fit my requirement all time, how do you think? | Which urllib I should choose? | 0.066568 | 0 | 1 | 22,979 |
20,467,107 | 2013-12-09T09:23:00.000 | 10 | 0 | 1 | 0 | python,urllib2,urllib,urllib3 | 20,467,287 | 3 | true | 0 | 0 | As Alexander says in the comments, use requests. That's all you need. | 2 | 9 | 0 | as we know, python has two built-in url lib:
urllib
urllib2
and a third-party lib:
urllib3
if my requirement is only to request a API by GET method, assume it return a JSON string.
which lib I should use? do they have some duplicated functions?
if the urllib can implement my require, but after if my requirements get more and more complicated, the urllib can not fit my function, I should import another lib at that time, but I really want to import only one lib, because I think import all of them can make me confused, I think the method between them are totally different.
so now I am confused which lib I should use, I prefer urllib3, I think it can fit my requirement all time, how do you think? | Which urllib I should choose? | 1.2 | 0 | 1 | 22,979 |
20,468,670 | 2013-12-09T10:49:00.000 | 13 | 1 | 1 | 0 | python,pycharm | 20,634,928 | 5 | false | 0 | 0 | PyCharm sorts imports only according to groups specified in PEP-8, not alphabetically. | 1 | 29 | 0 | I am enjoying PyCharm's optimizing of Python imports - as well as removing unused imports, following PEP8 gives them a sensible layout and makes them easier to read. Is there any way to get PyCharm to additionally alphabetize them (which would make scanning them faster, for me at least)? | Can PyCharm's optimize imports also alphabetize them? | 1 | 0 | 0 | 10,848 |
20,470,493 | 2013-12-09T12:17:00.000 | 3 | 0 | 1 | 0 | python,performance,int | 20,471,640 | 6 | false | 0 | 0 | Although Martijn Pieters answered your question of what is faster and how to test it I feel like speed isn't that important for such a small operation. I would use int() for readability as Inbar Rose said. Typically when dealing with something this small readability is far more important; although, a common equation can be an exception to this. | 1 | 15 | 0 | I've been using n = int(n) to convert a float into an int.
Recently, I came across another way to do the same thing :
n = n // 1
Which is the most efficient way, and why? | Which is the efficient way to convert a float into an int in python? | 0.099668 | 0 | 0 | 2,877 |
20,471,228 | 2013-12-09T12:56:00.000 | 2 | 0 | 0 | 0 | python,image-processing,gimp | 20,483,571 | 2 | true | 0 | 0 | pdb.gimp_image_select_contiguous_color is the programatic way - in a Python plug-in - of doing the magic wand. The drawback is that you have to issue suitable starting coordinates for it to work well.
Maye repeating the process in 3 distant points of the image, and if the selection does not diverge by much in two of those, assume that to be the one you want.
The procedure does not return the selection drawable, so you have to get it by issuing
pdb.gimp_image_get_selection afterwards. You will also need to set the threshold by calling pdb.gimp_context_set_sample_threshold before calling it.
(My suggestion: copy it to another, new image, resize that to an 8x8pixel image, from which you can get the pixel values and compare directly against other selections made); | 1 | 1 | 1 | I need to automate the analyses of many similar images which are basic lots of small blackish blobs on a somewhat homogeneous brown background.
I have tried the find_blobs method from simpleCV but it is not accurate enough. However with gimps contiguous selection tool, also known as Magic wand, I was able to achieve much better results, in separating the background from my blobs.
My problem is that I need to automate this process, so I can't have a person clicking on each image. Any suggestion of a Python friendly library in which I can find this functionality? Is using Gimp in batch mode the only way? | Programmatic equivalent of Gimp's Contiguous selection tool | 1.2 | 0 | 0 | 1,258 |
20,471,702 | 2013-12-09T13:21:00.000 | 0 | 0 | 0 | 1 | python,windows,batch-file,cmd | 20,471,771 | 5 | false | 0 | 0 | Those wildcards are expanded at "shell (i.e. bash) level" before running your python script.
So the problem doesn't reside in python, but in the "shell" that you are using on Windows.
Probably you cloud try PowerShell for Windows or bash via CygWin. | 1 | 2 | 0 | I am trying to run python script from windows cmd. When I run it under linux I put
python myscript.py filename??.txt
it goes through files with numbers from filename01.txt to filename18.txt and it works.
I tried to run it from cmd like
python myscript.py filename*.txt
or
python myscript.py filename**.txt
but it didnt work. If I tried the script on one single file in windows cmd it works.
Do you have any clue where the problem could be?
Thanks! | running python script for multiple files from windows cmd | 0 | 0 | 0 | 2,906 |
20,471,968 | 2013-12-09T13:35:00.000 | 2 | 0 | 1 | 0 | pydev,ipython | 20,476,909 | 1 | true | 0 | 0 | Actually, that's correct, the PyDev console is not able to show images such as you'd have on IPython notebook (which is an HTML viewer in the end), so, you need to show the plot widget to see the results (note that the plot should be interactive and shouldn't halt the console in the latest version).
It should be possible to create a special view in PyDev where those results could be seen in an HTML viewer, but there are currently no plans to do so. | 1 | 2 | 0 | Just installed pyDev and eclipse. I see that the console is an IPython console, but when Im trying to plot, I need to use the show() command instead of the plots just appearing inline like a regular IPython console. I've tried to use %pylab inline but there is no such magic.
The console loads IPython 1.1.0. What do I need to do to get inline figures? | Plotting Inline with IPython Console in PyDev | 1.2 | 0 | 0 | 1,039 |
20,473,837 | 2013-12-09T15:06:00.000 | 6 | 0 | 0 | 0 | python,django,django-apps | 20,473,908 | 1 | true | 1 | 0 | Divide et impera.
This is one of the basic rule of programming.
Divide your problem in smaller pieces and on the long run you will be happy:
Code re-usability
Maintenance
Elegance?
Also if you are working on an opensource project your main goal would be to find someone else who is interested in it and that could help you. It is easier to find someone interested in something really specific than to find someone who wants to adopt your super-huge app which does a lot of beautiful things that nobody else like. | 1 | 2 | 0 | In django,What is the difference between creating multiple applications and using the same application and using all models and views in the same application? Will the latter create any problems? | Disadvantages of using multiple apps django | 1.2 | 0 | 0 | 373 |
20,476,969 | 2013-12-09T17:37:00.000 | 0 | 0 | 1 | 0 | python,list,python-3.x | 20,477,231 | 8 | false | 0 | 0 | Even numbers are divisible by 2. Odd numbers are not.
len(X) will get the length of X
If the length of X is divisible by 2, then it is an Even number
If the length of X is not divisible by 2 then it is an Odd Number
len(X)%2 returns the "remainder" of a division problem
for example 5%2 will return 1 which is NOT zero, (because 5 divided by 2 is 2 with a remainder of 1), therefore it is not even.
Same thing as 6%4 which would return a 2, because 6 divided by 4 is 1 with a remainder of 2.
so len(X)%2 where X is your list, will return either a 1, indicating it is Odd, or a 0 indicating it is Even. | 1 | 2 | 0 | How can I find out if there is even, or odd, number of elements in an arbitrary list.
I tried list.index() to get all of the indices... but I still don't know how I can tell the program what is an even and what is an odd number. | How to know if a list has an even or odd number of elements | 0 | 0 | 0 | 14,621 |
20,478,949 | 2013-12-09T19:25:00.000 | 3 | 0 | 0 | 0 | python,optimization,numpy,scipy,gaussian | 61,375,377 | 4 | false | 0 | 0 | I realize this is an old question but I haven't been able to find many discussion of similar topics. I am facing a similar issue with scipy.optimize.least_squares. I found that xtol did not do me much good. It did not seem to change the step size at all. What made a big difference was diff_step. This sets the step size taken when numerically estimating the Jacobian according to the formula step_size = x_i*diff_step, where x_i is each independent variable. You are using fmin so you aren't calculating Jacobians, but if you used another scipy function like minimize for the same problem, this might help you. | 1 | 13 | 1 | I have a function compare_images(k, a, b) that compares two 2d-arrays a and b
Inside the funcion, I apply a gaussian_filter with sigma=k to a My idea is to estimate how much I must to smooth image a in order for it to be similar to image b
The problem is my function compare_images will only return different values if k variation is over 0.5, and if I do fmin(compare_images, init_guess, (a, b) it usually get stuck to the init_guess value.
I believe the problem is fmin (and minimize) tends to start with very small steps, which in my case will reproduce the exact same return value for compare_images, and so the method thinks it already found a minimum. It will only try a couple times.
Is there a way to force fmin or any other minimizing function from scipy to take larger steps? Or is there any method better suited for my need?
EDIT:
I found a temporary solution.
First, as recommended, I used xtol=0.5 and higher as an argument to fmin.
Even then, I still had some problems, and a few times fmin would return init_guess.
I then created a simple loop so that if fmin == init_guess, I would generate another, random init_guess and try it again.
It's pretty slow, of course, but now I got it to run. It will take 20h or so to run it for all my data, but I won't need to do it again.
Anyway, to better explain the problem for those still interested in finding a better solution:
I have 2 images, A and B, containing some scientific data.
A looks like a few dots with variable value (it's a matrix of in which each valued point represents where a event occurred and it's intensity)
B looks like a smoothed heatmap (it is the observed density of occurrences)
B looks just like if you applied a gaussian filter to A with a bit of semi-random noise.
We are approximating B by applying a gaussian filter with constant sigma to A. This sigma was chosen visually, but only works for a certain class of images.
I'm trying to obtain an optimal sigma for each image, so later I could find some relations of sigma and the class of event showed in each image.
Anyway, thanks for the help! | How to force larger steps on scipy.optimize functions? | 0.148885 | 0 | 0 | 4,444 |
20,479,696 | 2013-12-09T20:07:00.000 | 111 | 0 | 1 | 0 | python,pycharm | 20,479,761 | 8 | true | 0 | 0 | The key is to mark your source directory as a source root. Try the following:
In the Project view, right-click on the Python source directory
In the dialog menu select Mark Directory As > Source Root
The folder should now appear blue instead of beige, to indicate it is a Python source folder.
You can also configure this in PyCharm preferences by doing the following for a project that is already in PyCharm:
In the Mac toolbar, select PyCharm > Preferences
In the window that opens, select Project Structure from the menu pane on the left
Select your project in the middle pane, if necessary
Right-click on your Python source in the right pane and select Sources from the menu dialog | 7 | 56 | 0 | Intro
I have a Python project on a git repository. Everything works ok for most of the team members, we can sync the code and edit it without any problem with Pycharm on different platforms (Windows, Linux)
The problem
On one of the computers we are getting "Unresolved reference" all over the code on almost every import with the exception of Python's built in libraries (i.e. import datetime is working). This computer is running the Mac version of Pycharm.
The question
Anyone knows how to solve this?, since most of the imports are not recognized code completion and navigation trough goto->declaration and so on is not working. Is there any known issue with the Mac version?
Thanks in advance! | Pycharm: "unresolved reference" error on the IDE when opening a working project | 1.2 | 0 | 0 | 70,388 |
20,479,696 | 2013-12-09T20:07:00.000 | 3 | 0 | 1 | 0 | python,pycharm | 36,310,088 | 8 | false | 0 | 0 | I did all the stuff above from einnocent and myildirim but still had to do the following:
close pycharm and manually delete the .idea folder, this deletes everything pycharm knows about the code.
open pycharm, reimport the project
the combination of setting the correct source root, restarting python with invaliding cache and deleting the .idea folder / reimporting the pycharm project fixed it for me. | 7 | 56 | 0 | Intro
I have a Python project on a git repository. Everything works ok for most of the team members, we can sync the code and edit it without any problem with Pycharm on different platforms (Windows, Linux)
The problem
On one of the computers we are getting "Unresolved reference" all over the code on almost every import with the exception of Python's built in libraries (i.e. import datetime is working). This computer is running the Mac version of Pycharm.
The question
Anyone knows how to solve this?, since most of the imports are not recognized code completion and navigation trough goto->declaration and so on is not working. Is there any known issue with the Mac version?
Thanks in advance! | Pycharm: "unresolved reference" error on the IDE when opening a working project | 0.07486 | 0 | 0 | 70,388 |
20,479,696 | 2013-12-09T20:07:00.000 | 0 | 0 | 1 | 0 | python,pycharm | 42,169,671 | 8 | false | 0 | 0 | The other reason may be project interpreter. For example, if you are using Python3.x, but the interpreter is for Python2.x You can check here:
File | Settings | Project: 'projectname' | Project Interpreter | 7 | 56 | 0 | Intro
I have a Python project on a git repository. Everything works ok for most of the team members, we can sync the code and edit it without any problem with Pycharm on different platforms (Windows, Linux)
The problem
On one of the computers we are getting "Unresolved reference" all over the code on almost every import with the exception of Python's built in libraries (i.e. import datetime is working). This computer is running the Mac version of Pycharm.
The question
Anyone knows how to solve this?, since most of the imports are not recognized code completion and navigation trough goto->declaration and so on is not working. Is there any known issue with the Mac version?
Thanks in advance! | Pycharm: "unresolved reference" error on the IDE when opening a working project | 0 | 0 | 0 | 70,388 |
20,479,696 | 2013-12-09T20:07:00.000 | 0 | 0 | 1 | 0 | python,pycharm | 44,300,088 | 8 | false | 0 | 0 | PyCharm - Alt-F(ile); Settings; Project Structure; click +Add content root;
point your folder containing the package in contention: /home/joker/anaconda3/envs/conda_py27/lib/python2.7/site-packages.
I additionally marked as resources (not sure if this is mandatory). Click ok and the reindexing happens.
This solved the problem for me in PyCharm Professional 2016.2.3 | 7 | 56 | 0 | Intro
I have a Python project on a git repository. Everything works ok for most of the team members, we can sync the code and edit it without any problem with Pycharm on different platforms (Windows, Linux)
The problem
On one of the computers we are getting "Unresolved reference" all over the code on almost every import with the exception of Python's built in libraries (i.e. import datetime is working). This computer is running the Mac version of Pycharm.
The question
Anyone knows how to solve this?, since most of the imports are not recognized code completion and navigation trough goto->declaration and so on is not working. Is there any known issue with the Mac version?
Thanks in advance! | Pycharm: "unresolved reference" error on the IDE when opening a working project | 0 | 0 | 0 | 70,388 |
20,479,696 | 2013-12-09T20:07:00.000 | 1 | 0 | 1 | 0 | python,pycharm | 57,056,944 | 8 | false | 0 | 0 | My ten-penneth - If you're working with virtual environments (have a venv directory) make sure it is marked as excluded.
Plagiarised from above:
In the Project view, right-click on the venv directory
In the dialog menu select Mark Directory As > Excluded
The directory should turn orange...
This sometimes happens if you've done a git clean or for whatever reason had to rebuild your environment and PyCharm hasn't noticed | 7 | 56 | 0 | Intro
I have a Python project on a git repository. Everything works ok for most of the team members, we can sync the code and edit it without any problem with Pycharm on different platforms (Windows, Linux)
The problem
On one of the computers we are getting "Unresolved reference" all over the code on almost every import with the exception of Python's built in libraries (i.e. import datetime is working). This computer is running the Mac version of Pycharm.
The question
Anyone knows how to solve this?, since most of the imports are not recognized code completion and navigation trough goto->declaration and so on is not working. Is there any known issue with the Mac version?
Thanks in advance! | Pycharm: "unresolved reference" error on the IDE when opening a working project | 0.024995 | 0 | 0 | 70,388 |
20,479,696 | 2013-12-09T20:07:00.000 | 0 | 0 | 1 | 0 | python,pycharm | 65,142,294 | 8 | false | 0 | 0 | PyCharm > select "File" menu > select "Invalidate Caches / Restart" menu option | 7 | 56 | 0 | Intro
I have a Python project on a git repository. Everything works ok for most of the team members, we can sync the code and edit it without any problem with Pycharm on different platforms (Windows, Linux)
The problem
On one of the computers we are getting "Unresolved reference" all over the code on almost every import with the exception of Python's built in libraries (i.e. import datetime is working). This computer is running the Mac version of Pycharm.
The question
Anyone knows how to solve this?, since most of the imports are not recognized code completion and navigation trough goto->declaration and so on is not working. Is there any known issue with the Mac version?
Thanks in advance! | Pycharm: "unresolved reference" error on the IDE when opening a working project | 0 | 0 | 0 | 70,388 |
20,479,696 | 2013-12-09T20:07:00.000 | 5 | 0 | 1 | 0 | python,pycharm | 25,261,083 | 8 | false | 0 | 0 | I also had the problem, and it took me few hours to find the exact solution.
You need to confirm the following things.
'django.contrib.staticfiles', is added to INSTALLED_APPS in the settings.py file of your application.
The directory with the static contents (for example, images), named static, resides under the application root.
Now Do the following
PyCharm > Preferences > Project Settings > Django
Make sure your Django Project root, Settings.py and manage.py script are well defined in the dialog box.
You are good to go.
Hope this helps. | 7 | 56 | 0 | Intro
I have a Python project on a git repository. Everything works ok for most of the team members, we can sync the code and edit it without any problem with Pycharm on different platforms (Windows, Linux)
The problem
On one of the computers we are getting "Unresolved reference" all over the code on almost every import with the exception of Python's built in libraries (i.e. import datetime is working). This computer is running the Mac version of Pycharm.
The question
Anyone knows how to solve this?, since most of the imports are not recognized code completion and navigation trough goto->declaration and so on is not working. Is there any known issue with the Mac version?
Thanks in advance! | Pycharm: "unresolved reference" error on the IDE when opening a working project | 0.124353 | 0 | 0 | 70,388 |
20,480,808 | 2013-12-09T21:07:00.000 | 3 | 0 | 1 | 0 | python | 20,480,834 | 5 | false | 0 | 0 | I usually use the Python interpreter inside of cmd. You can get to this by running your python executable in cmd
I find its a little better than the standalone interpreter, but its just a matter of opinion | 2 | 0 | 0 | I want to learn how to program in Python and I've got plenty of tutorials/resources to do that however I don't have a solution as to where I'd test out my code and see the result.
For example: When I was learning Javascript I was using the Firefox Web Console and that would show me the result of my code.
I'd like to get something similar to this in Python. If it matters I'm running Windows 7 OS.
Thanks for any help and sorry for the basicness of the question. | What's the best solution for a Python programming environment? | 0.119427 | 0 | 0 | 138 |
20,480,808 | 2013-12-09T21:07:00.000 | 0 | 0 | 1 | 0 | python | 20,481,086 | 5 | false | 0 | 0 | PyScripter is an awesome Python IDE on Windows 7. Amongst other features, it allows you to run your Python code right within the IDE, just like on the cmd.
Last (but not least), who can forget IDLE. It is installed by default with any Python installation. Check your start menu; you should have it there. It has an interpreter for you to run your commands (or scripts) as well.
Hope this helps. | 2 | 0 | 0 | I want to learn how to program in Python and I've got plenty of tutorials/resources to do that however I don't have a solution as to where I'd test out my code and see the result.
For example: When I was learning Javascript I was using the Firefox Web Console and that would show me the result of my code.
I'd like to get something similar to this in Python. If it matters I'm running Windows 7 OS.
Thanks for any help and sorry for the basicness of the question. | What's the best solution for a Python programming environment? | 0 | 0 | 0 | 138 |
20,485,787 | 2013-12-10T03:59:00.000 | 4 | 0 | 1 | 0 | python,import,module,spyder | 20,485,970 | 2 | false | 0 | 0 | This is what you need to do:
Open a terminal and run python or ipython.
In there execute these two commands:
import sys
sys.executable
Copy the output of the last command
Open Spyder and go to
Spyder > Preferences > Console > Advanced settings > Python Executable
Select the option
Use the following Python interpreter
and paste there the result of step 3 (this option is only available in Spyder 2.2.3 or newer).
Finally go to Interpreters > Open a Python interpreter. This will open a new console that will be running the same Python version that you use in a terminal. | 1 | 0 | 0 | I am trying to import cv2 module in Spyder.app but somehow it does not import. By the way I am able to import it in a terminal. Can anyone of you guys please help me? | Spyder Module Import | 0.379949 | 0 | 0 | 10,814 |
20,485,792 | 2013-12-10T03:59:00.000 | 10 | 0 | 0 | 0 | python,colors,reportlab | 20,485,864 | 2 | true | 0 | 0 | From what I can tell, using the 256 color space won't work. The manual states that using 1 is 'all lights on full'. So, to create 256,256,256 is actually done by using (1,1,1). Thus, to get something in between, you'll have to use decimals. For me, I wanted the RGB: (75,116,156) so I had to write: setFillColorRGB(0.29296875,0.453125,0.609375). That's the equivelant to: 75/256, 116/256, 156/256. A bit ridiculous IMO, but it came out perfect | 1 | 6 | 0 | I'm using reportlabs library of python to generate PDF reports. I need to understand which format of color code is needed to be passed.
When I pass RGB code for light green (178,255,102), to the_canvas.setFillColorRGB(178,255,102) it gives me white. And if I provide universal RGB color code for any color, it still gives me the same white color.
If I provide (25,51,0) , it gives me yellow, which is not RGB code for yellow.
How should I provide color codes to the reportlab in order to get the color I wanted. Which format is it using? | color codes in reportlabs-python | 1.2 | 0 | 0 | 7,458 |
20,489,514 | 2013-12-10T08:32:00.000 | 2 | 1 | 1 | 0 | python,integration-testing,setup.py | 20,489,835 | 2 | false | 0 | 0 | If you really want isolation instead just doing python setup.py install in virtualenv. Then use virtualbox and install some free linux os in it. Take a snapshot of the machine after the install so you can revert easily with one click to the starting point at any time and try python setup.py install there. | 1 | 8 | 0 | I have a pretty big Python package I've written, about 3500 statements, with a robust unit and acceptance test suite. I feel quite confident about the quality of the code itself, but I'm uneasy about the install process going smoothly for users of the package as I don't know how to reliably test the install in an appropriately isolated environment, short of something like keeping a spare machine around and re-imaging it with a fresh OS install for each test run.
I suspect using virtualenv in the right way might provide a proper test fixture for testing installation, but after extended web searches have uncovered no helpful guidance.
How can I effectively test my setup.py and other installation bits on my development machine? | How do I test the setup.py for my package? | 0.197375 | 0 | 0 | 1,343 |
20,490,415 | 2013-12-10T09:20:00.000 | 2 | 0 | 0 | 0 | python,xml,xml-rpc | 20,534,267 | 1 | true | 0 | 0 | Found out the way for <struct> data type for xmlrpc.
data type is like a dict type.
For my case, it's actually SearchInfo({'id' : 12345}).
Good luck to whoever needing this information (: | 1 | 1 | 0 | I'm having problem with data type in python.
I run system.methodSignature('SearchInfo'), it returns [['array', 'struct']].
What should I put as the argument in SearchInfo()?
And what is struct data type in xml-rpc?
Please help. | Python XML-RPC data type | 1.2 | 0 | 1 | 617 |
20,492,587 | 2013-12-10T10:57:00.000 | 0 | 0 | 0 | 0 | python-2.7,turbogears2 | 20,525,832 | 1 | true | 0 | 0 | tgext.datahelpers uploads files on disk inside the public/attachments directory (this can be change with tg.config['attachments_path']).
So your file is already stored on disk, only the file metadata, like the URL, filename, thumbnail_url and so on are stored on database in JSON format | 1 | 1 | 0 | how to do file uploading in turbogears 2.3.1? I am using CrudRestController and tgext.datahelpers and it is uploading the file in the sqlite3 database but in an unknown format. I want to make a copy of the uploaded file in the hard drive. My query is how to ensure that when user uploads a file, it is loaded both in the database and the hard drive.
(Thank you for suggestions) | file upload turbogears 2.3.1 | 1.2 | 1 | 0 | 226 |
20,492,683 | 2013-12-10T11:02:00.000 | 3 | 0 | 0 | 0 | python,django,verbose | 20,495,156 | 2 | true | 1 | 0 | you just need to go to.
/admin/templates/admin/includes/fieldset.html
template.
Here you can see source code like.
{% if field.is_checkbox %}
{{ field.field }} {{ field.label_tag }}
Just change code to :
{% if field.is_checkbox %}
{{ field.label_tag }} {{ field.field }}
We put field.label_tag before field.field | 1 | 1 | 0 | I have inserted a verbose name for a field in my models (Boolean Field) and when displaying in the admin, the checkbox is shown before the verbose name.
How can I do so that the checkbox shows after the verbose name in the admin console?!
Or is there another way of assigning a specific label to a field other than the fieldname so that it shows correctly in the admin?
Thanks! | How to add verbose name after a field in Admin - Django | 1.2 | 0 | 0 | 597 |
20,494,017 | 2013-12-10T12:03:00.000 | 0 | 0 | 0 | 1 | python,celery,celerybeat | 20,506,294 | 1 | false | 0 | 0 | I figured out the problem and it turns out to be a really stupid one, rather shows that I was doing a bad practice.
I was using Gevent for measuring performance difference on the server and the way I was spawning Celery workers was not the right way to handle Gevent code. Not that I did not know that Celery needs a flag in the command line argument for Gevent, not using the same code on the local machine always worked for me. It just never struck my mind that I was using Gevent and that was causing the issue.
All resolved after almost 20 hours of debugging, googling and chatting on IRC. | 1 | 0 | 0 | I have been working on a project which uses Celery beat for scheduling tasks. Locally, I have been using RabbitMQ as the broker and everything was working fine.
When I pushed my project to the remote server, I changed the broker to Redis.
The celery beat process seams to work fine as I can see in the console that it is scheduling the task. But the worker in unable to pick up the task. When I call the task asynchronously from a shell by using delay() on the task, even then the task does not get picked up by the worker.
I assumed that there could be something weird with Redis. However, that doesn't seem to be the cases. I made my project work with Redis locally. On the server, when I changed the broker to RabbitMQ, even then I was getting the same issue.
My local machine runs Mac OS and the server runs Debian 6.
What could be the issue? How can I debug this situation and just get the worker to consume tasks and do the work? I am using Python 2.7. | Unable to get celery worker to work | 0 | 0 | 0 | 450 |
20,498,752 | 2013-12-10T15:42:00.000 | 0 | 0 | 0 | 0 | python,optimization,parameters,scipy | 20,499,162 | 3 | false | 0 | 0 | The order in which function parameters are passed is only ever not known when the function is defined with **kwargs (unnamed keyword arguments -- the function then has a dict called kwargs that contains them, obviously unordered).
When the function is defined with named parameters, though, the f(a=b, c=d) syntax does not create a dict -- it simply assigns the values to the corresponding named parameters within the function. | 1 | 2 | 1 | I want to model a data with gaussian with parameters (mu=1, sig=2, height=1) and pass initial parameters x0 = (0.8, 0.8, 0.9).
I am wondering how does the optimizer knows the order of parameters. I could have taken the parameters as (mu,height,sig) or in any other order.
Edit:
Gaussian model (mu=1,sig=1.5,height=0.8)
Initial parameters passed x0=(0.8,0.8,0.8)
How can I be sure that the optimizer understands it as (mu,sig,height) and not as (sig,mu,height)? | How scipy.optimize.leastsq knows the order of parameters passed to it? | 0 | 0 | 0 | 160 |
20,500,675 | 2013-12-10T17:03:00.000 | 2 | 0 | 0 | 1 | c++,python,c,mpi,distributed-computing | 20,500,867 | 1 | false | 0 | 0 | You can use MPI_ANY_SOURCE and MPI_ANY_TAG for receiving from anywhere. After receiving you can read the Information (source and tag) out of the MPI_Status structure that has to passed to the MPI_Recv call.
If you use this you do not neccessary need any asynchronous communication, since the master 'listens' to everybody asking for new jobs and returning results; and each slave does his task and then sends the result to the master asks for new work and waits for the answer from the master.
You should not have to work with scatter/gather at all since those are ment for use on an array of data and your problem seems to have more or less independant tasks. | 1 | 1 | 1 | I would like to write a MPI program where the master thread continuously submits new job to the workers (i.e. not just at the start, like in the MapReduce pattern).
Initially, lets say, I submit 100 jobs onto 100 workers.
Then, I would like to be notified when a worker is finished with a job. I would send the next job off, whose parameters depend on all the results received so far. The order of results does not have to be preserved, I would just need them as they finish.
I can work with C/C++/Python.
From the documentation, it seems like I can broadcast N jobs, and gather the results. But this is not what I need, as I don't have all of them available, and gather would block. I am looking for a asynchronous, any-worker recv call, essentially. | MPI distributed, unordered work | 0.379949 | 0 | 0 | 182 |
20,500,717 | 2013-12-10T17:05:00.000 | 3 | 0 | 1 | 0 | python | 20,500,806 | 1 | true | 0 | 0 | Context managers all have __enter__() and __exit__() methods, so checking to see if those attributes exist and that they have __call__ attributes will work almost all the time.
But yeah, read the code and/or documentation for the class first. | 1 | 4 | 0 | The only time I ever use the with keyword is when reading and writing files, mostly because that's the only case I actually know that I can use it. I can imagine there are numerous instances where I preferably could have used with, but didn't know a class or method accepted it.
So, how do I detect instances where the with keyword can be used? | How can I easily find out if a Python class accepts the with keyword? | 1.2 | 0 | 0 | 44 |
20,502,766 | 2013-12-10T18:45:00.000 | -3 | 0 | 0 | 0 | python,angle,turtle-graphics | 49,330,538 | 2 | false | 0 | 1 | turtle.right(90)
this will turn the turtle 90 | 1 | 6 | 0 | I'm creating a function that will cause a giraffe to move in a certain direction and distance (don't ask).
If the user types "west" in the parameters, the turtle should move west however the direction is. But the turtle's angle changes every time, I can't fix a value for my turtle to turn to go a certain direction.
I need to set the angle to, say, 90 so that it can move East. I can't find useful functions for this purpose. I tried to use Pen().degrees(90) but that didn't work. Does anyone know how I can do this? | Setting the angle of a turtle in Python | -0.291313 | 0 | 0 | 18,276 |
20,505,011 | 2013-12-10T20:55:00.000 | 1 | 0 | 1 | 0 | python,django,virtualenv,vagrant | 20,828,364 | 1 | false | 0 | 0 | Using virtualenv with Vagrant in the gswd tutorial is slightly more tricky than normal virtual env work because of where the virutal environment is stored.
Here is an example where I create 1 virutalenv on vagrant, deactivate it and create a 2nd virtual env:
vagrant@precise64:/vagrant/projects$ virtualenv ~/blog-venv1
-- note that in the above line we are passing a path to the virtual env
vagrant@precise64:/vagrant/projects$ source ~/blog-venv1/bin/activate
(blog-venv1)vagrant@precise64:/vagrant/projects/$ deactivate
vagrant@precise64:/vagrant/projects$ virtualenv ~/blog-venv2
vagrant@precise64:/vagrant/projects2$ source ~/blog-venv2/bin/activate | 1 | 0 | 0 | I am following the getting started with Django tutorial and managed to finish the 1st project but when I re-entered Vagrant SSH all packages i installed on my vagrant shared folder and my virtual environment were gone.
Whats is best practice for setting up a development environment once in Vagrant SSH?
Currently i have done:
1) Vagrant SSH
2) Installed default python packages (pip, dev, git, etc.)
3) Install Virtual env
4) CD to shared folder (ie /vagrant)
5) Create virtual env ( 'virtualenv env_name')
6) Source virtual env (source env_name/bin/activate)
7) Install Virtual env pkgs (ie. Django, pyscho2, etc.)
Once im done for the day:
8) deactivate virtual env
9) exit out of ssh
10) vagrant halt
Is this generally the correct workflow? I'm confused about step 5 in particular. Is this the correct way to create the virtual env or should I default to a different folder (the tutorial starts the folder with '~/')?. Am i'm shutting things down properly?
Any help would be appreciated - Thanks in advance!
Edit: I just noticed that virtual box has several different version of my precise box. This might be whats causing the missing Envs and packages that ive already installed. It seems like im doing something wrong spinnng up the vagrant instance. | Recommended workflow/best practice for setting up Virtual env within Vagrant | 0.197375 | 0 | 0 | 1,381 |
20,505,085 | 2013-12-10T20:59:00.000 | 2 | 0 | 1 | 1 | python,macos,updates,automator | 33,398,907 | 1 | true | 0 | 0 | I couldn't specify explicitly which python for it to use.
So, I ran it in bash environment with following command:
$ your/python/path /path/to/your/python/script.py
And make sure first line of your python program contains the path to the python environment you wish to use.
Eg:
#! /usr/local/bin/python | 1 | 2 | 0 | In my terminal and in CodeRunner my Python is updated to 2.7.6 but when I ran a shell script in the OSX Automator I found that it is running 2.7.2
How can I update the Automator Python to 2.7.6 like the rest of my compilers ? | Specify which version of Python runs in Automator? | 1.2 | 0 | 0 | 952 |
20,507,380 | 2013-12-10T23:15:00.000 | 0 | 0 | 1 | 0 | python,string,compression | 20,510,394 | 2 | false | 0 | 0 | There is a much simpler encoding scheme than base 62 or modifications of base 64 for limiting the output to 62 values. Take your input as a stream of bits (which in fact it is), and then encode either five or six bits as each output character. If the five bits are 00000 or 00001, then encode it as your first two characters from your set of 62. Otherwise, take one more bit, giving you 60 possible values. Use your remaining 60 characters for those. Continue with the remaining bits. Pad with zero bits on the end to get your last five or six bits.
Decoding is even simpler. You just emit five or six bits for each character received. You throw away any extra bits at the end that don't make up a full byte.
The expansion resulting from this scheme is 35%, close to the theoretical optimal of 34.36%. | 1 | 1 | 0 | I have a long string and I would like to compress it to a new string with the restriction that the output alphabet only contains [a-z] [A-Z] and [0-9] characters.
How can I do this, specifically in Python? | String Compression: Output Alphabet Restricted to Alphanumeric Characters | 0 | 0 | 0 | 1,443 |
20,507,907 | 2013-12-11T00:00:00.000 | 4 | 0 | 1 | 1 | python,windows,shell,startup | 20,508,067 | 2 | true | 0 | 0 | Create a batch file with the line start C:\python27\python.exe D:your_program_location\your_program.py'
Drag the batch file from desktop to "Start - All Programs - Startup". That should do the trick. | 2 | 0 | 0 | I have made a program that takes infrared values serially, transmits them them to another program(the one im having trouble with), and uses the win32 python api to react to a matched value. It all works, but I need this program to run on the startup of my computer.
It uses the IDLE python shell to run, and I need to open/run the file directly from that program. Is there any way to do this? I can't just put a shortcut into the startup directory because its an unrecognized file, and it needs to be run, not just opened. Any help would be great, thanks! | how to Start python shell program on windows 7 startup? | 1.2 | 0 | 0 | 6,240 |
20,507,907 | 2013-12-11T00:00:00.000 | 0 | 0 | 1 | 1 | python,windows,shell,startup | 20,508,698 | 2 | false | 0 | 0 | It sounds like your actual problem is just that you didn't put the right extension on the file.
Just rename it to, e.g., script.py, or script.pyw, and, unless you've changed the settings from the default, that should open the file with the command-line or windowed Python launcher, which will just run it.
If you've changed your settings so .py files open in IDLE instead of in the Python launcher… is there a reason you want those weird settings? If not, just undo it. | 2 | 0 | 0 | I have made a program that takes infrared values serially, transmits them them to another program(the one im having trouble with), and uses the win32 python api to react to a matched value. It all works, but I need this program to run on the startup of my computer.
It uses the IDLE python shell to run, and I need to open/run the file directly from that program. Is there any way to do this? I can't just put a shortcut into the startup directory because its an unrecognized file, and it needs to be run, not just opened. Any help would be great, thanks! | how to Start python shell program on windows 7 startup? | 0 | 0 | 0 | 6,240 |
20,509,103 | 2013-12-11T01:54:00.000 | 1 | 0 | 0 | 0 | python,random | 20,509,223 | 2 | false | 0 | 0 | To generate retrieve the path of a random image in a folder img_folder, it's not too difficult. You can use img_path_array = os.listdir('.../img_folder'). Randomly generate an integer between 0 and len(img_path_array) using random_index = randrange(len(img_path_array)) (import random to use this function), and gain access to the random file url by calling img_path_array[random_index]. | 1 | 1 | 1 | I really appreciate any responses. I am thoroughly confused and never knew this experiment design/builder software was so complicated!
I am a fast learner, but still a newbie so please be patient.
Yes I have googled the answers for my question but no answers to similar questions seem to work.
I have an experiment, there are 8 conditions,
each condition needs to show 1 image, chosen at random from a folder of similar images.
Each trial needs to be different (so each participant sits a differently ordered set of conditions) AND each condition's selected image will be different.
So;
Condition- Image
A - 1 to 140
B - 1 to 80
etc..
Recording data is not a problem as this can be done by hand, but I just need the images to be randomly selected from a pre-defined group.
I have tried using code to randomise and shuffle the order, but have got nowhere.
Please help,
Tom | how to randomise the image shown in a sketchpad | 0.099668 | 0 | 0 | 65 |
20,512,397 | 2013-12-11T06:48:00.000 | 5 | 0 | 0 | 0 | java,python,performance,neo4j | 20,512,703 | 1 | false | 1 | 0 | In general, the fastest way to do traversals in neo4j is with the Java API.
You might consider testing to see if it is fast enough before potentially prematurely optimizing. Try one of the python libraries w/ Cypher to see how it performs.
If you do have to resort to the Java API, you can usually get away with writing a simple unmanaged extension (<50 lines of java/scala), and then call that from your python. | 1 | 0 | 0 | I have to do traversals on neo4j graph in real time. The graph contains around 200,000 nodes and 300,000 relationships. My main concern is that results should be super fast.
Should I write the traversal algorithms in Java? Does Using python (py2neo or bulbflow) for the same has significant performance issues? My personal preference is for python here if performance is same for both python and java. | Which platform to use for fastest neo4j graph traversal? | 0.761594 | 0 | 0 | 208 |
20,516,490 | 2013-12-11T10:22:00.000 | 0 | 1 | 0 | 1 | python,logging,streaming | 21,938,560 | 2 | false | 0 | 0 | I'm doing something like that.
I have a server running on my raspberry pi + client that parse the output of the server and sends it to another server on the web.
What I'm doing is that the local server program write it's data in chunks.
Every time it writes the data (by the way, also on tmpfs) it writes it on a different file, so I don't get errors when trying to parse the file while something else is writing to that file..
After it writes the file, it starts the client program in order to parse and send the data (Using subprocess with the name of the file as a parameter).
Works great for me. | 1 | 0 | 0 | I made a program which is saving sensor data in a log file (server site).
This file is stored in a temporary directory (Ram-Disk).
Each line contains a timestamp and a JSON string.
The update rate is dependent on the sensor data, but the fastest is every 0.5s.
What I want to do is, to stream every update in this file to a client application.
I have several approaches in mind:
maybe a shared folder on server site (samba) with a script (client site), just checking the file every 0.5s
maybe a another server program running on the server, checking for updates (but this I don't want to do, because Raspberry Pi is slow)
Has anyone maybe done something like this before and can share some ideas? Is there maybe a python module for this already (which opens a file like a stream and if something changed then this stream is giving it out)? Is it smart to check a file constantly for updates? | Streaming of a log text file with constant updates | 0 | 0 | 0 | 189 |
20,519,669 | 2013-12-11T12:52:00.000 | 1 | 0 | 0 | 0 | python,grid,wxpython,sum,auto-update | 20,523,503 | 1 | true | 0 | 1 | You will need to catch a cell related events. I would recommend EVT_GRID_EDITOR_HIDDEN as that event fires after you have left a cell where you had double-clicked it to start an edit. You could also use EVT_GRID_CELL_CHANGE, although just because you changed cells doesn't mean you did an edit.
Either way, in the event handler, you would grab the first two cell values, sum them and insert them into the third cell. | 1 | 0 | 0 | I have a wx.grid with size 1*3 (1 row, 3 columns). Cell 1*1 has value 3, cell 1*2 has value 5 and I want cell 1*3 to display sum of the other cells (3 + 5 = 8). And I want cell 1*3 to autoupdate its value as cell 1*1 and cell 1*2 changes. How to do this wit wxpython grid? | How to display sum of 2 cell values in another cell and autorefresh it as cell values change in wxpython grid? | 1.2 | 0 | 0 | 163 |
20,521,456 | 2013-12-11T14:14:00.000 | 1 | 0 | 0 | 1 | python | 36,706,017 | 4 | false | 0 | 0 | I was having the same issue. The code works in the IDLE but not on double click. I ran the script through the command prompt and it gave me an error that the IDLE didn't find. Windows didn't like the ascii characters I was printing. I removed them and the script started to work on double click again. | 1 | 5 | 0 | I always ran my scripts on windows by double-clicking them. However after I reinstalled my python versions this is not happenning. My python installations are on C:\Python27 and C:\Python33. PATH has C:\Python27\ in it. If I try to run a script from cmd, it works ok. But when I double-click any .py file nothing happens.
I am completely clueless as I don't use windows often for scripting.
What can be the reason for that? | Python scripts stopped running on double-click in Windows | 0.049958 | 0 | 0 | 7,440 |
20,522,465 | 2013-12-11T15:00:00.000 | 0 | 1 | 0 | 0 | python,python-3.3,distutils | 20,535,929 | 1 | false | 0 | 0 | No distutils version supports test integration: it’s a setuptools add-on.
unittest in 2.7 and 3.2 gained support for auto-discovering tests, so even if you can’t run python setup.py test there’s still python -m unittest. | 1 | 0 | 0 | Is there a way to run unittests for a module with setup.py using distutils? python3.3 distutils doesn't seem to support the 'test_suite' option:
In setup.py I have the following code:
test_suite = 'test.run_tests', | How to run unittest with distutils in python3.3 | 0 | 0 | 0 | 175 |
20,524,025 | 2013-12-11T16:03:00.000 | 1 | 0 | 0 | 0 | python,django | 20,525,176 | 2 | true | 1 | 0 | I do not recommend using Django if you are not interested in using a database. Having written that disclaimer, if you insist on still using it, you can just scan over the documentation and identify what is still available to you if you do not have a database:
You can use Django's security features to help protect against clickjacking, cross site request forgeries, etc.
You can take advantage of Django's support for internationalization if you want to support multiple languages on your website.
You can have Django handle validation of any forms you have on your website.
...basically you can create a static website that takes advantage of the rapid prototyping enabled by a framework built using Python. | 1 | 0 | 0 | I recently got into Django out of curiosity after developing for quite a while w/ Ruby on Rails and Node.js, and found that it's splendid for working w/ databases. Django is primarily known for working with databases and every tutorial I've ever found on it has included databases. Django supports not requiring databases however, and, just out of curiosity since I'm still rather inexperienced w/ Django, what would be some practical uses w/ Django w/out requiring databases? | What would be the more practical uses for a Django application w/out a database? | 1.2 | 0 | 0 | 70 |
20,528,082 | 2013-12-11T19:19:00.000 | 1 | 0 | 0 | 0 | python,validation,user-interface,checkbox,tkinter | 20,528,169 | 2 | false | 0 | 1 | Don't use checkboxes; use radoibuttons instead. The behavior of checkboxes and radiobuttons is well established -- checkboxes allow you to select N of N choices, radiobuttons are designed to allow you to select exactly 1 of N. Don't violate this design pattern or your users will be confused.
To make radiobuttons work, create a single StringVar and associate it with two or more radiobuttons. All of the radiobuttons that share the same variable will work as a set, allowing only one to be selected. | 1 | 0 | 0 | I am trying to create a multiple choice quiz in Tkinter.
Each question has between 2-4 different answers all displayed as checkboxes, how do I ensure the user can only tick one check box and not all of them?
Thanks | Checkbox validation: how do i ensure user can only tick one box only? | 0.099668 | 0 | 0 | 1,562 |
20,528,328 | 2013-12-11T19:33:00.000 | 9 | 0 | 0 | 0 | python,arrays,numpy | 41,922,008 | 9 | false | 0 | 0 | Building on abarnert's answer for n-dimensional case:
TL;DR: np.logical_or.reduce(np.array(list)) | 1 | 129 | 1 | Numpy's logical_or function takes no more than two arrays to compare. How can I find the union of more than two arrays? (The same question could be asked with regard to Numpy's logical_and and obtaining the intersection of more than two arrays.) | Numpy `logical_or` for more than two arguments | 1 | 0 | 0 | 64,891 |
20,528,456 | 2013-12-11T19:41:00.000 | 0 | 0 | 0 | 0 | c++,python,opengl,blender,vtk | 25,369,835 | 1 | true | 0 | 1 | This was solved by requesting that Blender perform a triangulization of the mesh prior to the export operation.
The mangling was due to Blender performing implicit triangulization of quads, resulting in faces which were stored as 4 non-coplanar points. By forcing explicit triangulation in advance, I was able to successfully perform the export and maintain model integrity/manifold-ness. The holes that were being experienced were due to the implicit triangulation not being copied by the exporter and thus causing loss of data. | 1 | 0 | 1 | Using VTK version 5.1, I'm having some issues with some models not displaying correctly in OpenGL.
The process for getting the models into VTK is a bit roundabout, but gets there and is fairly simple. Each model is a manifold mesh comprised of only quads and tris.
Blender models->custom export format containing points, point normals, and polygons
Custom export format->Custom C++ parser->vtkPolyData
vtkPolydata->vtkTriangleFilter->vtkStripper->vtkPolyDataNormals->final product
As our final product was showing irregular and missing normals when it was rendered, I had VTK write the object to a plaintext file, which I then parsed back into Blender using python.
Initial results were that the mesh was correct and matched the original model, however, when I used the Blender "select non-manifold" option, about 15% of the model showed to be nonmanifold. A bit of reading around online suggested the "remove doubles" as a solution, which did in fact solve the issue of making the mesh closed, but the normals were still irregular.
So, I guess I'm hoping there are some additional options/functions/filters I can use to ensure the models are properly read and/or processed through the filters. | vtk Filters causing point doubling and mangling normal values | 1.2 | 0 | 0 | 175 |
20,529,081 | 2013-12-11T20:16:00.000 | 1 | 0 | 1 | 0 | python | 20,529,123 | 1 | false | 0 | 0 | Are you referring to the icons you see in the IDE (Integrated Development Environment)? If yes, then the spanner icon usually refers to Properties of the item / control / file in context. It could also mean Settings although the most common icon for Settings is the Gear icon. | 1 | 3 | 0 | This may sound like a dumb question, but I have searched everywhere and have come up with nothing. What does it mean to use a spanner or screwdriver when programming? | In programming, what is a spanner or screwdriver? | 0.197375 | 0 | 0 | 160 |
20,529,878 | 2013-12-11T21:04:00.000 | 5 | 0 | 0 | 0 | python,python-3.x,time-complexity | 20,531,306 | 3 | false | 0 | 0 | This is too long for a comment: in CPython, a yield passes its result to the immediate caller, not directly to the ultimate consumer of the result. So, if you have recursion going R levels deep, a chain of yields at each level delivering a result back up the call stack to the ultimate consumer takes O(R) time. It also takes O(R) time to resume the R levels of recursive call to get back to the lowest level where the first yield occurred.
So each result yield'ed by walk() takes time proportional to the level in the directory tree at which the result is first yield'ed.
That's the theoretical ;-) truth. In practice, however, this makes approximately no difference unless the recursion is very deep. That's because the chain of yields, and the chain of generator resumptions, occurs "at C speed". In other words, it does take O(R) time, but the constant factor is so small most programs never notice this.
This is especially true of recursive generators like walk(), which almost never recurse deeply. Who has a directory tree nested 100 levels? Nope, me neither ;-) | 2 | 3 | 0 | I've to calculate the time-complexity of an algorithm, but in it I'm calling os.walk which I can't consider as a single operation but many.
The sources of os.walk left me confused as the filetree may be ordered in many ways (1.000.000 files in a folder or a file per folder and 1.000.000 folders.
I'm not an expert on time-complexities, I can't be sure on what I should consider as only an operation or many, so this left me stuck. Don't count the simlink flag, which I assume set to false to ignore them.
PD: I found the sources of os.walk in the Komodo IDE, but I wouldn't know how to find them as the javadocs. | Time complexity of os.walk in Python | 0.321513 | 0 | 0 | 2,735 |
20,529,878 | 2013-12-11T21:04:00.000 | 2 | 0 | 0 | 0 | python,python-3.x,time-complexity | 20,530,026 | 3 | false | 0 | 0 | os.walk (unless you prune it, or have symlink issues) guarantees to list each directory in the subtree exactly once.
So, if you assume that listing a directory is linear on the number of entries in the directory,* then if there are N total directory entries in your subtree, os.walk will take O(N) time.
Or, if you want the time for walk to produce each value (the root, dirnames, filenames tuple): if those N directory entries are split among M subdirectories, then each of the M iterations takes amortized O(N/M) time.
* Really, that's up to your OS, C library, and filesystem not Python, and it can be much worse than O(N) for older filesystems… but let's ignore that. | 2 | 3 | 0 | I've to calculate the time-complexity of an algorithm, but in it I'm calling os.walk which I can't consider as a single operation but many.
The sources of os.walk left me confused as the filetree may be ordered in many ways (1.000.000 files in a folder or a file per folder and 1.000.000 folders.
I'm not an expert on time-complexities, I can't be sure on what I should consider as only an operation or many, so this left me stuck. Don't count the simlink flag, which I assume set to false to ignore them.
PD: I found the sources of os.walk in the Komodo IDE, but I wouldn't know how to find them as the javadocs. | Time complexity of os.walk in Python | 0.132549 | 0 | 0 | 2,735 |
20,532,581 | 2013-12-12T00:10:00.000 | 0 | 0 | 0 | 0 | unicode,wxpython,wxwidgets,wxstyledtextctrl | 20,545,016 | 1 | true | 0 | 1 | Saving code uses wxConvCurrent, so you could try setting it to wxConvUTF8 to ensure that UTF-8 is used even when it's not the encoding of the current locale (which is never the case under Windows).
Unfortunately I'm not sure if you can change wxConvCurrent from Python. If you can't, the simplest solution would probably be to just write wxStyledTextCtrl::GetValue() to a file yourself instead of relying on its SaveFile() method. Don't forget to call SetSavePoint() after saving successfully if you do this. | 1 | 1 | 0 | I have a wxPython GUI with a wx.stc.StyledTextCtrl text editor. It is possible that its content contain some unicode characters such as Greek letters. I have noticed that StyledTextCtrl.SaveFile() method works only when the content has no unicode characters. Otherwise the saved file ends up being an empty file.
I tried calling StyledTextCtrl.SetCodePage(stc.STC_CP_UTF8) but it did not help either. So, I am not quite sure whether there is a bug in the StyledTextCtrl code, or that I am missing something. Any help is appreciated. | An issue with calling w.stc.StyledTextCtrl.SaveFile with a unicode content | 1.2 | 0 | 0 | 255 |
20,532,621 | 2013-12-12T00:14:00.000 | 0 | 0 | 1 | 0 | python,python-2.7,visual-studio-2012,pandas,ptvs | 45,561,466 | 4 | false | 0 | 0 | I faced the same issue, but just hitting 'Continue' will cause it to be ignored and the code execution will proceed in the usual way.
Or you could uncheck the "Break when this exception type is user-handled" option that comes up in the dialog box displaying the error. | 3 | 5 | 1 | I am dealing with a very silly error, and wondering if any of you have the same problem. When I try to import pandas using import pandas as pd I get an error in copy.py. I debugged into the pamdas imports, and I found that the copy error is thrown when pandas tries to import this: from pandas.io.html import read_html
The exception that is throwns is:
un(shallow)copyable object of type <type 'Element'>
I do not get this error if I try to straight up run the code and not use the PVTS debugger. I am using the python 2.7 interpreter, pandas version 0.12 which came with the python xy 2.7.5.1 distro and MS Visual Studio 2012.
Any help would be appreciated. Thanks! | Pandas import error when debugging using PVTS | 0 | 0 | 0 | 3,689 |
20,532,621 | 2013-12-12T00:14:00.000 | 0 | 0 | 1 | 0 | python,python-2.7,visual-studio-2012,pandas,ptvs | 37,602,619 | 4 | false | 0 | 0 | I had a system crash while developing a PTVS app and then ran into this problem, re-running the Intellisense 'refresh DB' cleared it. | 3 | 5 | 1 | I am dealing with a very silly error, and wondering if any of you have the same problem. When I try to import pandas using import pandas as pd I get an error in copy.py. I debugged into the pamdas imports, and I found that the copy error is thrown when pandas tries to import this: from pandas.io.html import read_html
The exception that is throwns is:
un(shallow)copyable object of type <type 'Element'>
I do not get this error if I try to straight up run the code and not use the PVTS debugger. I am using the python 2.7 interpreter, pandas version 0.12 which came with the python xy 2.7.5.1 distro and MS Visual Studio 2012.
Any help would be appreciated. Thanks! | Pandas import error when debugging using PVTS | 0 | 0 | 0 | 3,689 |
20,532,621 | 2013-12-12T00:14:00.000 | 0 | 0 | 1 | 0 | python,python-2.7,visual-studio-2012,pandas,ptvs | 36,753,326 | 4 | false | 0 | 0 | I had the same problem for a while, disabling "Debug standard library" didn't help, then I downloaded the latest version of Python (3.4), pip installed the libs (for example NLTK), and it worked! | 3 | 5 | 1 | I am dealing with a very silly error, and wondering if any of you have the same problem. When I try to import pandas using import pandas as pd I get an error in copy.py. I debugged into the pamdas imports, and I found that the copy error is thrown when pandas tries to import this: from pandas.io.html import read_html
The exception that is throwns is:
un(shallow)copyable object of type <type 'Element'>
I do not get this error if I try to straight up run the code and not use the PVTS debugger. I am using the python 2.7 interpreter, pandas version 0.12 which came with the python xy 2.7.5.1 distro and MS Visual Studio 2012.
Any help would be appreciated. Thanks! | Pandas import error when debugging using PVTS | 0 | 0 | 0 | 3,689 |
20,533,293 | 2013-12-12T01:22:00.000 | 0 | 0 | 1 | 0 | python,pyinstaller | 20,533,369 | 3 | false | 0 | 0 | As Ms Turdy mentioned, you should run it in a command prompt or terminal first, if it will have the same behavior as the exe.
You can execute a python script with python -m pdb script.py and it will enter into the debugger. You run it by pressing C for continue, then it will break when it raises the exception. | 1 | 0 | 0 | I have written a programme by python which is successfully tested under eclipse.Then I used pyinstaller to excute it as a .exe file. When the programme raise the exception ,the cmd window will quit immediately. I want to stay in this window to take a good look at this exception. How can I do it ? Thank you. | How to stay in the cmd window when the exception has been raised? | 0 | 0 | 0 | 172 |
20,539,077 | 2013-12-12T09:03:00.000 | 0 | 0 | 0 | 0 | wxpython | 20,569,837 | 1 | false | 0 | 1 | You may not be able to customize that particular control very well as it wraps the native widget (if it exists). Instead, I would recommend switching to BalloonTip or possibly better, the SuperToolTip. Both of these controls are generic, pure Python controls. That means that they usually have additional customization and they are definitely easier to modify yourself if you need to because they're Python instead of C++.
There are demos of both of those controls in the wxPython demo package. You should check them out and see if they work better for you. | 1 | 0 | 0 | Is it possible to create a custom tooltip with no border using wx.TipWindow. I can do this with PopupTransientWindow but I could not figure out the which event to use to dismiss the popup when the mouse is moved away from a given rectangle bound(not clicked but moved away). | Tooltip without border in wxpython | 0 | 0 | 0 | 131 |
20,539,363 | 2013-12-12T09:18:00.000 | 0 | 0 | 1 | 0 | ipython,usability,parentheses,tab-completion | 20,542,483 | 1 | true | 0 | 0 | On 1.1.0:
In[0]:/SPACE my_exTAB
-----> my_extremely_long_function_with_no_args()
Entering SPACE after / will work on a release after 0.8.4. 0.13.0 has it fixed. I cannot pinpoint the exact version it was introduced.
Still my expectation is not fulfilled (i.e. working without the SPACE in between) | 1 | 1 | 0 | In ipython (version 0.8.1 on Ubuntu 8.04, version 1.1.0 on Ubuntu 12.04) when forcing automatic parentheses by starting the function name with / will make useless the TAB completion.
E.g.
In[0]:/my_exTAB
In[0]:/my_extremely_long_function_with_no_args
-----> my_extremely_long_function_with_no_args()
Is there a setting for keeping the tab completion? | Forcing automatic parentheses in ipython loses tab completion | 1.2 | 0 | 0 | 121 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.