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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
24,944,626 | 2014-07-24T21:51:00.000 | 2 | 1 | 1 | 0 | python,python-3.x | 24,944,710 | 2 | false | 0 | 0 | They do two different things; compare bytes(1234) with struct.pack("!H", 1234). The first just provides a 4-byte string representation of the number bytes object with 1,234 null bytes; the second provides a two-byte string with the (big-endian) value of the integer.
(Edit: Struck out irrelevant Python 2 definition of b... | 2 | 3 | 0 | I'm just curious here, but I have been using bytes() to convert things to bytes ever since I learned python. It was until recently that I saw struct.pack(). I didn't bother learning how to use it because I thought It did essentially did the same thing as bytes(). But it appears many people prefer to use struct.pack(). ... | Python-bytes() vs struct.pack() | 0.197375 | 0 | 0 | 1,956 |
24,944,626 | 2014-07-24T21:51:00.000 | 3 | 1 | 1 | 0 | python,python-3.x | 24,944,749 | 2 | true | 0 | 0 | bytes() does literally what the name implies:
Return a new “bytes” object, which is an immutable sequence of
integers in the range 0 <= x < 256
struck.pack() does something very different:
This module performs conversions between Python values and C structs represented as Python strings
While for some inputs thes... | 2 | 3 | 0 | I'm just curious here, but I have been using bytes() to convert things to bytes ever since I learned python. It was until recently that I saw struct.pack(). I didn't bother learning how to use it because I thought It did essentially did the same thing as bytes(). But it appears many people prefer to use struct.pack(). ... | Python-bytes() vs struct.pack() | 1.2 | 0 | 0 | 1,956 |
24,944,869 | 2014-07-24T22:10:00.000 | 1 | 0 | 0 | 0 | database,django,mysql-python,django-database | 24,997,975 | 2 | false | 1 | 0 | For working inside virtualenv you need to install
pip install MySQL-python==1.2.5 | 2 | 0 | 0 | I am developing a system that will need to connect from a remote mysql database on the fly to do a specific task. To accomplish this, I am thinking to use Mysql-db module in python. Since the remote database is not part of the system itself I do not prefer to add it on the system core database settings (DATABASES setti... | Django Database Module | 0.099668 | 1 | 0 | 56 |
24,944,869 | 2014-07-24T22:10:00.000 | 0 | 0 | 0 | 0 | database,django,mysql-python,django-database | 24,997,774 | 2 | true | 1 | 0 | MySQLdb is the best way to do this. | 2 | 0 | 0 | I am developing a system that will need to connect from a remote mysql database on the fly to do a specific task. To accomplish this, I am thinking to use Mysql-db module in python. Since the remote database is not part of the system itself I do not prefer to add it on the system core database settings (DATABASES setti... | Django Database Module | 1.2 | 1 | 0 | 56 |
24,946,067 | 2014-07-25T00:13:00.000 | 3 | 0 | 1 | 0 | python,multiprocessing,python-3.4 | 26,242,741 | 2 | true | 0 | 0 | If you're using Eclipse and PyDev you need to include 'multiprocessing' as a forced builtin for the python interpreter. | 1 | 1 | 0 | I am porting a working application from Python 3.3 to 3.4 and have encountered a weird situation. The class multiprocessing.Process is not present in the download from python.org. Instead, in the multiprocessing.process module, I find a class multiprocessing.process.BaseProcess. The only trace of the old Process class ... | Where is multiprocessing.Process | 1.2 | 0 | 0 | 1,105 |
24,946,778 | 2014-07-25T01:44:00.000 | 0 | 1 | 0 | 1 | python,eclipse,shell,python-3.x,project | 24,947,778 | 2 | false | 0 | 0 | Based on current information, I would suggest you to run it this way in OSX
1) Bring up the Terminal app
2) cd to the location where bla lives
3) run python bla/blah/projMain.py
Show us stacktrace if the above failed. | 1 | 0 | 0 | Eclipse can run a python project rather than just one .py file. Is it possible to run an entire project from Python 3.x shell. I looked into it a little, but I didn't really find a way. I tried just running the .py file with the main using exec(open('bla/blah/projMain.py')) like you would any python file. All of my mod... | Run Python project from shell | 0 | 0 | 0 | 880 |
24,951,431 | 2014-07-25T08:35:00.000 | 3 | 0 | 0 | 0 | postgresql,roles,plpython | 24,958,698 | 2 | true | 0 | 0 | You're confusing operating system users and PostgreSQL users.
SECURITY DEFINER lets you run a function as the defining postgresql user. But no matter what PostgreSQL user is running the operating system user the back-end server runs as is always the same - usually the operating system user postgres.
By design, the Post... | 1 | 0 | 0 | I made a little PostgreSQL trigger with Plpython. This triggers plays a bit with the file system, creates and delete some files of mine. Created files are owned by the "postgres" unix user, but I would like them to be owned by another user, let's say foobar. Triggers are installed with user "foobar" and executed with u... | PostgreSQL trigger with a given role | 1.2 | 1 | 0 | 1,158 |
24,954,106 | 2014-07-25T10:53:00.000 | 0 | 0 | 1 | 0 | python,installation,kivy,suds | 25,000,617 | 2 | true | 0 | 1 | Are you by any chance running the Python 3 version of Kivy? Suds looks like it is abandondonware (last release in 2010) and likely does not have a Python3 port. You may have luck with the Python2.7 version of Kivy and pip installing suds, but keep in mind you will be relying on an apparently unsupported module (suds) f... | 1 | 1 | 0 | I am pretty new to python, my background is with VB visual studios, I am trying to develop a app in which I want to consume WCF service. Found Suds is the required python module.
I am using Kivy 1.8.0 and Eclipse with pydev on Windows 7 64bit. Could you please point me in correct direction on how to instal the package... | Kivy with suds - module installation | 1.2 | 0 | 0 | 396 |
24,956,390 | 2014-07-25T13:02:00.000 | 0 | 0 | 0 | 0 | python,elasticsearch,firewall,python-3.4 | 25,247,538 | 1 | true | 0 | 0 | It was the firewall caching that was causing the havoc! Once the caching was disabled for certain endpoints, the issue resolved itself. Painful! | 1 | 1 | 0 | For example when I have ids lookup and want to search one by by one to see if the document already exists or not. One of two things happen:
First -> first search request returns the correct doc and all the calls after that returns the same doc as first one even though I was searching for different Ids
Second -> first ... | ElasticSearch doesn't return hits when making consecutive calls - Python | 1.2 | 0 | 1 | 112 |
24,957,764 | 2014-07-25T14:12:00.000 | 1 | 0 | 1 | 0 | python,windows,sua | 24,960,688 | 1 | true | 0 | 0 | No, installing Subsystem for Unix-based Applications (Windows Services for Unix) doesn't change the behaviour of a binary distribution of Python in any way. The version of Python you're trying to use would have to be specifically built to support the Windows POSIX subsystem in order to take any advantage of it.
Microso... | 1 | 1 | 0 | When reading the Python docs, many libraries/functions indicate they work differently, or not at all, depending on the operating system.
Most of the libraries depend on whether the OS is POSIX compliant, or Win32.
When using the SUA package with Windows-7, does this allow python to enable/alter those
Posix-dependent ... | Python OS-dependent libraries: Windows 7 SUA | 1.2 | 0 | 0 | 190 |
24,958,237 | 2014-07-25T14:36:00.000 | 0 | 0 | 0 | 1 | python,pydev | 24,958,918 | 2 | true | 0 | 0 | Yes you can do that. Just type in the console what ever commands you want :). I usually have to right click then
Debug As >> Python run
PyDev is a little bit quirky, but you get used to it. | 1 | 0 | 0 | so far I used the Komodo IDE for Python development, but I'm now testing Eclipse with PyDev. Everything works fine, but there is one Komodo feature that I'm missing.
In Komodo I can inspect the running application in a debugger shell. I.e. after hitting a breakpoint I can not only read the content of variables, but I c... | Has PyDev an interactive shell (during debugging) as in Komodo? | 1.2 | 0 | 0 | 50 |
24,958,833 | 2014-07-25T15:06:00.000 | 15 | 0 | 1 | 0 | python,anaconda,conda | 43,454,479 | 4 | false | 0 | 0 | Before you proceed to conda update --all command, first update conda with conda update conda command if you haven't update it for a long time. It happent to me (Python 2.7.13 on Anaconda 64 bits). | 2 | 216 | 0 | Is there a way (using conda update) that I can list outdated packages and select or bulk update (compatible) packages in Anaconda?
It doesn't make much sense updating the packages individually as there are hundreds of them. | Bulk package updates using Conda | 1 | 0 | 0 | 118,886 |
24,958,833 | 2014-07-25T15:06:00.000 | 356 | 0 | 1 | 0 | python,anaconda,conda | 24,965,191 | 4 | true | 0 | 0 | You want conda update --all.
conda search --outdated will show outdated packages, and conda update --all will update them (note that the latter will not update you from Python 2 to Python 3, but the former will show Python as being outdated if you do use Python 2). | 2 | 216 | 0 | Is there a way (using conda update) that I can list outdated packages and select or bulk update (compatible) packages in Anaconda?
It doesn't make much sense updating the packages individually as there are hundreds of them. | Bulk package updates using Conda | 1.2 | 0 | 0 | 118,886 |
24,960,514 | 2014-07-25T16:40:00.000 | 3 | 0 | 1 | 0 | python,pip | 24,960,542 | 1 | true | 0 | 0 | Pip only installs packages that are not installed yet.
This does mean that even if a new version is available, old packages will be kept. You can pass the --upgrade flag to prevent that behavior and install the latest versions (but then pip will call pypi for every package in your requirements file, in order to identif... | 1 | 1 | 0 | I am wondering about this command pip install -r requirements.txt. Does pip install modules if they are not satisfied or does it try and install anyway even if the modules are already there? If it is the latter, than is there any way to write a shell script which checks if dependencies are satisfied and if not invoke p... | Python - Pip install requirements only if dependencies are not satisifed | 1.2 | 0 | 0 | 1,670 |
24,963,423 | 2014-07-25T19:47:00.000 | 2 | 0 | 1 | 0 | python,timedelta | 24,963,537 | 1 | false | 0 | 0 | Although the reviewer makes a valid point that in Python you can't tell by looking at the name of an object what type it is, I don't think this argument is applicable in this specific case - as this would be the case whether you pass a timedelta or int. Either way you won't be able to tell it's type. So I would ignore ... | 1 | 0 | 0 | I'm contributing to an open source project, and in there, I'm querying for objects that were updated recently, so I have a function that accepts a max_age object. The person reviewing my code has a slight preference for passing around time in seconds. While it's not a big issue, I see this as a learning opportunity for... | Is it better to accept timedeltas or number of seconds? | 0.379949 | 0 | 0 | 64 |
24,965,646 | 2014-07-25T22:52:00.000 | -2 | 0 | 0 | 0 | python,qt,python-3.x,pyqt | 24,965,943 | 2 | false | 0 | 1 | You have the right method if you want to directly access the data in memory. It is a C array, and has no python object associated, so it's a little tricky. You need: the start address from bits(), the depth() and the byteCount(). ctypes.string_at would give you access to the data there, which you would pass to a numpy ... | 1 | 0 | 0 | How can I get raw base64 PNG data from a PyQt4.QtGui.QImage object? The only method I can find that seems like it would help is bits(), but that just returns a sip.voidptr object and I have no idea where to go from there. | Convert PyQt4.QtGui.QImage object to base64 PNG data | -0.197375 | 0 | 0 | 1,434 |
24,966,803 | 2014-07-26T02:01:00.000 | 0 | 0 | 0 | 0 | python-3.x,pygame | 24,967,111 | 2 | false | 0 | 1 | You can use the pygame.APPACTIVE event. From the documentation for the pygame.display.iconify:
Then the display mode is set, several events are placed on the pygame event queue. pygame.QUIT is sent when the user has requested the program to shutdown. The window will receive pygame.ACTIVEEVENT events as the display gain... | 1 | 1 | 0 | I was playing Terraria the other day and in a new update they make the game pause when it's minimized. Obviously it's written in a different programme to python, but I was wondering if it was possible to replicate the effects. | Is there a way in pygame to make a programme pause when it's minimized? | 0 | 0 | 0 | 1,031 |
24,966,984 | 2014-07-26T02:41:00.000 | 3 | 0 | 0 | 0 | python,scikit-learn | 25,012,484 | 2 | false | 0 | 0 | There is no way around finding out which possible values your categorical features can take, which probably implies that you have to go through your data fully once in order to obtain a list of unique values of your categorical variables.
After that it is a matter of transforming your categorical variables to integer v... | 1 | 2 | 1 | I have a large dataset which I plan to do logistic regression on. It has lots of categorical variables, each having thousands of features which I am planning to use one hot encoding on. I will need to deal with the data in small batches. My question is how to make sure that one hot encoding sees all the features of eac... | One-hot encoding of large dataset with scikit-learn | 0.291313 | 0 | 0 | 3,004 |
24,971,400 | 2014-07-26T13:17:00.000 | 1 | 0 | 0 | 0 | python,numpy | 24,971,512 | 1 | true | 0 | 0 | Long answer short, when you need do huge mathematical operations, like vector multiplications and so on which requires writing lots of loops and what not, yet your codes gets unreadable yet not efficient you should use Numpy.
Few key benefits:
NumPy arrays have a fixed size at creation, unlike Python lists (which can ... | 1 | 1 | 1 | I'm a newbee of python. And recently I heard some people say that numpy is a good module for dealing with huge data.
I'm curious what can numpy do for us in the daily work.
As I know, most of us were not scientists and researchers, at what circumstances numpy can bring us benefit?
Can you share a good practice with me... | When should I use numpy? | 1.2 | 0 | 0 | 669 |
24,972,238 | 2014-07-26T14:51:00.000 | 1 | 1 | 0 | 1 | bash,emacs,path,pythonpath,.bash-profile | 24,980,728 | 1 | false | 0 | 0 | The issue might be that emacs, as many other programs you run, reads your login shell rc files, such as ~/.bash_login or ~/.profile, but not ~/.bashrc, where as your terminal also reads you user shell rc file: ~/.bashrc. | 1 | 1 | 0 | Usually I use my .bashrc file to load some functions for my bash environment. When I call these functions (that I created based on some frameworks I use). So, I play around with variables such as PATH and PYTHONPATH when I use the functions depending on the environment I'm working on.
So far so well with the terminal. ... | Emacs, bash, bashrc, functions and paths | 0.197375 | 0 | 0 | 594 |
24,973,568 | 2014-07-26T17:19:00.000 | 0 | 0 | 1 | 0 | python,django,eclipse,interpreter | 24,973,729 | 1 | false | 1 | 0 | On the menubar go to Window -> Preferences -> Pydev -> Interpreters -> Python
Remove the interpreter and click on Quick Auto Config.
That should do the trick. Make sure django is installed first. | 1 | 1 | 0 | I'm an eclipse noob.
After adding PyDev to eclipse, I try to create a "PyDev Django Project", but and I get the "Django not found" error.
I heard that you have to remove the python interpreter from eclipse, then add it again. But I don't know how to do that.
Can someone show me how to remove/add the python interpret... | How do I remove/add the python interpreter from eclipse? | 0 | 0 | 0 | 1,345 |
24,975,287 | 2014-07-26T20:32:00.000 | 2 | 0 | 1 | 0 | python,python-3.x | 24,975,313 | 1 | true | 0 | 0 | Python is duck-typed so you will never get the exact API for each variable that you can get from a strongly-typed (if you excuse me for using "strong-typed" as the opposite of "duck-typed") language such as Java.
However, most IDEs such as PyCharm and Eclipse PyDev do offer intelligent auto-completion that you would ex... | 1 | 0 | 0 | Is there a way/IDE to make python show the api for every type? (int, file etc...) just like in Eclipse for java where you write varname. and it shows you all the possible functions for it.
Thanks! | Python api for every type | 1.2 | 0 | 0 | 33 |
24,979,640 | 2014-07-27T09:28:00.000 | 1 | 1 | 0 | 0 | python,processing,paperjs,codea,pythonista | 38,641,689 | 1 | false | 0 | 0 | The ui module actually includes a lot of vector drawing functions, inside a ui.ImageContext. ui.ImageContext is a thin wrapper around part of one of the Objective-C APIs (maybe CALayer?) The drawing methods are designed to operate inside the draw method of a custom view class, but you can present these things in other ... | 1 | 4 | 0 | I've taken to creative coding on my iPad and iPhone using Codea, Procoding, and Pythonista. I really love the paper.js Javascript library, and I'm wondering how I might have the functionality that I find in paper.js when writing in Python.
Specifically, I'd love to have the vector math and path manipulation that paper.... | A paperjs-equivalent for python (specifically, Pythonista for iOS)? | 0.197375 | 0 | 0 | 901 |
24,980,103 | 2014-07-27T10:39:00.000 | 0 | 1 | 0 | 0 | python,google-app-engine,twitter,webapp2 | 25,003,619 | 1 | false | 1 | 0 | Are you talking about being logged in to Twitter.com or your app? If you have received oAuth access tokens by authenticating an app, then logging out of twitter.com won't 'log you out' of any apps, the tokens will remain valid until the user revokes the access. | 1 | 0 | 0 | I have managed to use oauth authentication and add a Sign in with Twitter functionality to a Google App Engine web app.
How should I verify, during the site navigation, if the user is still logged in Twitter? | Sign in with Twitter: how to verify the current user is stil logged in | 0 | 0 | 0 | 36 |
24,981,184 | 2014-07-27T12:56:00.000 | 20 | 0 | 0 | 0 | python,flask,filenames | 24,982,070 | 2 | true | 1 | 0 | Found the answer. request.files['upload'].filename gives the file name and extension in flask | 1 | 6 | 0 | lets say that I have <input name="upload" type="file"> and I am uploading picture.jpg. The question is how can I get the file name+extention? By other words the correct script for request.files.filename or request.upload.filename | get input file name and file extention using flask | 1.2 | 0 | 0 | 6,570 |
24,982,125 | 2014-07-27T14:50:00.000 | -1 | 0 | 1 | 0 | python,virtualenv,pythonpath | 24,982,206 | 4 | false | 0 | 0 | I assume that your other modules are at predictable path (relative to $0)
We can compute absolute path of $0
os.path.realpath(sys.argv[0])
then arrive at your module path and append it
sys.path.append(something) | 1 | 3 | 0 | I'm developing several different Python packages with my team. Say that we have ~/src/pkg1, ~/src/pkg2, and ~/src/pkg3. How do we add these to PYTHONPATH without each of us having to manage dot-files?
We could add, say, ~/src/site/sitecustomize.py, which is added once to PYTHONPATH, but is it "guaranteed" that there ... | Managing PYTHONPATH for development environment | -0.049958 | 0 | 0 | 1,555 |
24,985,127 | 2014-07-27T20:05:00.000 | 3 | 0 | 1 | 0 | python,algorithm,grid | 24,985,330 | 3 | true | 0 | 0 | You can hash all coordinate points (e.g. using dictionary structure in python) and then for each coordinate point, hash the adjacent neighbors of the point to find pairs of points that are adjacent and "merge" them. Also, for each point you can maintain a pointer to the connected component that that point belongs to (u... | 1 | 8 | 1 | Given a list of X,Y coordinate points on a 2D grid, what is the most efficient algorithm to create a list of groups of adjacent coordinate points?
For example, given a list of points making up two non-adjacent squares (3x3) on a grid (15x15), the result of this algorithm would be two groups of points corresponding to t... | Efficiently grouping a list of coordinates points by location in Python | 1.2 | 0 | 0 | 7,135 |
24,987,488 | 2014-07-28T01:49:00.000 | 0 | 0 | 0 | 0 | android,python,django,api | 24,988,398 | 6 | false | 1 | 0 | If I understand your question correctly, you have a Django installation on your laptop and you are able to hit a specific page/service locally using "localhost:8000/polls/link/2/" and it works fine. Now you want to access it from your mobile. Correct?
Replace the "localhost" with IP address of your laptop. For example,... | 2 | 0 | 0 | I am developing an android app. For local testing I have created a django server on my laptop. My problem is I am not able to call django apis from app code. For example, if I want to call any django server api from desktop I write "localhost:8000/polls/link/2/". Now how to replace this "localhost part of url" if calli... | Calling Django server api from android phone | 0 | 0 | 0 | 3,171 |
24,987,488 | 2014-07-28T01:49:00.000 | 0 | 0 | 0 | 0 | android,python,django,api | 47,381,501 | 6 | false | 1 | 0 | Firstly run the django server by typing python manage.py runserver 0.0.0.0:8000. Then check the ip of your private network i.e wlan ip using ifconfig command then simply replace your localhost text with that ip while calling API.
But above all make sure that your phone and lappy should be in same network. | 2 | 0 | 0 | I am developing an android app. For local testing I have created a django server on my laptop. My problem is I am not able to call django apis from app code. For example, if I want to call any django server api from desktop I write "localhost:8000/polls/link/2/". Now how to replace this "localhost part of url" if calli... | Calling Django server api from android phone | 0 | 0 | 0 | 3,171 |
24,988,880 | 2014-07-28T05:27:00.000 | -2 | 0 | 1 | 1 | python,python-2.7,python-idle | 24,988,918 | 2 | false | 0 | 0 | Right click on any .py file
Click Open With...
Click Choose a default program...
IfIDLEis on the list, click it.
else
Click Browse, and find the IDLE program
Click OK and voila! | 1 | 8 | 0 | I am on Windows 7. I have Python 2.7.8 (64 bit) installed. Today, I changed the default program that opens .py files from IDLE to Windows Command Processor and stupidly selected the checkbox that said "always use the selected program to open this kind of file".
What I want to do is change my default program back to I... | Set Python IDLE as Default Program to Open .py Extensions | -0.197375 | 0 | 0 | 22,665 |
24,989,488 | 2014-07-28T06:24:00.000 | 2 | 1 | 0 | 0 | php,python,cookies,web,login | 24,989,747 | 1 | true | 0 | 0 | Cookie are just cookies and browsers don't record (and possibly can't) how they were created. So when you create one cookie using PHP and then you would like to read the same cookie using any other language that support cookie, you should do it without a problem.
Of course you need to remember about cookie domain and p... | 1 | 2 | 0 | I'm busy creating a login system to the admin area of my new personal website. The site backend is written entirely in Python, owing to my knowledge of the language.
I have been looking at ways of tracking a user once they login so that the rest of the site knows they are logged in.
I can't get a definitive answer onli... | Are all cookies created equal? | 1.2 | 0 | 0 | 52 |
24,991,571 | 2014-07-28T08:52:00.000 | 1 | 0 | 1 | 1 | python,abaqus | 25,001,330 | 1 | false | 0 | 0 | on windows using abaqus cae will call the most recent version of abaqus installed. If you want to run on a specific version use this call instead abq6121 cae nogui = scriptname.py | 1 | 0 | 0 | I want to run a python script without Abaqus GUI and this already works well with the command:
abaqus cae nogui = scriptname.py
As I want to include a subroutine I have to run it in Abaqus version 12-1 but I have also version 13-1 installed (running the script in cae, I always got an error while using 13-1 but not with... | Run script using a certain version of Abaqus | 0.197375 | 0 | 0 | 1,939 |
24,993,048 | 2014-07-28T10:16:00.000 | 2 | 0 | 0 | 0 | javascript,python,angularjs,client-server | 24,993,506 | 2 | true | 1 | 0 | It doesn't have much to do with Python, really. Your javascript code is executed on the client's brower, and all it can do is issuing HTTP requests (synchronous or asynchronous). At this point which webserver / technology / language is used to handle the HTTP request is totally irrelevant. So, from the client javascrip... | 1 | 0 | 0 | this question have been asked numerous times, I know and I'm sorry if by ignorance I didn't get the answers.
I have a hosting plan which doesn't allow me to install django, which was really nice to call an rest api easily with the routing settings.
What I want is to be able to call a python function from javascript cod... | Call python FUNCTION from javascript | 1.2 | 0 | 0 | 4,050 |
24,996,265 | 2014-07-28T13:23:00.000 | 0 | 0 | 0 | 0 | java,python,command-line,couchbase,couchbase-view | 24,997,007 | 2 | true | 1 | 0 | So it appears after watching how their Web UI console works, that they're essentially reusing the "create a design document," i.e. the PUT command, to overwrite the existing design document. I have no idea how this would work on a production machine while it is running or the implications of such actions. The documenta... | 1 | 1 | 0 | I can query the views of a design document. I can create a brand new design document. I can delete a design document. I can add a view to a design document I'm in the process of creating but...
How do you add a view to an already existing design document without going through their web UI? Is it even possible or do you... | Couchbase: Add View to existing Design Document | 1.2 | 0 | 0 | 563 |
24,997,946 | 2014-07-28T14:52:00.000 | 0 | 0 | 0 | 0 | mysql,python-2.7,unicode,sqlalchemy,cherrypy | 25,016,312 | 1 | false | 0 | 0 | SQLAlchemy provides Unicode or UnicodeText for your purposes.
Also don't forget about u'text' | 1 | 0 | 0 | I am using cherrypy along with sqlalchemy-mysql as backend. I would like to know the ways of dealing with UNICODE strings in cherrypy web application. One brute-force way would be to convert all string coming in as parameters into UNICODE (and then decoding them to UTF-8) before storing them to database. But I was wond... | how to handle UNICODE characters in cherrypy-sqlalchemy-mysql application? | 0 | 1 | 0 | 153 |
25,001,824 | 2014-07-28T18:27:00.000 | 1 | 0 | 0 | 1 | python,linux,bash,gdb,named-pipes | 25,047,902 | 1 | true | 0 | 0 | My recommendation is not to do this. Instead there are two more supportable ways to go:
Write your code in Python directly in gdb. Gdb has been extensible in Python for several years now.
Use the gdb MI ("Machine Interface") approach. There are libraries available to parse this already (not sure if there is one in ... | 1 | 0 | 0 | Here's a general example of what I need to do:
For example, I would initiate a back trace by sending the command "bt" to GDB from the program. Then I would search for a word such as "pardrivr" and get the line number associated with it by using regular expressions. Then I would input "f [line_number_of_pardriver]" into... | Use named pipes to send input to program based on output | 1.2 | 0 | 0 | 289 |
25,001,953 | 2014-07-28T18:35:00.000 | 2 | 1 | 0 | 0 | php,python,session | 25,001,993 | 1 | false | 0 | 0 | You can assign to and read anything you want from the $_SESSION array. It's just a regular array like any other in PHP, except for two things:
a) It's a superglobal
b) IF you've called session_start(), then PHP will auto-populate the array from whatever's in session storage (files, db, etc...), and auto-save the conten... | 1 | 1 | 0 | So I've been working on porting a python tester to PHP, but I'm fairly new to PHP still. I understand there is a session command within PHP, and I've read the documentation as well as other questions that have come up here in stackoverflow that are close to it, but not quite what I'm looking for.
So my question is whe... | Is it possible to pass in the session as a variable like in Python for PHP? | 0.379949 | 0 | 0 | 212 |
25,003,108 | 2014-07-28T19:45:00.000 | 0 | 0 | 0 | 0 | python,ajax,django | 25,031,586 | 1 | true | 1 | 0 | Turns out it was a "feature" of the client-side AJAX package we were using (flow.js) and we just had to increase chunkSize. | 1 | 3 | 0 | I'm making a Django app in which a user can upload a file (an image) using AJAX.
While developing locally, I saw that PIL, which I used to process the image after upload, had a bug. After investigating I found out it's because PIL is getting the file data cut off. It's only getting the first 1MB of the file, which is w... | Django cutting off uploaded file | 1.2 | 0 | 0 | 86 |
25,003,730 | 2014-07-28T20:26:00.000 | 0 | 0 | 0 | 1 | python,ssh,expect,spawn,pexpect | 25,003,819 | 1 | false | 0 | 0 | The prompt should be needed after having written a command and waiting for it to finish. You have to tell "readline" what it should expect (in your case "testuser:"). | 1 | 0 | 0 | I have a custom shell which looks like below.
testuser:
How do I set custom PROMPT attribute to login to a shell which look like
I'm reusing the hive.py code from samples section and set original_prompt to :.
original_prompt='[:]'
The result is it skips the host as it fails to connect with
ERROR could not synchronize... | pexpect to login to custom shell | 0 | 0 | 0 | 203 |
25,003,748 | 2014-07-28T20:27:00.000 | 1 | 1 | 1 | 1 | python,linux,shell,command,executable | 25,003,823 | 2 | false | 0 | 0 | You should add the folder that contains the script to your system's $PATH variable (I assume you're on Linux). This variable contains all of the directories that are searched looking for a specific command. You can add to it by typing PATH=/path/to/folder:$PATH. Alternately, you need to move the script into a folder th... | 2 | 0 | 0 | I have a python script, which has multiple command line options. I want to make this script runnable without having to type "python myscript.py" and without having to be in the same directory as the script. For example, if one installs git on linux, regardless of which directory the user is in, the user can do "git add... | Making python script executable from any directory | 0.099668 | 0 | 0 | 4,406 |
25,003,748 | 2014-07-28T20:27:00.000 | 0 | 1 | 1 | 1 | python,linux,shell,command,executable | 25,003,818 | 2 | false | 0 | 0 | Your script needs to be in a location searchable via your PATH. On Unix/Linux systems, the generally accepted location for locally-produced programs and scripts that are not part of the system is /usr/local/bin. So, make sure your script is executable by running chmod +x myscript, then move it to the right place with s... | 2 | 0 | 0 | I have a python script, which has multiple command line options. I want to make this script runnable without having to type "python myscript.py" and without having to be in the same directory as the script. For example, if one installs git on linux, regardless of which directory the user is in, the user can do "git add... | Making python script executable from any directory | 0 | 0 | 0 | 4,406 |
25,004,564 | 2014-07-28T21:21:00.000 | 1 | 0 | 0 | 0 | python,numpy,scipy,linear-algebra,numerical-methods | 25,005,318 | 1 | true | 0 | 0 | For symmetric sparse matrix eigenvalue/eigenvector finding, you may use scipy.sparse.linalg.eigsh. It uses ARPACK behind the scenes, and there are parallel ARPACK implementations. AFAIK, SciPy can be compiled with one if your scipy installation uses the serial version.
However, this is not a good answer, if you need al... | 1 | 1 | 1 | Is anyone aware of an implemented version (perhaps using scipy/numpy) of parallel exact matrix diagonalization (equivalently, finding the eigensystem)? If it helps, my matrices are symmetric and sparse. I would hate to spend a day reinventing the wheel.
EDIT:
My matrices are at least 10,000x10,000 (but, preferably, at ... | Parallel exact matrix diagonalization with Python | 1.2 | 0 | 0 | 3,153 |
25,005,943 | 2014-07-28T23:28:00.000 | 0 | 0 | 1 | 0 | python,windows | 25,006,282 | 3 | false | 0 | 0 | Insert input() in the last line. It will make the program wait for a input. While it doesn't occur the windows program will be open. If you press any key and then enter, it will close. | 1 | 1 | 0 | I am new to all programming and I just started to get interested in learning how to program. So to do so I started with what most people consider the easiest language: Python.
The problem I am having right now though is that if I say to Python print("Hello!"), save it in a file, and then run it, a black window opens up... | Window closes immediately after running program | 0 | 0 | 0 | 7,183 |
25,006,539 | 2014-07-29T00:37:00.000 | -1 | 0 | 0 | 0 | python | 25,006,589 | 1 | false | 1 | 0 | You have a couple of options these are the only ones I can think of:
fork (sorry but this may be the easiest/ quickest),
wait for a new version for the older package, or
change it to not use zipped eggs (I don't really understand this though).
[EDIT] could you potentially trick one into thinking that it is using its v... | 1 | 1 | 0 | I (thankfully) never ran into this before, and (sadly) just did.
My app now imports 2 packages, which each import the requests library. The two authors have pegged the version of requests to different versions. One wants 2.1.0 , the other wants 2.3.0.
Automated tests appear to pass on both. My app appears to functio... | handling different required package versions | -0.197375 | 0 | 0 | 49 |
25,007,098 | 2014-07-29T01:53:00.000 | 2 | 0 | 1 | 0 | macos,ipython,keyboard-shortcuts,ipython-notebook,jupyter-notebook | 25,007,221 | 3 | false | 0 | 0 | You first press Ctrl and m (don't press the minus key), that will put the interface in command mode. For deletion you then have to press d twice. | 2 | 11 | 0 | I had a hard time figuring the keyboard shortcut.
Is that true that I should press Ctrl-m together and press the other key such as d to delete one cell? I tried it but it did not work for me I also tried without - but it still does not work for me :(
I am using a Mac. | IPython/Jupyter notebook shortcut not working on Mac | 0.132549 | 0 | 0 | 8,696 |
25,007,098 | 2014-07-29T01:53:00.000 | 4 | 0 | 1 | 0 | macos,ipython,keyboard-shortcuts,ipython-notebook,jupyter-notebook | 27,818,613 | 3 | false | 0 | 0 | On my mac, I use fn key, instead of ctrl, to make shortcuts work in iPython notebook (in Safari). For example,
fn + d + d deletes a cell (d + d works too)
fn + x cuts a cell
fn + c copies a cell
fn + z undoes an action,
and so on. As already noted above, you must press Esc before applying any of these shortcuts; th... | 2 | 11 | 0 | I had a hard time figuring the keyboard shortcut.
Is that true that I should press Ctrl-m together and press the other key such as d to delete one cell? I tried it but it did not work for me I also tried without - but it still does not work for me :(
I am using a Mac. | IPython/Jupyter notebook shortcut not working on Mac | 0.26052 | 0 | 0 | 8,696 |
25,012,108 | 2014-07-29T09:30:00.000 | 0 | 0 | 1 | 0 | python,character,word-count | 25,012,260 | 4 | false | 0 | 0 | If all your words written in latin letters are in English you could use regular expressions. | 1 | 1 | 0 | Let's say that I have a paragraph with different languages in it. like:
This is paragraph in English. 这是在英国段。Это пункт на английском языке. این بند در زبان انگلیسی است.
I would like to calculate what percentage (%) of this paragraph includes English words. So would like to ask how to do that in python. | How to calculate percentage of english words in a paragraph using Python | 0 | 0 | 0 | 3,245 |
25,018,343 | 2014-07-29T14:51:00.000 | 0 | 1 | 0 | 0 | python,antlr4 | 51,549,667 | 2 | false | 0 | 0 | The example you used was badly written. input is the name of a built-in Python function. Give the Lexer a FileStream and it might work. | 1 | 0 | 0 | Is it possible to use the antlr4 python runtime with python 2.6 or is the minimun required version python 2.7? I want to use it on CentOS 6.3 that comes with python 2.6.6. If it is not possible, is it known what features of python 2.7 that is used? | use antlr4 python runtime with python 2.6 | 0 | 0 | 0 | 805 |
25,020,482 | 2014-07-29T16:35:00.000 | 6 | 0 | 0 | 0 | python,scikit-learn,feature-selection | 25,036,779 | 1 | true | 0 | 0 | You can't. The feature selection routines in scikit-learn will consider the dummy variables independently of each other. This means they can "trim" the domains of categorical variables down to the values that matter for prediction. | 1 | 6 | 1 | My question is i want to run feature selection on the data with several categorical variables. I have used get_dummies in pandas to generate all the sparse matrix for these categorical variables. My question is how sklearn knows that one specific sparse matrix actually belongs to one feature and select/drop them all? F... | How can sklearn select categorical features based on feature selection | 1.2 | 0 | 0 | 3,078 |
25,023,050 | 2014-07-29T19:03:00.000 | 1 | 0 | 1 | 0 | python,memory | 25,023,098 | 2 | false | 0 | 0 | In your first example s is still in memory until the garbage collector deletes it, so your second example is more efficient in terms of memory use. However, considering that's a very very little portion of the RAM, in many cases it's better to go for readability (the first example looks better).
Hope this helps. | 1 | 2 | 0 | This has been bugging me for a while. I'm wondering about the comparative memory-efficiency of assigning variables and calling methods. Consider, for example:
s = "foo"
x = s.lower()
Versus
x = "foo".lower()
Which one of these is more efficient in terms of memory use?
This is obviously a trivial example, but it ... | Python: Memory-Efficiency of Assigning Variables and Calling Methods | 0.099668 | 0 | 0 | 58 |
25,024,010 | 2014-07-29T20:06:00.000 | 2 | 1 | 0 | 1 | python | 25,026,388 | 1 | true | 0 | 0 | The current python executable is always available as sys.executable, which should give full path (but you can ensure this using os.path functions). | 1 | 3 | 0 | I have a series of unit tests that are meant to run in two contexts:
1) On a buildbot server
2) in developer's home environments
In both our development procedure and in the buildbot server we use virtualenv. The tests run fine in the developer environments, but with buildbot the tests are being run from the python exe... | How can I get the path to the calling python executable | 1.2 | 0 | 0 | 313 |
25,024,416 | 2014-07-29T20:30:00.000 | 0 | 0 | 1 | 0 | javascript,python,macos,ide | 25,026,782 | 2 | false | 0 | 0 | I use PyCharm. It's a heavyweight IDE, so expect more features than you probably want if you're just getting started. It has a very good integrated debugger. You'll be able to break into both your Python and Javascript. Further, you'll see a pretty nice productivity jump with all the editing support like auto compl... | 1 | 1 | 0 | I looking for python/JavaScript IDE where I can put breakpoints. Currently I'm using coderunner but I can not put break points. I'll really appreciate you recommendations | mac os x python/JavaScript IDE where I can use break points | 0 | 0 | 0 | 103 |
25,024,437 | 2014-07-29T20:32:00.000 | -1 | 0 | 0 | 0 | python,excel,xlwt | 25,032,965 | 1 | false | 0 | 0 | You will get data from queries, right? Then you will write them to an excel by xlwt. Just before writing, you can sort them. If you can show us your code, then maybe I can optimize them. Otherwise, you have to follow wnnmaw's advice, do it in a more complicate way. | 1 | 1 | 1 | I'm using python to write a report which is put into an excel spreadshet.
There are four columns, namely:
Product Name | Previous Value | Current Value | Difference
When I am done putting in all the values I then want to sort them based on Current Value. Is there a way I can do this in xlwt? I've only seen examples of... | Sorting multiple columns in excel via xlwt for python | -0.197375 | 1 | 0 | 1,410 |
25,024,919 | 2014-07-29T21:00:00.000 | 1 | 0 | 0 | 0 | python,linux,scp | 25,025,029 | 2 | false | 0 | 0 | Consider:
1) copy file to all servers, into a temporary path on the same drive as the final location. If this fails just restart it.
2) across all servers, move the file from temp path into the final path. On Linux and probably other OSes, moving files on a single drive is fast, durable, and probably atomic.
This isn't... | 2 | 0 | 0 | I need to SCP the same file to multiple servers, transactionally. It will overwrite the previous version of the file. I need to guarantee that every server has the new file, or every server has the old file. It is acceptable for the servers to appear to be in an intermediate state temporarily, as long as it ends in con... | Transactionally SCPing to multiple servers in python | 0.099668 | 0 | 0 | 80 |
25,024,919 | 2014-07-29T21:00:00.000 | 2 | 0 | 0 | 0 | python,linux,scp | 25,025,058 | 2 | false | 0 | 0 | Real transactions are probably best handled with databases that reach the replication level that you need
While their is probably not something that will magically handle this for you, you can follow some best practices and end up with OK results. I don't really know where to start but let's try some of these:
Paramik... | 2 | 0 | 0 | I need to SCP the same file to multiple servers, transactionally. It will overwrite the previous version of the file. I need to guarantee that every server has the new file, or every server has the old file. It is acceptable for the servers to appear to be in an intermediate state temporarily, as long as it ends in con... | Transactionally SCPing to multiple servers in python | 0.197375 | 0 | 0 | 80 |
25,025,299 | 2014-07-29T21:27:00.000 | 1 | 0 | 1 | 1 | python | 25,025,400 | 1 | false | 0 | 0 | Creating a new directory is effectively the same as writing small amount of data. It adds an inode.
The only way mkdir (or os.mkdirs) should fail is if the directory exists - otherwise the directory will always be created. In terms of the data being buffered - it's unlikely that this would happen - even journaled file... | 1 | 1 | 0 | I am running Python with MPI on a supercomputing cluster. I am getting strange nondeterministic behavior that I think is a result of I/O complications that are not present on the single machines I'm used to working with.
One of the things my code does is to create directories using os.makedirs somewhat frequently. I kn... | Force directory to be created in Python | 0.197375 | 0 | 0 | 147 |
25,025,928 | 2014-07-29T22:18:00.000 | 0 | 1 | 1 | 0 | python,unit-testing | 25,025,972 | 6 | false | 0 | 0 | I am sure that there are other, better, methods but you could always set a global flag from your main and not under unit test then access it in your method.
The other way of course would be to override the method as a part of the unit test set-up - if your method is called brian and you have a test_brian then simply du... | 1 | 29 | 0 | I have a large project that is unit tested using the Python unittest module.
I have one small method that controls large aspects of the system's behaviour. I need this method to return a fixed result when running under the UTs to give consistent test runs, but it would be expensive for me to mock this out for every sin... | How can a piece of python code tell if it's running under unittest | 0 | 0 | 0 | 11,612 |
25,027,339 | 2014-07-30T01:11:00.000 | 0 | 0 | 0 | 0 | python,html,extract | 25,027,442 | 4 | false | 1 | 0 | BeautifulSoup could be used to parse the html document, and extract anything you want. It's not designed for downloading. You could find the elements you want by it's class and id. | 1 | 6 | 0 | I'd like to get the data from inspect element using Python. I'm able to download the source code using BeautifulSoup but now I need the text from inspect element of a webpage. I'd truly appreciate if you could advise me how to do it.
Edit:
By inspect element I mean, in google chrome, right click gives us an option cal... | How to get data from inspect element of a webpage using Python | 0 | 0 | 1 | 34,323 |
25,032,656 | 2014-07-30T08:59:00.000 | 1 | 0 | 1 | 0 | python,kivy | 25,033,218 | 1 | true | 0 | 1 | Run your computationally intensive stuff in one or more threads or separate sub-processes and have them periodically post some updates to the GUI to say how they are doing, (and the results at the end of course). | 1 | 0 | 0 | I want to visualize a computing process in kivy. The problem is that kivy freezes when the python function runs. Any ideas how to manage that problem.
It is like a progress bar. The computation is running and the user should see that his PC did not hang up. | manual update kivy screen when a user function is doing heavy computation | 1.2 | 0 | 0 | 330 |
25,036,688 | 2014-07-30T12:21:00.000 | 0 | 0 | 1 | 1 | python | 39,276,446 | 3 | false | 0 | 0 | You need to go into the directory that you are going to "setup". For example, if you are installing numpy, and you have git-cloned it, then it probably is located at ~/numpy. So first cd into ~/numpy, and the type the commend like "python setup.py build" there. | 1 | 23 | 0 | This problem started while I was installing pyswip and needed to run a setup.py file. Using the command "python setup.py", I'm greeted with the following message: "python: can't open file 'setup.py': [Errno 2] No such file or directory."
I know this question's been asked a lot before, so I've tried everything in previo... | "Cannot access setup.py: No such file or directory" - can't run any .py files? | 0 | 0 | 0 | 102,215 |
25,041,311 | 2014-07-30T15:50:00.000 | 1 | 1 | 1 | 0 | python | 25,041,459 | 1 | true | 0 | 0 | file.write() appends to the end of the file. You never clear the file after reading the contents. The simplest thing to do, probably, would be to read the file once in 'r' mode, then open it again in 'w' mode (which will clear the file), and write out the edited content.
The output doesn't print because you don't tell ... | 1 | 0 | 0 | So i am suppose to open a text file by >>>yyy('yyy.txt') and after inputing that python should find my file (which is does, since in the same directory) and edit all the words 'hot' to new word 'why not'. after editing the text file the content of the entire file should be printed.
Its opening the file and its editing ... | Python, opening the file, reading the file, editing the file, and priting the file string? | 1.2 | 0 | 0 | 52 |
25,042,205 | 2014-07-30T16:33:00.000 | 0 | 1 | 0 | 1 | python,apache,.htaccess,wsgi | 25,056,888 | 2 | false | 1 | 0 | You should not stick the WSGI file in the DocumentRoot directory in the first place. You have created the situation yourself. It doesn't need to be in that directory for WSGIScriptAlias to work. | 2 | 1 | 0 | I am using mod_wsgi with apache to serve the python application. I have a directive in the VirtualHost entry as follows WSGIScriptAlias /app /home/ubuntu/www/app.wsgi. I also have DocumentRoot /home/ubuntu/www/. Therefore, if the user attempts to read /app.wsgi it gets the raw file. If I try to block access to it via .... | How do I prevent the raw WSGI python file from being read? | 0 | 0 | 0 | 77 |
25,042,205 | 2014-07-30T16:33:00.000 | 0 | 1 | 0 | 1 | python,apache,.htaccess,wsgi | 25,045,724 | 2 | false | 1 | 0 | This is far from the best option, but it does seem to work: I added WSGIScriptAlias /app.wsgi /home/ubuntu/www/app.wsgi to the VirtualHost as well so that it will run the app on that uri instead of returning the raw file. | 2 | 1 | 0 | I am using mod_wsgi with apache to serve the python application. I have a directive in the VirtualHost entry as follows WSGIScriptAlias /app /home/ubuntu/www/app.wsgi. I also have DocumentRoot /home/ubuntu/www/. Therefore, if the user attempts to read /app.wsgi it gets the raw file. If I try to block access to it via .... | How do I prevent the raw WSGI python file from being read? | 0 | 0 | 0 | 77 |
25,043,745 | 2014-07-30T17:59:00.000 | 0 | 0 | 1 | 0 | python | 25,043,827 | 4 | false | 0 | 0 | The code as written doesn't even examine the input text at all. You're counting the number of times each vowel appears in vowels.
Replace with text.count(i) instead of vowels.count(i). | 1 | 0 | 0 | So i am typing a code where a user will need to input >>Count('bla bla bla') and the program needs to count the in the bla bla bla phrase and return the word with its count in this SPECIFIC order.
Any Help? | Python, counting from an inputted string. Needs to be returned in a specific order? | 0 | 0 | 0 | 67 |
25,045,924 | 2014-07-30T20:04:00.000 | -1 | 1 | 0 | 0 | python,multithreading,web,browser,python-webbrowser | 31,276,859 | 3 | false | 1 | 1 | i have written winks-up in vala.
It's small and fast and compile well on raspbian.
All the code was optimize to reduce memory occupation.
isn't perfect but was better like nothing | 2 | 0 | 0 | Got a bit of weird request here, however it's one which I can't really figure out the answer to.
I'm writing a python application that displays web pages and locally stored images.
What I need is a way of displaying a web page using python that is really lightweight and quite fast. The reason for this is that it is ru... | Lightweight Python Web Browser | -0.066568 | 0 | 0 | 1,135 |
25,045,924 | 2014-07-30T20:04:00.000 | 0 | 1 | 0 | 0 | python,multithreading,web,browser,python-webbrowser | 25,051,761 | 3 | false | 1 | 1 | I'd use PyQT to display the page but if the way PyQT use threads does not fit within you application, you may just write a minimalist (I'm speaking of ~10 lines of code here) web browser using PyQT, and fork it from your main application ? | 2 | 0 | 0 | Got a bit of weird request here, however it's one which I can't really figure out the answer to.
I'm writing a python application that displays web pages and locally stored images.
What I need is a way of displaying a web page using python that is really lightweight and quite fast. The reason for this is that it is ru... | Lightweight Python Web Browser | 0 | 0 | 0 | 1,135 |
25,049,859 | 2014-07-31T02:23:00.000 | 0 | 0 | 1 | 0 | python-3.x,epoch | 25,050,216 | 1 | false | 0 | 0 | This syntax for long int literals is no longer valid in python 3. All integers are now longs by default. | 1 | 0 | 0 | I am trying to write a simple sntp client for printing time.when I try to assign TIME1970 = 2208988800L ,it gives an error saying invalid syntax.I am running program on python3 plus windows environment 64 bit. | Error in geting Epoch Time in python3 | 0 | 0 | 0 | 674 |
25,054,347 | 2014-07-31T08:37:00.000 | 0 | 0 | 0 | 0 | python,django,apache | 25,054,828 | 1 | true | 1 | 0 | No, there is no way to do this, and that's a very good thing as it is a bad idea. There is no reason to use the same Apache process for different sites: instead you should have different virtual hosts for each of your sites, and let Apache manage them. | 1 | 0 | 0 | I'd like to change the environment variable DJANGO_SETTINGS_MODULE (along with a few others) and then have ALL relevant modules like django.conf, django.db etc reloaded to reflect the information from the new settings module. The new settings module will have different database. I will be doing this in a middleware.
I ... | How to change settings in a middleware? | 1.2 | 0 | 0 | 394 |
25,056,040 | 2014-07-31T10:00:00.000 | 0 | 0 | 1 | 0 | python,html,dictionary,key | 25,056,118 | 2 | false | 0 | 0 | As long as keys are hash-able you can have keys of any format. Note, tuples are hash-able so that would be a possible solution to your problem
Make a tuple of case-owner and type and use it as a key to your dictionary.
Note, generally all objects that are hashable should also be immutable, but not vice-versa. So | 1 | 2 | 0 | I am currently writing a script that extracts data from an xml and writes it into an html file for easy viewing on a webpage.
Each piece of data has 2 pieces of "sub data": Owner and Type.
In order for the html to work properly I need the "owner" string and the "type" string to be written in the correct place. If it wa... | Multiple Values for a single key in a dictionary | 0 | 0 | 0 | 1,335 |
25,057,063 | 2014-07-31T10:52:00.000 | 0 | 0 | 0 | 0 | python,signals,filtering,time-series | 25,069,634 | 1 | false | 0 | 0 | There are some rather quick ways.
I assume you are only interested in the slope and average of the signal Y. In order to calculate these, you need to have:
sum(Y)
sum(X)
sum(X.X)
sum(X.Y)
All sums are over the samples in the window. When you have these, the average is:
sum(Y) / n
and the slope:
(sum(X.Y) - sum(X) sum... | 1 | 0 | 1 | I have to perform linear regressions on a rolling window on Y and a time lagged version of X, ie finding Y(t) = aX(t-1) + b. The window size is fixed at 30 samples. I want to return a numpy array of all the beta coefficients. Is there a quick way of doing this? I read about the Savitsky-Golay filter, but it regresses o... | Performing a rolling vector auto regression with two variables X and Y, with time lag on X in Python | 0 | 0 | 0 | 149 |
25,057,937 | 2014-07-31T11:38:00.000 | 1 | 0 | 0 | 0 | wxpython,wxwidgets | 25,059,718 | 1 | true | 0 | 1 | The widget probably doesn't support text alignment. If you want complete control over how it displays its contents, then you should probably switch to a custom drawn control, such as ComboCtrl. | 1 | 0 | 0 | I have a combobox in wxpython but I cant figure out how to align the text it contains to the right?
I have tried to use wx.ComboBox(self, choices=["1","2","3"], style=wx.TEXT_ALIGNMENT_RIGHT) but that didnt work. | How do I right align the text in a wx.ComboBox? | 1.2 | 0 | 0 | 835 |
25,064,876 | 2014-07-31T17:03:00.000 | 1 | 0 | 0 | 0 | javascript,python,django,angularjs,rest | 25,067,631 | 1 | true | 1 | 0 | It depends on the architecture of your application.
If you are building your client as a single page web application using Angular & your business logic is served using the Django REST API in JSON/XML format. Then rendering of the view should be the responsibility of the client side code.
As per me whatever you are do... | 1 | 1 | 0 | Ok, so basically what is happening is I have a search input on my index page. The user types something in the search input, and that is sent to the Django REST api which returns the data in JSON format. I can loop through that results array using Angular ng-repeat. But my question is: is there a way to send that reques... | Pass a request to a DJANGO REST api using Angular and then return those results in a DJANGO view | 1.2 | 0 | 0 | 109 |
25,066,084 | 2014-07-31T18:11:00.000 | 4 | 0 | 1 | 1 | python,setuptools | 25,168,476 | 3 | false | 0 | 0 | Have you tried `os.path.abspath(__file__)' in your entry point script? It'll return yours entry point absolute path.
Or call find_executable from distutils.spawn:
import distutils.spawn
distutils.spawn.find_executable('executable') | 1 | 13 | 0 | So I have an entry point defined in my setup.py [console_scripts] section. The command is properly installed and works fine, but I need a way to programatically find out the path to the script (e.g. on windows it'll be something like C:/my/virtual/env/scripts/my_console_script.exe). I need this so I can pass that scrip... | Get entry point script file location in setuputils package? | 0.26052 | 0 | 0 | 5,445 |
25,067,790 | 2014-07-31T19:53:00.000 | 7 | 0 | 1 | 0 | python,c | 25,069,295 | 2 | false | 0 | 0 | I don't think that is possible for the basic reason that Python String objects are embedded into the PyObject structure. In other words, the Python string object is the PyObject_HEAD followed by the bytes of the string. You would have to have room in memory to put the PyObject_HEAD information around the existing ... | 1 | 10 | 0 | I have a large buffer of strings (basically 12GB) from a C app.
I would like to create PyString objects in C for an embedded Python interpreter without copying the strings. Is this possible? | Create PyString from c character array without copying | 1 | 0 | 0 | 1,617 |
25,069,005 | 2014-07-31T21:11:00.000 | 2 | 0 | 0 | 0 | python,port,forwarding | 25,069,162 | 4 | false | 0 | 0 | So your application needs to do TCP/UDP networking if I understand correctly. That means that at least one of the connecting clients needs a properly open port, and if both of them is behind NAT (a router) and have no configured open ports, your clients cannot connect.
There are several possible solutions for this, but... | 1 | 6 | 0 | I'm developing a client-server game in python and I want to know more about port forwarding.
What I'm doing for instance is going to my router (192.168.0.1) and configure it to allow request for my real IP-adress to be redirected to my local adress 192.168.0.X. It works really well. But I'm wondering if I can do it by ... | Python port forwarding | 0.099668 | 0 | 1 | 9,022 |
25,069,079 | 2014-07-31T21:17:00.000 | 1 | 1 | 1 | 0 | python,eclipse,package | 25,069,554 | 1 | false | 0 | 0 | Three things spring to mind:
Does the project have a pythonpath set? Right-click the project -> properties -> pythonpath. Add the root project directory, or whatever is appropriate for your project.
Do your packages contain an __init__.py file?
Have you got a python interpreter configured in PyDev?
Is your package exp... | 1 | 1 | 0 | I have a project on eclipse and I am wondering why I do not see the package symbol on the folders in the hierarchy.
Do I have to choose an option to be able to see the folders appear as package on eclipse?
I am using PyDev plugin here.. | How to get package icon in eclipse? | 0.197375 | 0 | 0 | 254 |
25,070,854 | 2014-08-01T00:00:00.000 | 1 | 0 | 1 | 0 | python | 25,071,044 | 6 | false | 0 | 0 | I had a problem with that recently:
I was writing some stuff to a file in a for-loop, but if I interrupt the script with ^C, a lot of data which should have actually been written to the file wasn't there. It looks like Python stops to writing there for no reason. I opened the file before the for loop. Then I changed th... | 3 | 53 | 0 | Usually when I open files I never call the close() method, and nothing bad happens. But I've been told this is bad practice. Why is that? | Why should I close files in Python? | 0.033321 | 0 | 0 | 54,943 |
25,070,854 | 2014-08-01T00:00:00.000 | 86 | 0 | 1 | 0 | python | 25,070,939 | 6 | true | 0 | 0 | For the most part, not closing files is a bad idea, for the following reasons:
It puts your program in the garbage collectors hands - though the file in theory will be auto closed, it may not be closed. Python 3 and Cpython generally do a pretty good job at garbage collecting, but not always, and other variants genera... | 3 | 53 | 0 | Usually when I open files I never call the close() method, and nothing bad happens. But I've been told this is bad practice. Why is that? | Why should I close files in Python? | 1.2 | 0 | 0 | 54,943 |
25,070,854 | 2014-08-01T00:00:00.000 | 1 | 0 | 1 | 0 | python | 25,070,925 | 6 | false | 0 | 0 | You only have to call close() when you're writing to a file.
Python automatically closes files most of the time, but sometimes it won't, so you want to call it manually just in case. | 3 | 53 | 0 | Usually when I open files I never call the close() method, and nothing bad happens. But I've been told this is bad practice. Why is that? | Why should I close files in Python? | 0.033321 | 0 | 0 | 54,943 |
25,072,996 | 2014-08-01T04:44:00.000 | 2 | 0 | 0 | 0 | python-2.7,robotframework | 32,266,513 | 1 | false | 1 | 0 | You should check the content of dbConfigFile. You don't specify one so the default one is ./resources/db.cfg.
The error says when python try to parse that file it cannot find a section named default. In documentation it says:
note: specifying dbapiModuleName, dbName dbUsername or dbPassword directly will override the... | 1 | 1 | 0 | I am using Robot Framework with Database Library to test database queries on localhost. I am running it by XAMPP.
This is my test case:
*** Settings ***
Library DatabaseLibrary
*** Variables ***
@{DB} robotframework root \ localhost 3306
*** Test Cases ***
Select from database
... | Error: No section: 'default' in Robot Framework using DatabaseLibrary | 0.379949 | 1 | 0 | 4,534 |
25,074,173 | 2014-08-01T06:30:00.000 | 2 | 0 | 0 | 0 | python,utf-8 | 25,074,740 | 4 | false | 1 | 0 | HTTP headers are strictly 7-bit US ASCII. The RFC allows you to accept ISO8859-1as a compatibility hack, but don't send any byte beyond 127.
There is no standard or best way to send any other data type beside ASCII in the headers. It is your application's responsibility to encode arbitrary sequences of bytes (and your ... | 2 | 1 | 0 | I have an app that submit a request to a Python webserver. The app has a UTF8 string with the following contents:
la langue franþaise.ppt
This is put into a HTTP header, and somehow converted as such:
la langue fran\xfeaise.ppt
Then Python on the web-server tried to do something with the string that maybe expects i... | How to preserve UTF8 string from app to webserver in Python | 0.099668 | 0 | 0 | 191 |
25,074,173 | 2014-08-01T06:30:00.000 | 2 | 0 | 0 | 0 | python,utf-8 | 25,074,360 | 4 | true | 1 | 0 | \xfe is ISO-8859-1 encoding for þ.
While utf8 in content is widely supported, HTTP headers should be ASCII. The HTTP spec allows ISO-8859-1, but it's not recommended or reliable in tooling. Other encodings are not allowed without special escaping.
If possible, escape your special chars in a way that allows them to be t... | 2 | 1 | 0 | I have an app that submit a request to a Python webserver. The app has a UTF8 string with the following contents:
la langue franþaise.ppt
This is put into a HTTP header, and somehow converted as such:
la langue fran\xfeaise.ppt
Then Python on the web-server tried to do something with the string that maybe expects i... | How to preserve UTF8 string from app to webserver in Python | 1.2 | 0 | 0 | 191 |
25,078,549 | 2014-08-01T10:46:00.000 | 1 | 1 | 0 | 0 | python,eclipse,pydev,importerror | 25,087,270 | 1 | false | 1 | 0 | For that to work you need to have init.py under 'project_dir', 'dira' and 'dirb' and then you need to set as a source folder the directory which is the parent of the 'project_dir' (and not the project_dir itself) -- and no other directories should be set as source folders.
I.e.: the source folder is the directory added... | 1 | 1 | 0 | I have co'd existing code from an SVN repo that uses full imports - by which I mean:
-->projectdir
-------->dira
-------------->a1.py
-------------->a2.py
-------->dirb
-------------->b1.py
Suppose a1.py imports a method from a2.py:
Normally I would simply write:
from a2 import xyz
Here they have written it as:
fro... | Import Error - Pydev Eclipse | 0.197375 | 0 | 0 | 249 |
25,078,815 | 2014-08-01T11:01:00.000 | 0 | 0 | 0 | 1 | python,sqlalchemy,celery | 25,086,833 | 1 | true | 0 | 0 | It wasn't so complicated, subclass Session, providing a list for appending tasks via after_insert. Then run through the list in after_commit. | 1 | 0 | 0 | I'm initiating celery tasks via after_insert events.
Some of the celery tasks end up updating the db and therefore need the id of the newly inserted row. This is quite error-prone because it appears that if the celery task starts running immediately sometimes sqlalchemy will not have finished committing to the db and ... | SQLAlchemy after_insert triggering celery tasks | 1.2 | 1 | 0 | 209 |
25,085,813 | 2014-08-01T17:43:00.000 | 1 | 0 | 1 | 0 | python,iterator,abc | 25,085,843 | 1 | false | 0 | 0 | Your options are not to inherit from that class, provide your own, correct and proper next method, or provide an alternative iterator to be returned from the __iter__ method.
There is no registration involved here other than that isinstance(instance, collections.Iterator) is True, and that returns True for two reasons:... | 1 | 0 | 0 | I've been handed code with a class that incorrectly subclasses the abstract base class collections.Iterator. It doesn't follow the Iterator contract and this flawed inheritance relationship causes issues downstream. Is there any way to unregister an abstract base class?
Note: I know that this is a strange situation. ... | Can I unregister a class as an `Iterator`? | 0.197375 | 0 | 0 | 148 |
25,087,111 | 2014-08-01T19:11:00.000 | 1 | 0 | 0 | 0 | python,interpolation | 32,809,719 | 4 | false | 0 | 0 | Another function that could work is scipy.ndimage.interpolation.map_coordinates.
It does spline interpolation with periodic boundary conditions.
It does not not directly provide derivatives, but you could calculate them numerically. | 1 | 7 | 1 | I'm running a simulation on a 2D space with periodic boundary conditions. A continuous function is represented by its values on a grid. I need to be able to evaluate the function and its gradient at any point in the space. Fundamentally, this isn't a hard problem -- or to be precise, it's an almost already solved pr... | 2D Interpolation with periodic boundary conditions | 0.049958 | 0 | 0 | 3,228 |
25,088,006 | 2014-08-01T20:15:00.000 | 3 | 1 | 1 | 0 | python | 25,088,132 | 2 | true | 0 | 0 | Scripts need shebangs. Modules don't need shebangs -- they're sometimes used to make text editors' jobs easier (in detecting the programming language easier), or if a module can be run as a script to execute its tests, but are not called for otherwise.
All Python code, whether in modules or scripts, should have encodin... | 1 | 1 | 0 | our application is composed of several modules grouped in two packages, and one script.
I am not sure, and don't manage to google my way through to knowing if the modules need a coding directive in order to manage our native french accented strings, and while we're at it, a shabang with the interpreter directive, or if... | Do Python modules need shebangs or encoding directives? | 1.2 | 0 | 0 | 98 |
25,089,702 | 2014-08-01T22:39:00.000 | 0 | 0 | 0 | 1 | python,datetime,batch-file,csv,ubuntu | 25,089,847 | 2 | false | 0 | 0 | So your options, roughly, are:
Python
Windows 'cmd' script
Transfer the files to a *nix environment and do it there with those tools if you are more familiar
If using Python, look at:
the os module, os.listdir(), os.path etc.
Regex replace using a function (re.sub taking a function rather than a string as a replacem... | 1 | 0 | 0 | I have a question about writing a command prompt script (DOS) in Windows 7.
The task I have:
I have a directory of raw data files (*.csv) where the 38th line is where the date and time are saved.
Example File cell A38:
Start Date/Time: 6/20/2014 13:26:16
However, this date format is M/DD/YYYY because it was saved u... | Script for changing one line of *.csv file for a whole directory of files? | 0 | 0 | 0 | 115 |
25,090,573 | 2014-08-02T00:47:00.000 | 0 | 0 | 0 | 0 | python,django,memory-leaks,uwsgi | 68,154,893 | 2 | false | 1 | 0 | Django doesn't have known memory leak issues.
I had a similar memory issue. I found that there is a slow SQL causing a high DB CPU percentage. The memory issue is fixed after I fixed the slow SQL. | 1 | 21 | 0 | I've a Django application that every so often is getting into memory leak.
I am not using large data that could overload the memory, in fact the application 'eats' memory incrementally (in a week the memory goes from ~ 70 MB to 4GB), that is why I suspect the garbage collector is missing something, I am not sure though... | Django memory leak: possible causes? | 0 | 0 | 0 | 15,649 |
25,090,619 | 2014-08-02T00:57:00.000 | 0 | 0 | 0 | 0 | python,html,ads,adsense | 25,090,652 | 1 | true | 1 | 0 | If the HTML is definitely the same every time, the variations are probably being done on the client side using javascript.
The answer depends on what you mean by "classify." If you just want to know, on any given load of the page, where the widgets are, you will probably have to use something like Selenium that actuall... | 1 | 0 | 0 | There is a webpage which when loaded uses a random placement of forms / controls / google ads. However, the set is closed--from my tests there are at least three possible variations, with two very common and the third very rare.
I would like to be able to classify this webpage according to each variation. I tried a... | Classify different versions of the same webpage | 1.2 | 0 | 1 | 34 |
25,090,620 | 2014-08-02T00:59:00.000 | 2 | 0 | 0 | 0 | python,widget,kivy,python-3.4 | 32,950,247 | 2 | false | 0 | 1 | One thing you can do is to make use of the copy function in python.
This does not copy all the pos/size values but you will have all the attributes.
Ex:
from copy import copy
new_box = copy(self.current_box)
Hope this helps. | 2 | 0 | 0 | I have 2 widgets, I need to copy all attributes (pos, size, canvas, etc.) from one widget to another somehow (and then move the last to new pos). Probably I can copy attributes one by one, but is there some built-in function?
It seems Python's copy makes only shell copy (I can't move duplicate etc.) and deepcopy fails. | Can I copy attributes from one widget to another in Kivy? | 0.197375 | 0 | 0 | 1,181 |
25,090,620 | 2014-08-02T00:59:00.000 | 2 | 0 | 0 | 0 | python,widget,kivy,python-3.4 | 25,102,895 | 2 | false | 0 | 1 | I'm not aware of a pre-existing way to do this in general, but you could probably fairly easily make a function to do it. You can get a list of the widget properties through the properties() method of EventDispatcher, though you'd also need to manually keep track of any non-kivy-property attributes you want to copy, an... | 2 | 0 | 0 | I have 2 widgets, I need to copy all attributes (pos, size, canvas, etc.) from one widget to another somehow (and then move the last to new pos). Probably I can copy attributes one by one, but is there some built-in function?
It seems Python's copy makes only shell copy (I can't move duplicate etc.) and deepcopy fails. | Can I copy attributes from one widget to another in Kivy? | 0.197375 | 0 | 0 | 1,181 |
25,093,943 | 2014-08-02T10:17:00.000 | 1 | 1 | 0 | 0 | python | 25,106,484 | 1 | true | 0 | 0 | When you're working on a library you can use python setup.py develop instead of install. This will install the package into your local environment and keep it updated as you develop.
To be clear, if you use develop you don't have to run it again when you change your source files. | 1 | 0 | 0 | I have installed a python package slimit and I have cloned the source code from github.
I am doing changes to this package in my local folders which I want to test (often) but I don't want to do allways python setup.py install.
My folder structure is:
../develop/slimit/src/slimit (contains package files)
../develop/tes... | how to test changes to an installed package | 1.2 | 0 | 0 | 227 |
25,096,357 | 2014-08-02T15:00:00.000 | 1 | 0 | 0 | 0 | python,pandas | 25,110,368 | 3 | false | 0 | 0 | I haven't done much with Panels, but what exactly is the functionality that you need? Is there a reason a simple python list wouldn't work? Or, if you want to refer by name and not just by list position, a dictionary? | 1 | 0 | 1 | I want to write a function to return several data frames (different dims) and put them into a larger "container" and then select each from the "container" using indexing. I think I want to find some data structure like list in R, which can have different kinds of objects.
What can I use to do this? | What is the data structure in python that can contain multiple pandas data frames? | 0.066568 | 0 | 0 | 104 |
25,096,745 | 2014-08-02T15:46:00.000 | 4 | 0 | 1 | 0 | python,python-3.x | 25,096,768 | 1 | true | 0 | 0 | Dictionaries and sets are not ordered. This is easy to overlook when you consider that iteration over them is supported... but one cannot assume any particular order in which iter() will provide items from sets and dictionaries, so it would not make sense to define a way to reverse this order. | 1 | 0 | 0 | Why is iter() implemented for all collections whereas reversed() isn't (e.g. dicts and sets don't implement it)? As the doc says reversed() returns a simple reverse iterator... | Why isn't reversed() implemented for all collections? | 1.2 | 0 | 0 | 43 |
25,097,038 | 2014-08-02T16:18:00.000 | 0 | 0 | 1 | 0 | python,macos,python-2.7,python-3.x | 25,097,174 | 2 | true | 0 | 0 | Python installations on OS X generally go in separately and don't uninstall each other. Also, the convention is still for the executable python to refer to 2 and python3 to refer to 3, so they don't even really overlap.
Common locations you might have python include
/usr/bin/python (the system installed one, probably ... | 2 | 0 | 0 | Could there possibly be hidden files that I would need to find. Or do I have to re-install Python 2.7 if I want to work with it?
Thanks | How to find out if I still have Python 2.7 on Mac? Does installing Python 3.3 also uninstall the older package? | 1.2 | 0 | 0 | 159 |
25,097,038 | 2014-08-02T16:18:00.000 | 0 | 0 | 1 | 0 | python,macos,python-2.7,python-3.x | 25,097,095 | 2 | false | 0 | 0 | python --version - will give you the version of the currently used python in environment variable PATH.
Nothing gets uninstalled. You have to just adjust the PATH variable according what you will be using. | 2 | 0 | 0 | Could there possibly be hidden files that I would need to find. Or do I have to re-install Python 2.7 if I want to work with it?
Thanks | How to find out if I still have Python 2.7 on Mac? Does installing Python 3.3 also uninstall the older package? | 0 | 0 | 0 | 159 |
25,099,749 | 2014-08-02T21:54:00.000 | 0 | 1 | 0 | 1 | python,ubuntu,digital-ocean | 25,100,208 | 2 | false | 0 | 0 | First install and enable fcron. Then, sudo -s into root and run fcrontab -e. In the editor, enter */30 * * * /path/to/script.py and save the file. Change 30 to 15 if every 15 minutes is what you're after. | 1 | 0 | 0 | I have correct python3 program looking like *.py.
I have Digital Ocean(DO) droplet with Ubuntu 14.04.
My program post message to my twitter account.
I just copy my *.py in some directory on DO droplet and run it with ssh and all works fine.
But I need to post message(rum my program) automatically every 15-30 min for ex... | Run my python3 program on remote Ubuntu server every 30 min | 0 | 0 | 0 | 492 |
25,101,081 | 2014-08-03T02:31:00.000 | 1 | 0 | 1 | 0 | python,numpy,scipy,ipython,spyder | 25,123,660 | 1 | false | 0 | 0 | You may find Spyder's array editor better suited for large arrays than the qt console. | 1 | 1 | 1 | I am using Spyder from the Anaconda scientific package set (3.x) and consistently work with very large arrays. I want to be able to see these arrays in my console window so I use these two commands:
set_printoptions(linewidth=1000)
to set the maximum characters displayed on a single line to 1000 and:
set_printoptions(... | Spyder, Python IDE startup code crashing GUI | 0.197375 | 0 | 0 | 604 |
25,103,685 | 2014-08-03T10:16:00.000 | 1 | 0 | 0 | 0 | python-3.x,gtk,gtk3 | 25,107,700 | 3 | false | 0 | 0 | The idea behind that is that the introspector converts GTK_ENUMTYPE_ELEMENT to Gtk.ENUMTYPE.ELEMENT for gtk3 python bindings (gi). So having a look at the original Gtk+-3 .x documentation suffices (i.e. using devhelp). (why not have a look at the binding doc itself anyways?). | 1 | 3 | 0 | It's been widely discussed that a few things changed from Python2/Gtk2 to Python3/Gtk+3. I got along with that so far, but there is one thing I am having trouble with: Where did all the constants go?
In Python 2.x I could just do gtk.RESPONSE_OK and now I can do (after a lot of trying around, I found) Gtk.ResponseType.... | Is there a list/guide/documentation where the GTK constants went in GTK+ 3 in Python 3.x? | 0.066568 | 0 | 0 | 282 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.