Q_Id
int64
2.93k
49.7M
CreationDate
stringlengths
23
23
Users Score
int64
-10
437
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
DISCREPANCY
int64
0
1
Tags
stringlengths
6
90
ERRORS
int64
0
1
A_Id
int64
2.98k
72.5M
API_CHANGE
int64
0
1
AnswerCount
int64
1
42
REVIEW
int64
0
1
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
15
5.1k
Available Count
int64
1
17
Q_Score
int64
0
3.67k
Data Science and Machine Learning
int64
0
1
DOCUMENTATION
int64
0
1
Question
stringlengths
25
6.53k
Title
stringlengths
11
148
CONCEPTUAL
int64
0
1
Score
float64
-1
1.2
API_USAGE
int64
1
1
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
15
3.72M
22,017,118
2014-02-25T14:28:00.000
3
0
1
0
0
python,multiprocessing,pool
0
33,544,728
0
2
0
false
0
0
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 CPU intensive work, i wouldn't want more workers in the pool than your CPU count. More workers would force the OS to context switch out your processes, which in turn lowers the system performance. Even resorting to using hyperthreading cores can, depending on your work, choke the processor. On the other hand, if your task is like a webserver with many concurrent requests that individually are not maxing out your processor, go ahead and spawn as many workers as you've got memory and/or IO capacity for. maxtasksperchild is something different. This flag forces the pool to release all resources accumulated by a worker, once the worker has been used/reused a certain number of times. If you imagine your workers read from a disk, and this work has some setup overhead, maxtasksperchild will clear that overhead once a worker has done this many tasks.
1
6
0
0
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 anyone know how to find the max value for my Pool? I'm guessing it depends on CPU or memory.
Python multiprocessing: max. number of Pool worker processes?
0
0.291313
1
0
0
6,331
22,020,129
2014-02-25T16:24:00.000
4
0
1
1
0
ipython-notebook
0
22,020,213
0
2
0
true
0
0
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
5
0
0
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 doesn't seem to get triggered. Anyone know how to format name to give to trigger loading a local file?
How to make nbviewer display local files?
0
1.2
1
0
0
4,226
22,029,142
2014-02-26T00:21:00.000
2
0
0
0
0
python,scipy
1
22,044,916
0
1
0
true
0
0
Try scipy.odr. It allows to specify weights/errors in both input and response variable.
1
0
1
0
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?
Scipy: Fitting Data with Two Dimensional Error
0
1.2
1
0
0
104
22,030,696
2014-02-26T02:47:00.000
0
0
0
0
0
python,django,content-management-system,django-cms
0
22,035,806
0
2
0
false
1
0
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, twitter stream, multi column layout etc.
1
1
0
1
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 CMS django building. PS- I have heard of django-cms, but am unsure what exactly it is and how it is different from django.
Best way to build a custom Django CMS
0
0
1
0
0
2,589
22,051,158
2014-02-26T19:22:00.000
2
0
1
0
0
python,pip,easy-install
0
51,204,337
1
3
0
false
0
0
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 pip --version This should give pip is not recognized as an internal or external command
1
7
0
0
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?
How to fully uninstall pip installed with easy_install?
1
0.132549
1
0
0
63,563
22,057,077
2014-02-27T01:15:00.000
-1
0
1
0
0
python,linux,tkinter,tk,python-2.6
0
22,057,396
0
3
0
false
0
1
Have you tried using pip-2.6 install package?
3
1
0
0
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?
Installed Python from source and cannot import Tkinter - how to install?
0
-0.066568
1
0
0
417
22,057,077
2014-02-27T01:15:00.000
1
0
1
0
0
python,linux,tkinter,tk,python-2.6
0
22,058,494
0
3
0
true
0
1
I solved this by adding '/usr/lib/x86_64-linux-gnu' to lib_dirs in setup.py, then rebuilding python
3
1
0
0
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?
Installed Python from source and cannot import Tkinter - how to install?
0
1.2
1
0
0
417
22,057,077
2014-02-27T01:15:00.000
1
0
1
0
0
python,linux,tkinter,tk,python-2.6
0
22,057,115
0
3
0
false
0
1
Install the TCL and Tk development files and rebuild Python.
3
1
0
0
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?
Installed Python from source and cannot import Tkinter - how to install?
0
0.066568
1
0
0
417
22,067,766
2014-02-27T11:54:00.000
0
0
0
0
0
python,django,angularjs,heroku,architecture
0
22,103,027
0
2
0
false
1
0
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 server?) How to scale the service in the future? (this is a legit thing as you already aware of huge traffic increase and assume 2 servers) How it can be improved? Use scala instead of python :) Will performance of portal will go down after adding above layers in architecture? It depends. It will get some performance penalty (any additional abtract layer has it's tax), but most probably you won't event notice it. But still, you should measure it using some stress tests. In the above architecture whether 2 servers should be used to run this (like one for client and other for serving the API's) or one server will be enough. Currently Heroku is used for deployment. Well, as usual, it depends. It depends on the usage profile you have right now and on the resources available. If you are interested in whether the new design will perform better than the old one? - there are a number of parameters. Resume This is a good overall approach for the system with different clients. It will allow you: Totally decouple mobile app and frontend development from backend development. (It could be different independent teams, outsourceable) Standardize your API layer (as all clients will consume the same endpoints) Make you service scalable easier (this includes the separate webserver for static assets and many more).
1
0
0
1
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-architect the whole portal. After some research I found following: Client side: AngularJS for all client side operations like show data and get data using ajax. Server side: Rest API exposed to AngularJS. This Rest API can be developed using either Tastypie or Django Rest Framework (still not decided). Rest API will be exposed over Django. I have few questions: What you guys think about architecture? Is this is a good or bad design? How it can be improved? Will performance of portal will go down after adding above layers in architecture? In the above architecture whether 2 servers should be used to run this (like one for client and other for serving the API's) or one server will be enough. Currently Heroku is used for deployment. Currently portal is getting 10K hits in a day and it is expected to go to 100K a day in 6 months. Will be happy to provide more information if needed.
How to re-architect a portal for creating mobile app
0
0
1
0
0
183
22,071,291
2014-02-27T14:22:00.000
0
0
0
0
1
python,events,pyqt,pyside,qt-designer
0
22,102,393
0
2
0
false
0
1
Monkey Patching did the job, I dont know why I didn't taught of that
1
0
0
0
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, all I want is I dont want to add code to the generated ui .py file (more like my view) Now here is the problem I Noticed that the generated PySide file doesn't inherit from the QDialog or QMainWindow as you have to create it when you are instantiating the class, as a result, events like closeEvent(self, event) doesn't work inside the class even when you put it there. I know hoe to write functions for QActions and widget connections, but I DONT KNOW HOW TO ADD A CLASS BASED FUNCTION TO A GENERATED PYSIDE CLASS OUTSIDE THE CLASS. If I have to edit the generated view class, I can perfectly tweak it to what I want BUT i dont want to because I can make amendment in QtDesigner and compile at any time This is my question, since I dont want to how do i attach say a closeEvent to the object created from the class in my controller class without touching the generated view class. Thanks
Adding Event functions outside PyQt/PySide Generated Code
0
0
1
0
0
1,710
22,077,846
2014-02-27T18:57:00.000
5
0
0
0
0
python,html,tkinter
0
22,094,453
0
1
0
true
0
1
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
3
0
0
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.
Read a HTML file and show it on a Tkinter window
1
1.2
1
0
0
3,286
22,087,875
2014-02-28T06:29:00.000
7
0
1
0
0
python,python-sphinx,sphinx-apidoc
0
22,088,341
0
1
0
true
0
0
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 autodoc - from the website: When documenting Python code, it is common to put a lot of documentation in the source files, in documentation strings. Sphinx supports the inclusion of docstrings from your modules with an extension (an extension is a Python module that provides additional features for Sphinx projects) called “autodoc”. In order to use autodoc, you need to activate it in conf.py by putting the string 'sphinx.ext.autodoc' into the list assigned to the extensions config value. Then, you have a few additional directives at your disposal. For example, to document the function io.open(), reading its signature and docstring from the source file, you’d write this: .. autofunction:: io.open You can also document whole classes or even modules automatically, using member options for the auto directives, like .. automodule:: io :members: autodoc needs to import your modules in order to extract the docstrings. Therefore, you must add the appropriate path to sys.path in your conf.py. Add your code modules to the list as above and then call make html to buildyour documentation and use a web browser look at it. Make some changes and then run make html again. If you have to use the sphinx-apidoc then I would suggest: putting your tutorials in a separate directory as .rst files and referencing the documentation produced from the API doc from within them plus referencing the tutorials from within your code comments at the points that they are intended to illustrate. This should allow you to build your tutorials and API documentation separately depending on where you have made changes and still have linkage between them. I would strongly recommend the following: Use a version control system such as mercurial or git so that you can commit your changes before running sphinx, Put your tutorial .rst files under the VCS for your project but not the generated documentation files. Put all of the tutorial files under a separate directory with a clear name, e.g. tutorials. If you are delivering documentation then use a separate repository for your generated documents that is used to store the deliveries. Always generate documents to a location outside of you code tree. Put your invocation of sphinx-apidoc into a batch or make file so that you are consistent with the settings that you use.
1
6
0
1
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 generates the whole document at once. So my question is: What is the correct workflow here so I could write the tutorial pages that are to be written manually and at the same time update the documentation in the code? Note that if I update the manually written tutorial pages (e.g. included in the index.txt) and run sphinx-apidoc I will lose them as the whole document is generated at once. In general are there any guidelines as how to proceed in building the documentation? Note: The source of inconvenience is that the basic procedure assumes you have all the code documentation already in place and will not make any updates as you proceed in producing the documentation. At least this is what I need to resolve.
What is the correct workflow in using Sphinx for Python project documentation?
1
1.2
1
0
0
2,050
22,106,380
2014-02-28T21:42:00.000
21
0
1
0
0
python,pypdf2
0
42,181,449
0
4
0
false
0
0
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
2
15
0
0
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?
How do I install pyPDF2 module using windows?
0
1
1
0
0
94,939
22,106,380
2014-02-28T21:42:00.000
1
0
1
0
0
python,pypdf2
0
33,626,099
0
4
0
false
0
0
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 right it should start installing PyPDF2.
2
15
0
0
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?
How do I install pyPDF2 module using windows?
0
0.049958
1
0
0
94,939
22,110,562
2014-03-01T05:29:00.000
0
0
0
0
0
python,database,redis,redis-py
0
22,111,910
0
1
0
false
0
0
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" command will be rejected.
1
1
0
0
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?
Insert a new database in redis using redis.StrictRedis()
0
0
1
1
0
460
22,121,368
2014-03-01T22:42:00.000
0
0
0
0
1
python,linux,django,sockets
0
22,125,431
0
3
0
false
1
0
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 it; so that it is processed and removed from the queue. The function that this consumer does is entirely up to you, but what you want to do in this scenario is write information from the message to a database model; the same database that is part of your django app. As the producer pushes messages and the consumer removes them from the queue, your database will get updated. On the django side, the process is simply to filter this database and display records for a particular machine. As such, django does not need to be aware of how the records are being populated in the database - all django is doing is fetching, filtering, sending to the template and rendering the views. The question comes how best (well actually, easily) populate the databases. You can do it the traditional way, by using Python's well documentation DB-API and write your own SQL statements; but since celery is so well integrated with django - you can use the django's ORM to do this work for you as well. I hope this gets you going in the right direction.
1
4
0
0
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 geting this data through a socket. But I want to make that student project simple. Also, I don't know how difficult it is to make a socket connection via Django. So, I thought I could solve my problem with RabbitMQ without socket programming. Basically, I send a message to rabbit queue. Then get whatever I want from the consumer server. On the Django side, the client will select one of the internal servers and click the "details" button. Then I want to show this information on web page. I already read almost all documentation about rabbitmq, celery and pika. Sending messages to all internal servers(clients) and the calculation of information that I want to get is OKAY but I can't figure out how I can put this data on a webpage with Django? How would you figure out that problem if you were me? Thank you.
Using RabbitMQ with Django to get information from internal servers
0
0
1
0
0
3,991
22,122,506
2014-03-02T00:52:00.000
4
0
0
0
0
python,r,machine-learning,scikit-learn,svm
0
22,123,913
0
2
0
true
0
0
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 going to be exactly the same, and in using SVMs with these libraries the main limitations you will face are the limitations of LIBSVM. I think that giving further advice is going to be difficult unless you clarify a couple of things in your question: what is your objective? Do you already know LIBSVM? Is this a learning project? Who is paying for your time? Do you feel more comfortable in Python or in R?
2
1
1
0
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'm thinking in terms of speed of training a model, scalability, availability of different kernels, and other such performance-related aspects. Given some data sets of different sizes, how could one decide which path to take? I apologize in advance for such a possibly vague question.
What's the difference between using libSVM in sci-kit learn, or e1070 in R, for training and using support vector machines?
1
1.2
1
0
0
381
22,122,506
2014-03-02T00:52:00.000
0
0
0
0
0
python,r,machine-learning,scikit-learn,svm
0
22,189,863
0
2
0
false
0
0
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 also prefer R's formula interface. And some of the nice data manipulation packages. Python is definitely better for general purpose programming and scikit-learn aids in using a single programming language for all tasks.
2
1
1
0
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'm thinking in terms of speed of training a model, scalability, availability of different kernels, and other such performance-related aspects. Given some data sets of different sizes, how could one decide which path to take? I apologize in advance for such a possibly vague question.
What's the difference between using libSVM in sci-kit learn, or e1070 in R, for training and using support vector machines?
1
0
1
0
0
381
22,132,285
2014-03-02T19:27:00.000
1
0
1
0
0
python,loops,while-loop
0
22,132,302
0
5
0
false
0
0
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
1
0
0
0
what does +=, -=, *= and /= stand for in Python? and how do you use it for while loop?
what does +=, -=, *= and /= stand for in Python?
0
0.039979
1
0
0
25,742
22,143,644
2014-03-03T10:02:00.000
0
0
0
0
0
python,arrays,numpy
0
37,731,398
0
5
0
false
0
0
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.
5
1
1
0
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 examples of where 3D, 4D, 5D ... etc arrays are used? And if one used numpy.sum(array, axis=5) for a 5D array would what happen?
Examples on N-D arrays usage
0
0
1
0
0
141
22,143,644
2014-03-03T10:02:00.000
0
0
0
0
0
python,arrays,numpy
0
22,146,242
0
5
0
false
0
0
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. All the shelves are in a warehouse with 3 floors. So you can identify any shelf using 3 numbers: the row, the column and the floor. A box is then identified by: row, column, floor and the index in the shelf. An item is identified by: row, column, floor, index in shelf, index in box. Basically, one way (not the best one...) to model this problem would be to use a 5D array.
5
1
1
0
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 examples of where 3D, 4D, 5D ... etc arrays are used? And if one used numpy.sum(array, axis=5) for a 5D array would what happen?
Examples on N-D arrays usage
0
0
1
0
0
141
22,143,644
2014-03-03T10:02:00.000
1
0
0
0
0
python,arrays,numpy
0
22,144,505
0
5
0
false
0
0
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 graphics paradigm, adding time adds an extra dimension, so a time-variant 3D gradient texture would be 5D numpy.sum(array, axis=5) is not valid for a 5D-array (as axes are numbered starting at 0)
5
1
1
0
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 examples of where 3D, 4D, 5D ... etc arrays are used? And if one used numpy.sum(array, axis=5) for a 5D array would what happen?
Examples on N-D arrays usage
0
0.039979
1
0
0
141
22,143,644
2014-03-03T10:02:00.000
0
0
0
0
0
python,arrays,numpy
0
22,144,263
0
5
0
false
0
0
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. For each time slot, you have a complete image. In this example, numpy.sum(array, axis=2) would integrate the exposure in a given pixel. If you think about a film taken in low light conditions, you could think of doing something like that to be able to see anything.
5
1
1
0
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 examples of where 3D, 4D, 5D ... etc arrays are used? And if one used numpy.sum(array, axis=5) for a 5D array would what happen?
Examples on N-D arrays usage
0
0
1
0
0
141
22,143,644
2014-03-03T10:02:00.000
0
0
0
0
0
python,arrays,numpy
0
22,144,157
0
5
0
false
0
0
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 then be used for further operations (simple ones like calculating its Transpose, its Determinant etc...). I recently had an assignment which involved modelling fluid dynamics in a 2D space. I could have easily extended it to work in 3D and this would have required me to use a 3D matrix instead. You may wish to also further extend matrices to cater for time, which would make them 4D. In the end, it really boils down to the specific problem you are dealing with. As an end note however, 2D matrices are still used for 3D graphics (You use a 4x4 augmented matrix).
5
1
1
0
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 examples of where 3D, 4D, 5D ... etc arrays are used? And if one used numpy.sum(array, axis=5) for a 5D array would what happen?
Examples on N-D arrays usage
0
0
1
0
0
141
22,146,944
2014-03-03T12:34:00.000
1
0
0
1
0
python,rabbitmq,celery
0
56,632,082
0
3
0
false
0
0
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.
1
5
0
0
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-worker model, as we're not using Celery where the messages are being produced. So, how do I go about this?
How to use celery to get messages from a rabbit-mq server?
0
0.066568
1
0
0
1,369
22,148,917
2014-03-03T14:10:00.000
0
0
0
0
0
python,pip,rackspace,iron.io,pyrax
0
22,153,710
0
2
0
false
0
0
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?
2
1
0
0
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 something with Windows 8 but I don't know how to check/fix. I do apologize in advance if I ramble or do not explain things clearly enough but any help would be greatly appreciated. My worker file looks like this: runtime "python" exec "rackspace.py" pip "pyrax" full_remote_build true Then I simply import pyrax in my python file.
pip "pyrax" dependency with iron worker
0
0
1
0
1
116
22,148,917
2014-03-03T14:10:00.000
2
0
0
0
0
python,pip,rackspace,iron.io,pyrax
0
22,153,804
0
2
0
false
0
0
I figured out that it was a bad Ruby install. No idea why, but reinstalling it worked.
2
1
0
0
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 something with Windows 8 but I don't know how to check/fix. I do apologize in advance if I ramble or do not explain things clearly enough but any help would be greatly appreciated. My worker file looks like this: runtime "python" exec "rackspace.py" pip "pyrax" full_remote_build true Then I simply import pyrax in my python file.
pip "pyrax" dependency with iron worker
0
0.197375
1
0
1
116
22,159,351
2014-03-03T22:58:00.000
2
0
1
0
0
python,text,machine-learning,classification,tf-idf
0
22,159,481
0
1
0
true
0
0
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". I think you are a little bit confused. TF-IDF style weighting functions specify how to make a per term score out of the term's token frequency in a document and the background token document frequency in the corpus for each term in a document. TF-IDF converts a document into a mapping of terms to weights. So more tokens sharing the same term in a document will increase the corresponding weight for the term, but there will only be one weight per term. There is no separate score for tokens sharing a term inside the doc.
1
0
1
0
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?
(Text Classification) Handling same words but from different documents [TFIDF ]
0
1.2
1
0
0
722
22,165,086
2014-03-04T07:01:00.000
0
0
0
0
0
python,web-scraping
0
22,165,257
0
1
0
true
1
0
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
1
0
0
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
Permission to get the source code using spider
0
1.2
1
0
1
43
22,175,349
2014-03-04T14:56:00.000
0
1
0
1
0
python,bash,shell,emacs,ipython
0
22,208,324
0
2
0
false
0
0
After running your /etc/university/env.sh, start Emacs from this shell. Then the variables set before are known.
1
1
0
0
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 environment variables. Is there a way to make emacs run /etc/corporate/env.sh before starting python?
how to load shell environment variables when Emacs starts py-shell?
0
0
1
0
0
392
22,177,872
2014-03-04T16:45:00.000
2
0
0
0
0
python,lxml,lxml.html
0
22,177,986
0
2
0
true
1
0
This will select the parent element of the XPath expression you gave: //*[@id="titleStoryLine"]/div/h4[text()="Genres:"]/..
1
2
0
0
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?
Traversing back to parent with lxml.html.xpath
0
1.2
1
0
1
405
22,215,361
2014-03-06T04:57:00.000
2
0
0
0
0
java,python,user-interface,photoshop
0
22,215,461
0
2
0
false
1
1
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 applies for web applications. If you want to build desktop application, you need to use Swings, SWT etc to achieve the same. I have zero experience in this If this is the case, I recommend to read some basic tutorials, then you will get idea what to do
1
0
0
0
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 Photoshop add some java or python code to it to make certain things happen? I have zero experience in this and I have only written code to accomplish tasks without the need for a GUI.
UI Designed in Photoshop for Software
0
0.197375
1
0
0
1,055
22,268,968
2014-03-08T11:53:00.000
1
1
0
0
0
python,web,mod-wsgi
0
22,933,666
0
1
0
false
1
0
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 your div's html to the result. - The easiest way to get this working is probably to use the AJAX facilities in JQuery. Possibility 2, data generated by client - If it is possible to have your dynamic output generated on the client by a piece of JavaScript code this will scale better (since it takes the burden off the server.) - You may still load the input data needed to compute the dynamic output formatted as JSON by means of AJAX.
1
1
0
0
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?
Real time output of script on web page using mod_wsgi
0
0.197375
1
0
0
406
22,274,048
2014-03-08T19:35:00.000
0
0
1
0
0
python,events,event-handling,spss
0
22,282,456
0
1
0
false
0
0
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.
1
0
0
0
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?
how to hook on a table cell in spss using python?
0
0
1
0
0
76
22,274,186
2014-03-08T19:45:00.000
1
0
0
0
0
python,matplotlib,color-mapping
0
22,274,333
0
1
0
true
0
0
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
0
1
0
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 plot? Thanks, Alice
one colormap for multiple subplots with different maximum values
0
1.2
1
0
0
105
22,282,264
2014-03-09T12:39:00.000
0
0
0
0
1
python,django,forms,session
0
22,282,298
0
2
0
true
1
0
The user is never in request.session. It's directly on the request object as request.user.
1
0
0
0
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 need to see which user, or if this was an anonymous user that submitted the data so i though i would use the request.session['user'] but this doesnt work since the user key is not available. I tried setting the request.session['user'] value to the user object but the session dictionary doesnt accept objects, it says its not JSON serializable. I though the context processors would add this user variable to it was also available to the view but it isnt. I need a user object and not just the user name to save to the database along with the form. Is there any way to extract the user object when its not part of the form and the user is logged in ? I need to associate the submitted data with a user or an anonymous user and the foreign key requires an object which i also think is must convient to work with when extracting the data from the DB again. I dont see it being helpful to post any code here since this is a question of how to extract a user object after a post and not specifically a problem with the code.
User session object is not available on POST in django?
0
1.2
1
0
0
123
22,301,208
2014-03-10T13:16:00.000
-2
0
0
1
1
python,celery
0
29,481,481
0
2
0
false
0
0
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 shutdown. Also, having task split into chunks, you will be able to divert the task to another worker/host which is probably what you would like to do in the future.
1
4
0
0
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 it later. QUESTION: The problem is every time after I stopped the workers (via sudo service celeryd stop) I have to KILL the task manually (via kill -9); the task ignores SIGTERM from worker. I've read throw Celery docs & Stackoverflow but I can't find working solution. Any ideas how to fix the problem?
Notify celery task to stop during worker shutdown
0
-0.197375
1
0
0
1,753
22,357,298
2014-03-12T16:07:00.000
1
0
0
0
0
python,twitter-bootstrap,hosting
0
22,357,361
0
2
1
false
1
0
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?
1
2
0
0
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). I've never done such a thing, so I'm a bit lost. It looks like I can use without too many investment in effort my ubuntu computer. And apparently there is other tools for this application. I'm looking for advise and explanation on how to implement a working solution. EDIT: The 50 people are not in my local network. [ORIGINAL POST BELOW] What is the best way to share my website to partners? I'm developing a website for an association, and I want to know if there is a way to let them access to my work in progress. I was thinking of free hosting solutions? I'm not looking for a professional host, I'm just looking for a way to share my work with maximum 50 peoples. Is there another solution? I have an ubuntu pc that I could use as server (I have high speed connection). (I don't know if this is relevant, but I'm using python-django and bootstrap for the design)
How can I share my website in progress to partner?
0
0.099668
1
0
0
122
22,358,713
2014-03-12T17:01:00.000
2
0
1
1
0
python-3.x
0
22,358,774
0
1
0
true
0
0
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
0
0
0
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 the 2.7.3 version. I thought that every python version install its own IDLE so I am quiet confused here. When I run Hello world program from the console it runs using the version 3.3.5 I have checked that. So what I need to do is to run IDLE using 3.3.5 version Anybody knows what to do?
How to set Python IDLE to use certain python version
0
1.2
1
0
0
271
22,360,412
2014-03-12T18:17:00.000
0
0
0
0
0
python,neural-network
0
22,360,726
0
1
0
true
0
0
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 with a standard sigmoid output function. It's usually better in practice to let the values go negative and instead transform the outputs from the network into the range [0,1] after the fact (shift up by the minimum, divide by the range (aka max-min)).
1
1
1
0
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 simulation of my learned NN are always positive? (how I do it in neurolab?)
Python Neurolab - fixing output range
0
1.2
1
0
0
948
22,378,590
2014-03-13T12:25:00.000
0
1
0
0
1
python,c++,dll,swig
0
22,378,831
0
3
0
false
0
1
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
2
0
0
0
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 the DLL file. Everything on the tutorial shows that I need to have the header so SWIG knows what the function prototypes look like. Is SWIG the right route to use in this case? I am trying to load this DLL in Python so I can utilize a function. From all of my research, it looks like Python's ctypes does not work with C++ DLL files and I am trying to find the best route to follow to do this. Boost.python seems to require changing the underlying C++ code to make it work with Python. To sum up, is there a way to use SWIG when I know the function prototype but do not have the header file or source code?
SWIG C++ Precompiled DLL
1
0
1
0
0
1,508
22,378,590
2014-03-13T12:25:00.000
0
1
0
0
1
python,c++,dll,swig
0
22,389,172
0
3
0
false
0
1
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.
2
0
0
0
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 the DLL file. Everything on the tutorial shows that I need to have the header so SWIG knows what the function prototypes look like. Is SWIG the right route to use in this case? I am trying to load this DLL in Python so I can utilize a function. From all of my research, it looks like Python's ctypes does not work with C++ DLL files and I am trying to find the best route to follow to do this. Boost.python seems to require changing the underlying C++ code to make it work with Python. To sum up, is there a way to use SWIG when I know the function prototype but do not have the header file or source code?
SWIG C++ Precompiled DLL
1
0
1
0
0
1,508
22,381,841
2014-03-13T14:32:00.000
4
0
1
0
1
python,dll
0
22,383,385
0
2
0
true
0
0
It's most probably a 32-bit or 64-bit issue. Try downloading proper version.
2
6
0
0
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 this program I have also downloaded and installed python 2.7 on my system but when I run it generates the same error. Please tell me how can I fix this problem.
Python27.dll File Missing - Exception
0
1.2
1
0
0
16,517
22,381,841
2014-03-13T14:32:00.000
3
0
1
0
1
python,dll
0
30,247,563
0
2
0
false
0
0
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 file missing error message. I solved it by installing the 64 bit version of python first on my target computer, and then did my copy of the environment, i.e. copied c:\pythonFromComputerA to target computer's c:\python27, effectively overwriting the python that had just been installed. But because the installer updated the registry, I could now run with my python environment on the target computer without getting the error message. Thought I'd provide this in case others are out there scratching their heads, having correctly matching installation with OS yet getting this error message.
2
6
0
0
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 this program I have also downloaded and installed python 2.7 on my system but when I run it generates the same error. Please tell me how can I fix this problem.
Python27.dll File Missing - Exception
0
0.291313
1
0
0
16,517
22,384,473
2014-03-13T16:11:00.000
0
0
0
0
0
python,django
0
22,384,701
0
1
0
false
1
0
Try to move your app name up to admin app in your INSTALLED_APPS settings.py tuple.
1
0
0
0
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've edited the base.html template like so {% trans 'My Console' %} And added the msgstr in my .po files and ran makemessages and compilemessages I am running out of things to try. Can anyone shed some light on how to do this? I can supply code if it will help. Thanks for reading.
Where do I put the specific translation functions in Django App?
0
0
1
0
0
90
22,391,805
2014-03-13T21:54:00.000
0
0
0
1
0
python,linux,bash,file-io
0
22,392,153
0
4
0
false
0
0
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 line of every file must be copied (except the duplicates). It might be faster than Python, though, because those tools are written in C.
1
0
0
0
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 contains those specified dates. I know how to do this in python (rewriting each of the lines I want) but because of the size of the files (each is a few GBs) I was wondering if it would be a lot faster to do this through linux? The text files will be sorted by date, earliest to latest, and the dates I need to delete are always going to be in the beginning of the file so I can search until I hit a row that has a date right after the ones I want to delete and write out the rest of the file to another file (or delete all the contents above).
deleting rows in linux
0
0
1
0
0
115
22,404,358
2014-03-14T11:58:00.000
2
0
0
0
0
javascript,python,angularjs,google-app-engine,jinja2
0
22,408,064
0
2
0
false
1
0
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 to deal with html or templates in the back end? Angular already has Service and $http that can abstract away the two-way data binding, and using webapp2's RESTful nature you can make this happen fairly painlessly.
1
0
0
0
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 need to create another page or handler. I am wondering if there is some way which I can do the below actions. On the server python handler, retrieve the stored data, then passing to the jinja2 template values. Render the html. Display some of the data on the html view via jinja2 template values. (The missing part) How to pass the data to js from the python handler? Or how to pass the data to js from html view? I know two ways from the html view. One is using embedded javascript code. var data = {{serverData}}; The other is using hidden input form with angular data bind. Both of them not so nicely. 4.Compute the data and draw back to the view using d3js or other js lib. Any idea about this? I reckon there might be some angular way to do this beautifully but didnt figure out.
How to transfer html view data or (Python) server data to Angular or Javascript?
1
0.197375
1
0
0
586
22,413,763
2014-03-14T19:10:00.000
-1
0
1
0
0
python,regex,expression
0
22,430,200
0
6
0
false
0
0
So I was actually able to get it to work like this : [a-z]\w+.
2
0
0
0
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?
Combining regular expressions in Python
0
-0.033321
1
0
0
449
22,413,763
2014-03-14T19:10:00.000
1
0
1
0
0
python,regex,expression
0
22,413,846
0
6
0
true
0
0
If you only want lowercase words, all you need is [a-z]+ \w includes uppercase letters, digits, and underscore
2
0
0
0
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?
Combining regular expressions in Python
0
1.2
1
0
0
449
22,425,631
2014-03-15T15:19:00.000
0
0
0
0
0
python,iphone,nscache,memory-optimization
0
22,482,214
0
1
1
false
1
0
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-value pairs, similar to the NSDictionary class. Developers often incorporate caches to temporarily store objects with transient data that are expensive to create. Reusing these objects can provide performance benefits, because their values do not have to be recalculated. However, the objects are not critical to the application and can be discarded if memory is tight. If discarded, their values will have to be recomputed again when needed. Description of NSData by Apple: *NSData and its mutable subclass NSMutableData provide data objects, object-oriented wrappers for byte buffers. Data objects let simple allocated buffers (that is, data with no embedded pointers) take on the behavior of Foundation objects. NSData creates static data objects, and NSMutableData creates dynamic data objects. NSData and NSMutableData are typically used for data storage and are also useful in Distributed Objects applications, where data contained in data objects can be copied or moved between applications.*
1
1
0
0
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 can i retrieve more objects? what is the maximum amount of memory allocated to an application in iphone and is there a way to extend it? How many objects should I retrieve from server How many can be stored in NSCache?
How many objects should I retrieve from server and How many can be stored in NSCache?
1
0
1
0
0
54
22,438,569
2014-03-16T15:06:00.000
1
0
0
0
1
algorithm,python-3.x,message-passing
0
22,452,071
0
1
0
false
0
1
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 additional sound effect to be played as well. The most straightforward way to go about it would requiring that any new object's priority for a given call be linked to another object with that call. It then requires selecting if the new object's priority is lower or higher. So shields and hull are linked (hull < shields) and super-shields and shields are linked (shields < super-shields). That information would make it fairly easy to build a 2D multiple items (2D to have allow for same priority) linked list that holds the priorities for each call. Thus the register function might look like this, "myship.register("hit",shields,"lower",super-shields)" and give shields a lower priority than super-shields. You could allow for additional conditions such as myship.register("hit",hull,"lower",shields,"lower",super-shields) if you already had the hull and super-shields, and wanted to add shields between them. However, then you run the risk of having to deal with contradictions or violating the conditions.
1
0
0
0
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 its systems (which is not the same as the standard __init__ function called whenever an instance of an object is made) that will (among other things) call a register() function on the ship the system is a part of. That register() function takes a string as a parameter, which is the name of a function that the system expects to be called on the ship object. Whenever that function is called on the ship object, the ship object will call it on all systems that registered to receive it until either one of them returns True (indicating that the system 'dealt with' the action in a final manner) or it runs out of systems that have signed up to receive the call. So far so good. However, some systems might want to get their calls before other systems do. For example, your hull system will want to be the last system to receive a hit(); the shields will want to hear it first. The simplest solution might be to implement a priority system: the shields will call myship.register("hit",priority=1), and the hull will call myship.register("hit",priority=0). But now we imagine that there ought to be "super-shields" that intercept the hit before the main shields take it. Simple enough: give them priority 2. This might get annoying for the developer if a whole lot of systems want to take a certain request, but he can manage it. However, this game is intended to be highly user-extensible. If someone releases an addon that (for a stupid example) plays Full Metal Jacket sound clips every time the player's ship is hit, the developer of that addon might not be aware of the addon that adds the "super-shields", and give his Annoying Drill Sergeant system the same or lower priority as the super-shields, and thus may not receive hit messages before they are acknowledged by the super-shield. This is, of course, undesirable behavior. Does anyone have any ideas as to how to avoid this problem? Others have suggested having a way a system can request the priority level one higher than or one lower than the highest/lowest current priority level, but that causes largely undefined behavior, since the priority levels would be based on the order in which the systems are initialized. I've also considered adding a "super-priority", where a system always receives the message before other systems but cannot acknowledge and stop it. This would be only a partial solution though; it'd fix the given example, but not a situation where there are super-shields layered under super-super-shields that need to block the message.
Algorithm design for systems on a spaceship taking messages
0
0.197375
1
0
0
112
22,449,304
2014-03-17T08:02:00.000
2
0
0
1
0
python,macos,python-imaging-library
1
22,470,752
1
2
0
false
0
0
following line helped me. sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pillow
1
2
0
0
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-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DHAVE_LIBJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -I/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/Cellar/freetype/2.5.2/include/freetype2 -I/private/tmp/pip_build_root/pillow/libImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.9-intel-2.7/_imaging.o clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future] clang: note: this will be a hard error (cannot be downgraded to a warning) in the future error: command 'cc' failed with exit status 1
how to install PIL on Macosx 10.9?
0
0.197375
1
0
0
751
22,453,554
2014-03-17T11:51:00.000
3
0
0
0
0
python,widget,tkinter,label,styling
0
22,455,831
0
2
0
false
0
1
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.
1
2
0
0
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 much of the string should be bold. I don't it is possible but suggestions appreciated.
How to change font style for part of a tkinter label
1
0.291313
1
0
0
9,774
22,456,509
2014-03-17T14:07:00.000
1
0
0
0
0
python,sdk,render,maya,autodesk
0
22,980,455
0
1
0
true
0
1
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 Python build wrapped with a bunch of examples within the V-Ray Application SDK. The price is 1250 euro annually for a single development license (for one server node). Support is included. They can give you a preliminary evaluation version for 3 months under NDA (What I used). No reverse engineering is permitted so if you are planning to develop over V-Ray you should buy it.
1
0
0
0
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 that Python library or how I can call it?
Getting access to VRay Python SDK
0
1.2
1
0
0
1,560
22,495,767
2014-03-19T03:42:00.000
1
0
0
0
0
python,django,session,flask,server-side
0
22,520,376
0
2
0
false
1
0
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.
1
0
0
0
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 and allow to make some settings and also my app needs to run some python process(script which basically is a separate file) on the server on a per-session per-settings made by user basis. This process is quite long - can take even days to perform and shouldn't affect the execution and performance of MVC part of an app. Another issue is that this process should be run per user so the basic usage model of such app would be: 1. the user enters the site. 2. the user makes some settings which are mirrored to database. 3. the user pushes the launch button which executes some python script just for this user with the settings he has made. 4. the user is able to monitor some parameters of the script running based on some messages that the script itself generates. I do understand that my question is related to the architecture of the app itself and i'm quite new to python and haven't had any experience of developing such complex application but I'm also quite eager to learn about it. I do understand the bricks from which my app should be built (like django or flask and the server-side script itself) but i know very little about how this elements should be glued together to create seamless environment. Please direct me to some articles related to this topic or recommend some similar threads or just give a clear high level explanation how such separate python processes could be triggered,run and monitored further on a per-user basis from controller part of MVC.
Server side python code runing continuosly per session
0
0.099668
1
0
0
183
22,498,877
2014-03-19T07:18:00.000
0
1
1
0
1
python,migration,dynamic-typing
0
22,498,955
0
5
0
false
0
0
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, but even the best of them will not be able to match the tools developed for statically typed languages. Dynamic language programmers typically ensure correctness while refactoring in one or more of the following ways: Use grep to look for function invocation sites, and fix them. (You would have to do that in languages like Java as well if you wanted to handle reflection.) Start the application and see what goes wrong. Write unit tests, if you don't already have them, use a coverage tool to make sure that they cover your whole program, and run the test suite after each change to check that everything still works.
1
4
0
0
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 such a thing in python considering there are no types?! I'm using TextMate2 for python coding. Currently I'm doing the brute-force way. Opening every python script file and check where I'm using that function and then modify. But I'm sure this is not the way to deal with large projects!!! Edit: as an example I define a class called Graph in a python script file. Graph has two objects variables. I created many objects (each with different name!!!) of this class in many script files and then decided that I want to change the name of the object variables! Now I'm going through each file and reading my code again in order to change the names again :(. PLEASE help! Example: File A has objects x,y,z of class C. File B has objects xx,yy,zz of class C. Class C has two instance variables names that should be changed Foo to Poo and Foo1 to Poo1. Also consider many files like A and B. What would you do to solve this? Are you serisouly going to open each file and search for x,y,z,xx,yy,zz and then change the names individually?!!!
Tracking changes in python source files?
0
0
1
0
0
696
22,553,659
2014-03-21T08:26:00.000
2
0
0
1
0
python,celery,celery-task,flower
0
22,554,555
0
1
0
true
0
0
I found i out. It is the matter of setting the persistant flag in command running celery flower.
1
1
0
0
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 advance
Celery Flower - how can i load previous catched tasks?
0
1.2
1
0
0
1,345
22,563,386
2014-03-21T15:49:00.000
3
0
0
0
1
android,python,kivy
0
22,563,987
0
1
0
true
0
1
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 kivy. Android itself works with activities, a particular way of choosing what is displayed, how apps move between screens, and also how apps may call particular subsets of one another (plus a lot more of course). You don't need to know about this to use kivy, it works within a single activity (plus appropriate interaction with the rest of the system), but you should read up on it if you want to understand how android manages programs and how this is different to most desktop environments.
1
0
0
0
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 approach using Kivy for android ?
Kivy Multiple windows
1
1.2
1
0
0
1,083
22,564,503
2014-03-21T16:40:00.000
0
0
0
0
0
python,sql,oracle,pandas,cx-oracle
0
53,431,165
0
7
0
false
0
0
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.
1
18
0
0
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 DataFrame so that I could use Python to do something to it and produce results. I might need to call Python several times during the Oracle procedure. Does anyone know if this is possible and how could it be done?
Calling Python from Oracle
1
0
1
1
0
12,854
22,590,811
2014-03-23T12:18:00.000
1
0
0
0
0
python,c++,opencv,numpy
0
22,591,329
0
1
0
true
0
0
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
1
1
0
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 know how basic techniques (Iplimage* and cvMat) differ and why later is faster and better and how that being used in cv and cv2 respectively makes difference in terms of performance. Thanks.
Can anyone in detail explain how cv and cv2 are different and what makes cv2 better and faster than cv?
1
1.2
1
0
0
230
22,591,947
2014-03-23T14:08:00.000
1
0
1
0
0
c,stack,pypy,vm-implementation,rpython
0
22,592,504
0
1
0
true
0
0
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
0
0
0
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 it the same as when you push a number to the top of the stack or do I have to do something else when working with strings?
Stack Machine with Strings
0
1.2
1
0
0
393
22,604,620
2014-03-24T08:46:00.000
0
0
0
0
0
python,openerp
0
22,627,251
0
1
0
false
1
0
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.
1
0
0
0
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 will be implemented. I have set up mind to create a button that will call a function and it will create a new field according to the details entered by the user . Is this approach of mine is right or not? And will this work . ? Please guide me so that I can work smartly. Hopes for suggestion
How to code in openerp so that user can create his fields?
0
0
1
0
0
103
22,619,506
2014-03-24T20:04:00.000
2
0
0
0
0
python,opencv,image-processing,numpy,scikit-image
0
22,619,589
0
2
0
false
0
0
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
2
0
1
0
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.
How can i check in numpy if a binary image is almost all black?
0
0.197375
1
0
0
1,554
22,619,506
2014-03-24T20:04:00.000
2
0
0
0
0
python,opencv,image-processing,numpy,scikit-image
0
22,619,838
0
2
0
true
0
0
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 True
2
0
1
0
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.
How can i check in numpy if a binary image is almost all black?
0
1.2
1
0
0
1,554
22,621,259
2014-03-24T21:46:00.000
3
0
0
0
0
python,ios,xcode,python-requests,kivy
0
22,622,162
0
1
0
true
0
1
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
3
0
0
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 particular, I need Requests module. Maybe there's some template script to include custom python modules? Thanks in advance
Compile custom module for Kivy-ios
0
1.2
1
0
0
462
22,624,070
2014-03-25T01:55:00.000
0
0
0
0
0
python,wxpython,wxwidgets
0
22,635,854
0
1
0
true
0
1
Selected items in wxListCtrl, wxListBox and so on always use the system background selection colour, it can't be changed.
1
0
0
0
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.
Setting selection background in ListCtrl
0
1.2
1
0
0
209
22,633,008
2014-03-25T11:19:00.000
1
0
1
0
0
python,permutation,combinatorics
0
22,666,834
0
2
0
true
0
0
I believe that a block cipher, like AES, provides exactly this functionality.
1
4
0
0
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 without any seeming structure.) I want to have a function available to get the nth item in the permutation for each n, and I want to have another function available to get the index of every number in the permutation. And the big, final condition is this: I want to do all of that without having to store all the items of the permutation. (Which can be a huge amount of space.) I want each item to be accessible, but I don't want to store all the items, like range in Python 3. Is this possible?
Python: Generating a big uniform permutation cheaply
1
1.2
1
0
0
151
22,634,264
2014-03-25T12:13:00.000
0
0
0
1
0
python
1
22,634,599
0
2
0
false
0
0
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.
1
0
0
0
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 want is to know if it ended with sys.exit or any exception or if it ended normally PS:I'm running python 2.6 (can't use subprocess.check_output ) Thanks
launch a python program with it's arguments on cmd and get the output messages python
0
0
1
0
0
47
22,636,894
2014-03-25T14:01:00.000
0
0
0
0
0
python,router
0
22,789,614
0
1
0
true
0
0
Its possible by using route add command in linux
1
1
0
0
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 with fast download speed. If this is possible how I can do it?
Use different interfaces (eth0 and wlan0) for sending and receiving in Python program
1
1.2
1
0
1
409
22,689,597
2014-03-27T13:47:00.000
0
1
1
0
0
python,c++,excel,automation,ms-word
0
22,691,619
0
1
1
false
0
0
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 from one click to run such a program.
1
0
0
0
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 tricky. I used macros to some success but if something about a specific form differed to greatly the entire thing would mess up and I still had to open each word file individually and then hit the macro. Some of this process isn't going to be automatable as it requires pulling information from pdfs that isn't always in a standard format but any fast automation would be better than none. I have a good bit of c++ experience (by a good bit I just mean several courses on data structures etc, nothing way too high level). I have also used python some and stumbled my way through visual basic a tad. Any idea on how to go about automating generating sometimes 100+ of these forms?
What would be the best way to automate filling in a premade form in word
0
0
1
0
0
602
22,702,428
2014-03-28T01:16:00.000
1
0
0
0
0
python-2.7,numpy,scipy,cluster-analysis
0
22,731,897
0
2
0
false
0
0
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 data. IIRC there is k-modes, for example, and there is k-medoids (PAM, partitioning around medoids). It's unclear to me what you want to achieve overall... your data seems to be 1-dimensional, so you may want to look at the many questions here about 1-dimensional data (as the data can be sorted, it can be processed much more efficiently than multidimensional data). In general, even if you projected your data into unix time (seconds since 1.1.1970), k-means will likely only return mediocre results for you. The reason is that it will try to make the three intervals have the same length. Do you have any reason to suspect that "before", "during" and "after" have the same duration? If not, don't use k-means. You may however want to have a look at KDE; and plot the estimated density. Once you have understood the role of density for your task, you can start looking at appropriate algorithms (e.g. take the derivative of your density estimation, and look for the largest increase / decrease, or estimate an "average" level, and look for the longest above-average interval).
1
2
1
0
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 were before, during or after a certain event. I don't have the time for this event, but that's why I'm guessing it by breaking the date/times into three groups. Can anyone please help with a simple example on how to use something like numpy or scipy to do this?
Clustering a list of dates
0
0.099668
1
0
0
7,440
22,719,863
2014-03-28T17:48:00.000
0
0
0
0
1
python,networkx
0
24,051,792
0
1
0
false
0
0
I had to change the seed inside every class I used.
1
1
1
0
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
Fix the seed for the community module in Python that uses networkx module
0
0
1
0
1
165
22,764,927
2014-03-31T14:55:00.000
0
0
0
0
0
python,tkinter
0
46,719,809
0
4
0
false
0
1
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()
1
3
0
0
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....?
How To Hide Tkinter python Gui
0
0
1
0
0
11,986
22,775,423
2014-04-01T01:54:00.000
1
0
1
0
0
python,python-2.7
0
22,775,536
0
2
0
true
0
0
"Data driven programming": store your questions in a data file, and your program just needs the required logic to load and present them.
1
0
0
0
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 it would be great if I could fold all of the variables by section and label them with a comment. I am using Pydev for Eclipse. I have done some searching but haven't found anything promising. Any suggestions for how to do this or how to better organize my variables?
How to manage many variables
0
1.2
1
0
0
115
22,785,010
2014-04-01T11:49:00.000
6
0
0
1
0
python,apache-spark
0
23,485,718
0
2
0
false
0
0
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.
1
1
0
0
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.
Starting up PySpark for using python with Spark in eclipse
0
1
1
0
0
6,907
22,800,258
2014-04-02T02:12:00.000
0
0
1
0
1
python,multithreading,python-3.x
0
22,852,404
0
1
0
true
0
0
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
0
0
0
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 can't figure out how to stop it. I have tried Thread._stop(), but that frequently doesn't work. I end up with a thread that I can't control hogging both interpreter time and CPU power. The code in the thread doesn't open any files or do anything else that would cause problems if I hard-killed it. Python's multiprocessing.Process.terminate() does this really well; unfortunately, initiating a process on Windows takes nearly a second, which is long enough to cause annoying delays in my GUI. Does anyone know either a: how to kill a Python thread (I don't think I care how dirty the exit is), or b: how to speed up starting a process? A third possibility would be a third-party library that provides an alternative method for asynchronous execution, but I've never heard of any such thing.
Isolating code with a Python thread
0
1.2
1
0
0
301
22,807,281
2014-04-02T09:35:00.000
0
0
0
0
0
python-2.7,tcl
0
22,811,026
0
2
0
false
0
0
Surya, you should have a look at the ncgi and htmlparse packages in tcllib to extract the information you need. Joachim
1
0
0
0
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
Read input from the webpage, parse the data submitted using python or tcl and start the script execution based on the inputs given
0
0
1
0
1
514
22,811,844
2014-04-02T12:41:00.000
1
1
0
1
0
python,c++,linux,input,keyboard
0
22,812,228
0
2
0
false
0
0
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 doing the exec. This is much simpler, but the pipes look more like a file than a terminal to the program being monitored.
1
2
0
0
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... windows u_u Anyone have a library for this ? thanks EDIT: I found that /dev/input/event3 is my keyboard. I think write in to simulate keyboard, i'm searching how do that
Simulate keyboard input linux
0
0.099668
1
0
0
2,879
22,826,006
2014-04-03T01:08:00.000
4
0
1
0
0
python,jenkins
0
22,840,336
0
3
0
false
0
0
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't help you.
2
11
0
0
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?
how to get python print result in jenkins console output
0
0.26052
1
0
0
15,615
22,826,006
2014-04-03T01:08:00.000
16
0
1
0
0
python,jenkins
0
51,525,067
0
3
0
true
0
0
Try using -u (unbuffered) option when running the python script. python -u my_script.py
2
11
0
0
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?
how to get python print result in jenkins console output
0
1.2
1
0
0
15,615
22,831,520
2014-04-03T08:10:00.000
8
0
0
0
0
python,excel,python-2.7,xlwt
0
22,837,578
0
3
0
true
0
0
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
9
0
0
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?
how to do excel's 'format as table' in python
0
1.2
1
1
0
10,141
22,850,591
2014-04-03T23:05:00.000
2
0
1
1
0
c#,python
0
22,850,707
0
1
0
true
0
0
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 the case, then the answer would be that no you can't as I highly doubt that C# can be run in kernel-mode.
1
1
0
0
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 the service of avast you can kill the process avastui.exe. Someone have any idea how avast do it? how can i make it on c# or python? Thanks in advance
How to prevent an app from being killed in windows task manager?
0
1.2
1
0
0
1,098
22,852,845
2014-04-04T03:14:00.000
2
0
0
0
0
django,python-2.7
0
22,856,740
0
2
0
true
1
0
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 this: random_django_app/ __init__.py models.py ... another_app/ ... settings_app/ settings/ __init__.py base.py example_co_uk.py example_ca.py ... wsgis/ __init__.py example_co_uk.py example_ca.py __init__.py urls.py
1
1
0
0
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 views, static files,etc. would be almost the same for each country. What's the best way of setting this up? Should I have one main app and then have per-country apps that extend the app? (Using Django 1.6.2/Python 2.7)
Multiple websites using the same app - how to set this up?
0
1.2
1
0
0
60
22,872,888
2014-04-04T20:58:00.000
1
0
0
0
0
python,django,apache,security,permissions
0
24,634,526
0
1
0
false
1
0
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 directories. From a system administrator's perspective that is deploying the applications; you may want them all accessible from /var/www... so they are easier to locate. The permissions you set for serving the files seem fine, however they may need to run as different users... depending on the number of people using this machine. For example, lets say you have one other application running on the server and that both applications run as www-data. If the www-data user has read permissions of Django's config file, then the other user could deploy a script that can read your database credentials.
1
4
0
0
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}, but have often seen people using /var/www/... or /srv/www; is there any reason picking one of these directories is better than the other? or any reason why keeping the site in my home dir is a bad idea? Secondly, the permissions of the dir and files themselves. I'm serving using apache with mod_wsgi, and have the file WSGIScriptAlias / ~/www/mysite.com/mainapp/wsgi.py file. Apache runs as www-data user. For optimal security who should own the wsgi.py file, and what permissions should I grant it and its containing dir? Similarly, for the www, www/mysite.com, and www/mysite.com/someapp directories? What are the minimal permissions that are needed for the dirs and files? Currently I am using 755 and 644 for dir and files respecitvely, which works well enough which allows the site to function, but I wonder if it is optimal/too liberal. My Ubuntu user is the owner of most files, and www-data owns the sqlite dbs.
Security optimal file permissions django+apache+mod_wsgi
1
0.197375
1
1
0
1,003
22,877,052
2014-04-05T05:40:00.000
8
0
0
1
1
eclipse,google-app-engine,python-2.7
1
23,118,828
0
1
0
true
1
0
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 can customize it as if you had made it anew.
1
4
0
0
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
pydev Google App run Path for project must have only one segment
0
1.2
1
0
0
1,009
22,879,518
2014-04-05T10:17:00.000
2
0
1
0
0
python,class,inheritance
0
22,879,590
0
2
0
true
0
0
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 Animal as well. You can now add an additional method to it: climb. This will print that a monkey can climb trees. Both Monkey and Bird derive from Animal, so they can walk, they have a same functionality/feature. But both have a distinct feature as well: birds can fly and monkeys can climb trees. So it takes sense, right? The reverse is false, because not every Animal can fly or can climb trees. EDIT: I exaplined it to you in terms of methods. But this can apply to variables as well. The Animal class can have a weight field. Which is accessible from both inherited classes: Monkey and Bird. But Monkey can also have a field called max_power and Bird can have a class variable called max_fly_altitude. This fields are unique for these certain types of animal and NOT for the generic Animal. Which can also be a crocodile. And a crocodile can't fly to have a max_fly_altitude attribute.
1
2
0
0
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 as well? Please give your answer in as much layman's terms as possible. I'm not an native Englisch speaker and I've never had proper programming education. Give me an explenation, not a definiton :]
What does inheritance actually do in Python?
0
1.2
1
0
0
80
22,884,351
2014-04-05T17:37:00.000
0
0
0
0
0
python,python-2.7,graphics,pygame,turtle-graphics
0
31,048,800
0
2
0
false
0
1
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.
1
0
0
0
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 You
Computer Graphics with python
0
0
1
0
0
1,621
22,897,243
2014-04-06T17:12:00.000
0
0
0
0
0
python,pandas,linear-regression
0
22,897,471
0
2
0
false
0
0
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 isolated linear algebra problem... so I don't think there is much time to save here...
1
0
1
0
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?
Perform n linear regressions, simultaneously
1
0
1
0
0
472
22,910,772
2014-04-07T11:14:00.000
0
0
1
0
0
python,json,rest,python-2.7,simplehttpserver
0
22,915,936
0
2
0
true
0
0
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 the zip file using zipfile module Using the file path (ex: c:/temp/zipfile.zip) open the file using 'rb' method to read the binary information openObj = open( < path > , 'rb') return the object back to the browser openObj.close() del openObj self.wfile.write(openObj.read()) That's about it. Thank you all for your help.
1
0
0
0
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 server? Do I just return the URL where the file can be downloaded or can I send the file back to the user directly? If option two is possible, how do I do this? Thank you
Issue with Python Server Returning File On GET
1
1.2
1
0
1
257
22,913,080
2014-04-07T12:56:00.000
0
0
0
0
0
python,django
0
22,915,407
0
1
0
true
1
0
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
0
0
0
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 I've been making in the same /admin/ url (as i read you login to the cms part via the /admin/ url). Would installing the CMS overwrite anything current in my /admin/ view, or would the data management merely appear within the CMS control panel?
If I install Django CMS will it still show my current work in Django admin
0
1.2
1
0
0
34
22,939,260
2014-04-08T13:56:00.000
1
0
1
0
0
python,itertools
0
22,940,159
0
5
0
false
0
0
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
1
2
0
0
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 balls that preserves N?
Every way to organize N objects in M list slots
0
0.039979
1
0
0
1,779
22,939,822
2014-04-08T14:18:00.000
0
0
0
0
0
python,amazon-web-services,boto,amazon-sqs
0
23,070,269
0
1
0
false
0
0
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
1
0
0
0
I'm trying to send this string on Python SQS: "Talhão", with no quotes. How do I do that? Thanks!
Amazon SQS Python/boto: how do I send messages with accented characters?
0
0
1
0
1
95
22,940,269
2014-04-08T14:35:00.000
1
0
0
0
0
python,gtk
0
22,942,890
0
1
0
true
0
1
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 currently selected Gtk.TreePaths which is what you desire.
1
0
0
0
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
Finding Mouse click position in IconView in GTK
0
1.2
1
0
0
84
22,949,966
2014-04-08T23:11:00.000
1
0
0
0
0
python,numpy
0
22,949,986
0
5
0
false
0
0
If you want an inner product then use numpy.dot(x,x) for outer product use numpy.outer(x,x)
1
13
1
0
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 calculate a (n x 1) x (1 x n) vector multiplication in numpy? numpy.dot(x,x.T) gives a scalar, not a 2D matrix as I want.
dot product of two 1D vectors in numpy
0
0.039979
1
0
0
11,187
22,951,806
2014-04-09T02:39:00.000
1
0
1
0
0
python,json,database,performance,security
0
22,951,848
0
1
0
false
1
0
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 like the perfect way to ensure that your user population will be small. Is all the data JSON? Document based? Maybe you should consider a NoSQL document based solution like MongoDB.
1
0
0
0
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 the user id. Also, which is safer? I'm biased towards storing user data in JSON files because that is something I already know how to do. Any advice? I'd post some code I already have, but this is more theoretical than code-based.
Storing user data in one big database or in a different file for each user - which is more efficient?
0
0.197375
1
1
0
242
22,964,033
2014-04-09T13:27:00.000
2
0
0
0
0
python-2.7,sqlite,max
0
22,964,138
0
1
0
true
0
0
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
1
0
0
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 maximum number of columns to for example 30.000 - what is the specific code, that I should run? Hope my question is clearly stated. Thanks
How to actually change the maximum number of columns in SQLITE
1
1.2
1
1
0
1,019
22,969,365
2014-04-09T17:08:00.000
1
1
0
1
0
python,celery
0
23,090,632
0
1
0
true
0
0
The solution for me was to restart redis after the time update, and also restart celerybeat. That combination seems to work.
1
1
0
0
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 (every few minutes), the tasks are not run. All the times are UTC, and celery is set to UTC mode. Celery itself is working fine, I can run the tasks manually. What might be going on here? Also, how does celery keep track of the system time for its scheduling, how does it handle a system time update? Could it be that celery's time and the system time get out of sync somehow? This is Celery 3.1.0 with redis as broker/backend
Celery periodic tasks: testing by modifying system time
0
1.2
1
0
0
283
22,989,689
2014-04-10T13:38:00.000
1
0
0
0
1
python,django,foreign-key-relationship
0
22,990,016
0
2
0
false
1
0
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.
1
5
0
0
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 want to modify it (future update problems etc.). I wold have no problem with ManyToMany or OneToOne but don't know how to do it with ManyToOne (many tickets from external app to one Client from my app)
How to add many to one relationship with model from external application in django
0
0.099668
1
0
0
564
22,993,206
2014-04-10T16:02:00.000
0
0
1
0
0
python,emacs
0
22,996,440
0
3
0
false
0
0
Open a newline with C-j, you should get the indentation.
2
1
0
0
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++?
How to make emacs automatically indent Python code?
0
0
1
0
0
4,538
22,993,206
2014-04-10T16:02:00.000
3
0
1
0
0
python,emacs
0
23,000,155
0
3
0
false
0
0
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.
2
1
0
0
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++?
How to make emacs automatically indent Python code?
0
0.197375
1
0
0
4,538