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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
19,383,989 | 2013-10-15T14:37:00.000 | 0 | 0 | 0 | 0 | python,django,macos | 39,356,674 | 1 | true | 1 | 0 | I figured out the problem. Its the way I installed django in my system. Previously I used sudo easy_install , but this time I created a virtual env and installed django with pip and it worked well. Virtual environment is the best solution for package installation in python. It wont mess with system packages. | 1 | 0 | 0 | I installed Django 1.5.4 on my MAC OSX 10.6.8. I created a test project.
And I am unable to edit any of those files, it says read only. I can sudo it and do the modifications.
But what are the other files it may try to access during run time, if they are read only then my application is not working, for example: sqlite database file "storage.db". Can I change the file permissions on the project root folder level and have it applied all the files inside?
Even If could do that, why Django starting project like this? I tried Virtualenv as well, but of no use same thing happens | Django and file permissions problems | 1.2 | 0 | 0 | 125 |
19,386,254 | 2013-10-15T16:24:00.000 | 2 | 0 | 1 | 0 | ipython,julia,ijulia-notebook | 19,387,317 | 1 | true | 0 | 0 | Probably just a caching issue of the logo. Try executing some code to see if the kernel is actually python or Julia. IJulia notebook is actually an IPython notebook, but which talk to Julia in the back. | 1 | 4 | 0 | How can I use IJulia in my browser?
When I start to open it by executing ipython notebook --profile julia on my Terminal, a new window opens on my browse - however, it is IPython notebook, not IJulia notebook.
Why does it show IPython? For your information, I use Python 2.7.5 and iPython 1.1, and 0.2.0 for Julia. Also, when I tried running Pkg.add("IJulia"), INFO: Nothing to be done. was shown on my screen. | Cannot open IJulia; it instead starts IPython | 1.2 | 0 | 0 | 2,547 |
19,393,098 | 2013-10-15T23:54:00.000 | 2 | 1 | 1 | 0 | c++,python,setup.py | 19,427,165 | 1 | false | 0 | 0 | I would recommend to use Make (other other build systems like CMake) for development and setup.py only for the final installation / deployment. I have done similar Python + C++ projects and it works great that way. | 1 | 6 | 0 | I'm developing a python package that contains a C++ extension. When I install the package using the setup.py script or using pip, the C++ source files are all compiled and linked to obtain a single .so library, which can then be imported in the Python source code. During development, I need to make multiple changes to the source code (testing, debugging, etc). I find that re-installing the package involves rebuilding all the C++ source files, even if only a small part of one file was changed. Obviously, this takes up quite a bit of time.
I'm aware of the development mode (python setup.py develop or pip install -e) that places a link to the source files, so that changes made are immediately seen when the module is re-imported. However, this applies only to the .py source files and not the C++ extension, which has to be re-compiled after every change.
Is there a way to have setup.py look at the .o files in the build directory (while in development mode) and use their timestamps to figure which ones need to be re-compiled? I'm thinking of the way GNU Make performs selective compilation based on timestamps. Thanks | Python C++ extension: compile only modified source files | 0.379949 | 0 | 0 | 702 |
19,393,524 | 2013-10-16T00:50:00.000 | 1 | 0 | 0 | 0 | python,html,parsing,beautifulsoup | 19,393,621 | 1 | true | 1 | 0 | consider this example: http://www.pythonforbeginners.com/python-on-the-web/web-scraping-with-beautifulsoup/ there is line-by-line processing and matching of href(you need td)
additionaly consider: soup.find_all("td", limit=3) | 1 | 1 | 0 | I am parsing an HTML webpage with Python and Beautiful Soup (I am open to other solutions, though). I am wondering if it is possible to parse the file based on a line of HTML, i.e., get the td tag from line3. Is this possible? | Parse HTML by line | 1.2 | 0 | 1 | 378 |
19,394,658 | 2013-10-16T03:19:00.000 | 0 | 0 | 1 | 0 | python,ibm-mq,pymqi | 19,412,440 | 2 | false | 0 | 0 | You can only get messages by MsgID, CorrelID or GroupID. | 1 | 0 | 0 | Using the module pymqi how do you get a message in MQ queue using a parameter, for example "UserIdentifier"? So, I would only get messages from the queue that possess this parameter "UserIdentifier". Thank you for your attention. | Python - PyMQI - Get a message from a queue MQ using parameter | 0 | 0 | 0 | 1,295 |
19,397,436 | 2013-10-16T07:24:00.000 | 0 | 1 | 0 | 0 | c#,ironpython,dynamic-language-runtime | 19,430,707 | 2 | true | 0 | 1 | IronPython will always use BindGetMember and then Invoke the result because that's how Python works - get the attribute from the object, then call it. Your BindGetMember implementation should return another dynamic object that implements BindInvokeMember, which will have the arguments you need. | 1 | 1 | 0 | I have an hybrid c# object, with some instance properties and methods, and I pass it to IronPython. What I want is to syncronize the dispatch to the c# members, both static and dynamics, from Py code.
I implemented the IDynamicMetaObjectProvider on the c# object, and I noticed that when Py invokes the static methods of my object, and with instance methods, defined at compile time vs dynamics, the method BindInvokeMember is never used, but it is always called the method BindGetMember.
I'm a little confused, probably this thing can't be done? | Intercepting method invocation to c# objects | 1.2 | 0 | 0 | 216 |
19,400,489 | 2013-10-16T10:04:00.000 | 0 | 0 | 0 | 0 | python,algorithm | 19,400,758 | 2 | false | 0 | 1 | You can map the 4 vertices on the coordinate axis. Suppose the A(x1, y1),B(x2, y1), C(x1, y2),D(x2, y2) and x1 <= x2 && y1 <= y2, if and only if x1<= x <=x2 and y1 <= y <= y2, the point p(x,y) falls into rectangle ABCD. | 1 | 4 | 0 | In 2D plane, I have a rectangle defined by 4 vertices, A, B, C and D. I now wish to find the integer points (coordinates are integer) that fall into rectangle ABCD.
Before asking, what I did is extremely expensive in computation. Briefly, I was enumerating all the integer points and checked whether that point was in the rectangle or not. I found that it was too brutal to be used in my project, as I have many many point.
How should this be done elegantly?
UPDATE: Note that the rectangle can be of a random orientation, depending on the coordinates of the four points. Assuming nicely-placed is kinda cheating. | Find integer points within a rectangle in Python? | 0 | 0 | 0 | 1,554 |
19,401,302 | 2013-10-16T10:40:00.000 | -1 | 0 | 0 | 1 | python,python-2.7,redhat,python-2.4 | 32,932,552 | 1 | false | 0 | 0 | This page describes the main key differences between Python 2.4 and Python 2.7:
Multithreading
Python 2.4 : Not available.
Python 2.7: You can use the Python 2.7 threading library. All threads in a request must finish before the request deadline (60 seconds for online requests and 10 minutes for offline).
Concurrent requests
Python 2.4 : Not supported.
Python 2.7 :Can use concurrent requests as long as you specify the threadsafe directive in app.yaml. Script handlers must use the Python WSGI interface in order to be threadsafe.
In backends, raising an exception from a shutdown hook copies that exception to all threads.
Bytecode upload
Python 2.4: Not available.
Python 2.7: Can upload .pyc files, but not in combination with .py files. However, you can upload .zip files containing .py or .pyc files (or a combination).
Preferred interface (WSGI vs. CGI)
Python 2.4: CGI is the only supported interface.
Python 2.7: WSGI is the preferred interface, and is required for multithreading. For more information about converting CGI handlers to WSGI, see Migrating to Python 2.7.
Support for C modules
Python 2.4: Some C modules are not available. See the libraries knowledge base for more information.
Python 2.7: The following C modules are not available:
ctypes, sqlite, ssl, _ssl, fcntl, spwd, pwd, grp, syslog, select, _socket | 1 | 1 | 0 | I am running SLC5 (RedHat 4 Linux). The distributed Python version is 2.4. I have installed Python 2.7 in addition manually (altinstall).
Running in terminal mode (Runlevel 3), the key mapping in bash and the Python 2.4 interpreter are correct (backspace, key arrows, etc. are working fine). When running the Python 2.7 interpreter, the key mappings are wrong (Backspace = ^? instead of ^H; Ctrl-H is working fine)
When running under gnome (Runlevel 5) in the gnome-terminal, the mapping is correct for Python 2.7.
Any idea what I need to set/configure that the key mapping is correct for Python 2.7 in the terminal mode (RL3) ?
Thanks very much !
Markus | Keymapping different between Python2.4 and Python2.7 on RedHat | -0.197375 | 0 | 0 | 103 |
19,406,170 | 2013-10-16T14:30:00.000 | 0 | 0 | 0 | 0 | python,django,django-models,django-south | 19,406,368 | 2 | false | 1 | 0 | South will run all the remaining migrations. | 2 | 1 | 0 | I couldn't find a clear cut answer to this via google or the south docs, so i'm posting it here.
I've been using south for a while to manage my django models, however, until now i've always done one migration, pushed to the production server and migrated on there as well. I was wondering, is it possible to do multiple migrations on the production server at the same time?
For example, if i create multiple migrations on my dev server (that were migrated only on the dev server), if i push the migrations via git and run migrate AppName, will it run all the migrations its missing? or just the most recent one? | Multiple migrations in django south | 0 | 0 | 0 | 117 |
19,406,170 | 2013-10-16T14:30:00.000 | 1 | 0 | 0 | 0 | python,django,django-models,django-south | 19,406,489 | 2 | true | 1 | 0 | South keeps track of the migrations that were done in a history table.
In your production environment database, it will reflect the migrations you have done in there and once you push one or more new migrations and run migrate, it will check your migrations against the history table and do the necessary. | 2 | 1 | 0 | I couldn't find a clear cut answer to this via google or the south docs, so i'm posting it here.
I've been using south for a while to manage my django models, however, until now i've always done one migration, pushed to the production server and migrated on there as well. I was wondering, is it possible to do multiple migrations on the production server at the same time?
For example, if i create multiple migrations on my dev server (that were migrated only on the dev server), if i push the migrations via git and run migrate AppName, will it run all the migrations its missing? or just the most recent one? | Multiple migrations in django south | 1.2 | 0 | 0 | 117 |
19,406,444 | 2013-10-16T14:42:00.000 | 0 | 1 | 0 | 1 | python,linux,terminal,raspberry-pi | 19,407,980 | 2 | false | 0 | 0 | What are you using to play the streams? Depending on how you boot up the second Raspberry it might not have started some daemons for audio/video playback?!
You should (if you're not already doing) write a log (import logging ;)) and write a logfile which you can track for errors. | 2 | 0 | 0 | Here's a short description of what I have:
I have to raspberry pi's in a local net work. I one of them I have a .py script named watchdog.py that starts a stream and then uses a sshpass command to the other pi to display the video stream.It also has some signaling LEDs a some push buttons for control
the problem is:
If I open a terminal and run the watchdog.py script in the GUI everything runs as it should be. So I thought of running it as a service as boot and installed upstart and made it run as a service (successfully I think). The thing is. If I boot the pi and then press the button to start the streams,they wont play on the other Pi, the LEDs ligh up and all the buttons work. And even the CPU load behaves the same way, but i still don't video nor audio. I have thought of trying automatically open a terminal (LXterminal) widow and run the python scrip on that window. but I didn't want the streaming raspberry pi also booting into gui (tough I guess I would mind if that makes the whole thing work).This little thing i making the whole project useless. | Run terminal command as startup reacts different from manually (linux raspberry pi) | 0 | 0 | 0 | 631 |
19,406,444 | 2013-10-16T14:42:00.000 | 0 | 1 | 0 | 1 | python,linux,terminal,raspberry-pi | 42,814,929 | 2 | false | 0 | 0 | answer moved from OP's question itself:
I found a way that seems to work so far. instead of running the python script as a service I tried running it as cron job at reboot, and it worked. now it all works straight from reboot and I have Audio and video. | 2 | 0 | 0 | Here's a short description of what I have:
I have to raspberry pi's in a local net work. I one of them I have a .py script named watchdog.py that starts a stream and then uses a sshpass command to the other pi to display the video stream.It also has some signaling LEDs a some push buttons for control
the problem is:
If I open a terminal and run the watchdog.py script in the GUI everything runs as it should be. So I thought of running it as a service as boot and installed upstart and made it run as a service (successfully I think). The thing is. If I boot the pi and then press the button to start the streams,they wont play on the other Pi, the LEDs ligh up and all the buttons work. And even the CPU load behaves the same way, but i still don't video nor audio. I have thought of trying automatically open a terminal (LXterminal) widow and run the python scrip on that window. but I didn't want the streaming raspberry pi also booting into gui (tough I guess I would mind if that makes the whole thing work).This little thing i making the whole project useless. | Run terminal command as startup reacts different from manually (linux raspberry pi) | 0 | 0 | 0 | 631 |
19,407,901 | 2013-10-16T15:46:00.000 | 0 | 0 | 1 | 0 | python,django,xcode,macos,python-imaging-library | 19,429,549 | 2 | true | 0 | 0 | Solved.
I've just install python by homebrew (not linked) and copy all files from /include to my /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
And all started work properly. | 1 | 1 | 0 | Recently i updated to OSX 10.9 DP.
And PIL stop working properly. Django debug said that "decoder jpeg don't working".
Using stackoverflow answer, i tried to reinstall PIL, but PIL said:
"fatal error: 'Python.h' file not found" when installing.
And again i used stackoverflow to find why this happening, and it said that command line tools are not installed, but Xcode 5.0 does not give it download and xcode-select --install give that
'Can not install software because it is not available from the Software Update center'.
How i can solve this? | OSX 10.9 and command line tools, PIL | 1.2 | 0 | 0 | 888 |
19,409,095 | 2013-10-16T16:44:00.000 | 1 | 1 | 1 | 0 | python,simulink | 22,297,932 | 1 | true | 0 | 0 | In Matlab simulink, there is block named TCP/IP receive.
after choosing this block, double click on it. You will see number of option regarding type of data that matlab receiving. | 1 | 0 | 0 | I have a Simulink block, accepting TCP/IP connections and reading the incoming data.
The data has to be integers of type int32.
Imagine we have a variable of any integer number in Python.
We can convert the number to a string and send it via a tcp socket. So far no Problem.
But how to convert the number to that kind of string, that my Simulink blocks receives the number in int32 format? | TCP/IP Message from Python to Simulink | 1.2 | 0 | 0 | 544 |
19,410,823 | 2013-10-16T18:19:00.000 | 0 | 0 | 1 | 0 | python,synchronization | 19,410,884 | 3 | false | 0 | 0 | When you write the config file write it to a temporary file first. When it's done, rename it to the correct name. The rename operation (os.rename) is normally implemented as an atomic operation on Unix systems, Linux and Windows, too, I think, so there will be no risk of the other process trying to read the config while the writing has not been finished yet. | 1 | 1 | 0 | I'm a Python beginner and facing the following : I have a script periodically reading a settings file and doing something according to those settings . I have another script triggered by some UI that writes the settings file with user input values. I use the ConfigParser module to both read and write the file.
I am wondering if this scenario is capable of leading into an inconsistent state (like in middle of reading the settings file, the other script begins writing). I am unaware if there are any mechanism behind the scene to automatically protect against this situations.
If such inconsistencies are possible, what could I use to synchronize both scripts and mantain the integrity of the operations ? | Consistent reading and writing a file in python | 0 | 0 | 0 | 2,469 |
19,411,039 | 2013-10-16T18:30:00.000 | 0 | 0 | 0 | 0 | python,push-notification,google-cloud-messaging | 19,411,494 | 1 | true | 1 | 0 | It is possible to send a notification to a single device on which the app is installed. Each device is assigned a registration ID when your app registers to GCM on that device. If you send this registration ID along with some identifier that identifies the user of the app on that device (the professor in your case), your server will be able to send messages to specific users. | 1 | 0 | 0 | just I want to ask you about GCM technology,I have to use it for my client in his application(college application). So my question : Is it possible to send a message for someone let's say a professor working in that college(Hi Sir, please you have to be present in administration today at 9 Am), of course as I said just for one professor not all the users application !!!
my idea here is to pick the specific professor from the listview of all persons in that college (by fetching the database) and send to him my message as push information .
just I want to note that I'm using python as backend language and Android as client
Is my idea valid or should I see another way ???
thanks a lot. | customed message for a specific person via GCM(google cloud messaging) | 1.2 | 0 | 0 | 84 |
19,411,111 | 2013-10-16T18:34:00.000 | 2 | 0 | 0 | 0 | python,gtk,custom-controls,scrollbar,pygtk | 19,477,901 | 1 | true | 0 | 1 | Most widgets in Gtk do not have scrollbars.
If you want to scroll the entire widget, you have to implement the GtkScrollable interface. Then, you add the widget to a GtkScrolledWindow. The scrolled window has the scrollbars, those GtkScrollbars are linked with GtkAdjustments which are passed to your custom widget through the GtkScrollable interface set_vadjustment and set_hadjustment.
If you just want to add a scrollbar and control its behaviour yourself, then you need to somehow add a GtkScrollbar in your widget, which means you will need to make it a container too.
The GtkScrollable approach is the following, first you implement vadjustment and hadjustment setters and getters, then when the GtkAdjustments are set, you set its lower and upper limits and the page size(how much of the widget is visible at once). After that, you connect their value-changed signal so you can refresh your widget when the scrollbars are dragged. A GtkScrollable doesn't get to check the scrollbars, only the adjustments that will be bound to the scrollbars. When drawing the widget you get the adjustments' value property in order to determine how much the scrollbars have shifted in the horizontal and vertical axes. | 1 | 0 | 0 | I'm working on a X-plotter like widget that plots incomming data live.
I already searched for an solution to realize a scrolling along the x-axis if the widget has to much values and so they don't fit.
I had the folling approaches to realize it:
derive from a widget that supports scrolling and child widgets and add my own widget while making it bigger and bigger during the live updates: -> Which parent do I need to use and how do I avoid to draw all the stuff that is currently not visible?
modify my widget in a way that it supports the scrollbars itself -> but how?
draw/handle my own scrollbars -> worstcase :(
I really searched the web for suggestions or examples, but there is nothing about how to "construct" custom controls in a good way (beyond drawing something) esp. in the case of interaction...
Sorry but I'm a newbie at GTK in general :/ | Python: Creating own Widget with scrollbars | 1.2 | 0 | 0 | 574 |
19,411,652 | 2013-10-16T19:04:00.000 | 0 | 1 | 0 | 0 | php,python | 19,448,302 | 2 | true | 0 | 0 | The problem was the matplotlib backend setting. I changed to 'Agg' and the plot function worked fine. | 1 | 0 | 0 | I want to run Python script from PHP. The script's syntax is good, when I run it from command line it generates an image file next to it. When I run the PHP file (contains Python exec) from command line it generates an image file. It's good. The problem is: when I use browser and run PHP it isn't generate any image file. I use Xubuntu OS. | Run Python script from PHP | 1.2 | 0 | 0 | 408 |
19,414,847 | 2013-10-16T22:11:00.000 | 0 | 0 | 1 | 0 | python,floating-point,hex | 19,415,085 | 5 | false | 0 | 0 | Try float.hex(input) if input is already a float. | 1 | 3 | 0 | How to convert floating point number to base-16 numbers, 8 hexadecimal digits per 32-bit FLP number in python?
eg : input = 1.2717441261e+20 output wanted : 3403244E | How to convert floating point number in python? | 0 | 0 | 0 | 10,632 |
19,417,402 | 2013-10-17T02:47:00.000 | 1 | 0 | 0 | 0 | python,django,django-admin | 19,418,721 | 1 | true | 1 | 0 | There is the django.contrib.auth.signals.user_logged_in signal. If you only want to call the function for admin logins check the request against your admin urlconf. | 1 | 0 | 0 | I thought this would be simple thing to figure out but I have not been able find any examples.
I just want to run a function whenever a user logs in to the Django Admin. | Run Function When Loggin To Django Admin | 1.2 | 0 | 0 | 63 |
19,422,749 | 2013-10-17T09:22:00.000 | 0 | 0 | 0 | 0 | python,matplotlib | 19,423,078 | 2 | false | 0 | 0 | my 2 cents:
x^3+y^3+y^2+2xy^2=0
y^2=-x^3-y^3-2xy^2
y^2>0 => -x^3-y^3-2xy^2>0 => x^3+y^3+2xy^2<0 =>
x(x^2+2y^2)+y^3<0 => x(x^2+2y^2)<-y^3 => (x^2+2y^2)<-y^3/x
0<(x^2+2y^2) => 0<-y^3/x => 0>y^3/x =>
(x>0 && y<0) || (x<0 && y>0)
your graph will span across the 2nd and 4th quadrants | 1 | 2 | 1 | I would like to draw the curve a generic cubic function using matplotlib. I want to draw curves that are defined by functions such as: x^3 + y^3 + y^2 + 2xy^2 = 0. Is this possible to do? | how to draw a nonlinear function using matplotlib? | 0 | 0 | 0 | 2,800 |
19,426,810 | 2013-10-17T12:30:00.000 | 1 | 1 | 1 | 0 | c++,python,boost-python | 19,427,479 | 2 | false | 0 | 0 | It sounds like you want to subclass, which would be the other answer provided; however if you are looking to change an objects class on-the-fly, you could use object.__class__ = NewClass -- though this may be considered EVIL in some (probably most) circles. | 1 | 0 | 0 | I've used Boost.Python to expose my class into Python. I want to change this class or override some parts of it in Python as well as what we can do on classes in Python by default. | Expose a class to Python and change it in Python as well | 0.099668 | 0 | 0 | 56 |
19,430,346 | 2013-10-17T15:03:00.000 | 0 | 0 | 1 | 1 | python,pip,setuptools | 56,683,743 | 7 | false | 0 | 0 | This will display the version of your setuptools if it is installed already
$python -c "import sys; import setuptools; print(setuptools.version.__version__)" | 2 | 18 | 0 | I'm writing a quick shell script to make it easier for some of our developers to run Fabric. (I'm also new to Python.) Part of installing Fabric is installing pip, and part of installing pip is installing setuptools.
Is there any easy way to detect if setuptools is already installed? I'd like to make it possible to run the script multiple times, and it skip anything it's already done. As it stands now, if you run ez_setup.py twice in a row, you'll get a failure the second time.
One idea I had was to look for the easy_install scripts under the /Scripts folder. I can guess at the Python root using sys.executable, and then swap off the executable name itself. But I'm looking for something a little more elegant (and perhaps cross-OS friendly). Any suggestions? | How can I tell if Python setuptools is installed? | 0 | 0 | 0 | 68,259 |
19,430,346 | 2013-10-17T15:03:00.000 | 0 | 0 | 1 | 1 | python,pip,setuptools | 62,062,115 | 7 | false | 0 | 0 | Depends with the python version installed. you can try "pip list" or "pip3 list" and check for the setuptools and version installed. | 2 | 18 | 0 | I'm writing a quick shell script to make it easier for some of our developers to run Fabric. (I'm also new to Python.) Part of installing Fabric is installing pip, and part of installing pip is installing setuptools.
Is there any easy way to detect if setuptools is already installed? I'd like to make it possible to run the script multiple times, and it skip anything it's already done. As it stands now, if you run ez_setup.py twice in a row, you'll get a failure the second time.
One idea I had was to look for the easy_install scripts under the /Scripts folder. I can guess at the Python root using sys.executable, and then swap off the executable name itself. But I'm looking for something a little more elegant (and perhaps cross-OS friendly). Any suggestions? | How can I tell if Python setuptools is installed? | 0 | 0 | 0 | 68,259 |
19,430,713 | 2013-10-17T15:18:00.000 | 1 | 1 | 0 | 0 | python,web,nginx,apache2,webserver | 19,431,028 | 2 | true | 1 | 0 | I would probably go with - Apache2(mod_wsgi) + Nginx(Proxy) . Where Nginx will be serving the static content and directing the dynamic content request to Apache2 server . This will improve the performance of your application . | 1 | 0 | 0 | We want to write our Webapps in Python for High-Traffic use (800 req/sec), but we don't know which Webserver and module are the best one.
We actually think Apache2 + mod_wsgi is a good option, but maybe Apache2 + FastCGI or Nginx + mod_wsgi oder FastCGI could be better.
Any Ideas? | Which Webserver shall i take for High-Traffic Python Web-Pages? | 1.2 | 0 | 0 | 227 |
19,433,585 | 2013-10-17T17:41:00.000 | 0 | 0 | 1 | 0 | python,module,beautifulsoup,ipython-notebook,anaconda | 23,173,707 | 1 | false | 1 | 0 | There are two possible answers to your question. If you have no need for running multiple copies of Python running different modules, you can simply change all instances of the string "Python27" in your PATH to "Anaconda" (assuming you want to run the Anaconda Python) as suggested in the comments.
Alternately, if you want to run different combinations of modules in two copies of the same version of Python, you can segregate/partition the modules you install into Anaconda/default Python versions. If you install using Windows installer, just make sure both versions of Python are in the registry (they should be by default) and the install wizard should allow you to choose where you want to install it. You can also individually install modules from their source code, adding them to "C:\Python27\Lib" or "C:\Anaconda\Lib" depending on the environment in which you want to use them. | 1 | 1 | 0 | When I try and import BeautifulSoup into IPython Notebook I get an error message: ImportError: No module named BeautifulSoup. The package is installed and works perfectly in IDLE. When I check system version, it returns 2.7.5 |Anaconda 1.7.0 (64-bit)| (default, Jul 1 2013, 12:37:52) [MSC v.1500 64 bit (AMD64)]. This would seem to be the same version of python I run in IDLE, though minus the Anaconda. How can I fix this problem? | Importing Packages in Ipython Notebook | 0 | 0 | 0 | 1,282 |
19,434,458 | 2013-10-17T18:29:00.000 | 0 | 0 | 0 | 0 | google-api,google-apps,google-api-python-client,google-admin-sdk,google-apps-for-education | 19,525,414 | 1 | true | 1 | 0 | You cannot, that's the answer. | 1 | 1 | 0 | This is for users in Google Apps for Business or Education.
Using the Reports API in the Admin SDK I can see when the admin changed another user's password, but I cannot find an API that will tell me when a user has changed their password. I have changed mine twice in the past couple days and it does not come up in Reports API any where. Thanks for the help. | How do I find the time the user changed their password using the Google APIs? | 1.2 | 0 | 1 | 1,254 |
19,436,220 | 2013-10-17T20:06:00.000 | 0 | 0 | 0 | 0 | python,excel,pandas | 41,857,586 | 1 | false | 0 | 0 | It sounds to me like your python code is inserting a carriage return either before or after the value.
I've replicated this behavior in Excel 2016 and can confirm that the cell appears blank, but does contain a value.
Furthermore, I've verified that using the text to columns will parse the carriage return out. | 1 | 2 | 1 | I used the Python Pandas library as a wrap-around instead of using SQL. Everything worked perfectly, except when I open the output excel file, the cells appear blank, but when I click on the cell, I can see the value in the cell above. Additionally, Python and Stata recognize the value in the cell, even though the eye cannot see it. Furthermore, if I do "text to columns", then the values in the cell become visible to the eye.
Clearly it's a pain to go through every column and click "text to columns", and I'm wondering the following:
(1) Why is the value not visible to the eye when it exists in the cell?
(2) What's the easiest way to make all the values visible to the eye aside from the cumbersome "text to columns" for all columns approach?
(3) I did a large number of tests to make sure the non-visible values in the cells in fact worked in analysis. Is my assumption that the non-visible values in the cells will always be accurate, true?
Thanks in advance for any help you can provide! | Python Pandas Excel Display | 0 | 0 | 0 | 311 |
19,438,160 | 2013-10-17T22:07:00.000 | 2 | 1 | 0 | 1 | python,linux,ubuntu,cron | 19,448,431 | 1 | false | 0 | 0 | The GPL is not anti-commercial. python-crontab can be used in commercial products and services. You must only follow the copy-left rules witch state that the actual code itself can't be made proprietary. You can sell it as much as you like, and as the author I encourage you to make money from my work.
Besides that error, it doesn't look like your problem requires python-crontab anyway. You could just open the files yourself and if that doesn't work, it was never going to work with python-crontab anyway. | 1 | 2 | 0 | I have a Python script that runs in several modes. One of those modes monitors certain files, and if those files have been modified, the script restores them. The way I do this is to run the script every minute via cron.
Another cron job exists (actually the same script called with a different argument) to remove the script from the crontab when the scheduled time has elapsed. Initially, I was attempting to work with a crontab in /etc/cron.d. The script behaves as expected if executed on the command line, but does not edit the crontab when it is run from cron.
I then switched to writing a temporary file and executing crontab tempfile (via subprocess.Popen) from the script. This doesn't work either, as the crontab is simply not created. Executing crontab tempfile from the commandline and using the temporary file created by the script works as expected.
I can't use the python-crontab library as this is a commercial project and that library is GPLed.
Are there any inherent limitations in cron that prevent either approach from working? | Modifying a crontab from a cron job | 0.379949 | 0 | 0 | 1,397 |
19,438,580 | 2013-10-17T22:43:00.000 | 1 | 0 | 1 | 1 | python,environment-variables,virtualenv | 20,532,631 | 1 | true | 0 | 0 | I discovered that the reason my virtual environment's environment variables were keeping their previous values was because I was still in the same terminal session. Restarting my terminal fixed the issue. | 1 | 1 | 0 | When I created my virtual environment, it inherited all of the environment variables that were currently on my Windows machine. I have since changed many of those variables, and my virtual environment is now stuck with the old values. How can I change the environment variables within my virtual environment? | Why does my virtualenv inherit the system's old environment variables? | 1.2 | 0 | 0 | 410 |
19,440,448 | 2013-10-18T02:09:00.000 | 0 | 0 | 1 | 0 | python-2.7 | 19,440,477 | 1 | false | 0 | 0 | Dictionary literals are created by the compiler (or rather, the compiler emits bytecode to create them directly). If you want to override this then you'll need to compile the source into into bytecode yourself and then iterate through the bytecode, replacing the dict creation with a bytecode sequence of your choosing. | 1 | 0 | 0 | Can I overload the {} dictionary definition meta-characters/operator for a particular python namespace?
What I am asking is how to (in pure python), replace the type({}) == dict with type({}) == instance && isinstance({}, MyDict) == True.
I have a configuration file in python syntax. I'd the user to be able to define dictionaries, but I want to guarantee the order of the dictionary items are the same as the user put them in the code. I figured the only way this could be done is if I could overload the syntactic sugar surrounding {} dictionary declaration characters.
If it can't be done, that'd be a OK answer.
Thanks,
Chenz | Can I overload the {} dictionary definition meta-characters/operator for a particular python namespace? | 0 | 0 | 0 | 24 |
19,441,031 | 2013-10-18T03:20:00.000 | 2 | 0 | 1 | 0 | python,offline | 19,441,388 | 9 | false | 0 | 0 | Windows Idle - F1 from shell window or editing window gets you a windows help file of all the docs. I think it's better than the online version - it's easier to find stuff. | 3 | 40 | 0 | In python I can get some rudimentary documentation for any object using help(<object>). But to be able to search the documentation, I have to go online. This isn't really helpful if I'm somewhere where the internet isn't accessible.
In R, there is a handy double question mark feature (??<topic>) that allows me to search through the documentation of all installed libraries for any function that includes <topic> in its name or documentation string. Is there anything similar for python? Perhaps even just for loaded objects? | Search python docs offline? | 0.044415 | 0 | 1 | 17,711 |
19,441,031 | 2013-10-18T03:20:00.000 | 29 | 0 | 1 | 0 | python,offline | 20,266,169 | 9 | false | 0 | 0 | pydoc comes with python and can do searches but only in the synopsis lines of available modules. Quoting pydoc --help:
pydoc -k
Search for a keyword in the synopsis lines of all available modules.
Note that into pydoc you can perform searches using "/". | 3 | 40 | 0 | In python I can get some rudimentary documentation for any object using help(<object>). But to be able to search the documentation, I have to go online. This isn't really helpful if I'm somewhere where the internet isn't accessible.
In R, there is a handy double question mark feature (??<topic>) that allows me to search through the documentation of all installed libraries for any function that includes <topic> in its name or documentation string. Is there anything similar for python? Perhaps even just for loaded objects? | Search python docs offline? | 1 | 0 | 1 | 17,711 |
19,441,031 | 2013-10-18T03:20:00.000 | 2 | 0 | 1 | 0 | python,offline | 20,134,465 | 9 | false | 0 | 0 | Although there are certainly better documentations built into your computer than help() like windows idle, another option for some of the more common topics would just be to save some of the online documentation to your computer. For the modules you use a lot and want to access offline, you could just download a text file version of the official online python documentation, which is the best place to get documentation. (file > save page as > select .txt file format) | 3 | 40 | 0 | In python I can get some rudimentary documentation for any object using help(<object>). But to be able to search the documentation, I have to go online. This isn't really helpful if I'm somewhere where the internet isn't accessible.
In R, there is a handy double question mark feature (??<topic>) that allows me to search through the documentation of all installed libraries for any function that includes <topic> in its name or documentation string. Is there anything similar for python? Perhaps even just for loaded objects? | Search python docs offline? | 0.044415 | 0 | 1 | 17,711 |
19,445,789 | 2013-10-18T09:10:00.000 | 0 | 0 | 1 | 0 | python,regex,python-2.7 | 19,445,831 | 2 | true | 0 | 0 | Wrap each sub-regexp in (). After the match, you can go through all the groups in the matcher (match.group(index)). The non-empty group will be the one that matched. | 1 | 0 | 0 | I have a multiple regex which combines thousands of different regexes e.g r"reg1|reg2|...".
I'd like to know which one of the regexes gave a match in re.search(r"reg1|reg2|...", text), and I cannot figure how to do it since `re.search(r"reg1|reg2|...", text).re.pattern gives the whole regex.
For example, if my regex is r"foo[0-9]|bar", my pattern "foo1", I'd like to get as an answer "foo[0-9].
Is there any way to do this ? | Find which part of a multiple regex gave a match | 1.2 | 0 | 0 | 89 |
19,446,500 | 2013-10-18T09:45:00.000 | 10 | 0 | 0 | 0 | django,python-sphinx | 19,479,061 | 1 | true | 1 | 0 | In for sphinx-doc (i have never used django-sphinx) it would never work to run make html inside the build folder. You need to go one folder level up so that the folders build and source ar visible. Most likely you will see the Makefile file here as well.
Try to change directories and run make html again. | 1 | 4 | 0 | I have installed django sphinx for my project.After successful installation and sphinx quickstart operation, i tried for creating html inside the "build" folder using the command "make html" and it gives me the error
"make: * No rule to make target `html'. Stop.".
Any help..Thanks in advance. | Error while executing django sphinx | 1.2 | 0 | 0 | 4,743 |
19,446,843 | 2013-10-18T10:00:00.000 | 1 | 0 | 1 | 0 | python-3.x | 19,446,876 | 2 | false | 0 | 0 | If you are using Python 3.x, you have to do print('hello world').
In Python 2.x, print was a statement, like if, for, etc. Now it is a function, thus the (). | 2 | 0 | 0 | I have just downloaded Python 3.3.2 to use on windows7 and run the msi file to install. After installation I have tried using the prog only to find that every time I run my initial print 'hello world' it keeps reporting a syntax error.
I have tried both single and double quotes but each time reports a syntax. It will add say 8 + 9 and return the answer but no joy with using a print statement.
I have tried both the shell and a new window but without success.
Any advice please much appreciated. | Novice with Python | 0.099668 | 0 | 0 | 45 |
19,446,843 | 2013-10-18T10:00:00.000 | 1 | 0 | 1 | 0 | python-3.x | 19,446,883 | 2 | false | 0 | 0 | You're probably using instructions for a python-2 program, where print was a statement, rather than a function. In python >= 3, you have to do print(something), rather than just print something. | 2 | 0 | 0 | I have just downloaded Python 3.3.2 to use on windows7 and run the msi file to install. After installation I have tried using the prog only to find that every time I run my initial print 'hello world' it keeps reporting a syntax error.
I have tried both single and double quotes but each time reports a syntax. It will add say 8 + 9 and return the answer but no joy with using a print statement.
I have tried both the shell and a new window but without success.
Any advice please much appreciated. | Novice with Python | 0.099668 | 0 | 0 | 45 |
19,447,427 | 2013-10-18T10:29:00.000 | 1 | 0 | 0 | 0 | python,django,django-templates | 19,448,846 | 4 | false | 1 | 0 | That happens by default, because of Django's autoescaping. You have to specifically mark content as safe before it will be interpreted as HTML. | 3 | 0 | 0 | Is it possible in django to print a string keeping the html tags?
So if I write {{ variable }} the html content inside the variable doesn't get interpreted by the browser as html.
(Really a newbie)
Thanks | Print html tags in Django | 0.049958 | 0 | 0 | 2,731 |
19,447,427 | 2013-10-18T10:29:00.000 | 2 | 0 | 0 | 0 | python,django,django-templates | 19,447,655 | 4 | false | 1 | 0 | You can use the escape filter {{variable|escape}}
Same as php's htmlentities or htmlspecialchars | 3 | 0 | 0 | Is it possible in django to print a string keeping the html tags?
So if I write {{ variable }} the html content inside the variable doesn't get interpreted by the browser as html.
(Really a newbie)
Thanks | Print html tags in Django | 0.099668 | 0 | 0 | 2,731 |
19,447,427 | 2013-10-18T10:29:00.000 | 0 | 0 | 0 | 0 | python,django,django-templates | 61,307,178 | 4 | false | 1 | 0 | You can use the safe filter {{variable|safe}} | 3 | 0 | 0 | Is it possible in django to print a string keeping the html tags?
So if I write {{ variable }} the html content inside the variable doesn't get interpreted by the browser as html.
(Really a newbie)
Thanks | Print html tags in Django | 0 | 0 | 0 | 2,731 |
19,448,553 | 2013-10-18T11:26:00.000 | 0 | 0 | 1 | 1 | python,windows-7,intellij-idea,virtualenv,python-2.6 | 19,448,864 | 2 | false | 0 | 0 | Just install an appropriate python and virtualenv for that python directly on the windows 7 machine. | 2 | 1 | 0 | I have Python application and virtualenv for it. I run it on Debian virtual machine. Is it possible to configure IntelliJ to start application and use IntelliJ debug tools? The problem is how to use virtualenv for debian in Windows 7 system. | IntelliJ IDEA - unix python virtualenv on WIndows | 0 | 0 | 0 | 426 |
19,448,553 | 2013-10-18T11:26:00.000 | 0 | 0 | 1 | 1 | python,windows-7,intellij-idea,virtualenv,python-2.6 | 19,809,928 | 2 | false | 0 | 0 | I solved it. If connect with my virtual machine by remote debug tool. I add one line with IntellJ/PyCharm generate to entry point of paster script. Before debug i run script (using IntelliJ remote tool) with run application on virtual machine. | 2 | 1 | 0 | I have Python application and virtualenv for it. I run it on Debian virtual machine. Is it possible to configure IntelliJ to start application and use IntelliJ debug tools? The problem is how to use virtualenv for debian in Windows 7 system. | IntelliJ IDEA - unix python virtualenv on WIndows | 0 | 0 | 0 | 426 |
19,452,172 | 2013-10-18T14:28:00.000 | 5 | 0 | 0 | 1 | python,google-app-engine | 19,454,685 | 2 | true | 1 | 0 | If you use the ancestor in the key you will create a big entity group (assuming a single root to the tree/hierarchy) which may in fact not be what you want from a write performance point of view. Also a deep hierarchy can mean very big keys.
If you want to move nodes around using ancestor keys, you have to delete and recreate the entire child hierarchy of keys, where as storing the parent in the node (or the children keys in the parent) means you just store different keys in properties.
If you normally walk down the hierarchy (say url traversal) you may find it more efficient to just store the childrens keys in a list in the parent, assuming each level is not going to have too many immediate children, as well as storing the parent key in the child.
I would examine your actual requirements in detail before deciding which way to go. | 1 | 3 | 0 | I'm trying to store a hierarchy in NDB and I'm confused about if I should use just the 'parent' parameter while constructing the keys to new entities or should I include an extra property in my models to hold the parent key? | Hierarchy in Google App Engine NDB | 1.2 | 0 | 0 | 1,057 |
19,455,782 | 2013-10-18T17:35:00.000 | 5 | 0 | 1 | 0 | python,performance | 19,455,848 | 4 | true | 0 | 0 | Python's regex module does cache the compiled versions of recently-used regexes, so you can probably remove the explicit compiles and not have an issue. | 2 | 2 | 0 | I have a function that iterates over a text file to extract certain information by using regular expressions to find the information. But, the program goes over multiple files and so calls this function several times.
Currently, I have the regular expressions compile as the first steps of the function. But I started wondering if this is good design from a programming perspective since the function gets called several times.
Is the interpreter smart enough to see that these do not change and cache them away between runs? Alternatively I considered compiling them as global variables so that it would always be available only compiled once, but that separates the regex from the place it will be used which makes it harder to read. The other option I looked at was creating the function as a closure with regex values passed in when it is created, but that seemed unnecessarily complex.
In short, What is the most efficient way to compile the RE's (or any other value which is calculated once) that is still readable and pythonic?
Thank you. | Python: Where to compile an RE? | 1.2 | 0 | 0 | 151 |
19,455,782 | 2013-10-18T17:35:00.000 | 0 | 0 | 1 | 0 | python,performance | 19,456,056 | 4 | false | 0 | 0 | There's nothing wrong with having the re's compiled and available as module-level objects. Not that it's always current best practice, but it's what's used in various modules in the stdlib.
To me, using module-level compiled re objects would be preferable to 3.3's caching as the cache relies on an implementation detail that you likely have not much control over (or could change in future versions). Defining them at module scope makes it obvious to the reader of your code that they're compiled once and used N times. | 2 | 2 | 0 | I have a function that iterates over a text file to extract certain information by using regular expressions to find the information. But, the program goes over multiple files and so calls this function several times.
Currently, I have the regular expressions compile as the first steps of the function. But I started wondering if this is good design from a programming perspective since the function gets called several times.
Is the interpreter smart enough to see that these do not change and cache them away between runs? Alternatively I considered compiling them as global variables so that it would always be available only compiled once, but that separates the regex from the place it will be used which makes it harder to read. The other option I looked at was creating the function as a closure with regex values passed in when it is created, but that seemed unnecessarily complex.
In short, What is the most efficient way to compile the RE's (or any other value which is calculated once) that is still readable and pythonic?
Thank you. | Python: Where to compile an RE? | 0 | 0 | 0 | 151 |
19,458,338 | 2013-10-18T20:17:00.000 | 0 | 0 | 0 | 0 | python,google-bigquery | 19,459,294 | 2 | true | 0 | 0 | Unfortunately, there isn't a way to do this right now, since, as you realized, all results are flattened. | 1 | 1 | 0 | I have a few large hourly upload tables with RECORD fieldtypes. I want to pull select records out of those tables and put them in daily per-customer tables. The trouble I'm running into is that using QUERY to do this seems to flatten the data out.
Is there some way to preserve the nested RECORDs, or do I need to rethink my approach?
If it helps, I'm using the Python API. | Bigquery: how to preserve nested data in derived tables? | 1.2 | 1 | 0 | 234 |
19,460,457 | 2013-10-18T23:18:00.000 | 0 | 0 | 1 | 0 | python | 19,460,500 | 5 | false | 0 | 0 | Take a look pickle Object serialization. With pickle you can serialize your list and then save it to a text file. Later you can 'unpickle' the data from the text file. The data will be unpickled to a list and you can use it again in python. @inspectorG4dget beat me to the answer so take a look at. | 1 | 4 | 0 | I have a list of 16 elements, and each element is another 500 elements long. I would like to write this to a txt file so I no longer have to create the list from a simulation. How can I do this, and then access the list again? | How can I write a list of lists into a txt file? | 0 | 0 | 0 | 6,780 |
19,463,702 | 2013-10-19T07:42:00.000 | 1 | 0 | 0 | 0 | python,django,structure | 19,463,759 | 2 | true | 1 | 0 | If the module is independent from Django, then it should be a standalone Python package, complete with a setup.py to install it. The Django models and webservices that use it can import like any other external dependencies.
If the module depends on you Django app, then it should be inside the app's directory. If it doesn't define new models, then it should not be in models.py.
Does this answer your question? | 1 | 4 | 0 | I'm currently working on a django project. I'm not completly new in django, but have some difficulties figuring out how would be the most 'djangonic' way to organize some files.
I have some classe that compute stuff, and can be used from the manage.py's cli, and by a webservice app. Those computation uses models from my core app and make call to the database.
The problem I face is that I can't figure where to put those source file.
I do not want to put them in a 'lib' folder. I think the modules in this folder will be django independent modules.
For the moment, the module is in the model of my app. But since it doesn't define any new structure, I don't think it is the cleanest way.
Any ideo to have a clean structure that respect the 'django way of life' ?
Thanks | Django, project structure | 1.2 | 0 | 0 | 2,336 |
19,465,158 | 2013-10-19T10:44:00.000 | 0 | 0 | 0 | 1 | python,shared-hosting,mezzanine | 21,524,630 | 2 | false | 1 | 0 | Now supporting with Mezzanine 3.x | 1 | 0 | 0 | I'm trying to use Mezzanine cms in a shared hosting at 1and1. I installed a recent python version 3.3.2.
setup works well but when i try to create a project I got the following error message:
~/Mezzanine-1.4.16 > mezzanine-project blog
Traceback (most recent call last):
File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/bin/mezzanine-project", line 9, in
load_entry_point('Mezzanine==1.4.16', 'console_scripts', 'mezzanine-project')()
File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/lib/python3.3/site-packages/distribute-0.6.49-py3.3.egg/pkg_resources.py", line 345, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/lib/python3.3/site-packages/distribute-0.6.49-py3.3.egg/pkg_resources.py", line 2382, in load_entry_point
return ep.load()
File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/lib/python3.3/site-packages/distribute-0.6.49-py3.3.egg/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/lib/python3.3/site-packages/Mezzanine-1.4.16-py3.3.egg/mezzanine/bin/mezzanine_project.py", line 9, in
from mezzanine.utils.importing import path_for_import
File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/lib/python3.3/site-packages/Mezzanine-1.4.16-py3.3.egg/mezzanine/utils/importing.py", line 23
except (ValueError, ImportError, AttributeError), e:
^
SyntaxError: invalid syntax
Any thoughts on how to fix this ? thank you. | Issue creating project with mezzanine - shared hosting | 0 | 0 | 0 | 265 |
19,469,608 | 2013-10-19T18:37:00.000 | 1 | 0 | 1 | 0 | python,memory,logging,exception-handling,out-of-memory | 19,469,698 | 3 | false | 0 | 0 | In general, an out of memory error is likely to be the toughest problem to deal with in your program since you are out of the main resource that would let you do anything. Perhaps the program could be run in a script that detects the failure from the output and logs it.
You could try using some memory whose sole purpose is to be "released" on an out of memory error. But I am not sanguine about that approach in python. | 1 | 5 | 0 | As part of one of my programs, I want to catch any MemoryError and log them. Currently, I'm using traceback.format_exception to format all other exceptions; I would like to do that for MemoryError as well.
However, using format_exception requires using more memory, which is exactly what I cannot do when I'm out of memory.
What do?
What can I do when I'm thrown a MemoryError besides terminating? Ideally, I would log them and then resume the program on the assumption that freeing the part of the stack between the handler and the thrower* has freed up sufficient memory for me to do so.
(* and also those heap objects kept alive only by the references emanating from that stack section) | How to log a python MemoryError (when I'm out of memory) | 0.066568 | 0 | 0 | 3,532 |
19,470,798 | 2013-10-19T20:28:00.000 | 1 | 0 | 0 | 0 | c#,python,sockets | 19,470,856 | 1 | false | 0 | 0 | Socket addresses are a host and port, not just a host. And different connections from the same host will always have different ports. (I'm assuming TCP, not UDP, here.)
Or, even more simply, you can just compare the file descriptors (or, in Python, the socket objects themselves) instead of their peer addresses.
Meanwhile, for performance, on most platforms, 500 is nearing the limits of what you can do with threads, but not yet over the limits, so you could do it that way. But I think you'll be better off with a single-threaded reactor or a proactor with a small thread pool. Especially if you can use a preexisting framework like twisted or gevents to do the hard part for you.
As for the language, for just forwarding or filtering packets, the performance of your socket multiplexing will be all that matters, so there's no problem using Python. Pick a framework you like from either language, and use that language.
Some last side comments: you do realize that TCP packets aren't going to match up with messages in your higher level protocol(s), right? Also, this whole thing would probably be a lot easier to do, and more efficient, with a Linux or BSD box set up as a router so you don't have to write anything but the filters. | 1 | 1 | 0 | I'm looking to create some kind of a gateway that sits between a server and a client.
The so called gateway is supposed to filter some packets sent by the client and forward 99% of them.
Here are my questions:
Client opens a new socket to the gateway, i open a socket to the server from the gateway and store it in a list for further use. However, in one situation, all the connections will come from the same IP, thus leaving me with limited options on choosing the socket that should forward the packet to the server. How can i differentiate between opened sockets?
From previous situations, i'm expecting about 500 clients sending a packet every second. Performance wise, should i use a multithread model, or stick with a single thread application?
Still a performance question :I have to choose between C# and Python. Which one should give better performance? | Sockets packet forwarding | 0.197375 | 0 | 1 | 1,277 |
19,472,177 | 2013-10-19T23:16:00.000 | 0 | 1 | 0 | 0 | python,http,session,login,urllib2 | 19,481,620 | 1 | false | 0 | 0 | As you mentioned yourself, the logged-in state is most of the time determined by validity of specific cookie. You can check if the cookie is still valid by comparing it's expiry time with the current time. Alternatively you can make HEAD request which allows you to get cookies (and other headers) without the need to download page body. However you have to check if the site handles HEAD requests for this to work. | 1 | 0 | 0 | I wrote a program to login to a website and do some automatic stuff (by making HTTP requests).
Most of these automatic stuff requires the program/session is in logged-in state (if the cookie expires, the program/session can not be considered in logged-in state), so I am implementing a isLoggedIn function to test it.
My current approach to get a page only available after login, but this requires a HTTP request and the transfer of a web page, so it is not very fast, what are other possible solutions?
Any lead will be appreciated!
Thank you very much! | What is the fastest way to test whether logged in or not when use python to login to a website? | 0 | 0 | 1 | 47 |
19,473,185 | 2013-10-20T02:10:00.000 | 3 | 0 | 1 | 0 | python,variables,if-statement | 60,411,091 | 9 | false | 0 | 0 | All of these are good answers but I think there's more to explain why None is useful.
Imagine you collecting RSVPs to a wedding. You want to record whether each person will attend. If they are attending, you set person.attending = True. If they are not attending you set person.attending = False. If you have not received any RSVP, then person.attending = None. That way you can distinguish between no information - None - and a negative answer. | 1 | 142 | 0 | I have been studying Python, and I read a chapter which describes the None value, but unfortunately this book isn't very clear at some points. I thought that I would find the answer to my question, if I share it there.
I want to know what the None value is and what do you use it for?
And also, I don't get this part of the book:
Assigning a value of None to a variable is one way to reset it to
its original, empty state.
What does that mean?
The answers were great, although I didn't understand most of answers due to my low knowledge of the computer world (I haven't learned about classes, objects, etc.). What does this sentence mean?
Assigning a value of None to a variable is one way to reset it
to its original, empty state.
Final:
Finally I've got my answer from looking to different answers. I must appreciate all the people who put their times to help me (especially Martijn Pieters and DSM), and I wish that I could choose all answers as the best, but the selection is limited to one. All of the answers were great. | What is a None value? | 0.066568 | 0 | 0 | 208,445 |
19,473,378 | 2013-10-20T02:48:00.000 | 0 | 1 | 0 | 1 | macos,terminal-emulator,python-mode,jedi-vim | 19,501,157 | 1 | false | 0 | 0 | Solved. I have "set paste" and it disabled all user-defined key mappings under insert mode.
It didn't influence GUI macvim since pasted mode was unnecessary for GUI editors. | 1 | 0 | 0 | I want to use python-mode and jedi for autocompletion in Vim for python. However under my environment (vim 7.3 in terminal.app on OSX 10.8), I just cannot have the key-combination work.
I read many related articles and knows that it is because terminal.app interpret as and I tried to use inoremap to change it but it does not work. Anyone has similar problem and figured out ideal solutions? Thx!
(In macvim with Gui there is no such problem, but I'd prefer run vim in terminal. I tried iterm2 but it also suffers.) | How to make work in terminal.app on mac? | 0 | 0 | 0 | 437 |
19,474,693 | 2013-10-20T06:48:00.000 | 0 | 0 | 0 | 0 | python,pandas | 58,662,181 | 3 | false | 0 | 0 | Transpose df, reset index, and transopse again.
df.T.reset_index().T | 1 | 6 | 1 | Is there a reset_index equivalent for the column headings? In other words, if the column names are an MultiIndex, how would I drop one of the levels? | Pandas DataFrame.reset_index for columns | 0 | 0 | 0 | 4,607 |
19,476,982 | 2013-10-20T11:48:00.000 | 2 | 0 | 0 | 1 | python,google-app-engine,app-engine-ndb | 19,514,013 | 1 | true | 0 | 0 | Inside the same transaction you can delete 200 entities/keys in one go.
The 1/second limit (more likely 5/second) should be read as: How often can I start (and commit) an independent transaction on an entity group or x-group. T.i. because each transaction needs a lock on the root element you're commiting. | 1 | 0 | 0 | I'm deciding whether or not to include a "fetch 200/delete 200" routine of a pipeline inside a transaction.
If not included and the request/instance dies abruptly, the fetched entities would be lost.
Since with xg=True, the entity group limit is 5, the 200 entities need to have the same parent to be included in the transaction.
If delete_multi with 200 keys, count as 200 simultaneous updates to the entity group, the routine might fail, as the preferred limit to entity groups is 1/second.
When those 200 entities are deleted with ndb.delete_multi, does it count as 1 updates or 200 updates to the entity group? | Does ndb.delete_multi with all keys from the same parent count as a single update to the entity group? | 1.2 | 0 | 0 | 212 |
19,477,250 | 2013-10-20T12:21:00.000 | 1 | 0 | 1 | 0 | python,image,file | 19,477,441 | 2 | false | 0 | 0 | I'm not going to tell you your code is horrendous. But you could simplify it.
Everything in the try routine could be replaced by a single line:
print 'Space for about', int(totstor*1048576/25), 'standard jpg image files available'
In other words you can print the result of the calculation directly. Let int() take care of rounding, getting rid of ".0", etc., and rely on the fact that you can print integers (and most other data types) directly without converting them to a string. You simply chain together the items you need in the output using commas. (There are other ways of getting numbers into the desired output text, but this is simplest). | 1 | 0 | 0 | Someone on here asked a question similar to this, but it got quickly downvoted and closed due to the newbiness of it's nature. So I decided to answer it myself, and for others who want to know how to make this nifty program, because it isn't really such a bad idea. So here goes nothing! | Python Program to tell amount of image files that will fit on a disk/flash drive | 0.099668 | 0 | 0 | 94 |
19,484,981 | 2013-10-21T01:35:00.000 | 2 | 1 | 1 | 0 | python,python-2.7,licensing,gpl | 19,485,013 | 2 | true | 0 | 0 | You have no requirement to say that you modified it at all - your only obligation is to offer the source code to anyone who uses your version.
However the best solution for you, the original authors and future users is probably to have your changes put back into the main source tree, assuming that they would be useful to other users! At which point you the version history would mark your changes, you could also add your name in a comment if you wished. | 1 | 1 | 0 | So I created my own modified version of a program with the GPLv3, and it's open source and everything.
My question is how am I supposed to state that I modified it?
Do I just put in a comment saying # Modified by yentup ?
I've tried researching about this topic but I haven't found any directions on how to do so. | Is there a formal way to state modifications of a program covered with GPL? | 1.2 | 0 | 0 | 685 |
19,485,641 | 2013-10-21T03:04:00.000 | 1 | 0 | 0 | 0 | python,random,numpy | 69,479,472 | 4 | false | 0 | 0 | Using the numpy.random.randint function, you generate a list of random numbers, meaning that you can select certain datapoints twice. | 1 | 29 | 1 | I have two numpy arrays x and y, which have length 10,000.
I would like to plot a random subset of 1,000 entries of both x and y.
Is there an easy way to use the lovely, compact random.sample(population, k) on both x and y to select the same corresponding indices? (The y and x vectors are linked by a function y(x) say.)
Thanks. | Python random sample of two arrays, but matching indices | 0.049958 | 0 | 0 | 15,029 |
19,486,708 | 2013-10-21T05:15:00.000 | 0 | 0 | 1 | 0 | python,plugins,notepad++ | 30,208,084 | 4 | false | 0 | 0 | I have met the same error. It is probably because that you have got the wrong download.
For my case, at first I download the file PythonScript_TclTk_1.0.8.0.7z . This is not the right version to be install manually (by copying the extracted zip to the plugin folder of Notepad++). In fact, the structure is completely different. I still not check what this version is supposed to do.
You will need to get the full version, like :PythonScript_Full_1.0.8.0.zip, then extract and install manually. A quick way to check is that if you don't have a file dll like pythonXX.dll in the zip folder, then it is probably not the right plugin. | 3 | 0 | 0 | There is a problem when I try to run Notepad++ with Python Script plugin.
I downloaded the latest versions of both, v6.5 of Notepad++ and v0.92 of Python Script plugin.
However the two reject to work together, throwing the error:
This ANSI plugin is not compatible with your Unicode Notepad++. This
plugin is not compatible with current version of Notepad++.
As I see it there is no supported ANSI version of Notepad++ anymore, so what can I do to make Python Script work again? | Python Script plugin of Notepad++ not working | 0 | 0 | 0 | 5,413 |
19,486,708 | 2013-10-21T05:15:00.000 | 0 | 0 | 1 | 0 | python,plugins,notepad++ | 46,127,087 | 4 | false | 0 | 0 | You might have downloaded the .zip file. Try downloading and installing through .msi installer.
That worked for me. | 3 | 0 | 0 | There is a problem when I try to run Notepad++ with Python Script plugin.
I downloaded the latest versions of both, v6.5 of Notepad++ and v0.92 of Python Script plugin.
However the two reject to work together, throwing the error:
This ANSI plugin is not compatible with your Unicode Notepad++. This
plugin is not compatible with current version of Notepad++.
As I see it there is no supported ANSI version of Notepad++ anymore, so what can I do to make Python Script work again? | Python Script plugin of Notepad++ not working | 0 | 0 | 0 | 5,413 |
19,486,708 | 2013-10-21T05:15:00.000 | 1 | 0 | 1 | 0 | python,plugins,notepad++ | 19,486,931 | 4 | false | 0 | 0 | Three options:
Find a Unicode version of the plug-in
Modify the existing plug-in yourself and ideally share it back.
Use an older version of Notepad++. | 3 | 0 | 0 | There is a problem when I try to run Notepad++ with Python Script plugin.
I downloaded the latest versions of both, v6.5 of Notepad++ and v0.92 of Python Script plugin.
However the two reject to work together, throwing the error:
This ANSI plugin is not compatible with your Unicode Notepad++. This
plugin is not compatible with current version of Notepad++.
As I see it there is no supported ANSI version of Notepad++ anymore, so what can I do to make Python Script work again? | Python Script plugin of Notepad++ not working | 0.049958 | 0 | 0 | 5,413 |
19,487,291 | 2013-10-21T06:06:00.000 | 3 | 0 | 1 | 1 | python,macos,py2app,dmg | 19,920,734 | 2 | true | 0 | 0 | You can use py2app. It makes a standard app. All it needs is a python script and setup.py. | 1 | 1 | 0 | I am making an app in python, which is able to open different file types. This code is running fine on eclipse while passing filename which I want to open and configuration file as arguments respectively selectedFileName=(sys.argv)[1]
cfgFile=(sys.argv)[2]. Now I converted this into application by using py2app. So, the issue is how to deal with arguments, as different file types need to be open through app and this app also needs configuration file while processing. Through py2app, in terminal passing this command open -a myapp.app selectedFileName config.cfg opens the file as expected. But, What I want is to directly open file of any extension without the use of terminal. Is openwith for opening file possible in this case, then how?. What changes I have to make in code for passing arguments for both? I also want to distribute this app to others. | How to convert python code (.py) to an app on mac osx | 1.2 | 0 | 0 | 4,091 |
19,492,277 | 2013-10-21T10:39:00.000 | 0 | 0 | 1 | 0 | python,multithreading,qt,thread-safety,pyqt | 19,494,905 | 2 | false | 0 | 1 | There's no point really using Qt/PyQt if your're not using the signal-and-slot mechanism and rolling your own event loop. Basically, you'd be reimplementing the core of the framework itself. But I'm guessing this is not what you're asking about.
It would be nice if you could clarify your question a bit, (because of which I've had to make a few assumptions)
but here's the deal:
I think you're a bit confused about what the signal and slot mechanism does. (or maybe not, forgive me for reiterating some stuff that might probably be obvious to you).
The signals-and-slots do not implement threading for you (so the question of using signal/slots having any benefit over standard Python threads is moot)
You're probably assuming that the signal-slot mechanism is multithreaded, and that a slot when called by a signal, executes in a new thread. Well, this is not the case.
The signal and slot mechanism in Qt runs in a single event loop in Qt (implemented by QApplication), which itself runs in a single thread.
So signals and slots are not replacements for multi-threading in any way.
If there's a slot that blocks, then it will block your entire application.
So any blocking I/O or time intensive functions should ideally be in a separate thread from the UI, and your slots should start execution of these threads.
Now whether to use QThread or standard Python threads to implement your own threads is another issue, and it's been asked on StackOverflow before, but I tend to use QThreads for Qt apps.
So if you have a button, and you want to start a file download with the Requests library when its clicked, you'll connect the clicked signal of the QPushButton to a slot say for example downloadButtonClicked, and that slot would start a new QThread which would take care of downloading the file using Requests. You can further connect the finished() signal from the QThread to know when the download is complete and to update your UI
(I'll add a code example if this is indeed what you're asking about. So please clarify your question) | 1 | 0 | 0 | Anyone who has worked with Multithreaded PyQt4 apps? I was just wondering if the inbuilt signal/slot mechanism coupled with QtThread of PyQt4 framework has any benefit over the standard Python threads (which are designed in my code to handle the UI components in a thread safe way offcourse) using event driven async callback.
I am looking for any major speed or security concerns, any specific run-time exceptions or edge cases. (The UI is quite complex hence a re-write at a later stage would be very counter-productive).
Thanks.
Edit: I realize this might mean replicating some of the already present PyQt core functionality but it is ok if it allows more flexibility within the app. | PyQt4: Conventional multithreaded UI over Signal/Slot mechanism? | 0 | 0 | 0 | 257 |
19,497,587 | 2013-10-21T14:43:00.000 | 3 | 0 | 0 | 1 | python,subprocess,stdout,gevent | 19,500,240 | 3 | true | 0 | 0 | I solved this using a little hack. Just flush Pythons line-buffer w/ self.stream.flush() and a helper class whenever a line is written to stdout. | 1 | 5 | 0 | I'm trying to get the stdout of a process via POPEN as soon as it's there.
With gevent 1.0 readline() and read() still block process and wait for process to finish.
Any clues? And yes, I searched high and low for a simple solution. It has to be possible without threading, right? | Get live stdout from gevent-subprocess? | 1.2 | 0 | 0 | 3,089 |
19,498,155 | 2013-10-21T15:07:00.000 | 0 | 0 | 1 | 1 | python,tcl,file-access | 19,499,632 | 1 | false | 0 | 0 | I tested writes and reads with Python and TCL and it looks like python will write when TCL has a file open for reading. TCL can write when python has a file open for reading. | 1 | 1 | 0 | I have to concurrently run TCL and Python scripts which access the same files. I have decided to restrict each program so that they have exclusive write access to exactly one file. Each program has read access to all files (say two programs and two files). I don't care about dirty reads (ie reading a partially finished write). I just want to know what will happen in the following two cases:
a programs tries to open a file for writing when another program has it open for reading.
a program tries to open a file for reading while another program has it open for writing.
I guess I am concerned that the write will fail if the other program has the file open (even if it is only open in read mode). I am running in windows with a single Python thread and a TCL program called from Python on subprocess. | python write to a file that is open for reading by another program (TCL) | 0 | 0 | 0 | 1,515 |
19,499,079 | 2013-10-21T15:48:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,webapp2 | 19,500,983 | 1 | false | 1 | 0 | A RedirectRoute will issue a HTTP redirect telling the browser to go to the new URL, then the browser will make a new request at that URL.
How this is implemented is that two routes are created - your original route, and one for redirecting.
So, in your case, a route with /do/some/<action:.*>/ would be created that redirects to /do/some/<action.*>.
However, I think your route actually will be checked first (not positive, sorry), so it would just always fire. I would modify it to not match slashes, if that's okay. Luckily, that's the default behaviour if you omit the regex, so just /do/some/<action:> should work! | 1 | 1 | 0 | I have a RESTful API like /do/some/<action:.*> so my app with get <action> and run it.
My question is, if I use RedirectRoute and strict_slash=True, will my app keep getting <action> as argument or will it start getting <action>/ (notice the / at the end)?
EDIT: I'm using webapp2 | RedirectRoute in Google App Engine and url arguments | 0.197375 | 0 | 0 | 156 |
19,500,625 | 2013-10-21T17:07:00.000 | 2 | 1 | 1 | 0 | python,django-haystack,whoosh | 19,500,864 | 1 | true | 0 | 0 | I've done this "by hand" before--as it turns out, .(doc|ppt|xls)x files are just zip files which contain .xml files with all of your content. So you can use zipfile and your favorite xml parser to read the contents if you can find no better tool to do it. | 1 | 1 | 0 | I'm looking for a simple way to extract text from excel/word/ppt files. The objective is to index contents in whoosh for search with haystack.
There are some packages like xlrd and pandas that work for excel, but they go way beyond what I need, and I'm not really sure that they will actually just print the cell's unformatted text content straight from the box.
Anybody knows of an easy way around this? My guess is ms office files must be xml-shaped.
Thanks!
A. | Extract text from ms office files with python | 1.2 | 1 | 0 | 631 |
19,500,897 | 2013-10-21T17:23:00.000 | 0 | 0 | 0 | 0 | python,django | 19,501,434 | 1 | false | 1 | 0 | The problem lies in the to_upload method, I was getting filename and using it as it came.
The fix was to do: filename = os.path.basename(filename) and use that | 1 | 0 | 0 | I have this custom ModelAdmin that unzips the uploaded file to /tmp and the sets the unzipped file to a FileField in a model doing mymodel.myfilefield = File(open(path_to_file))
The thing is that after doing that the new file is copied to <MEDIA_ROOT>/<upload_to>/tmp/<filename>
And that's not desired. Why is appending the 'tmp' path?
Thanks | Django FileField appending temporary path name to media_root path on save | 0 | 0 | 0 | 343 |
19,501,279 | 2013-10-21T17:46:00.000 | 1 | 0 | 1 | 0 | python,integer,rounding | 19,501,335 | 6 | false | 0 | 0 | I'm not sure whether you want math.floor, math.trunc, or int, but... it's almost certainly one of those functions, and you can probably read the docs and decide more easily than you can explain enough for usb to decide for you. | 1 | 10 | 1 | I will have this random number generated e.g 12.75 or 1.999999999 or 2.65
I want to always round this number down to the nearest integer whole number so 2.65 would be rounded to 2.
Sorry for asking but I couldn't find the answer after numerous searches, thanks :) | How do I ONLY round a number/float down in Python? | 0.033321 | 0 | 0 | 42,133 |
19,503,460 | 2013-10-21T19:52:00.000 | 1 | 0 | 1 | 0 | python,string,file,line | 19,503,478 | 3 | false | 0 | 0 | I think you want \n, rather than /n. | 1 | 1 | 0 | I'm trying to write some text to a file in Python. I use /n to try and create a new line but it just comes out like this in the file which is created:
Player 1 - \nBob - Score - 12 - Goals - 12
I would prefer it if the solution did not contain the os module, thanks.
EDIT: I've just realised this works on one computer and not another. I will get back to this tomorrow when I have access to the other PC. | How do you write to a new line when writing to a file in Python? | 0.066568 | 0 | 0 | 246 |
19,503,736 | 2013-10-21T20:07:00.000 | 0 | 0 | 1 | 1 | python,pywin32 | 19,503,816 | 2 | false | 0 | 0 | Yes, SetFilePointer is less than obvious. The current file position is also found using SetFilePointer, specify a move method of FILE_CURRENT and a distance of zero. | 1 | 2 | 0 | I am trying to use python to create a tail-like utility that can read from a file that is actively open and being written to in another process. It needs to work on windows so I am having to use the win32file module. I will need to open this file and seek to a previously saved location. I have found the SetFilePointer function which will do the moving but, when I get done, I need to store the position of the read pointer for a future iteration. There does not appear to be a function that will give them the position of the read pointer. The naming convention on these functions is not always intuitive so maybe I'm just missing it. | How can I get the current read position in a win32file file handle? | 0 | 0 | 0 | 1,118 |
19,505,540 | 2013-10-21T21:59:00.000 | 3 | 0 | 1 | 0 | python,audio,pygame | 19,908,356 | 2 | true | 0 | 0 | These are the main differences, as far as I understood it:
Music:
Play one file at once
Queue multiple files in a playlist
Have more control over this one stream: Pause it, rewind it, set endevents
Get more information: Get current position, get endevents
Sound:
Play as many files as you want
Play each file you loaded as many times as you want
Each time you play a sound, it chooses a Channel to play on. This may stop another Sound from playing
So, the Music object is indeed suited best for playing long music files, since you have more control of it.
The Sound object is suited best for playing short sound files, e. g. a walking sound or a gunshot.
However, if you want to have multiple music files play at once, you'll have to use Sound. I don't see any benefit of playing a sound as Music though, unless you want to be able to pause it. | 1 | 2 | 0 | What are the key differences between the Sound and Music classes in Pygame?
What are the limitations of each?
In what situation would one use one or the other? Is there a benefit to using them in an unintuitive way such as using Sound objects to play music files or visa-versa?
Are there specifically issues with channel limitations, and do one or both have the potential to be dropped from their channel unreliably?
What are the risks of playing music as a Sound? | Difference between Sound and Music | 1.2 | 0 | 0 | 1,652 |
19,507,887 | 2013-10-22T02:12:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine | 19,508,340 | 1 | true | 1 | 0 | Pack more data into an entity, and arrange to not index any fields you're never going to query on. That may interfere with querying your logs, but if writes predominate, pack more into each write, saving writes and index updates. You'll pay for it later when querying, but if queries are infrequent, it may be a net win. | 1 | 0 | 0 | I'm trying to handle remote logging with app engine, but I find just by myself I'm exceeding the daily write limit. Are there any datastore tricks I can use to consume less of my write quota while posting data to the server constantly? | How to avoid hitting App Engines free limits with tons of writes? | 1.2 | 0 | 0 | 49 |
19,509,244 | 2013-10-22T04:54:00.000 | 0 | 0 | 0 | 0 | python-3.x,window,tkinter,multiple-monitors | 19,516,336 | 1 | true | 0 | 1 | Probably not a very portable solution, but what I have seen done in the past is to use absolute positioning (using wxPython, though). So if you have two monitors set at 1024X768 in a side by side setup, the first screen's x would be 0, and the second screen's x would be 1024 (or 768 if I have my x's and y's mixed up ;). | 1 | 1 | 0 | I have a program that opens two separate windows, one of which is full screen. I would like to open the full screen window on the secondary display (this program will require at least 2 screens to be properly functional, but is not enforced) and the other window on the main display.
Is there any way to do this in python 3 and tkinter? | python 3 open window on screen 2 by default (multi displays) | 1.2 | 0 | 0 | 2,170 |
19,509,314 | 2013-10-22T05:00:00.000 | 4 | 0 | 0 | 0 | python,numpy,reshape | 19,510,028 | 1 | false | 0 | 0 | Using reshape is never ambiguous. It doesn't change the memory-layout of the data.
Indexing is always done using the strides determined by the shape.
The right-most axis has stride 1, while the axes to the left have strides given by the product of the sizes to their right.
That means for you: as long as you collect neighboring axes, it will do the "right" thing. | 1 | 4 | 1 | Basically I want to reshape tensors represented by numpy.ndarray.
For example, I want to do something like this (latex notation)
A_{i,j,k,l,m,n,p} -> A_{i,jk,lm,np}
or
A_{i,j,k,l,m,n,p} -> A_{ij,k,l,m,np}
where A is an ndarray. i,j,k,... denotes the original axes.
so the new axis 2 becomes the "flattened" version of axis 2 and 3, etc. If I simply use numpy.reshape, I don't think it knows what axes I want to merge, so it seems ambiguous and error prone.
Is there any neat way of doing this rather than creating another ndarray manually? | How to merge specific axes without ambuigity with numpy.ndarray | 0.664037 | 0 | 0 | 802 |
19,509,911 | 2013-10-22T05:47:00.000 | 1 | 1 | 0 | 1 | python | 22,898,338 | 7 | false | 0 | 0 | It's Nautilus's fault. Open Nautilus (the file manager), go to Menu > Preferences.
Select the "Behaviour" section.
On the field titled "Executable text files", select the option "Execute executable text files when opened". | 6 | 2 | 0 | I am trying to make my python script executable without going through the terminal typing like
python test.py
I want to make it able to run when i click on the file.
How i going to do this in my fedora machine. | how to make python script executable when click on the file | 0.028564 | 0 | 0 | 12,507 |
19,509,911 | 2013-10-22T05:47:00.000 | 2 | 1 | 0 | 1 | python | 19,510,082 | 7 | false | 0 | 0 | Add #!/usr/bin/env python at the very beginning of file.
Make chmod u+x filename.py
Change your extension from .py to .sh, so your linux distro's UI will recognize it as shell script and try to execute. | 6 | 2 | 0 | I am trying to make my python script executable without going through the terminal typing like
python test.py
I want to make it able to run when i click on the file.
How i going to do this in my fedora machine. | how to make python script executable when click on the file | 0.057081 | 0 | 0 | 12,507 |
19,509,911 | 2013-10-22T05:47:00.000 | 0 | 1 | 0 | 1 | python | 19,510,040 | 7 | false | 0 | 0 | If you don't have any specific version requirement then using first line as #!/usr/bin/env python will be more efficient and give the execute permission chmod u+x test.py | 6 | 2 | 0 | I am trying to make my python script executable without going through the terminal typing like
python test.py
I want to make it able to run when i click on the file.
How i going to do this in my fedora machine. | how to make python script executable when click on the file | 0 | 0 | 0 | 12,507 |
19,509,911 | 2013-10-22T05:47:00.000 | 5 | 1 | 0 | 1 | python | 19,509,956 | 7 | false | 0 | 0 | Add #!/bin/python as the very first line of your file. Or, if you don't know where your python executable is, type which python in a terminal; then copy the result of that and put it after the #!.
Change the permissions of the file so that its executable chmod u+x test.py
i try but it still open back as gedit
Right click on the file in your gnome file browser or desktop.
Select Properties
Go to Open with and choose Python. If you don't see python in the list, add the command. Just type python in the command to be added. | 6 | 2 | 0 | I am trying to make my python script executable without going through the terminal typing like
python test.py
I want to make it able to run when i click on the file.
How i going to do this in my fedora machine. | how to make python script executable when click on the file | 0.141893 | 0 | 0 | 12,507 |
19,509,911 | 2013-10-22T05:47:00.000 | 0 | 1 | 0 | 1 | python | 55,925,012 | 7 | false | 0 | 0 | I use raspibian os (Linux)
Add #!/usr/bin/python as the first line of the file.py
right click file >> open with >> chose customize >> custom command line >> type python3
execute file with double click is working | 6 | 2 | 0 | I am trying to make my python script executable without going through the terminal typing like
python test.py
I want to make it able to run when i click on the file.
How i going to do this in my fedora machine. | how to make python script executable when click on the file | 0 | 0 | 0 | 12,507 |
19,509,911 | 2013-10-22T05:47:00.000 | 0 | 1 | 0 | 1 | python | 19,509,975 | 7 | false | 0 | 0 | Add #!/usr/bin/python as the first line of the file and set the permission to executable chmod 755 yourfile. | 6 | 2 | 0 | I am trying to make my python script executable without going through the terminal typing like
python test.py
I want to make it able to run when i click on the file.
How i going to do this in my fedora machine. | how to make python script executable when click on the file | 0 | 0 | 0 | 12,507 |
19,509,950 | 2013-10-22T05:50:00.000 | 1 | 0 | 0 | 0 | python,cursor,pyqt,qlineedit | 19,513,341 | 1 | true | 0 | 1 | It was my mistake. I was trying to use setFocus before i add the widget to the layout.
Now, I used the setFocus method after the wiget is added to the layout and it works fine. | 1 | 0 | 0 | I have a Qlineedit widget which i will use to accept the username. It will be displayed as soon as user launch the application. I want the Qlineedit widget ready for typing (ie, with cursor already in place) without needing the user to use mouse to click on the widget before typing.
I have tried .setFocus() and .setCursorPosition(1) but doesn't seem to work.
Which method should i use to set the cursor at the starting position of Qlineedit without user needing to click on it? | Tkinter .focus_set() equivalent in PyQt4 | 1.2 | 0 | 0 | 148 |
19,512,250 | 2013-10-22T08:01:00.000 | 1 | 0 | 0 | 0 | python,infinite-scroll | 19,512,436 | 2 | true | 1 | 0 | Those pages update their html with AJAX. Usually you just need to find the new AJAX requests send by browser, guess the meaning of the AJAX url parameters and fetch the data from the API.
API servers may validate the user agent, referer, cookie, oauth_token ... of the AJAX request, keep an eye on them. | 1 | 1 | 0 | I'm trying to parse the HTML of a page with infinite scrolling. I want to load all of the content so that I can parse it all. I'm using Python. Any hints? | Parse HTML Infinite Scroll | 1.2 | 0 | 1 | 1,165 |
19,513,621 | 2013-10-22T09:11:00.000 | 1 | 0 | 0 | 0 | ipython-notebook | 19,535,347 | 4 | false | 0 | 0 | $ ipython nbconvert ... --to slides (no serve option necessary) create a standalone html file you should be able to mail, or whatever.
The skip/- logic can be applied to pdf generation too, you just have to write your own extended template (which is not that hard, wild guess ~20 lines) | 2 | 2 | 0 | so I am adoring the new IPython notebook slideshow feature, however I could not figure out how to distribute such a slideshow in a userfriendly (I am no HTML/JS guy) way.
My usecase is:
I have a somewhat messy notebook which I want to filter by tagging cells as slides/skip/- etc.
In an optimal world there would be a fire-and-forget 'give me a pdf' button somewhere.
So I did already view the slides locally via ipython nbconvert ... --to slides -- post serve
But how do I distribute that to others? Can I get a pdf from such a slideshow easily (I do not care about transition animations etc.)
I hope this is developed further, great features so far! | Distribute a slideshow from IPython notebook | 0.049958 | 0 | 0 | 2,339 |
19,513,621 | 2013-10-22T09:11:00.000 | 1 | 0 | 0 | 0 | ipython-notebook | 21,978,035 | 4 | false | 0 | 0 | You can print it as a pdf file from Chrome.
Add "?print-pdf" at the end of your URL.e.g: 127.0.0.1:8000/index.html?print-pdf
Select print menu from Chrome.
Select Save As pdf, then print it out. | 2 | 2 | 0 | so I am adoring the new IPython notebook slideshow feature, however I could not figure out how to distribute such a slideshow in a userfriendly (I am no HTML/JS guy) way.
My usecase is:
I have a somewhat messy notebook which I want to filter by tagging cells as slides/skip/- etc.
In an optimal world there would be a fire-and-forget 'give me a pdf' button somewhere.
So I did already view the slides locally via ipython nbconvert ... --to slides -- post serve
But how do I distribute that to others? Can I get a pdf from such a slideshow easily (I do not care about transition animations etc.)
I hope this is developed further, great features so far! | Distribute a slideshow from IPython notebook | 0.049958 | 0 | 0 | 2,339 |
19,521,032 | 2013-10-22T14:42:00.000 | 3 | 0 | 1 | 0 | python,list | 19,521,125 | 3 | false | 0 | 0 | In the slice notation [a:b], the second value (b) is not length, but a upper bound.
To get five elements starting from 44 you should use [44:49] (49 = 44 + 5)
If upper bound is smaller than lower bound, you get empty sequence. | 1 | 9 | 0 | I have a list of unicode values. To the best of my knowledge I can use list[starting location:length to select] to select a range of values from a list, right?
I have a list of 78 unicode values, which are not all unique. When I select a range of 5 values beginning from the 0 position in the list (example: list[0:5]) the correct values are returned. However, when I try to select a range of values that do not begin at the 0 position in the list (example: list[44:5]) then the return is []. Changing the length of the range does not seem to make any difference. Furthermore, if I use list[44], for example, then the value that is returned is correct.
I do not understand why I cannot select from a list when the cursor is not located at 0. Can anyone tell me if lists in python have limitations on how data can be retrieved as a range? I hope my problem and question are clear enough. I would appreciate any feedback. Thanks. | Extracting a range of data from a python list | 0.197375 | 0 | 0 | 100,399 |
19,523,680 | 2013-10-22T16:43:00.000 | 14 | 0 | 1 | 0 | python,thread-safety,boto,amazon-dynamodb | 19,542,645 | 1 | true | 0 | 0 | The boto library uses httplib which has never been, and to my knowledge still is not, thread-safe. The workaround is to make sure each thread creates its own connection to DynamoDB and you should be good. | 1 | 13 | 0 | Specifically I'm interested in using a DynamoDB table object from multiple threads (puts, gets, updates, etc). If that's not safe, then is there a safe way (i.e., maybe one table object per thread)? Any other gotchas or tips about working with threads in boto appreciated. | Is boto library thread-safe? | 1.2 | 0 | 1 | 3,394 |
19,524,905 | 2013-10-22T17:50:00.000 | 4 | 0 | 0 | 0 | python,opencv | 19,540,052 | 2 | false | 0 | 0 | I would transform the images to the HSV color space and then compute a histogram of the H values. Then, take the bins with the largest values. | 1 | 3 | 1 | Hi I'm using Opencv and I want to find the n most common colors of an image using x sensitivity. How could I do this? Are there any opencv functions to do this?
Cheers!
*Note: this isn't homework, i'm just using opencv for fun! | Get most common colours in an image using OpenCV | 0.379949 | 0 | 0 | 4,153 |
19,527,097 | 2013-10-22T19:54:00.000 | 2 | 0 | 1 | 0 | python,django,web | 19,527,376 | 2 | true | 1 | 0 | Yes, since the arguments will need to be converted to strings before outputting and that can be a costly operation.
However, using print causes another issue. Some WSGI containers, notably mod_wsgi among them, do not like anything sent to stdout by default and so will raise an exception whenever that happens. You can fix this by printing to stderr instead, but the performance issue will remain. | 1 | 0 | 0 | We are using the python/Django for web development. While development phase wile coding i tends to put print statement a lot places to check the control flow of the code.
And same code with print statement is uploaded for server,
I know logging is a place to be more suitable but i find myself more comfortable with print.
I want to know how few lines of code will make site slow, if it makes it slow.
Lets say i have 100 line of code and upon that i added 5 print statements. another way of looking into it is to i wrote a 105 line of code. Then in that sense i should not make difference (i suppose).
Does this will make the website slow ? | Does print statement will make performance issue for a website | 1.2 | 0 | 0 | 1,976 |
19,528,277 | 2013-10-22T21:01:00.000 | 0 | 0 | 0 | 0 | python,google-chrome,python-3.x | 19,528,475 | 2 | false | 0 | 0 | The Web server on which the file is hosted sends a header that suggests to the browser how it might handle the file, and the user's preferences hold some sway as well. You likely won't be able to override it easily.
You can avoid this by not using a Web browser from Python. urllib2 or better yet, the third-party requests module is a much easier way to talk to the Web. | 1 | 0 | 0 | I'm trying to download files using python 3. I use webbrowser.open_new(url) to open file locations. some files are downloaded automatically by chrome's downloader, and some are just opened in a chorme window. How can I choose between the options? | using google chrome's downloader - python 3 | 0 | 0 | 1 | 86 |
19,529,573 | 2013-10-22T22:32:00.000 | 1 | 0 | 0 | 1 | python,zope,grok | 19,538,042 | 1 | false | 0 | 0 | No, the project has not been deprecated.
Like many open source software projects there is a natural cycle in interest and activity, with the only difference being the speed in which the cycle progresses.
Deprecation is an explicit choice by the maintainers; no such choice has been made. It's just that most interest in the project has moved on elsewhere. | 1 | 1 | 0 | Since the last version is 1.9, released on 2011, but the documentation only covers from 1.0 to 1.5. Also Windows Installers aren't available. It seems that there's poor activity around the framework, also in the mailing list and IRC channel.
Edited the title because of the confusions. Thanks to everyone for the replies. | Is Grok inactive? | 0.197375 | 0 | 0 | 141 |
19,530,015 | 2013-10-22T23:17:00.000 | -8 | 1 | 0 | 1 | python,linux,ubuntu | 28,650,632 | 5 | false | 0 | 0 | First create the file you want, with any editor like vi r gedit. And save with. Py extension.In that the first line should be
!/usr/bin/env python | 3 | 15 | 0 | I'm new with python, I've been learning for a few weeks. However now I've just changed my OS and I'm now using ubuntu and I can't run any script on my terminal.
I made sure to have the #!/usr/bin/env python
but when I go to the terminal and type, for example python test.py
the terminal shows an error message like this
python: can't open file 'test.py': [Errno 2] No such file or directory
what do I do?
I must save the file in any specific folder to make it run on terminal? | How to run python script on terminal (ubuntu)? | -1 | 0 | 0 | 205,865 |
19,530,015 | 2013-10-22T23:17:00.000 | 0 | 1 | 0 | 1 | python,linux,ubuntu | 42,282,440 | 5 | false | 0 | 0 | Save your python file in a spot where you will be able to find it again. Then navigate to that spot using the command line (cd /home/[profile]/spot/you/saved/file) or go to that location with the file browser. If you use the latter, right click and select "Open In Terminal." When the terminal opens, type "sudo chmod +x Yourfilename." After entering your password, type "python ./Yourfilename" which will open your python file in the command line. Hope this helps!
Running Linux Mint | 3 | 15 | 0 | I'm new with python, I've been learning for a few weeks. However now I've just changed my OS and I'm now using ubuntu and I can't run any script on my terminal.
I made sure to have the #!/usr/bin/env python
but when I go to the terminal and type, for example python test.py
the terminal shows an error message like this
python: can't open file 'test.py': [Errno 2] No such file or directory
what do I do?
I must save the file in any specific folder to make it run on terminal? | How to run python script on terminal (ubuntu)? | 0 | 0 | 0 | 205,865 |
19,530,015 | 2013-10-22T23:17:00.000 | 0 | 1 | 0 | 1 | python,linux,ubuntu | 61,037,599 | 5 | false | 0 | 0 | Sorry, Im a newbie myself and I had this issue:
./hello.py: line 1: syntax error near unexpected token "Hello World"'
./hello.py: line 1:print("Hello World")'
I added the file header for the python 'deal' as #!/usr/bin/python
Then simple executed the program with './hello.py' | 3 | 15 | 0 | I'm new with python, I've been learning for a few weeks. However now I've just changed my OS and I'm now using ubuntu and I can't run any script on my terminal.
I made sure to have the #!/usr/bin/env python
but when I go to the terminal and type, for example python test.py
the terminal shows an error message like this
python: can't open file 'test.py': [Errno 2] No such file or directory
what do I do?
I must save the file in any specific folder to make it run on terminal? | How to run python script on terminal (ubuntu)? | 0 | 0 | 0 | 205,865 |
19,531,480 | 2013-10-23T02:00:00.000 | 0 | 0 | 1 | 0 | python-3.x,compatibility | 20,641,011 | 1 | true | 0 | 0 | I accept the answer from Billy ONeal in the comment above | 1 | 1 | 0 | Something I'm doing works under the latest Windows Python 2 and 3, latest Debian Python 2 and 3, and Cygwin Python 2, but fails under Cygwin Python 3.2.3. Known bug fixes after 3.2.3 on Windows deal with the problem.
Where does that realistically leave me concerning deployment, if the latest version using traditional distribution paths (latest Cygwin Python 3) isn't high enough, should I:
tell the user oops, wait for an upgrade
tell the user to manually download a newer Python to shadow the official distro version
tell the user to use Windows Python 3 instead of Cygwin Python 3 to run this program
downgrade my code to stop using the multiprocessing class where bad things happen
I'm testing on six versions of Python right now and didn't even try OS X or BSD yet. Are compatibility issues and having to downgrade code to just not use certain Python Standard Library classes something others have to do often? | When Python 3.2.3 isn't good enough | 1.2 | 0 | 0 | 75 |
19,532,159 | 2013-10-23T03:18:00.000 | 1 | 0 | 0 | 0 | python,sqlite,csv | 19,532,207 | 3 | false | 0 | 0 | I would write all the lines to one file. For 10,000 lines it's probably not worthwhile, but you can pad all the lines to the same length - say 1000 bytes.
Then it's easy to seek to the nth line, just multiply n by the line length | 1 | 0 | 1 | baseline - I have CSV data with 10,000 entries. I save this as 1 csv file and load it all at once.
alternative - I have CSV data with 10,000 entries. I save this as 10,000 CSV files and load it individually.
Approximately how much more inefficient is this computationally. I'm not hugely interested in memory concerns. The purpose of the alternative method is because I frequently need to access subsets of the data and don't want to have to read the entire array.
I'm using python.
Edit: I can other file formats if needed.
Edit1: SQLite wins. Amazingly easy and efficient compared to what I was doing before. | Most efficient way to store data on drive | 0.066568 | 0 | 0 | 1,356 |
19,532,445 | 2013-10-23T03:51:00.000 | 0 | 0 | 0 | 1 | python,celery,zeromq,pyinstaller,pyro | 20,719,307 | 1 | true | 0 | 0 | if the individual tasks dont need to communicate to other tasks then use Celery, otherwise Pyro as it allows communication between tasks/objects running parallely on worker nodes. | 1 | 0 | 0 | Hi Everyone,
I have been developing with python for about a year. Now i have a need to develop distributed applications which communicate with each other.
I do not have an idea which modulue will be the best to learn, so i need your help and advise on this.
My app needs are,
Client Server must be able to communicate and exchange data with each other.
Tasks Needs to be scheduled on server and client. Kind of Cron like, no need for auto consuming stuff.
I would like to be able to complie everything into a exe,app,package to support Win,Mac,Linux. Thin Clients or workers, and fat servers
My issues are as follows.
Nearly everything i see is going towards the web application (Djano, Celery). I need to have a daemon worker running, and thats it. But if i want to use celery, then i would need to have the code in py files and running, which i am not so keen on. Not to mention pyinstaller does not support the packaging
I have researched quite a bit into it, and which module is best i am not sure. But i have sort of narrowed down to celery as the best bet. But i am thinking of ZeroMQ or Pyro as the compiling part later on i am not too sure.
Please do advise,
Kumar | Distributed Networked Applications (Python, Celery, 0MQ, etc) | 1.2 | 0 | 0 | 299 |
19,533,736 | 2013-10-23T05:47:00.000 | 2 | 0 | 0 | 0 | python,flask | 19,535,937 | 2 | true | 1 | 0 | Redirect with parameter: you set parameter for page1 link/form on page2 and if parameter set for page1 then show message. Good solution.
Redirect with special route: you have special route for page1 redirection from page2. It's similar to parameter.
Redirect with referer: you check http referer header to page2 for page1. Good solution, but can have issues with proxies.
Redirect with anchor: you set anchor on page2 and redirect without anchor replacing to page1, on page1 you check anchor and show message. This is best way for me when you have active ajax requests and store session in cookies. Good solution.
Store history in storage on frontend: you save page visiting or message for page1 on session storage and if page1 visited after page2 or message flag set and visited page1 then show message.
Store history in storage on backend: you save pages visiting and if page1 visited after page2 then show message. | 1 | 0 | 0 | I have a use case where, when page2 redirects user to page1, page 1 is supposed to show a flash message (e..g Your order was successfully placed). When a user visits page1 directly without being redirected from page2, I don't show any flash messages.
What is the best way to send flash_message from page2 to page1 while redirect.
Currently I am sending it as a query parameter. Page1 by default has a optional parameter, flash_message, but when user provides flash_message, it shows that flash message.
Is this how flash messages are passed between pages in flask | Passing flash messages in flask framework | 1.2 | 0 | 0 | 4,516 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.