Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2013-04-02 13:41:48.363 | Python 2.7 "import hashlib" segmentation fault | Whenever I try to import hashlib in Python 2.7 I get a segmentation fault. I've installed openssl version 1.0.0, pyOpenssl version .10, and recompiled python with the ssl lines uncommented in Modules/Setup, pointing to the correct path for the libraries and include files for openssl.
I've run ldd on all the libraries I... | hashlib uses libcrypto for hash algorithms if it can find libcrypto while building python.
I suspect somehow it's ending up using a different libcrypto at runtime vs. build time. | 1.2 | true | 1 | 2,472 |
2013-04-02 21:38:21.317 | How do you create a table with Sqlalchemy within a transaction in Postgres? | I'm using Sqlalchemy in a multitenant Flask application and need to create tables on the fly when a new tenant is added. I've been using Table.create to create individual tables within a new Postgres schema (along with search_path modifications) and this works quite well.
The limitation I've found is that the Table.cre... | (Copy from comment)
Assuming sess is the session, you can do sess.execute(CreateTable(tenantX_tableY)) instead.
EDIT: CreateTable is only one of the things being done when calling table.create(). Use table.create(sess.connection()) instead. | 1.2 | true | 1 | 2,473 |
2013-04-02 22:07:01.097 | How to improve Cython performance? | I am doing my first steps with Cython, and I am wondering how to improve performance even more.
Until now I got to half the usual (python only) execution time, but I think there must be more!
I know cython -a and I already typed my variables. But there is still a lot in yellow in my function. Is this because cython doe... | I believe you can benefit by using math functions from libc as you are calling np.sqrt and np.floor on scalars. This has not only the Python call overhead but there are different code paths in the numpy ufuncs for scalars and arrays. So that involves at least a type switch. | 1.2 | true | 1 | 2,474 |
2013-04-03 13:23:56.107 | Is it possible to upgrade a Python package on the fly? | I maintain an in-house Python package which is used by some not-really-technical people in the company. Being that their needs (or rather, their wants) change on an almost-daily basis, I have to update the library pretty often, and I create new installers for them too often for their liking.
The lib provides a high-le... | Have the "import X" call run a code in a wrapper library. The code the time of import would check the database for a new version of the library and download if it has changed. Then it can in turn import the downloaded library or import the existing library. There may be issues with this on frozen code so you might h... | 0.201295 | false | 1 | 2,475 |
2013-04-03 17:45:46.800 | Date grouping python | Can i borrow someone's brain for this issue.
I have got data and their relevant timestamps.
I am interested in grouping them by 5min frequency however i can only start the grouping on 00:00 format. I mean 13:23:27 (hours) would need to be group with 13:25:00 data and then it will be 13:30:00, 13:35:00 etc
Do you know... | Convert to seconds, divide by 300 and use the integer portion as your grouping. | 0.265586 | false | 1 | 2,476 |
2013-04-03 18:23:23.957 | How to get head revision number of a file, or the changelist number when it was checked in / changed | I'm writing a python app that connects to perforce on a daily basis. The app gets the contents of an excel file on perfoce, parses it, and copies some data to a database. The file is rather big, so I would like to keep track of which revision of the file the app last read on the database, this way i can check to see if... | Several options come to mind.
The simplest approach would be to always let your program use the same client and let it sync the file. You could let your program call p4 sync and see if you get a new version or not. Let it continue if you get a new version. This approach has the advantage that you don't need to remembe... | 1.2 | true | 1 | 2,477 |
2013-04-04 16:59:03.153 | weird scalling on displayport monitors in wx.python | I have been developing a wx.python application. at some point i need to create a fullscreen, no taskbar, etc. wx.Frame which has exactly the size of the screen and display in it a bimap which has exactly the dimensions of the screen, so one pixel of the bitmap equals exactly one pixel of the screen.
everything has... | So i found the solution of the problem.
It is because when I was plugging the different monitor - for some reason the DPI was changing. Adjusting the settings in the windows display control panel did the thing. | 1.2 | true | 2 | 2,478 |
2013-04-04 16:59:03.153 | weird scalling on displayport monitors in wx.python | I have been developing a wx.python application. at some point i need to create a fullscreen, no taskbar, etc. wx.Frame which has exactly the size of the screen and display in it a bimap which has exactly the dimensions of the screen, so one pixel of the bitmap equals exactly one pixel of the screen.
everything has... | Correct EDID values does not necessarily mean that the system is running it in that display mode. Have you checked the system's display properties or screen resolution properties to ensure that the system is driving the display at its full resolution? Your symptoms sound to me like it is running at a lower resolution... | 0.201295 | false | 2 | 2,478 |
2013-04-04 18:50:18.277 | What other alternative are there to stemming? | Given a list of words like this ['add', 'adds', 'adding', 'added', 'addition'], I want to stem all of them to the same word 'add'. That means stemming all different verb and noun forms of a word (but not its adjective and adverb forms) into one.
I couldn't find any stemmer that does that. The closest one I found is P... | The idea of stemming is to reduce different forms of the same word to a single "base" form. That is not what you are asking for, so probably no existing stemmer is (at least not by purpose) fullfilling your needs. So the obvious solution for your problem is: If you have your own custom rules, you have to implement them... | 0 | false | 1 | 2,479 |
2013-04-04 20:30:55.023 | What's the working directory when using IDLE? | So, I'm learning Python and would like to create a simple script to download a file from the internet and then write it to a file. However, I am using IDLE and have no idea what the working directory is in IDLE or how to change it. How can I do file system stuff in IDLE if I don't know the working directory or how to c... | Old question I know but maybe the OP's question was not answered? If you want Idle's File Open/Save/Save As menu items to interact with a particular folder, you need to set the CWD before starting Idle. So, assuming you have a folder on Windows "C:\Users<username>\Documents\python\my_project", then at a cmd prompt type... | 0 | false | 2 | 2,480 |
2013-04-04 20:30:55.023 | What's the working directory when using IDLE? | So, I'm learning Python and would like to create a simple script to download a file from the internet and then write it to a file. However, I am using IDLE and have no idea what the working directory is in IDLE or how to change it. How can I do file system stuff in IDLE if I don't know the working directory or how to c... | This will depend on OS and how IDLE is executed.
To change the (default) CWD in Windows, right click on the Short-cut Icon, go to "Properties" and change "Start In". | 0.386912 | false | 2 | 2,480 |
2013-04-06 20:06:36.410 | Django Oscar. How to add product? | I'm a beginner in Python and Django.
I have installed django-oscar. Then I Configured it and started the server, it works.
Now, I don't understand how to add a product?
At the dashboard there is a button Create new product. But in order to add new product it asks to select product class and I can not find any product c... | You have to add atleast one product class /admin/catalogue/productclass/ | -0.101688 | false | 1 | 2,481 |
2013-04-07 09:04:38.290 | How do I get a variable name from HTML back into my python | Hey guys how do I get a variable name from HTML back into my python. So I have this variable {{file}} in my html which I need to pass back into the python file in order the function to work. | You can send variables to the server using methods POST or GET.
Perhaps you can get the right answer if you elaborate more or showing us some of your code. | 0 | false | 1 | 2,482 |
2013-04-07 16:30:16.057 | PYQT4 - How do I compile and import a qrc file into my program? | I'm having trouble importing a resource file. I'm using pyqt4 with monkey studio and I am trying to import a png image. When I run the program I get an import error like
ImportError: No module named icon_rc
I know that I have to compile it using pyrcc4 but I don't understand how to do this can anybody help please. I... | you could try with pyside as well like:
--- pyside-rcc -o input.qrc output.py | 0 | false | 2 | 2,483 |
2013-04-07 16:30:16.057 | PYQT4 - How do I compile and import a qrc file into my program? | I'm having trouble importing a resource file. I'm using pyqt4 with monkey studio and I am trying to import a png image. When I run the program I get an import error like
ImportError: No module named icon_rc
I know that I have to compile it using pyrcc4 but I don't understand how to do this can anybody help please. I... | In Pyqt5 this command can be used Pyrcc5 input_file.qrc -o Out_file.py
We need to convert that qrc file into python file and then it can be imported to your code | 0.386912 | false | 2 | 2,483 |
2013-04-08 01:58:24.963 | How to queue up scheduled actions | I am trying to set up some scheduled tasks for a Django app with celery, hosted on heroku. Aside from not know how everything should be configured, what is the best way to approach this?
Let's say users can opt to receive a daily email at a time of their choosing.
Should I have a scheduled job that run every, say 5 mi... | It depends on how much accuracy you need. Do you want users to select the time down to the minute? second? or will allowing them to select the hour they wish to be emailed be enough.
If on the hour is accurate enough, then use a task that polls for users to mail every hour.
If your users need the mail to go out accurat... | 1.2 | true | 1 | 2,484 |
2013-04-08 07:14:14.227 | Fill wx.Choice at runtime | I was wondering how I fill a wxChoice with content at runtime.
When creating the GUI I do not have the information of the content since it depends on the users what directory to choose.
What am I doing? The user will have to select a directory from a wx.DirDialog. The event handler refers to a function that will search... | I personally think that SetItems(listOfItems) is the quickest way of doing it and it works for several other widget types as well, such as ComboBox. The answer that Thomas mentions forces the developer to clear the widget and then Append individual items OR use AppendItems to add a list of items. Either way, that's a 2... | 0.201295 | false | 1 | 2,485 |
2013-04-08 13:08:24.320 | Access Model.objects methods from Django templates | Let's say I have a "Person" model.
How can I display the number of persons in my system in a template?
In standard code, I would do: Person.objects.count().
But how to do this in a template? | You save the output of Person.objects.count() in a variable and pass it on to your template from the corresponding view. | 1.2 | true | 1 | 2,486 |
2013-04-08 15:28:34.383 | Flexible Arguments in Python | This has probably been asked before, but I don't know how to look up the answer, because I'm not sure what's a good way to phrase the question.
The topic is function arguments that can semantically be expressed in many different ways. For example, to give a file to a function, you could either give the file directly, o... | No, there is not more or less a "standard" approach to this. | 0 | false | 1 | 2,487 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | Look for files on your main python folder that you may create in names like "threading.py", "tkinter.py" and other names that overlapps with your Lib folder and move/delete them | 0.183429 | false | 11 | 2,488 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | I had this same problem today. I found another stack overflow post where someone had a tkinter.py file in the same directory as python, and they fixed it by removing that tkinter.py file. When I looked in my python directory, I realized I had created a script called random.py and put it there. I suspect that it confl... | 0.477299 | false | 11 | 2,488 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | I had exactly the same issue :"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."
I found the answer from this stackoverflow site. I created a file named string.py and that classhed with the normal python files. I removed the strin... | 0.037089 | false | 11 | 2,488 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | Adding to existing answers - it is actually possible to have firewall block IDLE when not running with -n flag. I haven't used IDLE for a few months and decided to try if it works properly with newly installed python3.3 (on Linux Mint 13 x86). In between I made iptables setup much more aggressive and apparently it bloc... | 0.11086 | false | 11 | 2,488 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | I had the same error message. Error not seen after I added all the *.exe filea to be found in the Python install directory to the Windows firewall exception list. | 0.037089 | false | 11 | 2,488 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | I finally got it to work when I disabled ALL firewalls and antivirus, because some antivirus ALSO have firewall control. Ex. avast | 0.037089 | false | 11 | 2,488 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | Using Windows 7 64 installation of Python 2.7.10 Shell I solved the above problem by opening the program as an administrator. | 0.037089 | false | 11 | 2,488 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | I came across this problem too. There are two things you can do
You may already have a process running call pythonw.exe which prevents IDLE from being starting. End that task and try running IDLE again
Use pythonwin or python command line | 0 | false | 11 | 2,488 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | Remove copy.py in your folder if you happen to have one | 0.037089 | false | 11 | 2,488 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | I'm running Windows 7 64-bit. I saw the same errors today. I tracked down the cause for me, hopefully it'll help you. I had IDLE open in the background for days. Today I tried to run a script in IDLE, and got the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall so... | 0.354916 | false | 11 | 2,488 |
2013-04-08 20:19:01.520 | Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection | Resolved April 15, 2013.
In windows 7 (64bit) windows explorer when I right clicked a Python file and selected "edit with IDLE" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firew... | i have the Same issue on os win7 64Bit and Python 3.1 and find a workaround because i have a Project with many .py files and just one gave this error. - Workaround is to copy a working file and copy the contents from not working file to working file. (i used Another editor as idle. The Problem with that workaround is..... | 0 | false | 11 | 2,488 |
2013-04-09 09:51:49.383 | Gtalk Service On Google App Engine Using Python | I searched a lot for built web service like Google Talk, using Google Application Engine and Python.
For that first step is to check the status of online user on the Gmail. I found many code of it on python using XMPP library but it work only on python not using Google Application Engine.
There is also suggestion of us... | You can only send messages from your app. There are two options: your_app_id@appspot.com or anything@your_app_id.appspotchat.com.
If you wanted to behave like an arbitrary xmpp client, you'll have to use a third party xmpp library running over HTTP and handle the authentication with the user's XMPP server. | 0 | false | 2 | 2,489 |
2013-04-09 09:51:49.383 | Gtalk Service On Google App Engine Using Python | I searched a lot for built web service like Google Talk, using Google Application Engine and Python.
For that first step is to check the status of online user on the Gmail. I found many code of it on python using XMPP library but it work only on python not using Google Application Engine.
There is also suggestion of us... | I think you are confused. Python runs ON appengine. Also theres a working java xmpp example provided. | 0 | false | 2 | 2,489 |
2013-04-09 11:16:33.607 | Python site packages: How can I maintain for both 2.x and 3.x version | I understand that we can install different version of Python on a same box - but there are packages that are not supported common to both.
So if I have two version of Python(2.x and 3.x) installed how can I automatically have packages deployed correctly for each version of Python using pip? | At least on Arch Linux, and presumably on other distros, there are two separate packages for pip, which if both installed give you two different commands: pip and pip3. Running pip ... will always install to the Python 2 site-packages, and pip3 ... to the Python 3 site-packages. This works both for system-wide packages... | 1.2 | true | 1 | 2,490 |
2013-04-09 14:02:08.560 | matplotlib bar graph black - how do I remove bar borders | I'm using pyplot.bar but I'm plotting so many points that the color of the bars is always black. This is because the borders of the bars are black and there are so many of them that they are all squished together so that all you see is the borders (black). Is there a way to remove the bar borders so that I can see th... | Set the edgecolor to "none": bar(..., edgecolor = "none") | 1.2 | true | 1 | 2,491 |
2013-04-09 14:40:57.920 | Python - Releasing/replacing a string variable, how does it get handled? | Say i store a password in plain text in a variable called passWd as a string.
How does python release this variable once i discard of it (for instance, with del passWd or passWd= 'new random data')?
Is the string stored as a byte-array meaning it can be overwritten in the memoryplace that it originally existed or is it... | Unless you use custom coded input methods to get the password, it will be in many more places then just your immutable string. So don't worry too much.
The OS should take care that any data from your process is cleared before the memory is allocated to another process. This may of course fail if the page is copied to d... | 1.2 | true | 2 | 2,492 |
2013-04-09 14:40:57.920 | Python - Releasing/replacing a string variable, how does it get handled? | Say i store a password in plain text in a variable called passWd as a string.
How does python release this variable once i discard of it (for instance, with del passWd or passWd= 'new random data')?
Is the string stored as a byte-array meaning it can be overwritten in the memoryplace that it originally existed or is it... | I finally whent with two solutions.
ld_preload to replace the functionality of the string handling of Python on a lower level.
One other option which is a bit easier was to develop my own C library that has more functionality then what Python offers through the standard string handling.
Mainly the C code has a shread()... | 0 | false | 2 | 2,492 |
2013-04-11 21:14:50.750 | How do I make sure a twitter bot doesn't retweet the same tweet multiple times? | I'm writing a simple Twitter bot in Python and was wondering if anybody could answer and explain the question for me.
I'm able to make Tweets, but I haven't had the bot retweet anyone yet. I'm afraid of tweeting a user's tweet multiple times. I plan to have my bot just run based on Windows Scheduled Tasks, so when the ... | Twitter is set such that you can't retweet the same thing more than once. So if your bot gets such a tweet, it will be redirected to an Error 403 page by the API. You can test this policy by reducing the time between each run by the script to about a minute; this will generate the Error 403 link as the current feed of ... | 0 | false | 2 | 2,493 |
2013-04-11 21:14:50.750 | How do I make sure a twitter bot doesn't retweet the same tweet multiple times? | I'm writing a simple Twitter bot in Python and was wondering if anybody could answer and explain the question for me.
I'm able to make Tweets, but I haven't had the bot retweet anyone yet. I'm afraid of tweeting a user's tweet multiple times. I plan to have my bot just run based on Windows Scheduled Tasks, so when the ... | You should store somewhere the timestamp of the latest tweet processed, that way you won't go throught the same tweets twice, hence not retweeting a tweet twice.
This should also make tweet processing faster (because you only process each tweet once). | 0 | false | 2 | 2,493 |
2013-04-12 10:38:47.273 | Python async and CPU-bound tasks? | I have recently been working on a pet project in python using flask. It is a simple pastebin with server-side syntax highlighting support with pygments. Because this is a costly task, I delegated the syntax highlighting to a celery task queue and in the request handler I'm waiting for it to finish. Needless to say this... | How about simply using ThreadPool and Queue? You can then process your stuff in a seperate thread in a synchronous manner and you won't have to worry about blocking at all. Well, Python is not suited for CPU bound tasks in the first place, so you should also think of spawning subprocesses. | 0.386912 | false | 1 | 2,494 |
2013-04-12 13:42:26.770 | Remove PIL from raspberry Pi | Hi i am getting an error
"IOError: decoder jpeg not available"
when trying to implement some functions from the PIL.
What i would like to do is remove PIL, install the jpeg decoder then re-install the PIL, but im lost as to how to uninstall the PIL?
Any help would be greatly appreciated | You can do this to re-install PIL
pip install -I PIL | 1.2 | true | 1 | 2,495 |
2013-04-12 23:50:01.147 | Enthought Canopy: how do I add to the PATH? | Running Enthought Canopy appears to de-activate the normal .profile PATH information (OS X) for python programs run within the Canopy environment. I need to make locations searchable for user files.
How to do this is not explained in the user manual. There are several possible places to enter such information (eg th... | The problem described also occurs in a Win 7 Canopy installation.
I tried to place files to be imported in several of the locations provided in sys.path().
['',
'C:\Users\Owner\AppData\Local\Enthought\Canopy\User\Scripts\python27.zip',
'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x... | 0 | false | 2 | 2,496 |
2013-04-12 23:50:01.147 | Enthought Canopy: how do I add to the PATH? | Running Enthought Canopy appears to de-activate the normal .profile PATH information (OS X) for python programs run within the Canopy environment. I need to make locations searchable for user files.
How to do this is not explained in the user manual. There are several possible places to enter such information (eg th... | On Mac OSX 10.6.8 this worked
% launchctl setenv PYTHONPATH /my/directory:/my/other/directory
then launch Canopy and you should see /my/directory and /my/other/directory on sys.path | 0.101688 | false | 2 | 2,496 |
2013-04-13 17:43:58.443 | In PyCharm, webpages refresh in debug mode, not in run mode | I'm writing a GAE webapp using Python 2.7, webapp2, and Jinja. In development, I run the app under PyCharm 2.7.1 on a Max OSX 10.7.5 (Lion). I'm currently using Chrome 26.0.1410.43 as my browser.
I don't know for sure that this is a PyCharm issue, but that's my best guess. Here's a description:
When I use the "Debug" c... | It turns out that this wasn't a refresh or caching issue but a timing issue. Under some circumstances, GAE uses an update algorithm that incurs a delay before transactions are applied. In Run mode, the new page was being requested before the update was completed; in Debug mode, enough time passed for the update to be c... | 1.2 | true | 1 | 2,497 |
2013-04-14 15:58:54.593 | How to store datas while connection is lost? | I've a client (currently in C#, a python version in progress) which gets computer data such as CPU %, disk space etc. and sends it to a server. I don't know how to manage if my client looses connection with the server. I have to continue collecting information but where to stock them? Just a buffer? Is using a log file... | I'd create a log file on the HDD and put in the last recorded data and time. Then just read it out when needed again. | 0 | false | 1 | 2,498 |
2013-04-15 07:03:12.683 | Python list implementation | How are the lists implemented in python? I mean how is it possible to append an element in constant time and also get an item in constant time? Can anyone please tell how to do it in C? | A simple implementation is to use a preallocated buffer and a counter for the number of elements.
When the buffer is filled up and you want to append element, then you allocate a bigger buffer (e.g. twice as big) and copy the old one's data into the new one.
Thus the append operation is not strictly O(1), but it's amor... | 0 | false | 1 | 2,499 |
2013-04-15 11:19:00.780 | Why was sys.modules chosen to be a dictionary? | When Python wants to import a module it is first going to look in sys.modules. But since the key-value pairs of dictionaries are not in a fixed order, how can you ever know for certain which of two identically named modules in sys.modules will be imported first? | Since it is a mapping, there can be no identically named modules in sys.modules.
That is the point. If use the statement import foo and sys.modules['foo'] exists, that module is returned. No file access is needed, no top-level code for that module needs to be run.
If foo is not present, then the sys.path determines whe... | 1.2 | true | 1 | 2,500 |
2013-04-15 13:38:24.707 | Can Python Script be included in PHP? | I want to implement one logic which is written in python, this code will do some searching stuffs, and I have a website done in PHP. can any one tell me whether I can include python script in PHP? if yes , how can I do that ?
Criteria :
Input to the python script will come from php or html [either text or file]. an... | If you have access to exec, you can run the python interpreter. However, that's:
Overkill
Not necessarily wise
A major waste of resources
If your logic is simple, why don't you write it in PHP? Furthermore, if your logic is not simple...why don't you make an API of some sort to access it and favour communication rath... | 0.386912 | false | 1 | 2,501 |
2013-04-15 15:25:01.153 | Can we calculate Net Salary with openERp | In our company we decided to use openERP
We now working to customize openERP with our work ... we can use it successfully in warehouse dept. and sallies dept.
My question is how to make openERP calculate monthly Net Salary
with deduct if the Employee absence or leave the work or if we decided to add bonus
and if... | Install hr_payroll module. Flow is as below:
Employee --> Contracts --> Salary Structure --> Salary Rules
In Contract, You can set Working Schedule for that employee with Wage. You need to configure Salary Structure with Salary Rules as per your need. Salary rules for Bonus, expenses, etc.
In that Salary structure, You... | 0.386912 | false | 1 | 2,502 |
2013-04-15 23:09:39.393 | Ipython and Curses on Windows | I have been trying all sorts of sourceforge projects that try to port GNU functionality to Windows, with the goal to create a very GNU aware Ipython profile providing the best terminal environment I know how (on Windows that is).
How close is QtConsole to having the ability of running something like Curses through the ... | No, it's not really in sight. The Qt console has some support for control characters, so it can do things like coloured text, but it's definitely not enough to support curses, and we're not really interested in going down that route.
The code is all in the open if you want to try to make it into a full terminal emulato... | 1.2 | true | 1 | 2,503 |
2013-04-16 00:21:57.840 | web2py. no such table error | I have an error no such table: mytable, even though it is defined in models/tables.py. I use sqlite. Interesting enough, if I go to admin panel -> my app -> database administration then I see a link mytable, however when I click on it then I get no such table: mytable.
I don't know how to debug such error?
Any ideas? | web2py keeps the structure it thinks the table has in a separate file. If someone has manually dropped the table, web2py will still think it exists, but of course you get an error when you try to actually use the table
Look for the *.mytable.table file in the databases directory | 1.2 | true | 1 | 2,504 |
2013-04-16 10:34:48.980 | get PID of QProcess with python on windows | Is there some way to read the PID of a process started with QProcess.start(...)? QProcess::pid() returns sip.voidptr and there's not much I can do with it (or I don't know how).
I want to have the PID to have the possibility to make the window active later on. | pid() function is provided to keep old source code working.
Use processId() instead.
Returns the native process identifier for the running process, if available. If no process is currently running, 0 is returned.
Note: Unlike processId(), pid() returns an integer on Unix and a pointer on Windows. | 0 | false | 1 | 2,505 |
2013-04-17 08:44:18.023 | File upload and store, then proccessing with remote worker | My question is about web application architecture.
I have a website, my users can upload files and from this files I need to create some kind of reports for users. When user upload file it stored on my server where website hosted. File path stored in Django model field. Worker is on another server and i need to get acc... | There are few interesting options.
As example, you can add additional reupload workers step for deploy process. It'll guarantee
consistence between deployed application and workers.
Using own (rest) api is great idea, i like it even more than sharing models between different beings | 0 | false | 2 | 2,506 |
2013-04-17 08:44:18.023 | File upload and store, then proccessing with remote worker | My question is about web application architecture.
I have a website, my users can upload files and from this files I need to create some kind of reports for users. When user upload file it stored on my server where website hosted. File path stored in Django model field. Worker is on another server and i need to get acc... | Why do you really need the exact same models in your workers? You can design the worker to have a different model to perform it's own actions on your data. Just design API's for your data and access it separately from your main site.
If it really necessary, Django app can be shared across multiple projects. So you can ... | 0 | false | 2 | 2,506 |
2013-04-17 12:02:54.653 | Why are python libraries not supplied as pyc? | If I am right in understanding, Python compile files are cross platform. So why are most libraries released requiring a build and install?
Is it laziness on the part of the distributer, or am I wrong in saying they could simply distribute the pyc files? If this isn't the case, how do I distribute a python script file t... | They are cross platform, but not cross-version and not cross-implementation. In other words, different CPython versions could have trouble with one and the same .pyc file.
And if you look at other implementations such as PyPy, IronPython, Jython etc., you won't have any luck with .pyc files at all.
Besides, .pyc files ... | 0.496174 | false | 2 | 2,507 |
2013-04-17 12:02:54.653 | Why are python libraries not supplied as pyc? | If I am right in understanding, Python compile files are cross platform. So why are most libraries released requiring a build and install?
Is it laziness on the part of the distributer, or am I wrong in saying they could simply distribute the pyc files? If this isn't the case, how do I distribute a python script file t... | The process of creating a .pyc file from a .py file is done transparently by the interpreter. The reason some installers generate them at install time is purely to avoid them having to be generated the first time the script is run - usually for speed reasons, but also so that the .pyc can end up in a system-wide (non-u... | 0 | false | 2 | 2,507 |
2013-04-17 19:33:17.090 | How to load a redis database after | I understand how to save a redis database using bgsave. However, once my database server restarts, how do I tell if a saved database is present and how do I load it into my application. I can tolerate a few minutes of lost data, so I don't need to worry about an AOF, but I cannot tolerate the loss of, say, an hour's ... | You can stop redis and replace dump.rdb in /var/lib/redis (or whatever file is in the dbfilename variable in your redis.conf). Then start redis again. | 0.386912 | false | 1 | 2,508 |
2013-04-18 17:04:06.800 | Escaping dollar sign in ipython notebook | I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.
ANy ... | You can escape $ with math mode by using a backslash. Try $\$$ | 0.565852 | false | 4 | 2,509 |
2013-04-18 17:04:06.800 | Escaping dollar sign in ipython notebook | I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.
ANy ... | If you use <span>$</span>, MathJax won't process it as a delimiter. You should be able to enter that in Markdown. For example, I've used that here: $ This is not math $. | 0.386912 | false | 4 | 2,509 |
2013-04-18 17:04:06.800 | Escaping dollar sign in ipython notebook | I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.
ANy ... | Put two backslashes in front of dollar signs. For example:
Some prices: \\$3.10, \\$4.25, \\$8.50.
(running Jupyter notebook server 5.7.0) | 1 | false | 4 | 2,509 |
2013-04-18 17:04:06.800 | Escaping dollar sign in ipython notebook | I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.
ANy ... | I'm aware that this topic is old, but it's still somehow the first google result and its answers are incomplete.
You can also surround the $ with `backticks`, the same way that you would display code in Jupyter.
So $ becomes `$`, and should display without error | 0.173164 | false | 4 | 2,509 |
2013-04-18 20:09:11.477 | How does find procedure work in python | I wish to create a 'find' procedure myself, which is capable of finding a sub-string in a string and it also should be able to read a string backward and give position of match- just like the original find function in python.
I am unable to figure out what logic should I use- also I don't know how the original find fu... | There is a simple solution to this problem, however there are also much faster solutions which you may want to look at after you've implemented the simple version. What you want to be doing is checking each position in the string you're search over and seeing if the string you're searching for starts there. This is ine... | 0.081452 | false | 1 | 2,510 |
2013-04-20 13:06:17.230 | How to Combine Html + CSS code with python function? | I have zero experience with website development but am working on a group project and am wondering whether it would be possible to create an interaction between a simple html/css website and my python function.
Required functionality:
I have to take in a simple string input from a text box in the website, pass it into... | First you will need to understand HTTP. It is a text based protocol.
I assume by "web site" you mean User-Agent, like FireFox.
Now, your talking about an input box, well this will mean that you've already handled an HTTP request for your content. In most web applications this would have been several requests (one for... | 0.201295 | false | 1 | 2,511 |
2013-04-20 15:50:04.093 | Json output with none, one or many dictionaries in a tubple - best way to manipulate? (Bitstamp transaction list) | Hy, still a python beginner, I am looking for help pointing me in the right direction:
I am trying to build sort of a database of api answers from bitstamp listing the transactions on bitstamp.
The api-call gives all transactions in a time frame, output is json.
After processing the api output with json.loads() output ... | Suppose all transactions contain the same structure, it is perfectly fine to use a for item in json_tuple to deal with the transactions.
It all really depends on what you want to do with the data set. | 0 | false | 1 | 2,512 |
2013-04-20 21:25:03.313 | Getting POST values from a Django request when they start with the same string | I have a form on my site that allows the user to add names to an object. The user can hit a plus button to add another name or a minus button to remove a name. I need to be able to easily pull all POST variables that start with a name.
For example. A user adds two names so we have two text boxes names 'name0' and 'name... | yeah, like Daniel said, so I add the next
posted = [{k.replace('person__',''):v} for k, v in request.POST.items() if k.startswith('person__')]
then I can use a model form with posted data | 0 | false | 1 | 2,513 |
2013-04-21 13:44:00.213 | IronPython - error while invoking | Im trying to write an IronPython app that uses a COM object interface. I manage to import it using clr.AddReference, and manage also to call some of the functions, create objects, etc.
However at a certain point when trying to call a function I get :
StandardError: Error while invoking GetK300RZ.
(GetK300RZ being the... | This is just for anyone who ever runs into this question with a similar problem - the problem was that the parameters of the functions were of type out and ref in C#. The function could not be invoked because there was no corresponding function signature. I had to use clr.Reference[] to explicitly create references for... | 1.2 | true | 1 | 2,514 |
2013-04-22 03:54:10.280 | How to determine if user is currently active on site in Django | Is there a way to see if a user is currently logged in and active on a site?
For example, I know you can check the authentication token of the user and see if he is still 'actively logged in', but this doesn't tell me much, since the user could technically be logged in for two weeks, though only actively on the site fo... | There are several ways to determine user activity:
1) Use javascript to send periodic requests to server.
+: You will be able to determine user activity despite he actively working on site or just keep open window.
-: Too many requests.
2) Use django middleware
-: Can`t determine user activity if he keeps only open wi... | 1.2 | true | 1 | 2,515 |
2013-04-22 07:12:34.847 | Detecting computer/program shutdown in Python? | I have a Python script that runs in a loop regularly making adjustments to my lighting system. When I shut down my computer, I'd like my script to detect that, and turn off the lights altogether.
How do I detect my computer beginning to shut down in Python?
Or, assuming Windows sends Python a "time to shut down" notic... | This is the wrong way to go about performing action at system shutdown time. The job of the shutdown process is to stop running processes and then switch off power; if you try to detect this happening from within your program and react by getting some last action in, it's a race between the OS and your program who gets... | 0.999967 | false | 1 | 2,516 |
2013-04-22 08:00:03.783 | Encryption -- how to do it | issue
I am writing an application in python. It takes care of contacts and other information about a person. I want to prompt the user for a master key every time that he/she wants to perform a major operation. I have everything figured out. The whole application is ready and works well. But I store the master key in a... | You don't need, or even want, complex encryption for passwords--and what you are describing is a password, not a key (it just grants access, it doesn't encrypt the data). Current best practice is to store passwords salted and hashed. That is, when the user creates a new account and enters a password, you build a strin... | 0.16183 | false | 1 | 2,517 |
2013-04-22 13:51:49.267 | Python will not run in windows powershell | I am trying to get python.exe to run in interactive mode in windows powershell. I have added c:\python27 to my PATH and when I type "python" in into the shell a new command prompt window opens running python, rather than running within powershell. This is a problem as when I run things like "python --version" it launch... | I just solved this issue after nearly pulling my hair out. Thought I would share. In windows system > advanced system settings > environment variables there are two places to change the PATH, user variables and system variables. I added ";c:\python27" as the value for PATH in both. It now works | 1.2 | true | 2 | 2,518 |
2013-04-22 13:51:49.267 | Python will not run in windows powershell | I am trying to get python.exe to run in interactive mode in windows powershell. I have added c:\python27 to my PATH and when I type "python" in into the shell a new command prompt window opens running python, rather than running within powershell. This is a problem as when I run things like "python --version" it launch... | I'm not expert in PS, but when I need to use python in interactive mode in windows powershell, I use something like this (version of python is 2.7.3, I didn't change env variables):
PS C:\Python27> ./python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "cre... | 0 | false | 2 | 2,518 |
2013-04-22 16:08:44.813 | How to make this bot work? | I got a bot in Python that I've made to simulate a player playing a flash web game. The thing is, I've used an approach that requires specific screen coordinates to work, and there is a pop-up I need to click to advance to the next state that seems to appear in random positions every time it shows up.
Do you know how t... | I'd try saving the button you have to click as a pic, then scan your entire screen and use PIL to match the pic you saved to the button you have to press; from there you should be able to retrieve the coordinates. | 0.386912 | false | 1 | 2,519 |
2013-04-22 16:53:50.257 | how to pack already installed software in symbain 3rd version? | in Symbian 2nd Version, there's a software called Sisboom which works with python, with Sisboom it was possible to get the installer file of already installed software, now i've Symbian 3rd Version, and i got the same software, and i'm unbale to do the same, please help... | With Symbian there is something called platform security, and from it there is something called data caging which is preventing access to the executable folders and some other ones as well, thus there are not really possibilities on 3rd party supplying such an application, and therefor I would suppose there would not b... | 0 | false | 1 | 2,520 |
2013-04-23 07:09:17.810 | How to protect yourself from package disappearance on pip? | We heavily use virtualenv and pip in our build system to isolate our Python deliveries. Everything is fully automated and was working fine until now.
A couple of days ago, an issue appeared: an indirect dependency was moved to a private bitbucket repository, and pip started to prompt for a login/password. Which was dra... | In reality, there is a more severe danger: pip downloads packages via plain HTTP, end even if you force it to use HTTPS, it can not check id the certificate is valid (since Python stdlib does not have the functionality either). That is someone in the middle can mask the expected package with something that you will rea... | 0.386912 | false | 1 | 2,521 |
2013-04-23 14:07:30.260 | how to make minepy.MINE run faster? | I have a numerical matrix of 2500*2500. To calculate the MIC (maximal information coefficient) for each pair of vectors, I am using minepy.MINE, but this is taking forever, can I make it faster? | first, use the latest version of minepy. Second, you can use a smaller value of "alpha" parameter, say 0.5 or 0.45. In this way, you will reduce the computational time in despite of characteristic matrix accuracy.
Davide | 0.386912 | false | 1 | 2,522 |
2013-04-23 23:35:56.020 | Drawing average line in histogram (matplotlib) | I am drawing a histogram using matplotlib in python, and would like to draw a line representing the average of the dataset, overlaid on the histogram as a dotted line (or maybe some other color would do too). Any ideas on how to draw a line overlaid on the histogram?
I am using the plot() command, but not sure how to d... | I would look at the largest value in your data set (i.e. the histogram bin values) multiply that value by a number greater than 1 (say 1.5) and use that to define the y axis value. This way it will appear above your histogram regardless of the values within the histogram. | 0.265586 | false | 1 | 2,523 |
2013-04-24 11:53:50.473 | Differentiating logged-in users as admin and normal user in Google App Engine? | I am developing an app in GAE. Application provides different view depending upon whether logged-in user is admin or normal user. I want to use 'Google Apps domain' as Authentication Type. So that all user of my domain can login into the application and use it.
Here, application can't differentiate a logged-in as admin... | Why is what you describe not possible? The object representing the logged-in user is an instance of google.appengine.api.users.User. That object has a user_id property. You can use that ID as a field in your own user model, to which you can add a field determining whether or not they are an admin. | 1.2 | true | 1 | 2,524 |
2013-04-24 17:45:33.487 | How to make pip install python modules in my current python2.7 installation on mac (instead of 2.6)? | I've got a mac on which I installed python using macports. I like it this way because I could manually install numpy, scipy etc. without needing to mess with pre-built packages like enthought. I now wanted to install web.py, but after trying to install it through both easy_install and pip, I can't import it on the inte... | If you are using macports for python then you should install pip and easy_install via macports as well. You seem to have a non macports pipon your path.
installing py27-pip will give you a pip-2.7 executable script on your path, similarly for easy_install.
The macports version have the python version in their name so a... | 1.2 | true | 1 | 2,525 |
2013-04-25 18:28:30.950 | How to design extendable error codes? | UPDATE:
The error codes here is not such a return value of a function. Actually I am not discussing using exception or error codes for error handling. I am trying to figure out, using what pattern to organize errors.
What I am really doing is like error codes showing on Windows blue screen. Back to the very old time,... | For every exception your app throws you insert it into a db, your error code is the id for that record, that's what the user sees. Obviously same exception gets the same id. The plugin information you need is stored in the DB | 0 | false | 1 | 2,526 |
2013-04-25 19:18:44.700 | DateTime field OpenErp | I need a field that can contain a number and text on it, like for example "6 months", i've used the datetime field, but it only takes a formatted date on it, and if use integer or float it takes a number, and char takes only a character, so how can i have an integer and a char on the same field? | What you want currently not possible in openerp. But you can use one trick, you should use two fields one is integer for giving interval and other in char fields for giving months, days etc. You can get this example on Scheduler , ir.cron object of opener. | 1.2 | true | 1 | 2,527 |
2013-04-26 07:29:53.907 | train nltk classifier for just one label | I am just starting out with nltk, and I am following the book. Chapter six is about text classification, and i am a bit confused about something. In the examples (the names, and movie reviews) the classifier is trained to select between two well-defined labels (male-female, and pos-neg). But how to train if you have on... | I see two questions
How to train the system?
Can the system consist of "sci-fi" and "others"?
The answer to 2 is yes. Having a 80% confidence threshold idea also makes sense, as long as you see with your data, features and algorithm that 80% is a good threshold. (If not, you may want to consider lowering it if not a... | 0 | false | 2 | 2,528 |
2013-04-26 07:29:53.907 | train nltk classifier for just one label | I am just starting out with nltk, and I am following the book. Chapter six is about text classification, and i am a bit confused about something. In the examples (the names, and movie reviews) the classifier is trained to select between two well-defined labels (male-female, and pos-neg). But how to train if you have on... | You can simply train a binary classifier to distinguish between sci-fi and not sci-fi
So train on the movie plots that are labeled as sci-fi and also on a selection of all other genres. It might be a good idea to have a representative sample of the same size for the other genres such that not all are of the romantic co... | 1.2 | true | 2 | 2,528 |
2013-04-26 17:09:14.607 | Tkinter PhotoImage: References in Memory? | I have a program that displays many tkinter PhotoImages at once (relevant: I'm not using PIL). It currently has several screens, and when the play gets to the edge it loads a new tilemap, creating a bunch more photoimages in the currentTiles array after clearing the old contents. I'm fairly certain there are no other r... | Every created image is assigned a unique name (unless you specify the name of the image when creating). This unique name is generated by using a counter, which increases monotonically. | 0.673066 | false | 1 | 2,529 |
2013-04-26 20:44:12.867 | how to write a client/server app in heroku | I am quite new to heroku and I reached a bump in my dev...
I am trying to write a server/client kind of application...on the server side I will have a DB(I installed postgresql for python) and I was hoping I could reach the server, for now, via a python client(for test purposes) and send data/queries and perform basic ... | Heroku is for developing Web (HTTP, HTTPS) applications. You can't deploy code that uses socket to Heroku.
If you want to run your app on Heroku, the easier way is to use a web framework (Flask, CherryPy, Django...). They usually also come with useful libraries and abstractions for you to talk to your database. | 0.995055 | false | 1 | 2,530 |
2013-04-27 13:11:21.470 | What happens when you have an infinite loop in Django view code? | Something that I just thought about:
Say I'm writing view code for my Django site, and I make a mistake and create an infinite loop.
Whenever someone would try to access the view, the worker assigned to the request (be it a Gevent worker or a Python thread) would stay in a loop indefinitely.
If I understand correctly, ... | Yes, your analysis is correct. The worker thread/process will keep running. Moreover, if there is no wait/sleep in the loop, it will hog the CPU. Other threads/process will get very little cpu, resulting your entire site on slow response.
Also, I don't think server will send any timeout error to client explicitly. If t... | 0 | false | 1 | 2,531 |
2013-04-29 21:45:52.480 | Python HSAudioTag for WMA files always returns 0? | I'm using the Python library HSAudioTag, and I'm trying to read the track number in my files, however, without fail, the file returns 0 as the track number, even if it's much higher. Does anybody have any idea how to fix this?
Thanks. | The solution was to go into the code, and change the following lines to: Line 118: self.track = u'' Lines 149-152: self.track = int(self._fields.get(TRACK, u'')) + 1 | 1.2 | true | 1 | 2,532 |
2013-04-30 06:29:22.357 | Receive an unknown number of UDP messages | Let's say a source A is sending me an unknown number of messages using UDP. How can I intercept all those messages? This is the complete scenario:
Send 7 messages
Wait for their ACKs
Process ACKs
Send another batch
Repeat...
Problems: (1) I don't know how many messages arrive, some may get lost and some are repeated,... | You could have a message loop continuously listening and processing received packets and putting them on a queue then read them at your leisure...
However you would need to implement you own ACKs taking into account the possibilities of lost and duplicates (if your application is concerned about them).. Which begs the ... | 0 | false | 1 | 2,533 |
2013-04-30 07:48:53.237 | Check if my Python has all required packages | I have a requirements.txt file with a list of packages that are required for my virtual environment. Is it possible to find out whether all the packages mentioned in the file are present. If some packages are missing, how to find out which are the missing packages? | You can run pip freeze to see what you have installed and compare it to your requirements.txt file.
If you want to install missing modules you can run pip install -r requirements.txt and that will install any missing modules and tell you at the end which ones were missing and installed. | 0.986614 | false | 1 | 2,534 |
2013-05-02 09:23:38.437 | Password Protection Python | I have a small python program which will be used locally by a small group of people (<15 people).But for accountability, i want to have a simple username+password check at the start of the program ( doesn't need to be super secure).For your information, I am just a beginner and this is my first time trying it.When i se... | You could use htpasswd which is installed with apache or can be downloaded seperately. Use subprocess.check_output to run it and you can create Python functions to add users, remove them, verify they have given the correct password etc. Pass the -B option to enable salting and you will know that it's secure (unlike if ... | -0.101688 | false | 1 | 2,535 |
2013-05-03 13:17:57.133 | Getting near objects. Django + Badoo | I have the following situation.
I keep track of a user's longitude and latitude using ios.
I send the longitude and latitude coordinates to a django server.
How can I use these longitude and latitude coordinates to determine what objects are near?
Basically how can I use these coordinates to determine the list of othe... | You keep track of all users, and you show all users whose coordinates are of a similar value.
Yes, that's a generic answer, but it is a very generic question.
I would not be surprised if there are modules for Django doing this already. | 0 | false | 1 | 2,536 |
2013-05-04 14:16:10.410 | Evaluate javascript on a local html file (without browser) | This is part of a project I am working on for work.
I want to automate a Sharepoint site, specifically to pull data out of a database that I and my coworkers only have front-end access to.
I FINALLY managed to get mechanize (in python) to accomplish this using Python-NTLM, and by patching part of it's source code to fi... | Well, in the end I came down to the following possible solutions:
Run Chrome headless and collect the html output (thanks to koenp for the link!)
Run PhantomJS, a headless browser with a javascript api
Run HTMLUnit; same thing but for Java
Use Ghost.py, a python-based headless browser (that I haven't seen suggested an... | 0.386912 | false | 1 | 2,537 |
2013-05-04 14:33:03.533 | Changing days and nights with pygame | I try to write a simple 2d game using python 3.x and pygame 1.9.2. I want to simulate changing of days/nights. I have got in-game time(like real, but faster) and I'd like to make my screen darker at exact time but have no ideas how to do it. Could you advice me how to reduce the brightness of my screen or other ways ho... | Setting gamma or screen brightness is not the best way to go.
When your game gets more complicated, it's easier if you use the technique ecline6 suggested:
changing your background image.
But since it is a loaded image i suppose, you can use this trick:
Let's say you have a background surface. Every 10s you will fire ... | 1.2 | true | 1 | 2,538 |
2013-05-04 21:52:00.340 | Using Python3 with Pymongo in Eclipse Pydev on Ubuntu | I am currently trying to run Pydev with Pymongo on an Python3.3 Interpreter.
My problem is, I am not able to get it working :-/
First of all I installed Eclipse with Pydev.
Afterwards I tried installing pip to download my Pymongo-Module.
Problem is: it always installs pip for the default 2.7 Version.
I read that you sh... | You can install packages for a specific version of Python, all you need to do is specify the version of Python you want use from the command-line; e.g. Python2.7 or Python3.
Examples
Python3 pip your_package
Python3 easy_install your_package. | 1.2 | true | 1 | 2,539 |
2013-05-06 10:35:58.180 | Delete the first three rows of a dataframe in pandas | I need to delete the first three rows of a dataframe in pandas.
I know df.ix[:-1] would remove the last row, but I can't figure out how to remove first n rows. | A simple way is to use tail(-n) to remove the first n rows
df=df.tail(-3) | 0.429419 | false | 2 | 2,540 |
2013-05-06 10:35:58.180 | Delete the first three rows of a dataframe in pandas | I need to delete the first three rows of a dataframe in pandas.
I know df.ix[:-1] would remove the last row, but I can't figure out how to remove first n rows. | inp0= pd.read_csv("bank_marketing_updated_v1.csv",skiprows=2)
or if you want to do in existing dataframe
simply do following command | 0.249709 | false | 2 | 2,540 |
2013-05-06 11:03:22.373 | Gedit plugin for python autocomplete: how to install? | Of course I tried to copy the files in the .gnome2/gedit/plugins and in the .local/share/gedit/plugins directories.
But it doesn't work at all. How do I install the plugin?
I'm on Fedora 18. Lxde desktop manager. | If you have gedit3, have you checked that this is a plugin for gedit3, not gedit2?
Take a look at *.plugin file. It should say IAge=3. | 0 | false | 1 | 2,541 |
2013-05-06 19:46:51.760 | Google App Engine urlfetch loop | Can I make a loop in Google App Engine that fetches information from a site?
I have made a small code that already gets the information I want from the site, but I don't know how to make this code run every lets say, 20 minutes.
Is there a way to do this?
P.S.: I have looked at TaskQueue, but I'm not sure if it is mean... | Take a look at the GAE cron functionality. | 0.201295 | false | 1 | 2,542 |
2013-05-07 04:19:46.430 | Unable to get Python to POST on html | I've been trying to get my python code to post. I have tried using the Postman Plugin to test the post method and I would get a 405 method error. I am planning to have the user post the information and have it displayed.
Currently if I press submit I would get a error loading page, changing the form to get results in t... | You're getting '405 method not allowed' because the POST is going to the same url that served up the page, but the handler for that path (MainPage) does not have a post method.
That's the same diagnosis that you were given when you asked this question two hours earlier under a different user id.
Stepping back further t... | 0.673066 | false | 1 | 2,543 |
2013-05-07 18:34:18.953 | remember password functionality in python | basically, I want to have a login box, and the option to remember the password next time you log in. I know there are encryption modules out there, but they require a password to work in the first place. is there a way to get the password the user used to log into the computer, and use that to encrypt the password for ... | There is no way out. If the application does not ask the user for a password, then it is not securely storing passwords, it's only doing... "things". In that case, don't give the user a false sense of security, use cleartext.
A notable exception is the GNOME login keyring (and equivalent on other platforms) not asking ... | 0.135221 | false | 2 | 2,544 |
2013-05-07 18:34:18.953 | remember password functionality in python | basically, I want to have a login box, and the option to remember the password next time you log in. I know there are encryption modules out there, but they require a password to work in the first place. is there a way to get the password the user used to log into the computer, and use that to encrypt the password for ... | You cannot get the password the user used to log in to the computer.
And, if you could, you would not want to store it.
In fact, the OS doesn't even have the user's password. The OS has a hash of it, and when the user logs in, it hashes what the user types and checks that it matches.
Also, if you ask the user to log i... | 0.135221 | false | 2 | 2,544 |
2013-05-08 04:58:56.767 | Custom Tokenizer for pylucene which tokenizes text based only on underscores (retains spaces) | I am new to pylucene and I am trying to build a custom analyzer which tokenizes text on the basis of underscores only, i.e. it should retain the whitespaces.
Example: "Hi_this is_awesome" should be tokenized into ["hi", "this is", "awesome"] tokens.
From various code examples I understood that I need to override the in... | Got it working eventually by creating a new tokenzier which considered every char other than an underscore as part of the token generated (basically underscore becomes the separator)
class UnderscoreSeparatorTokenizer(PythonCharTokenizer):
def __init__(self, input):
PythonCharTokenizer.__init__(self, input)
d... | 0.995055 | false | 1 | 2,545 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.