Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2014-02-25 14:28:08.817 | Python multiprocessing: max. number of Pool worker processes? | I am making use of Python's multiprocessor library and wondering what would be the maximum of worker processes I can call?
E.g. I have defined async.pool = Pool(100) which would allow me to have max 100 async processes running at the same time, but I have no clue what would be the real maximum value for this?
Does anyo... | You can use as many workers as you have memory for.
That being said, if you set up a pool without any process flag, you'll get workers equal to the machine CPUs:
From Pool docs:
processes is the number of worker processes to use. If processes is None then the number returned by os.cpu_count() is used.
If you're doing... | 0.545705 | false | 1 | 3,058 |
2014-02-25 16:24:25.603 | How to make nbviewer display local files? | I've got nbviewer installed and working. I see it has a --localfiles option that takes a folder name. It says: "Serving local notebooks in /home/gb/S14/inclass, this can be a security risk"
But I can't figure out the URL format to get it to look for the file there. The code adds a handler for /localfile/(.*) but that d... | One minute later and it occurs to me that the front page might not support even though the server does. Sure enough, http://localhost:5000/localfile/PythonReference.ipynb?create=1 renders the local notebook. | 1.2 | true | 1 | 3,059 |
2014-02-26 00:21:16.583 | Scipy: Fitting Data with Two Dimensional Error | So I already know how to use scipy.optimize.curve_fit for normal fitting needs, but what do I do if both my x data and my y data both have error bars? | Try scipy.odr. It allows to specify weights/errors in both input and response variable. | 1.2 | true | 1 | 3,060 |
2014-02-26 02:47:11.103 | Best way to build a custom Django CMS | I am new to Django, but heard it was promising when attempting to create a a custom CMS.
I am looking to get started, but their seems to be a lack of documentation, tutorials, etc on how to actually get something like this going.
I am curious if their are any books/tutorials/guides that can help me get started with CM... | django CMS is a CMS on top of django. It supports multiple languages really well and plays nice together with your own django apps. The basic idea is that you define placeholders in your template and then are able to fill those placeholders with content plugins. A content plugin can be a anything from text, picture, tw... | 0 | false | 1 | 3,061 |
2014-02-26 19:22:29.257 | How to fully uninstall pip installed with easy_install? | On Windows 7, I install pip with easy_install and want to install a lower version of pip.
I want to remove the old version, but have no idea how to completely remove the pip installed by easy_install (or if there is a way to do it without going through easy_install, that is fine). How do I do this? | To uninstall pip in windows:
Run command prompt as administrator
Give the command easy_install -m pip
This may not uninstall pip completely. So again give this command pip uninstall pip If by previous command pip got uninstalled then this command wont run, else it will completely remove pip
Now check by giving command... | 0.265586 | false | 1 | 3,062 |
2014-02-27 01:15:24.537 | Installed Python from source and cannot import Tkinter - how to install? | I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6? | Have you tried using pip-2.6 install package? | -0.135221 | false | 3 | 3,063 |
2014-02-27 01:15:24.537 | Installed Python from source and cannot import Tkinter - how to install? | I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6? | Install the TCL and Tk development files and rebuild Python. | 0.135221 | false | 3 | 3,063 |
2014-02-27 01:15:24.537 | Installed Python from source and cannot import Tkinter - how to install? | I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6? | I solved this by adding '/usr/lib/x86_64-linux-gnu' to lib_dirs in setup.py, then rebuilding python | 1.2 | true | 3 | 3,063 |
2014-02-27 11:54:53.770 | How to re-architect a portal for creating mobile app | Currently I am working on a portal which is exposed to end users. This portal is developed using Python 2.7, Django 1.6 and MySQL.
Now we want to expose this portal as a mobile app. But current design does not support that as templates, views and database are tightly coupled with each other. So we decided to re-archit... | What you guys think about architecture?
This is a common Service Oriented Architecture with decoupled Clients. You just have REST endpoints on your backend, and any Client can consume those endpoints.
You should also think about:
Do you need RESTful service (RESTful == stateless, will you store any state on the serve... | 0 | false | 1 | 3,064 |
2014-02-27 14:22:25.147 | Adding Event functions outside PyQt/PySide Generated Code | I am using PySide in a not-so-MVC fashion, meaning, I try as much as possible not to edit the generated .ui to .py file, I put my application logic in packages (models) and I have one module (.pyw file) more like a controller for them all to initialize and perform management. Not too best of practice but I'm doing fine... | Monkey Patching did the job, I dont know why I didn't taught of that | 0 | false | 1 | 3,065 |
2014-02-27 18:57:32.913 | Read a HTML file and show it on a Tkinter window | I would like to read a HTML and I show it on a Tkinter window. I would like to know if this is possible with any module and if it's how can I do it, as I'm totally lost finding solutions.
Thanks in advance. | There is no support for viewing rendered HTML in a tkinter widget. There was a project (tkhtml) to build a modern web browser using tcl/tk (which is what powers tkinter), but the project never got past a very early alpha release and the last check-in was in 2009. | 1.2 | true | 1 | 3,066 |
2014-02-28 06:29:48.653 | What is the correct workflow in using Sphinx for Python project documentation? | I want to use Sphinx to document a large project that is currently not well-documented. In particular I want to use sphinx-apidoc to produce the documentation from the code as I document it.
However I also want to have some pages of tutorial on how to use the project etc., but it seems when I call sphinx-apidoc it gen... | First you run sphinx-quickstart and accept the defaults to set up your basic structure this is only done once and you edit the table of contents section of index.rst to point to your tutorials, give an introduction, etc. - the you at least outline your tutorials in separate .rst files. You also edit config.py to add a... | 1.2 | true | 1 | 3,067 |
2014-02-28 21:42:27.107 | How do I install pyPDF2 module using windows? | As a newbie... I am having difficulties installing pyPDF2 module. I have downloaded. Where and how do I install (setup.py) so I can use module in python interpreter? | If you have pip, PyPDF2 is on the Python Package Index, so you can install it with the following in your terminal/command prompt:
Python 2:
pip install PyPDF2
Python 3:
pip3 install PyPDF2 | 0.999945 | false | 2 | 3,068 |
2014-02-28 21:42:27.107 | How do I install pyPDF2 module using windows? | As a newbie... I am having difficulties installing pyPDF2 module. I have downloaded. Where and how do I install (setup.py) so I can use module in python interpreter? | Here's how I did it:
After you have downloaded and installed Python (it usually installs under C:\Python** (** being python version - usually 27)), copy the extracted PyPDF2 contents to C:\Python** folder, after that enter in command prompt/terminal "cd C:\Python27\python.exe setup.py install". If you did everything r... | 0.101688 | false | 2 | 3,068 |
2014-03-01 05:29:55.513 | Insert a new database in redis using redis.StrictRedis() | I know that Redis have 16 databases by default, but what if i need to add another database, how can i do that using redis-py? | You cannot. The number of databases is not a dynamic parameter in Redis.
You can change it by updating the Redis configuration file (databases parameter) and restarting the server.
From a client (Python or other), you can retrieve this value using the "GET CONFIG DATABASES" command. But the "SET CONFIG DATABASES xxx" c... | 0 | false | 1 | 3,069 |
2014-03-01 22:42:01.770 | Using RabbitMQ with Django to get information from internal servers | I've been trying to make a decision about my student project before going further. The main idea is get disk usage data, active linux user data, and so on from multiple internal server and publish them with Django.
Before I came to RabbitMQ I was thinking about developing a client application for each linux server and... | You need the following two programs running at all times:
The producer, which will populate the queue. This is the program that will collect the various messages and then post them on the queue.
The consumer, which will process messages from the queue. This consumer's job is to read the message and do something with i... | 0 | false | 1 | 3,070 |
2014-03-02 00:52:54.350 | What's the difference between using libSVM in sci-kit learn, or e1070 in R, for training and using support vector machines? | Recently I was contemplating the choice of using either R or Python to train support vector machines.
Aside from the particular strengths and weaknesses intrinsic to both programming languages, I'm wondering if there is any heuristic guidelines for making a decision on which way to go, based on the packages themselves.... | Sometime back I had the same question. Yes, both e1070 and scikit-learn use LIBSVM. I have experience with e1070 only.
But there are some areas where R is better. I have read in the past that Python does not handle categorical features properly (at least not right out of the box). This could be a big deal for some.
I a... | 0 | false | 2 | 3,071 |
2014-03-02 00:52:54.350 | What's the difference between using libSVM in sci-kit learn, or e1070 in R, for training and using support vector machines? | Recently I was contemplating the choice of using either R or Python to train support vector machines.
Aside from the particular strengths and weaknesses intrinsic to both programming languages, I'm wondering if there is any heuristic guidelines for making a decision on which way to go, based on the packages themselves.... | I do not have experiece with e1070, however from googling it it seems that it either uses or is based on LIBSVM (I don't know enough R to determine which from the cran entry). Scilearnkit also uses LIBSVM.
In both cases the model is going to be trained by LIBSVM. Speed, scalability, variety of options available is goi... | 1.2 | true | 2 | 3,071 |
2014-03-02 19:27:46.970 | what does +=, -=, *= and /= stand for in Python? | what does
+=, -=, *= and /=
stand for in Python? and how do you use it for while loop? | That is not only python , that is in most of programming languages
x=1;
x+=1;
x will be 2
x=1;
x-=1;
x will be 0
x=3;
x*=2;
x will be 6
x=6;
x/=2;
x will be 3 | 0.081452 | false | 1 | 3,072 |
2014-03-03 10:02:12.037 | Examples on N-D arrays usage | I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them.
Can you please give me exa... | A few simple examples are:
A n x m 2D array of p-vectors represented as an n x m x p 3D matrix, as might result from computing the gradient of an image
A 3D grid of values, such as a volumetric texture
These can even be combined in the case of a gradient of a volume in which case you get a 4D matrix
Staying with the g... | 0.081452 | false | 5 | 3,073 |
2014-03-03 10:02:12.037 | Examples on N-D arrays usage | I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them.
Can you please give me exa... | Practical applications are hard to come up with but I can give you a simple example for 3D.
Imagine taking a 3D world (a game or simulation for example) and splitting it into equally sized cubes. Each cube could contain a specific value of some kind (a good example is temperature for climate modelling). The matrix can ... | 0 | false | 5 | 3,073 |
2014-03-03 10:02:12.037 | Examples on N-D arrays usage | I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them.
Can you please give me exa... | For example, a 3D array could be used to represent a movie, that is a 2D image that changes with time.
For a given time, the first two axes would give the coordinate of a pixel in the image, and the corresponding value would give the color of this pixel, or a grey scale level. The third axis would then represent time. ... | 0 | false | 5 | 3,073 |
2014-03-03 10:02:12.037 | Examples on N-D arrays usage | I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them.
Can you please give me exa... | There are so many examples... The way you are trying to represent it is probably wrong, let's take a simple example:
You have boxes and a box stores N items in it. You can store up to 100 items in each box.
You've organized the boxes in shelves. A shelf allows you to store M boxes. You can identify each box by a index... | 0 | false | 5 | 3,073 |
2014-03-03 10:02:12.037 | Examples on N-D arrays usage | I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them.
Can you please give me exa... | They are very applicable in scientific computing. Right now, for instance, I am running simulations which output data in a 4D array: specifically
| Time | x-position | y-position | z-position |.
Almost every modern spatial simulation will use multidimensional arrays, along with programming for computer games. | 0 | false | 5 | 3,073 |
2014-03-03 12:34:13.960 | How to use celery to get messages from a rabbit-mq server? | The celery docs suggest that Rabbit-MQ must act like a middleman, where it is used as a messaging platform.
In my infrastructure, Rabbit-MQ is the primary server that serves me with some data every second. Now, whenever the data is served, I want Celery to do certain tasks.
Now, this throws out the whole publisher-wo... | Celery can use several back-ends. If you are already using RabbitMQ, it makes that option attractive.
These are however different concerns. Use a generic RabbitMQ client library such as pika to implement a consumer for your messages, then, if needed, use Celery to schedule tasks. | 0.135221 | false | 1 | 3,074 |
2014-03-03 14:10:16.427 | pip "pyrax" dependency with iron worker | I created a Python script to use Rackspace's API (Pyrax) to handle some image processing. It works perfect locally, but when I upload it to Iron.io worker, it builds but does not import.
I am using a Windows 8 pc, but my boss runs OS X and uploading the exact worker package, it works fine. So I'm thinking it's somethi... | I figured out that it was a bad Ruby install. No idea why, but reinstalling it worked. | 0.386912 | false | 2 | 3,075 |
2014-03-03 14:10:16.427 | pip "pyrax" dependency with iron worker | I created a Python script to use Rackspace's API (Pyrax) to handle some image processing. It works perfect locally, but when I upload it to Iron.io worker, it builds but does not import.
I am using a Windows 8 pc, but my boss runs OS X and uploading the exact worker package, it works fine. So I'm thinking it's somethi... | It's difficult to know for sure what's happening without being able to see a traceback. Do you get anything like that which could be used to help figure out what's going on? | 0 | false | 2 | 3,075 |
2014-03-03 22:58:00.637 | (Text Classification) Handling same words but from different documents [TFIDF ] | So I'm making a python class which calculates the tfidf weight of each word in a document. Now in my dataset I have 50 documents. In these documents many words intersect, thus having multiple same word features but with different tfidf weight. So the question is how do I sum up all the weights into one singular weight? | First, let's get some terminology clear. A term is a word-like unit in a corpus. A token is a term at a particular location in a particular document. There can be multiple tokens that use the same term. For example, in my answer, there are many tokens that use the term "the". But there is only one term for "the".
... | 1.2 | true | 1 | 3,076 |
2014-03-04 07:01:33.153 | Permission to get the source code using spider | I am working on creating a web spider in python. Do i have to worry about permissions from any sites for scanning there content? If so, how do i get those? Thanks in advance | robots.txt file does have limits.
Its better to inform the owner of the site if you are crawling too often and read reserved rights at the bottom of the site. It is a good idea to provide a link, to the source of your content. | 1.2 | true | 1 | 3,077 |
2014-03-04 14:56:46.320 | how to load shell environment variables when Emacs starts py-shell? | I'm working for a university and they have their own libraries and paths for python libraries. Every time I start ipython, I need to run a shell script (e.g. /etc/university/env.sh)
The problem is that emacs doesn't recognize the env.sh file. When I do py-shell, emacs always envokes Python WITHOUT any pre-set environme... | After running your /etc/university/env.sh, start Emacs from this shell.
Then the variables set before are known. | 0 | false | 1 | 3,078 |
2014-03-04 16:45:30.437 | Traversing back to parent with lxml.html.xpath | How can we traverse back to parent in xpath?
I am crawling IMDB, to obtain genre of films, I am using
elem = hxs.xpath('//*[@id="titleStoryLine"]/div/h4[text()="Genres:"]')
Now,the genres are listed as anchor links, which are siblings to this tag. how can this be achieved? | This will select the parent element of the XPath expression you gave:
//*[@id="titleStoryLine"]/div/h4[text()="Genres:"]/.. | 1.2 | true | 1 | 3,079 |
2014-03-06 04:57:34.330 | UI Designed in Photoshop for Software | so I am actually trying to get into software development and I currently have just spent a few days making a GUI in Photoshop. Now I know how to code in Java and Python but I have never implemented a GUI before. I am stuck on this because I know I can write the code and everything but how do I take what I made in Photo... | but how do I take what I made in Photoshop add some java or python code to it to make certain things happen
No, you cannot expect things to happen magically, for that you need to learn front-end technologies like HTML, CSS, JavaScript etc and manually convert the UI which is in Photoshop to corresponding code. This ap... | 0.386912 | false | 1 | 3,080 |
2014-03-08 11:53:16.580 | Real time output of script on web page using mod_wsgi | I have a Python application that I launch from a form using mod_wsgi. I would like to display in real time the output of the script, while it is running, to a web page.
Does anybody know how I can do this? | You'll need JavaScript to do this
Possibility 1, data generated by server
- Make a static HTML page with an empty div.
- Place a piece of Javascript code onto it that is run after the page is loaded.
- The JavaScript will contain a timer that downloads the output of your script say every 5 seconds, using AJAX ands sets... | 0.386912 | false | 1 | 3,081 |
2014-03-08 19:35:09.433 | how to hook on a table cell in spss using python? | I want to write a hopefully short python script that would do things with the contents of a specially formatted text cell of an spss data table.
How can I hook on the event that the user clicked into a data cell? How can I then get its value and do things I want? Does spss have clear-cut interface for doing this? | You cannot catch events using the programmability or scripting apis. The only formatting in the Data Editor comes from variable formats (and column width) except for the special coloring using with missing data imputation. Tables in the Viewer, of course, have extensive cell formatting capabilities. | 0 | false | 1 | 3,082 |
2014-03-08 19:45:38.770 | one colormap for multiple subplots with different maximum values | I want to do two subplots with imshow using the same colormap by which I mean: if points in both plots have the same color, they correspond to the same value. But how can I get imshow to use only 9/10 or so of the colormap for the first plot, because it's maximal value is only 9/10 of the maximal value in the second pl... | imgshow takes two arguments vmin and vmax for the color scale. You could do what you want by putting the same vmin and vmax for both your subplots.
To find vmin you can take the minimum between the minimum of all the values in your data (and same reasoning for vmax). | 1.2 | true | 1 | 3,083 |
2014-03-09 12:39:07.530 | User session object is not available on POST in django? | I have a form where users are submitting data. One of the fields is "author" which i automatically fill in by using the {{ user }} variable in the template, it will have the username if the user is logged in and AnonymousUser if not. This {{ user }} is not part of the form, just text.
When a user submits the form i nee... | The user is never in request.session. It's directly on the request object as request.user. | 1.2 | true | 1 | 3,084 |
2014-03-10 13:16:49.310 | Notify celery task to stop during worker shutdown | I'm using celery 3.X and RabbitMQ backend. From time to time it needs to restart celery (to push a new source code update to the server). But there is a task with big loop and try/catch inside of the loop; it can takes a few hours to accomplish the task. Nothing critical will happen if I will stop it and will restart i... | Celery is not intended to run long tasks cause it blocks the worker for your task only. I recommend re-arranging your logic, making the task invoke itself instead of making the loop. Once shutdown is in progress, your current task will complete and will resume right at the same point where it stopped before celery shut... | -0.386912 | false | 1 | 3,085 |
2014-03-12 16:07:14.933 | How can I share my website in progress to partner? | I'm developing a website in python (with django and GIT) for an association, and I am to a point where I need to share my work for approval from the team.
I have around 50 people who need to be able to access my "website" 24/7.
Apparently, free hosting is not the best way to do it (see answers to my original question).... | Well, then use your ubuntu system, forward the right ports in your router and give your customers a link to your IPadres. I assume you use your ubuntu system as an webserver already for testing your site? | 0.201295 | false | 1 | 3,086 |
2014-03-12 17:01:38.577 | How to set Python IDLE to use certain python version | I am using Windows 8.
Python version 2.7.3 have been installed on my computer together with another software.
Now I have installed python 3.3.5 and i want to use this version from now.
But everytime I run Python IDLE it runs version 2.7.3.
Even if I go to C:\Python33\Lib\idlelib\idle.pyw and run idle.pyw it runs with ... | Each installation of Python comes with its own respective version if IDLE. I suggest you explore your Python installation folder, and find the version of IDLE you're looking for and create a shortcut to it, or add it to your environment variable list, so you can invoke a specific version from the command line. | 1.2 | true | 1 | 3,087 |
2014-03-12 18:17:30.693 | Python Neurolab - fixing output range | I am learning some model based on examples ${((x_{i1},x_{i2},....,x_{ip}),y_i)}_{i=1...N}$ using a neural network of Feed Forward Multilayer Perceptron (newff) (using python library neurolab). I expect the output of the NN to be positive for any further simulation of the NN.
How can I make sure that the results of sim... | Simply use a standard sigmoid/logistic activation function on the output neuron. sigmoid(x) > 0 forall real-valued x so that should do what you want.
By default, many neural network libraries will use either linear or symmetric sigmoid outputs (which can go negative).
Just note that it takes longer to train networks wi... | 1.2 | true | 1 | 3,088 |
2014-03-13 12:25:32.577 | SWIG C++ Precompiled DLL | I have a third party DLL (no header file) written in C++ and I am able to get the function prototype information from the developer, but it is proprietary and he will not provide the source.
I've gone through the SWIG tutorial but I could not find anywhere specifying how to use SWIG to access any functions with only th... | To use a library (static or dynamic), you need headers and library file .a, .lib...
Its true for c++ and I think its the same for Python | 0 | false | 2 | 3,089 |
2014-03-13 12:25:32.577 | SWIG C++ Precompiled DLL | I have a third party DLL (no header file) written in C++ and I am able to get the function prototype information from the developer, but it is proprietary and he will not provide the source.
I've gone through the SWIG tutorial but I could not find anywhere specifying how to use SWIG to access any functions with only th... | SWIG cannot be used without the header files. Your only option is a lib like ctypes. If you find ctypes doesn't do it for you and you can't find alternative then post a question with why ctypes not useable in your case. | 0 | false | 2 | 3,089 |
2014-03-13 14:32:17.560 | Python27.dll File Missing - Exception | I have downloaded my code from bit-bucket which was made by my group member. It contain all the frameworks and python script folder. But when I run this code on my system it generates the following error:
This program can't start because python27.dll is missing from your
computer. Try reinstalling the program to fix... | I also got this error when I copied my python environment from one computer to another. Both computers were 64 bit and the installation was 64 bit. What happens is that python installer updates Microsoft registry. When I simply copied the python files, the registry did not get updated, of course, resulting in the dll f... | 0.545705 | false | 2 | 3,090 |
2014-03-13 14:32:17.560 | Python27.dll File Missing - Exception | I have downloaded my code from bit-bucket which was made by my group member. It contain all the frameworks and python script folder. But when I run this code on my system it generates the following error:
This program can't start because python27.dll is missing from your
computer. Try reinstalling the program to fix... | It's most probably a 32-bit or 64-bit issue. Try downloading proper version. | 1.2 | true | 2 | 3,090 |
2014-03-13 16:11:08.657 | Where do I put the specific translation functions in Django App? | I have a Django project in which I have changed the default 'Django Administration' text in the header.
Now I have implemented translation of strings that django knows about, but I cannot figure out how to translate this title.
I put the translation function in models.py but it doesn't change when I change Language.
I'... | Try to move your app name up to admin app in your INSTALLED_APPS settings.py tuple. | 0 | false | 1 | 3,091 |
2014-03-13 21:54:41.307 | deleting rows in linux | I have a number of huge delimited text files containing information logged by date. Some of the files overlap slightly with each other by date (which I don't want since it leads to duplicates). I know what the overlapping dates are so I want to be able to go through some of the files and delete each of the rows that co... | There are various command line applications that would be able to accomplish this when working together. For example, you could cat all the files one after another, grep -v the patterns you don't want, redirecting >> to a new file. In effect this is doing the same thing as your Python script would do, because every lin... | 0 | false | 1 | 3,092 |
2014-03-14 11:58:00.050 | How to transfer html view data or (Python) server data to Angular or Javascript? | I am programming a small web app on GAE using python webapp2 framework.
What I want to achieve is displaying server data to the html view through javascript or angularjs. Actually the app draws some graph using d3.js based on the server data. I know I can use $http.get to retrieve the data from server. But this way I n... | Since you are already going to build an Angular app for the front-end, why not make the whole architecture RESTful? That way the front-end Angular app will be in charge of presentation and the server of just the data. You can pass data between the server and front-end through JSON which has the benefit of not needing t... | 0.386912 | false | 1 | 3,093 |
2014-03-14 19:10:24.020 | Combining regular expressions in Python | I'd like to combine the regular expressions \w+ and [a-z] together in Python to only accept a word that is all lowercase, but cannot seem to figure out the right way to do that. Does anyone know how? | So I was actually able to get it to work like this : [a-z]\w+. | -0.067922 | false | 2 | 3,094 |
2014-03-14 19:10:24.020 | Combining regular expressions in Python | I'd like to combine the regular expressions \w+ and [a-z] together in Python to only accept a word that is all lowercase, but cannot seem to figure out the right way to do that. Does anyone know how? | If you only want lowercase words, all you need is [a-z]+
\w includes uppercase letters, digits, and underscore | 1.2 | true | 2 | 3,094 |
2014-03-15 15:19:43.210 | How many objects should I retrieve from server and How many can be stored in NSCache? | My service return up to 500 objects at time i've notice that my iphone application is crashing when the amount of data goes over 60 objects. to workaround this issue I'm running a query that brings back only the top 40 results but that is slower than just returning the entire data
what are the best practices and how c... | Maybe you should use NSData to retrieve data from your service instead of NSCache.
NSCache is for temporary objects, however NSData is used to move data between applications (from your service to your app)
Description of NSCache by Apple:
An NSCache object is a collection-like container, or cache, that stores key-valu... | 0 | false | 1 | 3,095 |
2014-03-16 15:06:29.260 | Algorithm design for systems on a spaceship taking messages | I'm writing a prototype for the tactical spaceship combat in a game I'm working on.
The basic idea of the part I'm working on right now is that a 'ship' object (which represents a single individual ship) contains a list of 'system' objects. When a ship is first initialized, it calls an initialize() function on each of ... | The issue is trying to give an absolute value to the priority. Rather you need to build a relative priority data structure for each call. This way you can say that hit() is highest priority for super-shields then shields then hull. The mod would then simply need to change the hit sound effects for the hull or add an ad... | 0.386912 | false | 1 | 3,096 |
2014-03-17 08:02:57.147 | how to install PIL on Macosx 10.9? | When I try to install PIL library on Macosx 10.9.2, it's giving following error, how to install it.
$: sudo pip install pillow
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prot... | following line helped me.
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pillow | 0.386912 | false | 1 | 3,097 |
2014-03-17 11:51:21.733 | How to change font style for part of a tkinter label | I'm wondering how I can change the font of a Python Tkinter label widget so that half the displayed text is bold and half is not without having to use two labels. The text for the widget is assigned prior to the label actually being created and stored in a variable so I need some kind of flag presumably to tell it how ... | There is nothing you can do with the label widget -- it only supports a single font and single color for the entire label. However, you can easily substitute a canvas or text widget anywhere you need this feature. There's no reason why you can't use a text widget that is one line tall and a dozen or so characters wide. | 0.545705 | false | 1 | 3,098 |
2014-03-17 14:07:53.017 | Getting access to VRay Python SDK | I'm developing some Python scripts to read/parse/process some .vrscene files.
From others' examples, I can see that there is a Python SDK for VRay called vrayutils.
I want to get this information from the SettingsOutput object.
From a .vrscene file I want to get the total frame numbers.
Does anyone know where I can get... | I was able to do some of the things by parsing the file using basic Python and then extracting the things I needed.
The V-Ray API has a proprietary license, and there is no open source way to access the .vrscene
I decided to try with a trial version of the SDK, and by using the SDK you will be able to find a nice Pyth... | 1.2 | true | 1 | 3,099 |
2014-03-19 03:42:32.803 | Server side python code runing continuosly per session | I have searched the forums for my question but im either searching for a thing naming it wrongly or the question is hard which i really doubt.
I am developing a web-app which would have an web-interface written in one of the MVC frameworks like django or even flask and allow user to login, will identify users session a... | Celery is a great solution, but it can be overpowered for many setups. If you just need tasks to run periodically (once an hour, once a day, etc) then consider just using cron.
There's a lot less setup and it can get you quite far. | 0.201295 | false | 1 | 3,100 |
2014-03-19 07:18:21.080 | Tracking changes in python source files? | I'm learning python and came into a situation where I need to change the behvaviour of a function. I'm initially a java programmer so in the Java world a change in a function would let Eclipse shows that a lot of source files in Java has errors. That way I can know which files need to get modified. But how would one do... | One of the tradeoffs between statically and dynamically typed languages is that the latter require less scaffolding in the form of type declarations, but also provide less help with refactoring tools and compile-time error detection. Some Python IDEs do offer a certain level of type inference and help with refactoring,... | 0 | false | 1 | 3,101 |
2014-03-21 08:26:43.563 | Celery Flower - how can i load previous catched tasks? | I started to use celery flower for tasks monitoring and it is working like a charm. I have one concern though, how can i "reload" info about monitored tasks after flower restart ?
I use redis as a broker, and i need to have option to check on tasks even in case of unexpected restart of service (or server).
Thanks in ad... | I found i out.
It is the matter of setting the persistant flag in command running celery flower. | 1.2 | true | 1 | 3,102 |
2014-03-21 15:49:47.250 | Kivy Multiple windows | I'm evaluating Kivy for android development. I need to know if is it possible to create an application with multiple windows using Kivy. I dont know for sure how android works with this kind of approach.
In c#, windows forms, we have a main window and from that we open/close another forms. How can I accomplish this app... | What do you mean by 'window'? In the practical sense, you can easily create different screens with kivy and switch between them, e.g. to have a menu screen, settings screen, game screen etc. Is this the kind of thing you mean? More generally, you can easily achieve any particular windowing behaviour you want within kiv... | 1.2 | true | 1 | 3,103 |
2014-03-21 16:40:15.663 | Calling Python from Oracle | Is it possible to call Python within an Oracle procedure? I've read plenty of literature about the reverse case (calling Oracle SQL from Python), but not the other way around.
What I would like to do is to have Oracle produce a database table, then I would like to call Python and pass this database table to it in a Dat... | kind of complicated but possible. I have seen it once. You need to
create a javaclass inside oracle database. This class calls a .py file in the directory which contains it.
create a procedure that calls the java class of item 1.
in your sql query, call the procedure of item 2 whenever you need it. | 0 | false | 1 | 3,104 |
2014-03-23 12:18:56.083 | Can anyone in detail explain how cv and cv2 are different and what makes cv2 better and faster than cv? | I've recently started using openCV in python. I've come across various posts comparing cv and cv2 and with an overview saying how cv2 is based on numpy and makes use of an array (cvMat) as opposed to cv makes use of old openCV bindings that was using Iplimage * (correct me if i'm wrong).
However I would really like kn... | there is no question at all, - use cv2
the old cv api, that wraps IplImage and CvMat is being phased out, and will be no more available in the next release of opencv
the newer cv2 api uses numpy arrays for almost anything, so you can easily combine it with scipy, matplotlib, etc. | 1.2 | true | 1 | 3,105 |
2014-03-23 14:08:31.450 | Stack Machine with Strings | I'm making a stack based virtual machine in RPython using the PyPy toolchain to convert the RPython to C. So far I have 4 instructions.
EOP - End of Program
EOI - End of Instruction
PUSH - Push item onto the stack
PRINT - Print the top of the stack
My question is, how do you push a String to the top of the stack. Is ... | That depends. Do you want to push the string, or a pointer to a string? If it's the former, you have a problem, because the string will have variable length, unlike a pointer or a number. If it's the latter, you have to consider memory management aside from your stack. | 1.2 | true | 1 | 3,106 |
2014-03-24 08:46:33.057 | How to code in openerp so that user can create his fields? | I have been developing modules in OpenERP-7 using Python on Ubuntu-12.04. I want to give my users a feature by which they will have the ability to create what ever fields they want to . Like they will set the name, data_type etc for the field and then on click , this field will be created. I dont have any idea how this... | The user can add fields, models, can customize the views etc from client side. These are in Settings/Technical/Database Structure, here you can find the menus Fields, Models etc where the user can add fields. And the views can be customized in Settings/Technical/User Interface. | 0 | false | 1 | 3,107 |
2014-03-24 20:04:59.297 | How can i check in numpy if a binary image is almost all black? | How can i see in if a binary image is almost all black or all white in numpy or scikit-image modules ?
I thought about numpy.all function or numpy.any but i do not know how neither for a total black image nor for a almost black image. | Assuming that all the pixels really are ones or zeros, something like this might work (not at all tested):
def is_sorta_black(arr, threshold=0.8):
tot = np.float(np.sum(arr))
if tot/arr.size > (1-threshold):
print "is not black"
return False
else:
print "is kinda black"
return... | 1.2 | true | 2 | 3,108 |
2014-03-24 20:04:59.297 | How can i check in numpy if a binary image is almost all black? | How can i see in if a binary image is almost all black or all white in numpy or scikit-image modules ?
I thought about numpy.all function or numpy.any but i do not know how neither for a total black image nor for a almost black image. | Here is a list of ideas I can think of:
get the np.sum() and if it is lower than a threshold, then consider it almost black
calculate np.mean() and np.std() of the image, an almost black image is an image that has low mean and low variance | 0.386912 | false | 2 | 3,108 |
2014-03-24 21:46:48.337 | Compile custom module for Kivy-ios | I finally have some idea how to build Kivy app in Xcode with help of Kivy-ios. But Xcode and mac environment is new to me. My issue is: how to compile other python modules that required for my application. There is 'build-all.sh' in 'kivy-ios/tools' that builds standard things, but how to add some other module. In part... | I don't know how kivy-ios manages different modules, but in the absence of anything else you can simply copy the requests module into your app dir so it's included along with everything else. | 1.2 | true | 1 | 3,109 |
2014-03-25 01:55:09.347 | Setting selection background in ListCtrl | I'm trying to set a custom background for selected items in wxPython 2.8. I cannot figure out how to do so. I've tried SetItemBackground with no luck. | Selected items in wxListCtrl, wxListBox and so on always use the system background selection colour, it can't be changed. | 1.2 | true | 1 | 3,110 |
2014-03-25 11:19:55.923 | Python: Generating a big uniform permutation cheaply | I'm not sure whether this is possible even theoretically; but if it is, I'd like to know how to do it in Python.
I want to generate a big, random permutation cheaply. For example, say that I want a permutation on range(10**9). I want the permutation to be uniform (i.e. I want the numbers to be all over the place withou... | I believe that a block cipher, like AES, provides exactly this functionality. | 1.2 | true | 1 | 3,111 |
2014-03-25 12:13:42.377 | launch a python program with it's arguments on cmd and get the output messages python | I would like to launch a python program.exe to test it from another python code i,e launch it on the cmd (myprogram.exe -a arg1 -b arg2) and eventually get the error message it can print or any console output
does anyone have an idea how to do this?
thanks
EDIT
Actually I launch it with os.popen(command) but what I w... | You can run any python command from cmd using Python.exe -c //code
For example, Python.exe -c print(10*10) will print 100 to your console.
Does this help? Your question is a little unclear, sorry. | 0 | false | 1 | 3,112 |
2014-03-25 14:01:42.437 | Use different interfaces (eth0 and wlan0) for sending and receiving in Python program | Is it possible to switch between interfaces in Python program?
I will have eth0 and wlan0 connection, both are different routers.
I'm using boto to upload images to AWS server. And I need to upload using router with fast upload speed and for other downloads I need to use another interface which is connected to a router... | Its possible by using route add command in linux | 1.2 | true | 1 | 3,113 |
2014-03-27 13:47:56.443 | What would be the best way to automate filling in a premade form in word | Ok for my work we handle a lot of calculation documents. All of these have coversheets and revlogs that must be generated. We can easily create an excel file that has most of the information needed to fill in the forms but automating the actual process of filling in these forms that are premade in word has proven trick... | MS-Word has extensive programming capabilities built in ("Visual Basic for Applications (VBA)" These exact same programming capabilities are available to applications you write in any language, including C++, that can access Word via COM. Depending on your needs, it could be possible to fill in an entire Word document ... | 0 | false | 1 | 3,114 |
2014-03-28 01:16:32.930 | Clustering a list of dates | I have a list of dates I'd like to cluster into 3 clusters. Now, I can see hints that I should be looking at k-means, but all the examples I've found so far are related to coordinates, in other words, pairs of list items.
I want to take this list of dates and append them to three separate lists indicating whether they... | k-means is exclusively for coordinates. And more precisely: for continuous and linear values.
The reason is the mean functions. Many people overlook the role of the mean for k-means (despite it being in the name...)
On non-numerical data, how do you compute the mean?
There exist some variants for binary or categorial d... | 0.201295 | false | 1 | 3,115 |
2014-03-28 17:48:19.733 | Fix the seed for the community module in Python that uses networkx module | I am using the community module to extract communities from a networkx graph. For the community module, the order in which the nodes are processed makes a difference. I tried to set the seed of random to get consistent results but that is not working. Any idea on how to do this?
thanks | I had to change the seed inside every class I used. | 0 | false | 1 | 3,116 |
2014-03-31 14:55:45.870 | How To Hide Tkinter python Gui | anyone know how to hide python GUI Tkinter,
I 've created keylogger, for GUI I used python module Tkinter , I want to add button called HIDE, so when user click it it will hide GUI , and when user press key like CTRL+E , it should unhide GUI....? | To get rid of a GUI window I used the following in my code.
window.destroy()
and the following to bring it up again.
nameoffunction()
window.lift() | 0 | false | 1 | 3,117 |
2014-04-01 01:54:57.527 | How to manage many variables | I am making a program that asks a user a lot of questions, and I have each question defined at the top of my file. Unfortunately because of the ridiculous number of questions I need to have, the file has become extremely packed and difficult to navigate. The questions are organized by different sections, so I thought... | "Data driven programming": store your questions in a data file, and your program just needs the required logic to load and present them. | 1.2 | true | 1 | 3,118 |
2014-04-01 11:49:28.900 | Starting up PySpark for using python with Spark in eclipse | how do i use python for a Spark program in eclipse?
I've installed PyDev plugin in eclipse and installed Python on the system but how do i use PySpark. | I started a new Python project in PyDev, then went into Project -> Properties -> PyDev - PYTHONPATH -> External libraries. I added a "source path" entry for
/path/to/spark/spark-0.9.1/python
This allowed PyDev to see all Spark-related code and provide auto complete, etc.
Hope this helps. | 0.995055 | false | 1 | 3,119 |
2014-04-02 02:12:26.387 | Isolating code with a Python thread | I'm writing a program in which I want to evaluate a piece of code asynchronously. I want it to be isolated from the main thread so that it can raise an error, enter an infinite loop, or just about anything else without disrupting the main program. I was hoping to use threading.Thread, but this has a major problem; I ca... | In my case, the best way to do this seems to be to maintain a running worker process, and send the code to it on an as-needed basis. If the process acts up, I kill it and then start a new one immediately to avoid any delay the next time. | 1.2 | true | 1 | 3,120 |
2014-04-02 09:35:42.413 | Read input from the webpage, parse the data submitted using python or tcl and start the script execution based on the inputs given | I want to take input from the webpage, parse the data submitted using python or tcl and start the script execution based on the inputs given.
Please suggest me a solution, how it can be done.
I am not sure whether some web server need to be started for this.
Thanks in Advance.
Regards,
Surya | Surya,
you should have a look at the ncgi and htmlparse packages in tcllib to extract the information you need.
Joachim | 0 | false | 1 | 3,121 |
2014-04-02 12:41:46.503 | Simulate keyboard input linux | I work on a project to control my PC with a remote, and a infrared receptor on an Arduino.
I need to simulate keyboard input with a process on linux who will listen arduino output and simulate keyboard input. I can dev it with Python or C++, but i think python is more easy.
After many search, i found many result for...... | The most generic solution is to use pseudo-terminals: you connect tttyn to the standard in and standard out of the program you want to monitor, and use pttyn to read and write to it.
Alternatively, you can create two pipes, which you connect to the standard in and standard out of the program to be monitored before doin... | 0.201295 | false | 1 | 3,122 |
2014-04-03 01:08:31.777 | how to get python print result in jenkins console output | I have a Python script print strings. Now when run it in Jenkins I didn't see the printed strings in Jenkins Builds' Console Output.
Anyway to achieve that? | Any output to stdout from a process spawned by Jenkins should be captured by Console Output. One caveat is that it won't be displayed until a newline character is printed, so make sure your lines are terminated.
If you are launching python in some weird way that dis-associates it from Jenkins parent process, then I can... | 0.496174 | false | 2 | 3,123 |
2014-04-03 01:08:31.777 | how to get python print result in jenkins console output | I have a Python script print strings. Now when run it in Jenkins I didn't see the printed strings in Jenkins Builds' Console Output.
Anyway to achieve that? | Try using -u (unbuffered) option when running the python script.
python -u my_script.py | 1.2 | true | 2 | 3,123 |
2014-04-03 08:10:06.233 | how to do excel's 'format as table' in python | I'm using xlwt to create tables in excel. In excel there is a feature format as table which makes the table have an automatic filters for each column. Is there a way to do it using python? | OK, after searching the web, I realized that with xlwt it's not possible to do it, but with XlsxWriter it's possible and very easy and convenient. | 1.2 | true | 1 | 3,124 |
2014-04-03 23:05:32.417 | How to prevent an app from being killed in windows task manager? | I want to make a repeated question. how to prevent that someone stop an application with the task manager.
I now that is posible, if you try to kill avastui.exe form the task manager the task manager say "the operation could not be completed acces denied" and it happens when de service of avast is on, when you stop th... | I think it may be because things like anti-virus software are hooked into kernel-mode as drivers and can intercept user-mode input and intervene. The anti-virus may be hooked into the kernel APIs for process management, and reject calls through the process APIs to kill a process with the same PID as itself.
If this is... | 1.2 | true | 1 | 3,125 |
2014-04-04 03:14:27.710 | Multiple websites using the same app - how to set this up? | I have an app that shows products available in the US. If i want to change the country, I simply modify the value of a variable in my settings.py file.
Now... each country I serve needs to have its own site, e.g. example.co.uk, example.ca, etc. They'll all be hosted on the same server and use the same database. The vie... | I recently had something similar to do.
I have for each domain a specific setting file with an unique SITE_ID and also a wsgi file per site. Then in my http.conf (I'm using apache on webfaction) i set up multiple VirtualHost instances, each pointing out to the specific wsgi file.
My configuration looks something like t... | 1.2 | true | 1 | 3,126 |
2014-04-04 20:58:39.553 | Security optimal file permissions django+apache+mod_wsgi | I'm just about getting started on deploying my first live Django website, and I'm wondering how to set the Ubuntu server file permissions in the optimal way for security, whilst still granting the permissions required.
Firstly a question of directories: I'm currently storing the site in ~/www/mysite.com/{Django apps}, ... | In regards to serving the application from your home directory, this is primarily preference based. However, deployment decisions may be made depending on the situation. For example, if you have multiple users making use of this server to host their website, then you would likely have the files served from their home d... | 0.386912 | false | 1 | 3,127 |
2014-04-05 05:40:00.363 | pydev Google App run Path for project must have only one segment | I had trouble to run the pyDev Google App run on Eclipse. I can't create a new run configuration and I get this error message: Path for project must have only one segment.
Any ideas about how to fix it? I am running Eclipse Kepler on Ubuntu 13.10 | This is clearly a bug, but there's a possible workaround: In a .py file in your project, right-click and go to "Run As." Then, select "Python Run" (not a custom configuration). Let it run and crash or whatever this particular module does. Now, go look at your run configurations - you'll see one for this run. You ca... | 1.2 | true | 1 | 3,128 |
2014-04-05 10:17:32.500 | What does inheritance actually do in Python? | I'm struggling with how I should interpret class inheritance. What does it actually do? As far as I know, it allows your class to:
Use the inherited class function/methods
Use the inherited class local variables (self variables)
Does this go both ways? If something is inherited, will it be able to read his inheriter... | Let's say you have a class called Animal. In this class you have a method called walk, that prints "Animal is walking"
Now you have 2 other classes:
1. Class Bird that is inherited from Animal. You can now add an additional method to it: fly. This will print that a bird can fly.
2. Class Monkey that is inherited from A... | 1.2 | true | 1 | 3,129 |
2014-04-05 17:37:36.917 | Computer Graphics with python | I have to make a computer graphics project on "Vote for better Nation" using python in a week..I have a knowledge of pygame but don't know how to create a particular object(like small cartoon man)..And then how to make it move..So please help me if anyone knows how to make a moving object..
Sorry For The English
Thank ... | There is a series of books on Python Graphics called "Python Graphics for Games" (Amazon). It covers vector drawing and animation. Author Mike Ohlson de Fine. | 0 | false | 1 | 3,130 |
2014-04-06 17:12:34.313 | Perform n linear regressions, simultaneously | I have y - a 100 row by 5 column Pandas DataFrame
I have x - a 100 row by 5 column Pandas DataFrame
For i=0,...,4 I want to regress y[:,i] against x[:,i].
I know how to do it using a loop.
But is there a way to vectorise the linear regression, so that I don't have the loop in there? | as far as I know, there is no way to put this all at once in the optimized Fortran library, LAPACK, since each regression is it's own independent optimization problem.
note that the loop over 4 items is not taking any time relative to the regression itself, that you need to fully compute because each regression is an i... | 0 | false | 1 | 3,131 |
2014-04-07 11:14:02.173 | Issue with Python Server Returning File On GET | I created a simple threaded python server, and I have two parameters for format, one is JSON (return string data) and the other is zip. When a user selects the format=zip as one of the input parameters, I need the server to return a zip file back to the user. How should I return a file to a user on a do_GET() for my ... | The issue was that I hadn't closed the zipfile object before I tried to return it. It appeared there was a lock on the file.
To return a zip file from a simple http python server using GET, you need to do the following:
Set the header to 'application/zip'
self.send_header("Content-type:", "application/zip")
Create th... | 1.2 | true | 1 | 3,132 |
2014-04-07 12:56:24.633 | If I install Django CMS will it still show my current work in Django admin | I'm totally new to Python and I've been learning how to use Django and it's admin functionality to work with my models. My question really is how, if I were to install Django CMS, would work with the admin?
My understanding it limited so I wanted to check as I'm struggling to know if it will still show the model's that... | The Django CMS is a totally different environment. You can't install it on top of your current project. So if you want your models inside django cms you have to migrate them manually to the new enviroment. Maybe their are solutions for it but I'm not aware of them. | 1.2 | true | 1 | 3,133 |
2014-04-08 13:56:28.557 | Every way to organize N objects in M list slots | I'm trying to find a way, using built-in functions, to list every way to organize N balls in M slots. The balls can stack in the slots. For example:
N = 2, M = 3 -> {|0|1|1|, |1|0|1|, |1|1|0|, |2|0|0|, |0|2|0|, |0|0|2|}
itertools.permutations() is part of the puzzle, but how can you go through all possible stacks of ... | To find all assignments of N balls to M slots:
if N is 0 then
leave all M slots empty
otherwise, if M is 1, then
put all N balls to the only slot
otherwise
For each i in 0 .. N
put i balls in M-th slot, and
find all assignments of remaining N-i balls to remaining M-1 slots | 0.081452 | false | 1 | 3,134 |
2014-04-08 14:18:27.737 | Amazon SQS Python/boto: how do I send messages with accented characters? | I'm trying to send this string on Python SQS:
"Talhão", with no quotes.
How do I do that?
Thanks! | install the newest version of boto (2.27 or more, lower versions have an issue with unicode strings)
send it as unicode, and you will succeed | 0 | false | 1 | 3,135 |
2014-04-08 14:35:51.683 | Finding Mouse click position in IconView in GTK | I am building a file browser using Gtk.IconView in python. I am trying to find the path of an icon selected using " selection-changed" signal using gtk.IconView.get_path_at_pos(x,y).
The docs are mum on how to obtain the (x,y). How do I find them?
using python 2.7 and pygtk 2.24 | You don't use get_path_at_pos. It is meant for cases where you handle the button presses directly (which you should avoid unless you really have good reasons to do so).
Simply use gtk_icon_view_get_selected_items (C) or the pygtk equivalent iconview.get_selected_items() which gives you a list (in C a GList) of currentl... | 1.2 | true | 1 | 3,136 |
2014-04-08 23:11:12.087 | dot product of two 1D vectors in numpy | I'm working with numpy in python to calculate a vector multiplication.
I have a vector x of dimensions n x 1 and I want to calculate x*x_transpose.
This gives me problems because x.T or x.transpose() doesn't affect a 1 dimensional vector (numpy represents vertical and horizontal vectors the same way).
But how do I ca... | If you want an inner product then use numpy.dot(x,x) for outer product use numpy.outer(x,x) | 0.081452 | false | 1 | 3,137 |
2014-04-09 02:39:46.333 | Storing user data in one big database or in a different file for each user - which is more efficient? | I'm trying to store user data for a website in Python I'm making. Which is more efficient:
-Storing all the user data in one huge table
-Storing all the user data in several tables, one per user, in one database.
-Storing each user's data in a XML or JSON file, one file per user. Each file has a unique name based on ... | I don't think efficiency should be part of your calculus.
I don't like either of your proposed designs.
One table? That's not normalized. I don't know what data you're talking about, but you should know about normalization.
Multiple copies? That's not scalable. Every time you add a user you add a table? Sounds lik... | 0.386912 | false | 1 | 3,138 |
2014-04-09 13:27:02.537 | How to actually change the maximum number of columns in SQLITE | So I have a sqlite3 db, which I access from Python (2.7), where I would like to store more than the by default allowed 2.000 columns. I understand that there is a setting or command, SQLITE_MAX_COLUMN, which I can alter, so that my database can store up to ~32.000 columns. My question is how do I in practice set the ma... | That's a compile-time parameter for SQLite itself. As in, you'll need to recompile the SQLite library in order to change it. Nothing you can do in Python will be able to overcome this. | 1.2 | true | 1 | 3,139 |
2014-04-09 17:08:30.113 | Celery periodic tasks: testing by modifying system time | I'm trying to test out some periodic tasks I'm running in Celery, which are supposed to run at midnight of the first day of each month. To test these, I have a cron job running every few minutes which bumps the system time up to a few minutes before midnight on the last day of the month. When the clock strikes midnight... | The solution for me was to restart redis after the time update, and also restart celerybeat. That combination seems to work. | 1.2 | true | 1 | 3,140 |
2014-04-10 13:38:25.920 | How to add many to one relationship with model from external application in django | My django project uses django-helpdesk app.
This app has Ticket model.
My app got a Client model, which should have one to many relationship with ticket- so I could for example list all tickets concerning specific client.
Normally I would add models.ForeignKey(Client) to Ticket
But it's an external app and I don't wan... | There are (at least) two ways to accomplish it:
More elegant solution: Use a TicketProfile class which has a one-to-one relation to Ticket, and put the Client foreign key into it.
Hacky solution: Use a many-to-many relation, and manually edit the automatically created table and make ticket_id unique. | 0.201295 | false | 1 | 3,141 |
2014-04-10 16:02:21.923 | How to make emacs automatically indent Python code? | I'm using emacs 24.3 and Ubuntu 12.04 LTS. How do I make emacs automatically indent lines in Python, like in IDLE? Currently, it does not do that.
Also, in general, how would I do this for any programming language, say, Java or c++? | Open a newline with C-j, you should get the indentation. | 0 | false | 2 | 3,142 |
2014-04-10 16:02:21.923 | How to make emacs automatically indent Python code? | I'm using emacs 24.3 and Ubuntu 12.04 LTS. How do I make emacs automatically indent lines in Python, like in IDLE? Currently, it does not do that.
Also, in general, how would I do this for any programming language, say, Java or c++? | Try electric-indent-mode. It will be ebabled by default in Emacs-24.4. But note that the version in 24.3 probably doesn't work too well in python-mode buffers. | 0.386912 | false | 2 | 3,142 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.