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,534,230
2013-10-23T06:20:00.000
2
1
1
0
python
19,534,829
4
false
0
0
This sounds like you want to use virtualenv. It's a tool for creating isolated python environments with hooks for individual settings. Just put them in the bin/activate of your virtualenv.
1
1
0
I've heard about the PYTHONSTARTUP file as a way to automatically load specified modules and other code when starting python. But PYTHONSTARTUP is a global thing, for all instances of python. Is there such a thing as PYTHONSTARTUP that I can place in a specific directory and runs only when I start python in that directory?
A PYTHONSTARTUP file for a specific directory
0.099668
0
0
2,921
19,539,031
2013-10-23T10:22:00.000
0
0
0
0
python,winapi,pyqt,nfc,rfid
19,565,664
1
false
0
1
Unfortunately there is pretty much no way we can know how a particular rfid reader will work. Your best would just be to assume that it will fire off events somehow, and implement a fake rfid reader that sends off a string of data (that you expect to get from an rfid chip) when you want. Once you get an rfid reader, you can then wrap whatever library you have been provided to access it (or write your own) so that it matches the format/communications protocol you made up for your fake one. But the far simpler solution is to just get yourself an rfid reader and find out experimentally...
1
0
0
I'm building a medical application that should respond to a RFID card scan (and pop up some information). I'm using PyQT to build this, btw. Could someone tell me what tool to use to simulate rfid scans on the machine ? I'm a little noob to this, but I'm assuming I'll use a USB based reader and I should be able to somehow hook to the reader to get some data. Help...
What tool to simulate rfid events on windows (python-win32 compatible?)
0
0
0
331
19,545,847
2013-10-23T15:22:00.000
2
0
0
0
python,macos,scrapy
20,172,902
1
false
1
0
Some questions from osx 10.9. try xcode-select --install
1
2
0
I recently updated from OS X 10.8 to OS X 10.9. It looks like the upgrade removed the previous version of Python and all the libraries that were installed. I am trying to re-install Scrapy on OS X 10.9 but I keep getting an error using both pip and easy_install. Here is the error message I am encountering. /private/tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:9:10: fatal error: 'libxml/xmlversion.h' file not found #include "libxml/xmlversion.h" ^ 1 error generated. error: command 'cc' failed with exit status 1 Does anyone know to resolve this or have a work around?
Using Scrapy with OS X 10.9
0.379949
0
1
1,390
19,546,104
2013-10-23T15:34:00.000
1
0
0
0
python,tkinter
52,703,943
3
false
0
1
One way to do this is build your own msg queue with a lightweight caller and scheduler to process msg and state of widget. This class or function is usually there without such name as queue manager because having back-end class is general-purpose item for application. Adding to simple event transfer queue could have this done which is what I am now doing.
2
4
0
I have been playing with using tkinter to make overlays so some information would appear on top of the rest of the screen. I'd rather not have this window block the mouse. Is there any way I can have it so click events pass though my overlay? So the window below my tkinter app receives the event.
How to make click events pass though a tkinter window?
0.066568
0
0
2,078
19,546,104
2013-10-23T15:34:00.000
2
0
0
0
python,tkinter
19,547,637
3
true
0
1
No, there is nothing built in to tkinter that would allow you to do that. The best that you could hope for is to capture an event, then use some sort of platform-specific tool that lets you create new events, and use the coordinates from the captured event to generate a new, non-tkinter event.
2
4
0
I have been playing with using tkinter to make overlays so some information would appear on top of the rest of the screen. I'd rather not have this window block the mouse. Is there any way I can have it so click events pass though my overlay? So the window below my tkinter app receives the event.
How to make click events pass though a tkinter window?
1.2
0
0
2,078
19,549,655
2013-10-23T18:31:00.000
3
0
0
0
python,django,multithreading,thread-safety
19,551,006
1
true
1
0
As far as we speak about save versus get and query, you are safe, since distinct querysets objects are involved. In fact, every query, filter, get call and so on creates a new queryset instance, and do not modify any previously existed object. But obviously, you can run into issues when accessing/modifying same db record simultaneously from several threads/clients so on. As I remember, to deal with database updates consistency, in oracle db and mysql inndodb with disabled autocommit there is a select for update statement.
1
1
0
Specifically, I'm only talking about modifying separate instances of a Model (not sharing the same exact instance) across threads. But is it safe to be calling save() from one thread, while multiple other threads are invoking Model.objects.query() or Model.objects.get() for example?
Is Django's "Model" API thread-safe?
1.2
0
0
1,406
19,550,982
2013-10-23T19:49:00.000
2
0
1
0
python,windows
19,551,107
3
false
0
0
If you're going to use Python, which I think is a good choice, you'll use the glob module to get all the file names and the os module to rename the files. You'll want to figure out what delimeter you're looking for. In Python, strings have a split method. For each file name, split the file name at the delimeter, and rename the file using the second field from the split. This is a very broad description of what you'll need to do. Best of luck!
1
0
0
I have a bunch of mp3's that all have a long title, followed by "part 3" or "part 4", etc. So it's like "aasasdfjklakjsdf - part 3" and "aasasdfjklakjsdf - part 4" and "aasasdfjklakjsdf - part 5" and so on. I have over 100 of these and I would like to simply remove the "aasasdfjklakjsdf - " part from the title of each one. I have a CS degree so I know the basics of programming, but I've never actually written a script of any kind and would love to get started. I'm wondering what the fastest and easiest way to go about doing something like this is. I'm running windows 7. I'm guessing something with python maybe? Or is there something I could do from the windows command prompt?
What's the simplest way to write a program/script to remove the same string from the beginning of a bunch of file names?
0.132549
0
0
87
19,552,327
2013-10-23T21:09:00.000
2
0
1
0
python,python-import,python-module
19,552,441
1
true
0
0
It is both; importing a Python module is a process that loads Python code from a file, compiles it (or loads cached bytecode), then executes the bytecode to form a module object with attributes. Loading from a file is input. And it is neither; a process can also refer to a distinct program managed by the OS, each with its own Process ID, and input could refer to the interaction with the program after the modules have been imported, strictly limited to keyboard and mouse input. You need to be clear what your terminology means; define "input" and "process" more clearly and you can figure out the answer from that.
1
1
0
This question is really puzzling me, and I cannot work it out. At the start of almost every python program, we import things. I am unsure if it is a process, as it is loading something, or if it is an input, as it is inputting the module so that I can use it.
Is importing a module an input or a process?
1.2
0
0
770
19,552,495
2013-10-23T21:18:00.000
2
0
0
0
python,pyqt4,qfilesystemmodel
19,566,575
1
true
0
1
AFAIK QFileSystemModel relies on QFileIconProvider to get the correct icon. You can do the same in your implementation by using the icon (const QFileInfo &info) method. This may work or not depending on the Desktop Environment you use.
1
1
0
I have the path to a file/folder. How can I get the icon image in the system for this file/folder? I'm writing a customized file browse model for a QTreeView and would like to display the icon like what the QFileSystemModel does.
How do I retrieve the system icon for a file in python or qt?
1.2
0
0
688
19,554,835
2013-10-24T00:33:00.000
6
0
1
0
php,python
19,554,860
2
true
0
0
Assuming normal conventions are used in PHP: single underscore indicates a protected member variable or method double underscore indicates a private member variable or method This stems from when PHP had weak OOP support and did not have a concept of private and protected (everything was public). This convention allowed developers to indicate a member variable or method was private or protected as to better communicate this to users of the code. Users could choose to ignore these semantics and call the "private" and "protected" member variables and methods if so chose, though.
1
3
0
I have seen functions and variables beginning with underscores in various programming languages(PHP and Python) and am confused about the meaning behind it.
Functions and variables beginning with a single or double underscore
1.2
0
0
1,895
19,555,523
2013-10-24T01:55:00.000
1
0
1
0
python
19,555,588
4
false
0
0
You'll probably need two loops -- an outer one to loop thru the values, and an inner one to process the binary digits for each value. You can either loop thru the values as integers & convert them to binary -- or you can carry a "current value" in binary around the loop, copying & incrementing it.
1
0
0
Each binary number should be represented as a tuple. When the function is called, the result should be a tuple containing 2^N binary numbers. Ex. Binary(2)----> ((0,0), (0,1), (1,0), (1,1)) I am trying to use a while loop to do this. Just some advice on where I could begin would be very helpful.
How can I write a function to return all the binary numbers with N digits, and in sorted order?
0.049958
0
0
189
19,556,223
2013-10-24T03:11:00.000
0
0
0
0
python,cherrypy
19,556,266
2
false
0
0
This is a HTTP protocol problem and has nothing to do with python or cherrypy. HTTP clients don't send their hostname along with requests.
2
2
0
I have a cherrypy server on a machine, and i want to get the client identifier from the request. Now i can get the client IP by cherrypy.request.remote.ip, but if the client user use a proxy then the IP address will be the proxy address that i don't want, so is there any way for getting the host name of the client machine or some other ways to distiguish the client identifier
Is there a way to get client host name by cherrypy server
0
0
1
5,019
19,556,223
2013-10-24T03:11:00.000
1
0
0
0
python,cherrypy
19,593,632
2
true
0
0
Original client IP is usually passed along by proxy with X-Forwarded-For header. You can either study the header or use tools.proxy setting to automatically rewrite cherrypy.request.remote.ip. See cherrypy.lib.cptools.proxy for details.
2
2
0
I have a cherrypy server on a machine, and i want to get the client identifier from the request. Now i can get the client IP by cherrypy.request.remote.ip, but if the client user use a proxy then the IP address will be the proxy address that i don't want, so is there any way for getting the host name of the client machine or some other ways to distiguish the client identifier
Is there a way to get client host name by cherrypy server
1.2
0
1
5,019
19,556,467
2013-10-24T03:38:00.000
0
0
0
0
python,basehttprequesthandler
19,556,787
2
false
0
0
I think you have two choices. 1) Listen to all interfaces, but override BaseHTTPRequestHandler.init to check the client address and drop the connection if it comes from an undesired interface 2) Create multiple sockets, one per address you want to listen on. SocketServer.serve_forever() is blocking, so you will either need to use one thread per address or switch to a more sophisticated framework like twisted.
2
0
0
My server has 3 ip addresses, 127.0.0.1, 192.168.0.100 and an internet ip address. I'm going to run a service written by python on this server, but I don't want it to expose on internet. I'm using BaseHTTPRequestHandler class to implement this service, so how to bind only 127.0.0.1 and 192.168.0.100 but not the other one?
how to bind multiple specified ip address on BaseHTTPRequestHandler of python
0
0
1
758
19,556,467
2013-10-24T03:38:00.000
0
0
0
0
python,basehttprequesthandler
19,556,500
2
false
0
0
Generally, routers have an option where you can allow servers to be visible or not visible. If on the router you set you server to not be visible, then your server will not be accessible through the internet.
2
0
0
My server has 3 ip addresses, 127.0.0.1, 192.168.0.100 and an internet ip address. I'm going to run a service written by python on this server, but I don't want it to expose on internet. I'm using BaseHTTPRequestHandler class to implement this service, so how to bind only 127.0.0.1 and 192.168.0.100 but not the other one?
how to bind multiple specified ip address on BaseHTTPRequestHandler of python
0
0
1
758
19,560,701
2013-10-24T08:23:00.000
1
0
1
1
python,macos,py2app
19,920,707
2
true
0
0
You can use packagemaker. It makes myapp.pkg file that when double-clicked installa an app in Applications location.
2
1
0
I had developed an app in python on mac osx for opening different file types on double-clicking any file. Then I converted into app by using py2app. py2app creates a myapp.app within dist folder. I moved myapp.app from dist folder to Applications location. Now, I am able to open any file through myapp just by double-clicking on it. Now, I want to make it work in such a way that, I don't need to drag and drop myapp to Applications location,it should automatically install on system.
How to place myapp in Applications location developed through py2app on mac osx
1.2
0
0
382
19,560,701
2013-10-24T08:23:00.000
0
0
1
1
python,macos,py2app
19,619,226
2
false
0
0
py2app has a "--dist-dir" option for selecting the output directory (default is "diet"). That said, I have never tested using that option for installation in a directory containing other programs and don't know if "python setup.py py2app --dist-dir=/Applications" is save to use. The alternative is to use a script that copies the application to /Applications (a simple python script, a shell script, or even a distutils command in your setup.py file that invokes py2app and then copies the resulting application to the right location).
2
1
0
I had developed an app in python on mac osx for opening different file types on double-clicking any file. Then I converted into app by using py2app. py2app creates a myapp.app within dist folder. I moved myapp.app from dist folder to Applications location. Now, I am able to open any file through myapp just by double-clicking on it. Now, I want to make it work in such a way that, I don't need to drag and drop myapp to Applications location,it should automatically install on system.
How to place myapp in Applications location developed through py2app on mac osx
0
0
0
382
19,560,838
2013-10-24T08:30:00.000
2
0
0
0
python,sql,django,serialization
19,561,000
3
false
1
0
According to your answer, User passes some content-specific parameters into a form, then view function, that recieves POST, constructs query one option is to store parameters (pickle'd or json'ed, or in a model) and reconstruct query with regular django means. This is somewhat more robust solution, since it can handle some datastructure changes.
2
2
0
My use case is that I need to store queries in DB and retrieve them from time to time and evaluate. Thats needed for mailing-app where every user can subscribe to a web-site content selected by individually customized query. Most basic solution is to store raw SQL and use it with RawQuerySet. But I wonder is there better solutions?
How to serialize and deserialize Django ORM query (not queryset)?
0.132549
0
0
1,324
19,560,838
2013-10-24T08:30:00.000
1
0
0
0
python,sql,django,serialization
19,561,051
3
false
1
0
You could create a new model user_option and store the selections in this table. From your question, it's hard to determine whether it is a better solution, but it would make your user's choices more explicit in your data structure.
2
2
0
My use case is that I need to store queries in DB and retrieve them from time to time and evaluate. Thats needed for mailing-app where every user can subscribe to a web-site content selected by individually customized query. Most basic solution is to store raw SQL and use it with RawQuerySet. But I wonder is there better solutions?
How to serialize and deserialize Django ORM query (not queryset)?
0.066568
0
0
1,324
19,561,727
2013-10-24T09:14:00.000
0
0
0
0
python,tkinter,ttk
67,762,390
6
false
0
1
It is just a matter of the design of a GUI Window. So Tkinter is a really easy-to-use efficient and useful GUI toolkit. But it looks a bit outdated. Tkinter Ttk widgets are similar to that of Tkinter. It is basically a sub-module of Tkinter. So, in Tkinter Ttk, almost many widgets are the same but to use them is different. Tkinter Ttk widgets are more customizable and a lot of windows programs are done and designed using Tkinter
3
68
0
The main tkinter module and its submodule ttk in Python 3 appear to contain identical widgets (i.e. Buttons, CheckButtons, etc.). So, when creating a button, one has the freedom to either use a tkinter.Button widget or a tkinter.ttk.Button. Do you know what is the difference between them? Why would you choose one or the other?
What is the difference between the widgets of tkinter and tkinter.ttk in Python?
0
0
0
51,337
19,561,727
2013-10-24T09:14:00.000
8
0
0
0
python,tkinter,ttk
53,561,414
6
false
0
1
My opinion for beginners who are starting to learn Tkinter, is to use Tkinter widgets, because they're really easy to learn. But on the other hand Tkinter.ttk is a module designed to make Tkinter widgets look really perfectly, but is really hard to learn and there are no easy options there. Like there are no -fg, -bg. Perhaps, there are no new styles available in Tkinter. Style are only designed for ttk, and can be found in ttk. And Tkinter widgets really don't look like other native platform widgets. But ttk is nicer and smoother looking, and look like other native platforms. So if you are making apps for your own private use, then use Tkinter and also use some ttk if needed, because ttk supports much cooler widgets that can change the look of your app. And if you are making apps for public use, then go for both because Tkinter is needed for creating the window and some more important stuff, and for widgets go for ttk. But honestly, I say use both because there are no conflicts between the two; just use them both to your advantage. Honestly using ttk is a challenge! Because it has no Grid,Pack, Place and many other options that are normally available in Tkinter widgets. But wait!! Tkinter has those options! So use both! Try to make a nice app! That is the real difference between the two: Tkinter widgets are more configurable, and ttk is more modern and it is configurable with styles which are really handy shortcuts. And Tkinter is like the core of the window and ttk is styling. Think of it like this: Tkinter --- HTML, ttk --- CSS, Python --- JavaScript.
3
68
0
The main tkinter module and its submodule ttk in Python 3 appear to contain identical widgets (i.e. Buttons, CheckButtons, etc.). So, when creating a button, one has the freedom to either use a tkinter.Button widget or a tkinter.ttk.Button. Do you know what is the difference between them? Why would you choose one or the other?
What is the difference between the widgets of tkinter and tkinter.ttk in Python?
1
0
0
51,337
19,561,727
2013-10-24T09:14:00.000
90
0
0
0
python,tkinter,ttk
19,564,114
6
true
0
1
The widgets in tkinter are highly and easily configurable. You have almost complete control over how they look - border widths, fonts, images, colors, etc. ttk widgets use styles to define how they look, so it takes a bit more work if you want a non-standard button. ttk widgets are also a little under-documented. Understanding the underlying theme and layout engines (layout within the widgets themselves, not pack, grid and place) is a challenge. Generally speaking, the themed widgets will give you an application that looks more "native", but at the expense of a loss of configurability. My advice is to use ttk widgets if you want your GUI to look a little more modern, and the tkinter widgets if you need a bit more configurability. You can use them both in the same applications.
3
68
0
The main tkinter module and its submodule ttk in Python 3 appear to contain identical widgets (i.e. Buttons, CheckButtons, etc.). So, when creating a button, one has the freedom to either use a tkinter.Button widget or a tkinter.ttk.Button. Do you know what is the difference between them? Why would you choose one or the other?
What is the difference between the widgets of tkinter and tkinter.ttk in Python?
1.2
0
0
51,337
19,564,587
2013-10-24T11:23:00.000
0
0
1
0
python
19,564,805
3
false
0
0
No, in Python (both 2.x and 3.x), using ++var will return the same value of the variable as it was previously, provided that the variable's value was actually a number. And using var++ will raise an exception. Also, in Python the ++var operation's behavior is not as same as some other languages, like PHP, JS, C++, where ++var actually means that you're to increment the variable's value by 1. But in Python, to increment, you must use something like var = var + 1 or var += 1 or it will not work.
1
4
0
Python doesn't support C-style ++a increment but, to my surprise, it doesn't complain either leading to me being temporarily baffled as to why my loop wasn't working. Trying a few things (having first initialised with a=0) I find that a++ and a-- produce a syntax error, but ++a doesn't. While --a produces a syntax error in Python 3.3 but not in Python 2.7. What's going on? Why doesn't ++a give an error? Why does --a not give an error in 2.7 but does give an error in 3.3?
What is ++ operator doing in Python?
0
0
0
1,128
19,568,232
2013-10-24T14:04:00.000
-2
0
1
0
python,dictionary,multiprocessing,shared-memory
24,506,459
3
false
0
0
iteritems() is for a list dict. You could use a for loop. Or you could say sorted() which will return keys in a sorted list and then iterate over that list and do dict[key]. Hope that helps. If there is any better way. DO share with me. I am dying to know.
1
16
0
I'm using Python's multiprocessing.Manager to share access to a dataset that one process will generate and others will view. However, I'm running into the problem that a dict proxy returned by manager.dict() doesn't support iteritems(). I could iterate over items(), but that means constructing a new tuple of all the items in the dict, which is a large number. Is there a way to do it without constructing an intermediate list/tuple, thus using only a constant amount of extra memory? Note: It's OK if the solution requires that the generating process pauses for the iteration.
How to iterate over a dict proxy in Python?
-0.132549
0
0
9,690
19,570,490
2013-10-24T15:42:00.000
2
1
0
1
python,nginx,webserver,reverse-proxy,uwsgi
19,688,569
1
true
1
0
Simply put, when you use HttpUwsgiModule NGINX speaks the uwsgi protocol and it can leave out useless informations of the http protocol leading to less overhead and thus better performance.
1
1
0
Using HttpUwsgiModule with NGINX to control uWSGI has become quite popular since its release. I was wondering though, what is the advantage of it, compared to using NGINX as a reverse-proxy to uWSGI application? What are the gains and losses in two differing use cases?
What is the difference between using HttpUwsgiModule for NGINX and using NGINX as a reverseproxy to uWSGI?
1.2
0
0
125
19,574,210
2013-10-24T18:53:00.000
8
1
0
0
python,shell,ssh,ipython
19,574,232
1
true
0
0
Yes. Use screen, tmux (superior), or similar software. Both use the concept of sessions that you attach to and detach from. With tmux: Run tmux and then ipython. When you're finished, <Ctrl+b> d to detach. You're back in the normal shell. When you come back, tmux attach will take you back to ipython. Using screen, the commands are screen, <Ctrl+a> <Ctrl+d> and screen -r.
1
4
0
I work on a machine per ssh where I run ipython for interactive work. Can I start a long-running Python function from IPython, sever the ssh connection and log back in later into the IPython session to observe the result?
Is it possible to start an IPython session via ssh and log back in later?
1.2
0
0
467
19,574,683
2013-10-24T19:18:00.000
1
0
1
0
python,python-2.7
19,574,766
1
true
0
0
Unless you've somehow messed up your PYTHONPATH environment variable, it doesn't matter at all where you've stored your script. import random should always work. However, if you have a script named random.py in the same directory as your current script, then Python will attempt to import that first, before hitting the other paths that eventually lead to the standard library. Could that be your problem?
1
2
0
I am working through some exercises in Learning Python the Hard Way (LPTHW) and I am having some trouble while attempting to write some original code for a text-game I have made. My issue is importing the "random" module from the python standard library. The problem stems from NOT having my .py file in the main Python27 directory. My question: How do I tell my script where to look for the file? And if I am using a real path, how can I prevent an error when another user tries to run my script and their root python27 directory is in a different location? Any information or resources to study this would be helpful. Thank you.
Unsure how to import module from Python Standard Library
1.2
0
0
344
19,577,144
2013-10-24T21:36:00.000
2
0
1
0
python,mcmc,pymc
19,730,095
2
true
0
0
Are you talking about the batchsd function? That is what is used to calculate the MC error in PyMC 2. Its located in the pymc.database.base module, and can be used on any array, really. The pymc.diagnostics module contains all the convergence diagnostics functions, and should work on numpy arrays.
1
2
0
I'd like to use the pymc diagnostic and summary functions on samples I have generated without using pymc. As one example, I'd like to use pymc's mc_error routine on my own set of samples. Some of the pymc diagnostic functions can take an np.array of samples, but, if I understand correctly, others seem to require a trace object. How can I convert my own set of samples into a trace object that pymc can handle? I'd appreciate any pointers. My samples are currently stored as a dictionary where each key is a name of a variable I am sampling and points to an np.array of samples. Thanks!
Using pymc diagnostics and posterior summaries on samples not from pymc
1.2
0
0
413
19,578,392
2013-10-24T23:15:00.000
2
1
0
1
python,linux,background,ssh
19,578,445
3
false
0
0
You can use screen, as Robin Krahl recommended, or you can just run your command with nohup, which suppresses the SIGHUP (hangup) signal from your SSH session disconnecting. nohup "python -u test.py > output.txt" &
1
3
0
I need to run a python code that takes several hours and my computer disconnects from the ssh after a certain amount of inactive time. I have tried python test.py > output.txt & but my output file is empty. However, the python code "test" is still running after I log off and log back in to the ssh. I also tried python -u test.py > output.txt & which does write to the output.txt but it does not continue after the ssh connection is lost. I am very new to Linux so I do not know very many commands. I need the simplest/easiest to understand method. Thanks!
Running python code in background
0.132549
0
0
183
19,578,777
2013-10-24T23:52:00.000
0
0
1
0
python,string,list,eval
21,247,627
4
false
0
0
Here's one way: exec("list = "+foo) This should make a variable 'list' with the list in string converted to a real list. This also works for dictionaries, arrays, bools, etc in strings.
1
4
0
I have a string, something like this: "[['Cheese', 72], ['Milk', 45], ['Bread', 22]]". I want to convert this to a list. I know I can use eval(string) to get the list, but eval scares me because of its potential for catastrophe (and because I can get a non-list as valid output). Is there another saner/safer way to turn this string into a list? I know it's a list and anything that isn't a list is invalid data (and should be checked for and/or throw an error).
Convert String to List in Python Without Using Eval?
0
0
0
3,294
19,579,546
2013-10-25T01:21:00.000
0
0
1
1
ipython-notebook,ipython-magic
19,583,164
7
false
0
0
No, %%script magic are autogenerated and don't do any magic inter-process data communication. (which is not the case for %%R but which is a separate magic in its own class with extra care from R peoples) But writing your own magic that does it is not too hard to do.
1
81
0
Is there a way to access variables in the current python kernel from within a %%bash or other %%script cell? Perhaps as command line arguments or environment variable(s)?
Can I access python variables within a `%%bash` or `%%script` ipython notebook cell?
0
0
0
40,694
19,579,978
2013-10-25T02:09:00.000
2
0
1
1
python,unix,multiprocessing,xargs
19,580,680
1
true
0
0
The xargs program will collect multiple arguments from standard input, and glue them together to make one long command line. If there are many many many arguments, too long for one command line, then it will build and execute multiple command lines, as many as needed. This means less overhead for starting up processes and shutting them down. How much good this will do for you depends on how long your processes run. If you are starting up some sort of CPU-intensive program that will run for half an hour, the startup time for the process will be inconsequential. If you are starting up a program that runs quickly, but you are only running a small number of instances, again the savings will be inconsequential. However, if your program is truly trivial and requires minimal runtime, maybe you will notice a difference. From your problem description, it appears to be a good candidate for this. 10K things with relatively short processing for each. xargs might speed things up for you. However, in my experience, doing any nontrivial work in shell scripts brings the pain. If you have any directory names or file names that can have a space in them, the slightest mistake in quoting your variables makes your script crash, so you need to obsessively test your script to make sure it will work for all possible inputs. For this reason, I do my nontrivial system scripts in Python. Therefore, if you already have your program working in Python, IMHO you would be crazy to try to rewrite it as a shell script. Now, you can still use xargs if you want. Just use subprocess to run xargs and pass all the arguments via standard input. This gains all of the benefit and none of the pain. You can use Python to stick a NUL byte chr(0) at the end of each argument, and then use xargs --null, and it will be robust with filenames that have spaces in them. Alternatively you could use ' '.join() to build your own very long command lines, but I don't see any reason to do that when you can just run xargs as described above.
1
1
0
I have a question on the performance scalability with xargs. Currently I have a batch processing program written in python with multiprocessing and subprocess. Each process spawns an independent subprocess.popen() to execute an external command. Recently I realized that the whole process can be redone with xargs. However, I wonder whether it is a good idea to use xargs to process 10k+ files since I have never done something this scale with only commandline tools before. Given my test with small data sets, it is actually not a bad idea if all I am doing is batch running a bunch of commands, since it avoids many cycles of overhead imposed by python's modules, but I would like to learn more from anyone who may have more experience with xargs and python. More specifically, is there any buffer limit that I need to configure for xargs to consume a large number of inputs? Thanks.
performance for xarg vs. python multiprocessing+subprocess
1.2
0
0
575
19,582,197
2013-10-25T06:02:00.000
0
0
0
0
python,linear-algebra
19,650,488
3
false
0
0
Writing a program to solve an eigenvalue problem is about 100 times as much work as fixing the library mismatch problem.
1
3
1
I need to calculate eigenvalues and eigenvectors in python. numpy and scipy do not work. They both write Illegal instruction (core dumped). I found out that to resolve the problem I need to check my blas/lapack. So, I thought that may be an easier way is to write/find a small function to solve the eigenvalue problem. Does anybody know if such solutions exist?
How to find eigenvectors and eigenvalues without numpy and scipy?
0
0
0
12,872
19,583,656
2013-10-25T07:26:00.000
0
0
0
1
python,linux,solaris,expect
19,831,707
5
true
0
0
The only solution top this problem seems using uname to get the OS and set the df accordingly... same as what i had stated in the problem!!!
2
0
0
The df command displays the amount of disk space occupied by mounted or unmounted file systems, the amount of used and available space, and how much of the file system's total capacity has been used. Linux has df command in the following location /bin whereas in Solaris in the following location /usr/gnu/bin... If suppose /usr/bin is set in the PATH, then programmatically, i need to ensure that one of required df (as mentioned above) is invoked instead of the user defined df. One solution to this problem is using uname to get the OS and set the df accordingly... Is there any other better way to do this where i am not dependent on the OS. Note: the default df and gnu df give different outputs hence i need to invoke the required df command on two different OS programmatically (the paths are mentioned above) DID NOT FIND ANY SOLUTION TO THE PROBLEM Used the alternative solution that i had provided in the question itself!
df command across multiple os
1.2
0
0
752
19,583,656
2013-10-25T07:26:00.000
0
0
0
1
python,linux,solaris,expect
19,639,734
5
false
0
0
Are the target systems somehow under your control, and does this involve a limited set of servers? If so, how about adding a soft link in both the Solaris and Linux servers, in the same location and with the same name? Something like: Solaris: ln -s /usr/gnu/bin/df /usr/bin/my_df Linux: ln -s /bin/df /usr/bin/my_df Then let your script use /usr/bin/my_df for every box. Not fancy and rather simple approach... but maybe it would work for you? Just my 2c.
2
0
0
The df command displays the amount of disk space occupied by mounted or unmounted file systems, the amount of used and available space, and how much of the file system's total capacity has been used. Linux has df command in the following location /bin whereas in Solaris in the following location /usr/gnu/bin... If suppose /usr/bin is set in the PATH, then programmatically, i need to ensure that one of required df (as mentioned above) is invoked instead of the user defined df. One solution to this problem is using uname to get the OS and set the df accordingly... Is there any other better way to do this where i am not dependent on the OS. Note: the default df and gnu df give different outputs hence i need to invoke the required df command on two different OS programmatically (the paths are mentioned above) DID NOT FIND ANY SOLUTION TO THE PROBLEM Used the alternative solution that i had provided in the question itself!
df command across multiple os
0
0
0
752
19,585,830
2013-10-25T09:17:00.000
0
0
0
0
python,mysql,database,cloud,rackspace-cloud
19,761,340
2
true
1
0
I released version 1.6.1 of pyrax a few days ago that adds support for the 'host' parameter for users, as well as for Cloud Database backups.
1
1
0
Rackspace has added the feature to select certain cloud servers (as hosts) while creating a user in a cloud database instance. This allows the specified user to be accessed, only from those cloud servers. So I would like to know whether there is an API available in pyrax(python SDK for Rackspace APIs) to accomplish this or not. If possible, then how to pass multiple cloud server IPs using the API. Thanks,
Host Parameter While Creating a User in Rackspace Cloud Database Instance
1.2
1
0
70
19,586,583
2013-10-25T09:52:00.000
1
0
1
0
python,video,mpeg
19,589,146
2
false
0
0
gstreamer is the tool you are looking for. you'll probably need an appsrc or something like that.
1
0
0
I'm looking for a Python library that can combine images into a video. A library that just allows you to create an empty video and feed images into it as frames is ideal. Preferably with support for MPEG compression of the video file as well.
Combine images as frames to make a video with Python
0.099668
0
0
1,225
19,588,634
2013-10-25T11:30:00.000
3
0
1
0
python,random,header
19,589,554
3
false
0
0
here's a list of options with their associated problems: use a random number. you will get a collision (non-unique value) in about half the bits (this is the "birthday collision"). so for 32 bits you get a collision after 2*16 messages. if you are sending less than 65,000 messages this is not a problem, but 65,000 is not such a big number. use a sequential counter from some service. this is what twitter's snowflake does (see another answer here). the trouble is supplying these across the net. typically with distributed systems you give each agent a set of numbers (so A might get 0-9, B get's 10-19, etc) and they use those numbers then request a new block. that reduces network traffic and load on the service providing numbers. but this is complex. generate a hash from some values that will be unique. this sounds useful but is really no better than (1), because your hashes are going to collide (i explain why below). so you can hash IP address and timestamp, but all you're doing is generating 32 bit random numbers, in effect (the difference is that you can reproduce these values, but it doesn't seem like you need that functionality anyway), and so again you'll have a collisions after 65,000 messages or so, which is not much. be smarter about generating ids to guarantee uniqueness. the problem in (3) is that you are hashing more than 32 bits, so you are compressing information and getting overlaps. instead, you could explicitly manage the bits to avoid collisions. for example, number each client for 16 bits (allows up to 65,000 clients) and then have each client user a 16 bit counter (allows up to 65,000 messages per client which is a big improvement on (3)). those won't collide because each is guaranteed unique, but you have a lot of limits in your system and things are starting to get complex (need to number clients and store counter state per client). use a bigger field. if you used 64 bit ids then you could just use random numbers because collisions would be once every 2**32 messages, which is practically never (1 in 4,000,000,000). or you could join ip address (32 bits) with a 32 bit timestamp (but be careful - that probably means no more than 1 message per second from a client). the only drawback is slightly larger bandwidth, but in most cases ids are much smaller than payloads. personally, i would use a larger field and random numbers - it's simple and works (although good random numbers are an issue in, say, embedded systems). finally, if you need the value to be "really" random (because, for example, ids are used to decide priority and you want things to be fair) then you can take one of the solutions above with deterministic values and re-arrange the bits to be pseudo-random. for example, reversing the bits in a counter may well be good enough (compare lsb first).
1
0
0
I need to generate a 32 bit random int but depending of some arguments. The idea is generate a unique ID for each message to send through a own P2P network. To generate it, I would like as arguments: my IP and the time stamp. My question is, how can I generate this 32 bit random int from these arguments? Thanks again!
Python - Generate a 32 bit random int with arguments
0.197375
0
1
3,076
19,591,907
2013-10-25T13:59:00.000
0
0
1
0
python,scipy,enthought,scikits,canopy
19,674,497
1
false
0
0
You can try to download the package tar.gz and use easy_install . Or you can unpack the package and use the standard way of python setup.py install. I believe both ways require a fortran compiler.
1
0
1
I need to use scikits.bvp_solver in python. I currently use Canopy as my standard Python interface, where this package isn't available. Is there another available package for solving boundary value problems? I have also tried downloading using macports but the procedure sticks when it tries building gcc48 dependency.
Installing scikits.bvp_solver
0
0
0
611
19,598,213
2013-10-25T19:44:00.000
0
0
0
0
python,django,django-templates
19,624,727
2
true
1
0
This cannot be done in Django templates as of this writing without writing a custom template tag in Python.
1
3
0
I have a date in my template context, and I want to display that date plus 7 days in the rendered output. Something like this (which does not exist): {{some_date|plus_days:7}} How can I do this in a Django template without writing any Python code?
Generating a date relative to another date in Django template
1.2
0
0
3,339
19,598,454
2013-10-25T19:57:00.000
0
0
1
0
python,regex
19,598,658
3
false
0
0
You can compare Python strings alphabetically with < and >. For instance, "block_number_0" < "block_number_alt567" is True. If I understand you correctly, then you can stop looking if the regular expression doesn't match and the string is greater than "block_number_0" (or any other number).
1
1
0
I am looking for matches between an alphabetically sorted list of strings and a regular expression using python. The regular expression is relatively simple, something like "block_number_[0-9]+", representing "block_number_" followed by any string that represents a number, e.g. "block_number_1234". Beyond the alphabetical sorting, there is very little structure to the strings in the list; it also contains entries like "block_number_alt567" and "block_no_90210". Is there a way to test for when I have passed the point in my list of strings where a match to my regular expression is no longer possible, i.e. once I hit block_number_alt567, there's no need to test for any more matches to "block_number_[0-9]+" ? (The ultimate goal is to compare a relatively long list of strings, to a list of regular expressions which captures all of the variations in the list; the performance savings from not searching every element of the string list every time will be significant in the application environment).
String greater-than-less-than Tests Against a Regular Expression
0
0
0
916
19,600,545
2013-10-25T22:46:00.000
0
0
1
0
python,python-2.7
47,374,011
3
false
0
0
it has role similar to path. this variable tells the python interpreter where to locate the module files imported into a program. it should include the python source library directory and the directories contain in python source code
1
0
0
On windows 7, I currently don't have a python path. Can I safely make one? If so, how do I do it? Upon making this variable, I can no longer load Spyder (IDE) without it crashing. Does anyone know why? I would like to edit my existing python path if possible, but just don't know why it isn't already there in environmental variables. I would ultimately like to be able to run "python myscript.py" and have myscript be in a different directory from the call directory.
What is the purpose of the environmental variable PYTHONPATH
0
0
0
1,331
19,601,598
2013-10-26T00:50:00.000
11
0
0
1
macos,python-2.7,resume
19,601,896
1
true
0
0
This was originally a comment, but it seems to be what OP wants, so I'm reposting it as an answer I would use ctrl+z to suspend your live, running process. This will leave you with a PID, which you can later resume with a call to fg: fg <job-number>. This shouldn't have any implications with changed network settings (like IP, etc), at least as far as python is concerned. I can't speak to whether the API will freak out, though
1
3
0
I run python scripts on my macbook air that process data from external API's and often take several hours or occasionally even days. However, sometimes I need to suspend my laptop in the middle of running a script so I can go to work or go home or similar. How can I simply pause/resume these scripts in the middle of their for loops? Is there something very simple that I can add at the script level that just listens for a particular key stroke to stop/start? Or something I can do at the *nix process management level? I'm well aware of Pickle but I'd rather not deal with the hassle of serializing/unserializing my data--since all I'm doing is hibernating the mac, I'm hoping if the script gets paused and then I hibernate, that OS X will handle saving the RAM to disk and then restoring back to RAM when I reopen the computer. At that point, I can hit a simple keystroke to continue the python script. Since I'm switching between different wifi networks, not sure if the different IPs will cause problems when my script tries to access the internet to reach the 3rd party APIs.
How do I pause/resume a Python script?
1.2
0
1
7,855
19,605,580
2013-10-26T10:25:00.000
1
0
0
0
python,postgresql,ms-access,psycopg2,pyodbc
20,310,119
1
false
0
0
Your query syntax differences will depend on PostgreSQL extensions vs MS Access-specific quirks. The psycodb and pyodbc will both provide a query interface using whatever SQL dialect (with quirks) the underlying db connections provide.
1
0
0
We are building a datawarehouse in PostgreSQL. We want to connect to different data sources. Most data will come from ms access. We not not python experts (yet :-)). We found several database connectors. We want to use (as much as possible) standard SQL for our queries. We looked at pyodbc pscopg2. Given that we use MS Access and PostgreSQL and want to have the same query syntax and return data types; Which drivers should we use ?
python postgresql ms access driver advice
0.197375
1
0
126
19,606,275
2013-10-26T11:43:00.000
0
0
1
0
ipython,ipython-notebook
51,346,139
6
false
0
0
If you want completely from beginning, Just go and delete the following file manually(It worked for me) /home/user/.ipython/profile_default/history.sqlite
2
40
0
I have been learning how to use the paramiko package only to discover that all I stored passwords in plain text in IPython's %hist. Not so good. I therefore need to get rid of particular parts of what is stored in %hist. Saying that, I do not want to wipe the whole history. - Only the parts where I have been careless enough to type password = or similar chosen terms. Thanks Comments I don't need: %clear only clears the session. It does not wipe the history. Yes. I will only use xSA_keys from now on.
IPython: How to wipe IPython's history selectively & securely?
0
0
0
17,232
19,606,275
2013-10-26T11:43:00.000
1
0
1
0
ipython,ipython-notebook
52,141,421
6
false
0
0
I couldn't find the way to wipe IPython's history selectively, but I found out how to wipe data by built-in func, non-sqlite way: %clear out #it clears output history by the way, you can also clear in history by %clear in
2
40
0
I have been learning how to use the paramiko package only to discover that all I stored passwords in plain text in IPython's %hist. Not so good. I therefore need to get rid of particular parts of what is stored in %hist. Saying that, I do not want to wipe the whole history. - Only the parts where I have been careless enough to type password = or similar chosen terms. Thanks Comments I don't need: %clear only clears the session. It does not wipe the history. Yes. I will only use xSA_keys from now on.
IPython: How to wipe IPython's history selectively & securely?
0.033321
0
0
17,232
19,609,041
2013-10-26T16:28:00.000
2
0
1
0
python,virtualenv,pip
19,612,064
4
false
0
0
Alternative way is to name each dependency of your project in your "setup.py" or "requirements.txt". Exercise setup.py or pip install cat requirements.txt multiple times with virtualenv in order to run your application successfully. After that, manually add the new dependency to one of the files to keep your dependency in sync.
3
20
0
How can I keep track of the packages when I install them using pip inside a virtualenv? It seems like a mess now; if I install package A, it automatically install its dependancies; B, C and D. Then I decide to use package N instead which installs its dependancies as well. Now when I remove package A, its dependancies are not automatically removed. How I can keep my virtualenv clean? Is there a tool to check for unused packages and remove them?
How can I remove unused packages from virtualenv?
0.099668
0
0
28,191
19,609,041
2013-10-26T16:28:00.000
6
0
1
0
python,virtualenv,pip
19,609,288
4
false
0
0
To get a clean environment, create a new one. Some pip hooks can help you on this path: pip freeze to get list of installed packages and their versions, wich can later be used with -r <file> to install list of packages, stated in a requirements file --build <dir> to place builds in a specific directory --no-clean to not clean up build directories later you can use those builds with --no-download --no-deps to not install dependencies
3
20
0
How can I keep track of the packages when I install them using pip inside a virtualenv? It seems like a mess now; if I install package A, it automatically install its dependancies; B, C and D. Then I decide to use package N instead which installs its dependancies as well. Now when I remove package A, its dependancies are not automatically removed. How I can keep my virtualenv clean? Is there a tool to check for unused packages and remove them?
How can I remove unused packages from virtualenv?
1
0
0
28,191
19,609,041
2013-10-26T16:28:00.000
12
0
1
0
python,virtualenv,pip
19,609,202
4
true
0
0
Making virtualenvs is relatively cheap. You could just create a new virtualenv whenever you get into this situation and run your pip install again. Not very elegant, but it gets the job done. Of course you need to be maintaining some requirements file for the pip install and it will go faster if you have some local index or cache for pip.
3
20
0
How can I keep track of the packages when I install them using pip inside a virtualenv? It seems like a mess now; if I install package A, it automatically install its dependancies; B, C and D. Then I decide to use package N instead which installs its dependancies as well. Now when I remove package A, its dependancies are not automatically removed. How I can keep my virtualenv clean? Is there a tool to check for unused packages and remove them?
How can I remove unused packages from virtualenv?
1.2
0
0
28,191
19,611,177
2013-10-26T19:52:00.000
2
0
1
0
python,algorithm,3d,point
19,611,533
1
false
0
0
Given 2 points, (x1,y1,z1) and (x2,y2,z2), you can take the difference between the two, so you end up with (x2-x1,y2-y1,z2-z1). Take the norm of this (i.e. take the distance between the original 2 points), and divide (x2-x1,y2-y1,z2-z1) by that value. You now have a vector with the same slope as the line between the first 2 points, but it has magnitude one, since you normalized it (by dividing by its magnitude). Then add/subtract that vector to one of the original points to get your final answer.
1
2
1
I need to write a script in python which given coordinates of 2 points in 3d space finds a collinear point in distane 1 unit from one the given points. This third point must lay between those two given. I think I will manage with scripting but I am not really sure how to calculate it from mathematical point of view. I found some stuff on google, but they do not answer my question. Thanks for any advice.
Find a point in 3d collinear with 2 other points
0.379949
0
0
1,351
19,612,221
2013-10-26T21:42:00.000
0
1
0
1
eclipse,python-3.x,command-line-arguments,pydev,windows-8.1
19,624,100
1
false
0
0
I answered my own question in the comment above. I just had to wait to post an answer due to the fact that I just created a stackoverflow account yesterday.
1
0
0
This goes out to anyone who is well versed in the Eclipse IDE and or PyDev perspective plug-in who is willing to offer some technical support. I am trying to write a python module that must take in arguments from the command prompt with sys.argv function calls. Rather than printing out the correct output when I enter E:\ ... \src>program.py arg1 arg2, all that happens is a new command line (E:\ ... \src>) is output and the Eclipse IDE window flashes orange without any code in my python module actually being executed. Also, if I close the Eclipse IDE and try to run program.py, it will just open Eclipse again and open my program in a new tab. I'm confused as to why it is not working now when just last week it was working perfectly while testing another program that took in arguments from the command prompt by sys.argv function calls. My question for everyone is whether or not you are aware of any settings that may have been altered by updates, etc. that could cause this problem; or has anybody out there ever run into this problem and figured out how to resolve it? I have already checked my PATH variable, so that is not the problem :-(. Any help you can provide would be greatly appreciated ... thank you. OS: Windows 8.1 Pro / Eclipse ver.: Kepler (4.3) / Python ver.: 3.3.2
Python module will not run correctly from command prompt
0
0
0
213
19,612,642
2013-10-26T22:37:00.000
1
0
0
1
java,android,python,google-app-engine
19,613,781
1
true
1
0
Yes, you can use Python to do what you want. Google designs their services (such as GAE and endpoints) to be language agnostic, e.g. using JSON to serialize objects. There are a few advantages to using Java on both, such as being able to share code between client and service projects, but Google does not promote such dependencies at all - you will have no problem using Python instead.
1
0
0
Am I confused as to what is possible between an Android Client and Google App Engine? I would like to be able to create a Python API that would handle requests between GAE services such as Datastore, and an Android Client. I have found some examples that detail how to make a call from within an Android Client, but it doesn't seem to outline whether or not you can pass data to any specific API language. The question I have is whether or not it is possible to use a Python API deployed on GAE and making calls through Google End Points, or would I have to use Java Servlets to handle requests?
Android Client and Google App Engine APIs
1.2
0
0
127
19,612,872
2013-10-26T23:07:00.000
0
0
0
0
python,regex,excel,macos,applescript
20,011,728
1
false
0
0
I don't know what format your original list is in, but this sounds like a job for conditional formatting, if you can get the list into Excel. You can do conditional formatting based on a formula, and you can use a VLOOKUP() formula to do it.
1
2
0
The goal is to find values in an Excel spreadsheet which match values in a separate list, then highlight the row with a fill color (red) where matches are found. In other words: Excel file A: source list (approximately 200 items) Excel file B: has one column containing the list we are checking; must apply fill color (red) to entire row where matches are found Wondering what the best approach might be. I'm currently using AppleScript to highlight and sort data in a large volume of spreadsheets; a looped find checks each cell in a range for a single string of text and colors all matching rows. While this task is similar, the source list contains hundreds of items so it feels silly (and very slow) to include all this data in the actual script. Any suggestions would be greatly appreciated.
Find text in Excel file matching text in separate file, then apply fill color to row
0
1
0
961
19,615,178
2013-10-27T06:07:00.000
1
0
1
0
python-3.x,command-line,terminal
19,616,785
2
false
0
0
It looks like readline is not installed or working. Try running import readline and see whether it imports. This is usually because of building Python and not having the readline headers. In Debian/Ubuntu, one can install the libreadline-dev package. Then if you have compiled Python, rebuild Python with make to add readline support.
1
0
0
Like the title whenever I try to move around a command line in python3 through terminal, I get this ^[[D, ^[[A, ^[[B, and ^[[C. So I can't move between characters. What is going on?
When I use python3 in the terminal, I can't move around with my direction buttons on my keyboard
0.099668
0
0
121
19,616,817
2013-10-27T10:02:00.000
2
0
0
0
python,django,session,testing,cookies
19,616,880
1
true
1
0
The two statements do not contradict one another. You can use self.client more than once during one test. You can log in, and the cookie handling in the test client will 'remember' your session, for subsequent requests. Only when the test is done, is that state cleared. You do not need to log out, because that's a client state stored with cookies, and that state is cleared when the test is done. Only use .logout() if you wanted to test what happens after a user has logged in but their session has expired, or similar scenarios.
1
1
0
While reading the documentation I've come across two contradicts paragraphes that I couldn't really understand First one says: The test client is stateful. If a response returns a cookie, then that cookie will be stored >in the test client and sent with all subsequent get() and post() requests. Expiration policies for these cookies are not followed. If you want a cookie to expire, >either delete it manually or create a new Client instance (which will effectively delete all >cookies). While the other: Every test case in a django.test.TestCase instance has access to an instance of a Django >test client. This client can be accessed as self.client. This client is recreated for >each test, so you don’t have to worry about state (such as cookies) carrying over from >one test to another. Simply put, if I were to test login, do I have to use django.contrib.auth.logout() after each login() || post('/login/',data) ? or is it that each test case login|post|get has it's own state/cookies/session data ? it's a bit confusing for me.
Testing Django application cookies , sessions and states
1.2
0
0
1,147
19,618,735
2013-10-27T13:44:00.000
0
0
0
0
python,scrapy
19,618,864
2
false
1
0
I will be interested to see what other answers come up for this. I have done some web crawling / scrapping with code that I have written myself using urllib to get the html then just searching the html for what I need, but not tried scrapy yet. I guess to see if there are differences you may just need to compare the previous and new html pages, but you would need to either work out what changes to ignore e.g. dates etc, or what specific changes you are looking for, unless there is an easier way to do this using scrapy. On the storage front you could either store the html data just in a file system or look into just writting it to a database as strings. Just a local database like SQLite should work fine for this, but there are many other options. Finally, I would also advise you to check out the terms on the sites you are planning to scrape and also check for guidance in the robots.txt if included within the html as some sites give guidance on how frequently they are happy for web crawlers to use them etc.
1
2
0
I need help defining an architecture for a tool that will scrape more than 1000 big websites daily for new updates. I'm planning to use Scrapy for this project: Giving that Scrapy needs a project for each website, how can I handle scraping 1000+ websites and storing it's data with Scrapy in just one project? I tried adding a project generator, but is this a good idea? How can I tell if a website was updated with new content so I can scrape it again? Thanks!
Crawl and monitor +1000 websites
0
0
1
3,232
19,619,253
2013-10-27T14:37:00.000
0
0
0
0
python,scipy,openshift
19,621,115
2
false
0
0
You will probably find more info sshing into your app ad typing tail_all.
1
1
1
I want to install scikit-learn but this library needs scipy and numpy too. I tried to add them on the setup.py but I had an error with numpy. I handle to install scikit-learn and numpy from virtenv, but I cannot install scipy. I tried pip install scipy. The procedure finished without any problem but there isn't any scipy folder on site-packages. Also, I tried to add only scipy on setup.py. The same as above. The procedure finished without an error but scipy isn't there. Any help?
cannot install scipy on openshift
0
0
0
651
19,622,526
2013-10-27T19:34:00.000
0
0
1
0
python,python-3.x,binary,numbers,decimal
19,622,796
5
false
0
0
The general formula for base B is as follows: (B^N + ... + B^1 + B^0)*(B-1) = (B^(N+1) + ... + B^2 + B^1) - (B^N + ... + B^1 + B^0) = B^(N+1) - B^0 = B^(N+1)-1 Examples: B=2 and N=3 gives 2^4 - 1 = 1111 binary B=10 and N=3 gives 10^3 - 1 = 999 decimal
4
2
0
can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..
Binary to decimal conversion - formula explanation
0
0
0
426
19,622,526
2013-10-27T19:34:00.000
1
0
1
0
python,python-3.x,binary,numbers,decimal
19,622,562
5
false
0
0
Think of it like this, 111 is 1 less than 1000 (8 in binary).
4
2
0
can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..
Binary to decimal conversion - formula explanation
0.039979
0
0
426
19,622,526
2013-10-27T19:34:00.000
2
0
1
0
python,python-3.x,binary,numbers,decimal
19,622,553
5
true
0
0
It is a unique property of number 2 that the sum of it's previous powers is equal to the next power level subtracted by 1. In other words: 2^n=2^0+2^1+2^2+...+2^(n-1)+1 for n in (1,2,3...) If you need proof, use mathematical induction. Base: n=1; 2^1=2=2^0+1=1+1 Suppose that for n=k the property 2^n=2^0+2^1+...+2^(n-1)+1 is satisfied For n=k+1 you have 2^n=(2^k)*(2^1) then apply the hypothesis and you have 2^n=(2^0+2^1+...+2^(n-2)+1)*2 which yields 2^n=(2^1+2^2+...+2^(n-1)+2)=1+2^0+2^1+...+2^(n-1) which concludes our proof.
4
2
0
can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..
Binary to decimal conversion - formula explanation
1.2
0
0
426
19,622,526
2013-10-27T19:34:00.000
1
0
1
0
python,python-3.x,binary,numbers,decimal
19,622,560
5
false
0
0
Add 1 to 111: the result is 1000. It follows, therefore, that: 111 + 1 = 1000 → 1000 - 1 = 111 Now, 1000 is 23, hence: 23 - 1 = 111 Of course, you can say something similar about binary numbers with any number of 1s
4
2
0
can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..
Binary to decimal conversion - formula explanation
0.039979
0
0
426
19,624,484
2013-10-27T22:38:00.000
0
0
0
0
python,ajax,django,django-admin
19,624,592
1
true
1
0
For an easy implantation you could set up a button to only refresh the changelist through an ajax call instead of the whole page (though setting it up with a view would be easier than changing the built in admin site without breaking anything). You can also set that function to refresh on a given interval. Another option is to look at implementing Comet technology such as a push server. It would load new entries whenever they are added (like how Facebook does). It's rather complicated, but if you're up to it it might serve your purpose
1
0
0
I use the Django admin "change list" page to monitor the state of objects created and updated by my site's users. I find myself frequently refreshing the page as my users do their work. Is there a good way to make it automatically refresh, so that I can see new changes within a few seconds? Looking for a technique that is easily reusable across my project's many "change list" pages.
Django admin: live update of change list page
1.2
0
0
665
19,624,968
2013-10-27T23:30:00.000
0
0
0
0
python
54,815,571
1
false
0
1
I had the same issue caused by a top level window I had created and withdrawn but didn't destroy. Properly destroying it fixed my issue.
1
1
0
I made a program, which uses tkinter to create a window where stuff happens. It contains images and loops to constantly shift and move the images. Now, when I close the window, the scripts are still running and it creates error messages that it has nowhere to place the images with new coordinates. I think that the loops are still running. So my question is, how do I close the program all together after clicking the x on the window. Is there a way to bind the x(close window) to terminate the program, or cat n ibe done inside a code, to see when the tkinter window is closed(to me this way seems to be bad, because it would keep checking for if the window is still existing or not). Thanks a lot!
Closing a python program window leaves program still running in the background
0
0
0
1,700
19,627,743
2013-10-28T05:30:00.000
0
1
0
1
python,apache,unix,path,fastcgi
19,962,347
3
true
1
0
I had a call to python interpreter via env program in my fast cgi dispatch script. When I explicitly put path to 2.7 to the first line of the script it works as expected.
2
1
0
I have a VPS with system-wide installed python 2.5. I installed python 2.7 to one of the user's home dir (using --prefix). added it to bashrc and bash_profile, exported python variable to env, and now when I type python in console python 2.7 is running. But when I checked python version from my application (Django using with FastCGI) I still see that it is using 2.5. In ps output I see python processes running for this account and apache processes runing with hosting-specific account. How can I switch this particular account to 2.7 without changing system-wide version? Thanks!
Issue with path to python/pythonpath
1.2
0
0
137
19,627,743
2013-10-28T05:30:00.000
0
1
0
1
python,apache,unix,path,fastcgi
27,295,744
3
false
1
0
I've set PYTHONPATH in my /home/me/.bashrc and all worked ok from terminal, but when Apache w/ mod_wsgi starts my python scripts, it acts under sysem or dedicated user, which knows nothing of my .bashrc. For this particular situation, I just used apache config (apache2.conf) to set python path for apache (WSGIPythonPath option).
2
1
0
I have a VPS with system-wide installed python 2.5. I installed python 2.7 to one of the user's home dir (using --prefix). added it to bashrc and bash_profile, exported python variable to env, and now when I type python in console python 2.7 is running. But when I checked python version from my application (Django using with FastCGI) I still see that it is using 2.5. In ps output I see python processes running for this account and apache processes runing with hosting-specific account. How can I switch this particular account to 2.7 without changing system-wide version? Thanks!
Issue with path to python/pythonpath
0
0
0
137
19,628,571
2013-10-28T06:44:00.000
3
0
0
0
python,c
19,628,620
3
false
0
0
A program never return string. You can output a string to standard output and pipe it in your python code.
3
0
0
I know that C program generally ends with return, where we return the status of the program. However, I want to return a string. I will be calling the C-executable from a Python script and printing the returned string. Since main can't return a string, How do I do this?
Can I return a string from C main() program
0.197375
0
0
166
19,628,571
2013-10-28T06:44:00.000
6
0
0
0
python,c
19,628,608
3
true
0
0
the return value must be an integer (in general) What you can do is have the C program print out results (using printf, for example) and have the python script read the standard output of the process (popen functions that give access to child_stdout)
3
0
0
I know that C program generally ends with return, where we return the status of the program. However, I want to return a string. I will be calling the C-executable from a Python script and printing the returned string. Since main can't return a string, How do I do this?
Can I return a string from C main() program
1.2
0
0
166
19,628,571
2013-10-28T06:44:00.000
3
0
0
0
python,c
19,628,593
3
false
0
0
No, as per the C Standard main should return an int and not a char * or char []. (5.1.2.2.1) It (main) shall be defined with a return type of int and with no parameters ... or with two parameters ... or in some other implementation-defined manner
3
0
0
I know that C program generally ends with return, where we return the status of the program. However, I want to return a string. I will be calling the C-executable from a Python script and printing the returned string. Since main can't return a string, How do I do this?
Can I return a string from C main() program
0.197375
0
0
166
19,630,089
2013-10-28T08:29:00.000
4
0
1
0
python,xml,multithreading,openerp
19,630,408
1
true
0
0
you won't find any example because it's not the way of doing it. just use Schedulers, and that will do the trick. Cheers, Parthiv
1
0
0
Please can anyone give me a example for OpenERP [python] threads. my requirement is Need to read attendance [text based file] hourly and store it and backup i searched in forums & workspace also for example but still didn't get any please help me thanks a lot :-)
Openerp Timer task using python Threads
1.2
0
0
199
19,630,611
2013-10-28T09:01:00.000
3
0
1
0
python,jython,shared-memory,grinder
19,670,363
1
true
0
0
There are a couple of approaches you could take: When your dictionary is calculated, store it to a common external location everyone can read. (e.g. zookeeper, a shared network drive, a database, etc.) Ideally this could happen somewhere in module-level code, so that it's not being done by each agent thread. Generate the data deterministically in each agent, so that they independently generate identical dictionaries. You could then optionally have each agent/process only use a subset of the total data available, based on unique attributes such as the host name, thread number, etc.
1
1
0
Here is the requirement : In simple words, I have a static dictionary(say dictionaryX) in a class (say ClassX in shared.py file) that needs to be shared across multiple agents and multiple processes in grinder. How do I achieve this..? Any help would be greatly appreciated. Thanks in advance
Sharing resources across agents, across processes in grinder
1.2
0
0
71
19,632,667
2013-10-28T10:45:00.000
2
1
0
0
python,authentication,python-2.7,authorization,pyramid
19,646,493
1
false
0
0
if you are using the cookies based authenticate, then you can also save the user name into the cookies. For password, I am not sure it is a good idea to save it in client side. I think the better way is to use authenticated_userid to identity the user and return whatever necessary to the request.
1
2
0
Following the tutorial, I have built the authentication system using Auth. APIs of Pyramid. I would like to learn how to introduce two things (tick boxes) to the login though: Remember my name Remember my password How can I achieve this? What do I need to do? Thank you.
Intoducing "remember my name" and "remember my password" options to Pyramid's Authentication
0.379949
0
0
135
19,635,133
2013-10-28T12:44:00.000
1
0
1
0
python,tkinter,truetype
19,635,408
1
true
0
1
You cannot dynamically load fonts with tkinter.
1
1
0
How do I load a TrueType font file in Tkinter without installing it in the font directories and beside the running script, like for example in Windows/Linux? I'm trying to create a script with the fonts not need to be installed separately and already included in my main package.
Loading a TrueType font file in Tkinter without installing it in fonts folder
1.2
0
0
1,254
19,638,019
2013-10-28T14:53:00.000
1
0
0
0
python,postgresql
19,703,149
2
true
0
0
Thanks for all the comments, even if they are mostly "don't do this!" ;) Given: The dump is always produced in the same format from a 3rd-party system I need to be able to automate reading it on another 3rd-party system without postgres I've gone for writing my own basic parser, which is doing a good enough job for what I require.
1
3
0
I'd like my Python script to read some data out of a postgresql dump file. The Python will be running on a system without postgresql, and needs to process the data in a dump file. It looks fairly straightforward to parse the CREATE TABLE calls to find the column names, then the INSERT INTO rows to build the contents. But I'm sure there would be quite a few gotchas in doing this reliably. Does anyone know of a module which will do this?
How to read postgresql dump file in Python
1.2
1
0
4,660
19,643,855
2013-10-28T19:52:00.000
3
0
1
0
python,iterator
19,643,906
3
false
0
0
Yes, because every iterator is also an iterable. An object is iterable if it defines the __iter__() method. Every iterator has this method, it returns the iterator itself.
1
6
0
I know iterator is iterable, but only 1 pass. For example, many functions in itertools take iterable as parameter, e.g islice. Can I always pass in iterator if I see the api says iterable? As @delnan pointed out: Although every iterator is an iterable, some people (outside the core team) say "iterable" when they mean "something that can be iterated several times with with the same results". Some code in the wild claims to work on iterables but actually doesn't work with iterators. That is exact my concern. Is there a name for those iterable which support multipass? Like IEnumerable in C#? If I am to build a function which claims to support iterable, is it best practice to actually support iterator as well?
Does a function which takes iterable as parameter always accept iterator?
0.197375
0
0
3,097
19,645,527
2013-10-28T21:36:00.000
22
0
1
0
python,pycharm
19,651,990
12
false
0
0
Go to File->Settings->Project Settings->Project Interpreter->Python Interpreters There will be a "+" sign on the right side. Navigate to your python binary, PyCharm will figure out the rest.
6
65
0
I'm trying to learn Python and decided to use PyCharm. When I try to start a new project I get a dialog that says "No Python interpreter selected". It has a drop down to select a interpreter, but the drop down is empty.
Trying to get PyCharm to work, keep getting "No Python interpreter selected"
1
0
0
244,164
19,645,527
2013-10-28T21:36:00.000
3
0
1
0
python,pycharm
39,558,254
12
false
0
0
During the install of python make sure you have "Install for all users" selected. Uninstall python and do a custom install and check "Install for all users".
6
65
0
I'm trying to learn Python and decided to use PyCharm. When I try to start a new project I get a dialog that says "No Python interpreter selected". It has a drop down to select a interpreter, but the drop down is empty.
Trying to get PyCharm to work, keep getting "No Python interpreter selected"
0.049958
0
0
244,164
19,645,527
2013-10-28T21:36:00.000
1
0
1
0
python,pycharm
51,201,307
12
false
0
0
If you are using Ubuntu, Python has already been downloaded on your PC. so, go to -> ctrl + alt + s -> search interpreter -> go to project interpreter than select Python 3.6 in the dropdown menu. Edit: If there is no Python interpreter in drop-down menu, you should click the gear icon that on the right of the drop-down menu --> add --> select an interpreter. (on PyCharm 2018.2.4 Community Edition)
6
65
0
I'm trying to learn Python and decided to use PyCharm. When I try to start a new project I get a dialog that says "No Python interpreter selected". It has a drop down to select a interpreter, but the drop down is empty.
Trying to get PyCharm to work, keep getting "No Python interpreter selected"
0.016665
0
0
244,164
19,645,527
2013-10-28T21:36:00.000
1
0
1
0
python,pycharm
59,015,130
12
false
0
0
In my case, there are several interpreters, but I have to manually add them. To the right of where you see "No Interpreters", there is a gear icon. Click the gear icon -> Click "Add...", then you can add the ones you need.
6
65
0
I'm trying to learn Python and decided to use PyCharm. When I try to start a new project I get a dialog that says "No Python interpreter selected". It has a drop down to select a interpreter, but the drop down is empty.
Trying to get PyCharm to work, keep getting "No Python interpreter selected"
0.016665
0
0
244,164
19,645,527
2013-10-28T21:36:00.000
1
0
1
0
python,pycharm
63,027,128
12
false
0
0
In Linux, it was solved by opening PyCharm from the terminal and leaving it open. After that, I was able to choose the correct interpreter in preferences. In my case, linked to a virtual environment (venv).
6
65
0
I'm trying to learn Python and decided to use PyCharm. When I try to start a new project I get a dialog that says "No Python interpreter selected". It has a drop down to select a interpreter, but the drop down is empty.
Trying to get PyCharm to work, keep getting "No Python interpreter selected"
0.016665
0
0
244,164
19,645,527
2013-10-28T21:36:00.000
0
0
1
0
python,pycharm
69,233,742
12
false
0
0
I had the same problem and stumbled onto this solution. I ran PyCharm (as administrator, though not sure if necessary). After PyCharm has completely loaded (green tick mark top right), see bottom right. Click on it. An interface will open. In my case the path was already there. I just clicked OK and all was fine. closed PyCharm and ran it again normally. Still all fine.
6
65
0
I'm trying to learn Python and decided to use PyCharm. When I try to start a new project I get a dialog that says "No Python interpreter selected". It has a drop down to select a interpreter, but the drop down is empty.
Trying to get PyCharm to work, keep getting "No Python interpreter selected"
0
0
0
244,164
19,645,619
2013-10-28T21:42:00.000
0
0
1
0
python,regex,bash
19,645,676
4
false
0
0
what are you looking for? there is always range(19,22) which is depending on what you are looking close to curly expansion
1
1
0
Does python's regular expression have anything equivalent to match numbers in a given range? For example in bash, you can match test19.txt, test20.txt, test21.txt by test{19..21}.txt I am not looking for regular expression to match all digits like [1-2][0-9]. I want to match only a particular series of numbers starting from some number to another. Update: The final aim is to create a regexp object with re.compile(), so that i can use it to search a big list of strings.
Python regex equivalent of bash's {1..4}
0
0
0
1,470
19,645,720
2013-10-28T21:49:00.000
-1
0
1
0
python,time,schedule
19,645,758
8
false
0
0
you could use a while loop and sleep to not eat up the processor too much
1
5
0
I have a function that I want to trigger at every turn of the minute — at 00 seconds. It fires off a packet over the air to a dumb display that will be mounted on the wall. I know I can brute force it with a while loop but that seems a bit harsh. I have tried using sched but that ends up adding a second every minute. What are my options?
Trigger a Python function exactly on the minute
-0.024995
0
0
18,985
19,648,377
2013-10-29T02:03:00.000
1
0
0
0
python,shopify
19,648,899
1
false
1
0
I created a test recurring charge, it worked fine but I was not able to locate where to accept the charge in my test Shopify shop using admin. When you created your charge, you had to provide a callback so that Shopify could send the charge for you to accept. I would look there for it.
1
0
0
While testing Shopify recurring application charge today I got stuck in following issues, can anyone please look into this.... I created a test recurring charge, it worked fine but I was not able to locate where to accept the charge in my test Shopify shop using admin. I can see or query the newly created test recurring-application-charge object but can not remove or cancel it. Whenever I tried to remove, it gave me a ResourceInvalid: HTTP Error 422: Unprocessable Entity I am using Shopify python api to interact with Shopify server.
Shopify Recurring Application Charge related issue
0.197375
0
0
482
19,655,585
2013-10-29T10:28:00.000
0
0
1
0
python,loops
19,655,663
2
false
0
0
Either combine boolean flags and breaks or wrap loop in try: except: ... and raise an exception instead of loop. Second option probably is not that efficient but can be simpler and more reliable then tinkering with boolean flags.
2
0
0
I am making a game in python 3.3 and am using while True: and break to make a loop this is while True: print ("") print ("You must answer all questions in block capitals") print ("Welcome to maze runner") print ("To learn about the controls press C") print ("To learn the about the different types T") print ("To play press START") run = input () #controls while True: if run == "C": print ("To walk forward press W") print ("To turn left press A") print ("To turn right press D") print ("To turn around press S") print ("To block press B") print ("To open pack press E") print ("To open stats Press Q") print ("To go back to the main menu press M") return_to_main_menu = input () if return_to_main_menu != "M": break else: break Is there a way to get the break after else to go back to the second while true and also to get the break after the if to go back to the first while true
looping back to a certain point in Python
0
0
0
1,052
19,655,585
2013-10-29T10:28:00.000
0
0
1
0
python,loops
19,655,682
2
false
0
0
Not like you do it. Restructure your code so that everything in the inner loop is in a function.
2
0
0
I am making a game in python 3.3 and am using while True: and break to make a loop this is while True: print ("") print ("You must answer all questions in block capitals") print ("Welcome to maze runner") print ("To learn about the controls press C") print ("To learn the about the different types T") print ("To play press START") run = input () #controls while True: if run == "C": print ("To walk forward press W") print ("To turn left press A") print ("To turn right press D") print ("To turn around press S") print ("To block press B") print ("To open pack press E") print ("To open stats Press Q") print ("To go back to the main menu press M") return_to_main_menu = input () if return_to_main_menu != "M": break else: break Is there a way to get the break after else to go back to the second while true and also to get the break after the if to go back to the first while true
looping back to a certain point in Python
0
0
0
1,052
19,656,964
2013-10-29T11:26:00.000
1
0
1
0
python,matplotlib,ipython,pythonxy,wing-ide
19,658,785
1
false
0
0
Wing looks for 'python' on the path or if none tries to find Python on your path or (on Windows) in the registry. Look at sys.executable in the IPython notebook and set Python Executable in Wing's Project Properties (from the Project menu) to that full path. Then the debugger should use the right Python. Note that you'll need to restart the integrated Python Shell in Wing from its Options menu before that change takes effect there (Wing doesn't just automatically restart that, in case you have data or state there that you don't want to lose).
1
1
0
I am developing algorithms in python and mostly use IPython notebook, but when ever I need to debug I usually use Wing IDE. I'm currently having a strange problem. In the notebook, I do have a method from the matplotlib package (subplot2grid) but in Wing, I do not have this method. most of my packages were installed with the installation of pythonXY. still i do not understand why wing is using a different matplotlib from IPython, and how something like that had happend in the first place (I dont think I installed matplotlib again beside from the pythonXY automatic installation). What is going on here?
Python modules are different between IDE's
0.197375
0
0
244
19,657,370
2013-10-29T11:46:00.000
0
0
1
0
python,django,debugging,exception,pycharm
19,657,857
1
false
1
0
This should happen automatically in PyCharm. What you need to do is set no breakpoints, but run as debug (click on the green bug icon). When the exception occurs, execution should automatically halt.
1
1
0
I debug django application and want to suspend code execution at the point where exception occurs with cursor pointing to problematic place in code. Pretty HTML display by django would be helpful either but not mandatory. My IDE is PyCharm. If I set pycharm to suspend on termination of exception, then I never catch it, because django handles the exception with HTML debug info and exceptions never terminate. Setting DEBUG_PROPAGATE_EXCEPTIONS = True inside settings.py causes HTML debug info to disappear but the execution does not terminate either. If I set pycharm to suspend on raise of exception, then I have to pass all existing exceptions inside py internals such as copy.py, decimal.py, gettext.py, etc, which is inconvenient (there are so many of them that I could never reach exceptions caused by my code). If I set "temporary" setup to suspend on raise of exception which occurs after given breakpoint (which I place at the last line of settings.py) then django server does not start. Thanks in advance for your help.
Suspend on exceptions caused inside Django app in PyCharm
0
0
0
277
19,657,719
2013-10-29T12:03:00.000
3
0
1
1
python,python-2.7,tornado,keyword-argument
19,716,110
2
false
0
0
The tornado.options philosophy is that any module may define options, not just the main entry point. So if you might need a bluetooth mac address, you'd define that option in the module that interacts with bluetooth. (and if you might need more than one you can set multiple=True). The only tricky part is that you must import all modules that define options before calling parse_command_line. Truly arbitrary options are not supported by tornado.options. It's also possible to use argparse or another command-line library instead of tornado.options.parse_command_line - the rest of tornado doesn't care whether you're using tornado.options or not.
1
3
0
I'm using Tornado options to define command-line arguments. However, I would like to be able to throw arbitrary configuration options, not defined in code, to my program. These will differ, depending on what the program is supposed to do. For instance, connect to a bluetooth device using a MAC address or connect to a serial device using a TTY. If I define a set of "mandatory" options in code and then add an additional when calling the program, I get an exception thrown by parse_command_line(). It would be very handy to get e.g. a dictionary with the remaining (undefined) options. That is, much in the same way as **kwargs works in functions. Can this be done? (A work-around is to define a string option named e.g. configuration and throw everything in there, possibly encoded in some clever way. As the program is being called by another program I can e.g. base64-encode a serialized dict.) Update: I've noticed that if you add command-line args without leading dashes, Tornado will ignore them and return a list with remaining (undefined) options.
Handling of arbitrary options using Tornado options, i.e. like **kwargs
0.291313
0
0
4,015
19,659,864
2013-10-29T13:40:00.000
0
0
1
0
ipython
19,662,546
3
false
0
0
NBconvert does not run your code. So if you haven't plotted with SVG matplotlib backend it is not possible. If you did so, then you need to write a nbconvert preprocessor that does svg-> eps and extend the relevant template to know how to embed EPS.
1
10
1
I have an iPython notebook that contains an inline plot (i.e. it contains the command plot(x,y)). When I issue the command ipython nbconvert --to latex --post PDF --SphinxTransformer.author='Myself' MyNotebook.ipynb the resulting .PDF file contains the figure, but it has been exported to .PNG, so it doesn't look very good (pixelated). How can I tell nbconvert to export all plots/figures to .EPS instead? Thank you
iPython nbconvert and latex: use .eps instead of .png for plots
0
0
0
5,738
19,661,874
2013-10-29T15:03:00.000
1
0
1
1
python,api,subprocess
19,662,004
2
false
0
0
The only way that i see myself using subprocess instead of a native python api is if some option of the program is not provided in the api.
2
2
0
In case both options available: to call a command line tool with subprocess (say, hg) or to make use of native python API (say, mercurial API), is there a case where it's more favorable to use the former?
Python: subprocess vs native API
0.099668
0
0
322
19,661,874
2013-10-29T15:03:00.000
3
0
1
1
python,api,subprocess
19,662,115
2
true
0
0
If you want to execute some third party native code which you know is not stable and may crash with a segvault then it is better to execute it as a subprocess - you will be able to safely handle the possible crashes from your Python process. Also, if you want to call several times some code which is known to leak memory, leave open files or other resources, from a long running Python process, then again it may be wise to run it as a subprocess. In this case the leaking memory or other resources will be reclaimed by the operating system for you each time the subprocess exits, and not accumulate.
2
2
0
In case both options available: to call a command line tool with subprocess (say, hg) or to make use of native python API (say, mercurial API), is there a case where it's more favorable to use the former?
Python: subprocess vs native API
1.2
0
0
322
19,663,625
2013-10-29T16:12:00.000
6
0
1
0
python,python-3.x,word-wrap
19,664,045
1
false
0
0
Text wrapping is a function of your terminal, not python. All that python does is send a string to the terminal - think about it, when you say print "abcdef\n", there's no character in there that tells the terminal to wrap-text! You just need to configure the environment you're coding in. There should be a pretty easily accessible 'settings' option. However, if you can't find it, then tell us what environment you're using - we might be able to help.
1
1
0
I’m trying to print a string that is too long to be displayed on one line, so it automatically wraps to the next line. The problem is that I need it to all stay on one line and just go off the screen (where I can just scroll left to right to see it all).Is there a way to to disable word wrap in python IDLE by changing somethings in configure option
how to disable WORD WRAP in python IDLE
1
0
0
6,081
19,664,732
2013-10-29T17:05:00.000
1
0
0
0
python,django,postgresql
19,665,116
2
false
1
0
I guess you forgot to enter semicolon: SELECT * FROM myapp_stories;
2
1
0
I'm using Django + Postgres. When I do a SQL query using psql, e.g. \d+ myapp_stories correctly shows the columns in the table But when I do SELECT * FROM myapp_stories, it returns nothing. But querying the same database & table from my python code returns data just fine. So there is data in the table. Any thoughts? I'm using venv, not sure if that affects anything. Thanks in advance!
SELECT using psql returns no rows even though data is there
0.099668
1
0
82
19,664,732
2013-10-29T17:05:00.000
1
0
0
0
python,django,postgresql
19,666,882
2
false
1
0
Prefix the table in your query with the schema, as the search_path might be causing your query (or psql) to look in a schema other than what you are expecting.
2
1
0
I'm using Django + Postgres. When I do a SQL query using psql, e.g. \d+ myapp_stories correctly shows the columns in the table But when I do SELECT * FROM myapp_stories, it returns nothing. But querying the same database & table from my python code returns data just fine. So there is data in the table. Any thoughts? I'm using venv, not sure if that affects anything. Thanks in advance!
SELECT using psql returns no rows even though data is there
0.099668
1
0
82
19,668,027
2013-10-29T20:05:00.000
0
0
0
0
python,file-upload,pyramid
19,686,469
1
true
1
0
This sounds like your browser is caching the images. Try setting the cache_max_age=0 on your add_static_view, or viewing the page in your browser's incognito mode where it'll use a different cache.
1
1
0
I created new directory via 'myimages' under static directory. And whenever user upload files, file get stores in that directory. Once file uploaded I can access that on html using '/static/myimages/imagename.png'. It works fine whenever I am uploading new image. But whenver I try to override image. It shows me old image only. I manually check in directory. It has new image, but still when I try to access that via browser, it gives me old image.
pyramid static view and file upload
1.2
0
0
198
19,671,933
2013-10-30T00:55:00.000
2
0
0
0
python,user-interface,wxpython,xrc
19,686,565
1
true
0
1
You should learn wxPython. XRC does have its advantages, but it only covers the core widgets. If you want access to the rest of wxPython, then you'll have to figure out how to make XRC wrap the unsupported widgets, which is non-trivial and will require you to learn wxPython anyway. There are tons of wxPython tutorials, but only a few XRC tutorials. I've written about both, but I usually stick with wxPython code.
1
1
0
After some research I've decided to use wxWidgets to build user interfaces for my Python programs. I learnt this could be done in two ways: either I blend my "behind the scenes" raw Python code with interface related wxPython code, or I could separate the interface from the main code, creating a separated XRC file for the interface and just calling it in the main Python code. What should I do, should I learn wxPython or should I learn XRC code? I read some advantages of learning/using XRC: Separates the interface from the program logic. Dialog Blocks only outputs to C++ and XRC, not for Python. Ability to choose between different resource files at run time. XRC is a wxWidgets standard, so it can be generated and processed by any program that understands it. XML is easier to parse than most programming languages. But I think there are some disadvantages too: Documentation seems a lot bigger for wxPython. More people seems to learn and talk about wxPython, so support for. XRC may be scarce So, what would be the best to learn, XRC code or wxPython code?
Should I learn wxPython code or XRC code?
1.2
0
0
612
19,672,150
2013-10-30T01:21:00.000
2
0
1
0
python
21,016,755
2
false
0
0
This is a compatibility issue between 32 bit and 64 bit. So, either try 64 bit Python or 32 bit Python with 32 bit pywin32 installer.
1
1
0
I have a 64 bit architecture system. I installed Python 2.7.5. I then started the installation of pywin32-214.win-amd64-py2.7. That failed with the "ImportError: DLL load failed: %1 is not a valid Win32 application" error message. Any suggestions?
ImportError: DLL load failed: %1 is not a valid Win32 application
0.197375
0
0
4,144
19,673,279
2013-10-30T03:27:00.000
0
0
0
0
python,classification,scikit-learn
19,696,243
1
false
0
0
CCA doesn't support sparse matrices. By default, you should assume scikit-learn estimators do not grok sparse matrices and check their docstrings to find out if by chance you found one that does. (I admit the warning could have been friendlier.)
1
0
1
I am trying to run CCA for a multi label/text classification problem but keep getting following warning and an error which I think are related warnings.warn('Maximum number of iterations reached') /Library/Python/2.7/site-packages/sklearn/cross_decomposition/pls_.py:290: UserWarning: X scores are null at iteration 0 warnings.warn('X scores are null at iteration %s' % k) warnings.warn('Maximum number of iterations reached') /Library/Python/2.7/site-packages/sklearn/cross_decomposition/pls_.py:290: UserWarning: X scores are null at iteration 1 warnings.warn('X scores are null at iteration %s' % k) ... for all the 400 iterations and then following error at the end which I think is a side effect of above warning: Traceback (most recent call last): File "scikit_fb3.py", line 477, in getCCA(shorttestfilepathPreProcessed) File "scikit_fb3.py", line 318, in getCCA X_CCA = cca.fit(x_array, Y_indicator).transform(X) File "/Library/Python/2.7/site-packages/sklearn/cross_decomposition/pls_.py", line 368, in transform Xc = (np.asarray(X) - self.x_mean_) / self.x_std_ File "/usr/local/bin/src/scipy/scipy/sparse/compressed.py", line 389, in sub raise NotImplementedError('adding a nonzero scalar to a ' NotImplementedError: adding a nonzero scalar to a sparse matrix is not supported What could possibly be wrong?
UserWarning: X scores are null at iteration
0
0
0
877
19,674,364
2013-10-30T05:16:00.000
0
0
1
0
python,call,mousemove,xdotool
19,674,382
2
false
0
0
Remove the quotes. If you keep quotes, it will treat as a string. call(["xdotool", "mousemove", "500","600"])
1
0
0
I am using Python on Ubuntu. call(["xdotool", "mousemove", "500","600"])works fine. But if x=500, y=600, call(["xdotool", "mousemove", "x","y"]) does not work. What should be the syntax of x and y?
In Python how to use variables in call function?
0
0
0
159
19,676,538
2013-10-30T07:44:00.000
155
0
1
0
python,arrays,numpy
19,676,762
3
true
0
0
All three versions do different things: B = A This binds a new name B to the existing object already named A. Afterwards they refer to the same object, so if you modify one in place, you'll see the change through the other one too. B[:] = A (same as B[:]=A[:]?) This copies the values from A into an existing array B. The two arrays must have the same shape for this to work. B[:] = A[:] does the same thing (but B = A[:] would do something more like 1). numpy.copy(B, A) This is not legal syntax. You probably meant B = numpy.copy(A). This is almost the same as 2, but it creates a new array, rather than reusing the B array. If there were no other references to the previous B value, the end result would be the same as 2, but it will use more memory temporarily during the copy. Or maybe you meant numpy.copyto(B, A), which is legal, and is equivalent to 2?
2
127
1
For example, if we have a numpy array A, and we want a numpy array B with the same elements. What is the difference between the following (see below) methods? When is additional memory allocated, and when is it not? B = A B[:] = A (same as B[:]=A[:]?) numpy.copy(B, A)
Numpy array assignment with copy
1.2
0
0
76,805