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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
18,093,487 | 2013-08-07T02:10:00.000 | 0 | 0 | 0 | 0 | 0 | django,mechanize,mechanize-python | 0 | 27,438,161 | 0 | 1 | 0 | false | 1 | 0 | As per comments, the answer is:
pip install mechanize
then just open a python interpreter and import mechanize to confirm.
That should be it, you can start using mechanize in your Django project. | 1 | 1 | 0 | 0 | How do I use the mechanize library with Django?
I read online that I could put it in a directory (e.g. /lib/) and include as needed.
The problem is, the the source I had found didn't show how to use it from configuration to initial use. Unfortunately, I also looked high and low elsewhere on google with nothing to find. I also checked a book I have on django without any info..
Can anyone help me out?
I'm on a local install of django with python 2.7.
Thank you | Use of Mechanize Library with Python 2.7 and Django | 0 | 0 | 1 | 0 | 0 | 277 |
18,109,671 | 2013-08-07T17:16:00.000 | 1 | 0 | 1 | 0 | 0 | java,c++,python,c,coding-style | 0 | 18,109,807 | 0 | 5 | 0 | false | 0 | 0 | One thing is that, you can reference and navigate the arrays using pointers. Infact the the array operations decay to pointer arithmetic at the back end.
Suppose you want to reach a nth element of an array then you can simply do (a + n) where a is the base address of an array(1-dimension), but if the subscript starts at 1 then to reach the nth element you would have to do (a + n -1) all the time.
This is because just by taking the name of an array you the the address of the starting element of it, which is the simplest way! | 3 | 0 | 0 | 0 | Is there any special reason? I know that that's how the language has been written, but can't we change it?
And what are the challenges we'd face if the index start with 1? | Why doesn't the index/list of an array begin with 1? | 0 | 0.039979 | 1 | 0 | 0 | 278 |
18,109,671 | 2013-08-07T17:16:00.000 | 3 | 0 | 1 | 0 | 0 | java,c++,python,c,coding-style | 0 | 18,109,758 | 0 | 5 | 0 | false | 0 | 0 | The basic reason behind it is that the computer remembers the address at wich the first part of any variable/object is stored. So the index represents the "distance" in between that and what you're looking for, so the first one is 0 away, the second 1... | 3 | 0 | 0 | 0 | Is there any special reason? I know that that's how the language has been written, but can't we change it?
And what are the challenges we'd face if the index start with 1? | Why doesn't the index/list of an array begin with 1? | 0 | 0.119427 | 1 | 0 | 0 | 278 |
18,109,671 | 2013-08-07T17:16:00.000 | 3 | 0 | 1 | 0 | 0 | java,c++,python,c,coding-style | 0 | 18,109,818 | 0 | 5 | 0 | false | 0 | 0 | In C and C++, array indexing is syntactic sugar for dereferencing an offset pointer. That is,
array[i] is equivalent to *(array + i). It makes sense for pointers to point to the beginning of their block of memory, and this implies that the first element of the array needs to be *array, which is just array[0]. | 3 | 0 | 0 | 0 | Is there any special reason? I know that that's how the language has been written, but can't we change it?
And what are the challenges we'd face if the index start with 1? | Why doesn't the index/list of an array begin with 1? | 0 | 0.119427 | 1 | 0 | 0 | 278 |
18,113,426 | 2013-08-07T20:42:00.000 | 0 | 0 | 0 | 0 | 0 | python,amazon-web-services,amazon-s3,boto | 0 | 18,366,790 | 0 | 2 | 0 | false | 1 | 0 | The problem ended up being an internal billing error at AWS and was not related to either S3 or Boto. | 1 | 0 | 0 | 0 | I have several S3 buckets containing a total of 40 TB of data across 761 million objects. I undertook a project to copy these objects to EBS storage. To my knowledge, all buckets were created in us-east-1. I know for certain that all of the EC2 instances used for the export to EBS were within us-east-1.
The problem is that the AWS bill for last month included a pretty hefty charge for inter-regional data transfer. I'd like to know how this is possible?
The transfer used a pretty simple Python script with Boto to connect to S3 and download the contents of each object. I suspect that the fact that the bucket names were composed of uppercase letters might have been a contributing factor (I had to specify OrdinaryCallingFormat()), but I don't know this for sure. | Boto randomly connecting to different regions for S3 transfers | 0 | 0 | 1 | 1 | 1 | 878 |
18,114,285 | 2013-08-07T21:37:00.000 | 45 | 0 | 1 | 0 | 0 | python,multithreading,parallel-processing,process,multiprocessing | 1 | 18,114,475 | 0 | 6 | 0 | false | 0 | 0 | Multiple threads can exist in a single process.
The threads that belong to the same process share the same memory area (can read from and write to the very same variables, and can interfere with one another).
On the contrary, different processes live in different memory areas, and each of them has its own variables. In order to communicate, processes have to use other channels (files, pipes or sockets).
If you want to parallelize a computation, you're probably going to need multithreading, because you probably want the threads to cooperate on the same memory.
Speaking about performance, threads are faster to create and manage than processes (because the OS doesn't need to allocate a whole new virtual memory area), and inter-thread communication is usually faster than inter-process communication. But threads are harder to program. Threads can interfere with one another, and can write to each other's memory, but the way this happens is not always obvious (due to several factors, mainly instruction reordering and memory caching), and so you are going to need synchronization primitives to control access to your variables. | 1 | 188 | 0 | 1 | I am learning how to use the threading and the multiprocessing modules in Python to run certain operations in parallel and speed up my code.
I am finding this hard (maybe because I don't have any theoretical background about it) to understand what the difference is between a threading.Thread() object and a multiprocessing.Process() one.
Also, it is not entirely clear to me how to instantiate a queue of jobs and having only 4 (for example) of them running in parallel, while the other wait for resources to free before being executed.
I find the examples in the documentation clear, but not very exhaustive; as soon as I try to complicate things a bit, I receive a lot of weird errors (like a method that can't be pickled, and so on).
So, when should I use the threading and multiprocessing modules?
Can you link me to some resources that explain the concepts behind these two modules and how to use them properly for complex tasks? | What are the differences between the threading and multiprocessing modules? | 1 | 1 | 1 | 0 | 0 | 75,191 |
18,119,631 | 2013-08-08T06:50:00.000 | 0 | 0 | 0 | 0 | 1 | python,pyside,cx-freeze | 1 | 18,120,660 | 0 | 2 | 0 | false | 0 | 1 | Take a look at the pyside documentation and see if there is a redirect output to a window option - it is entirely possible that something is causing an error that is being printed out to nowhere. | 1 | 4 | 0 | 0 | I have small Python3 application for manipulating some specific XML files. For gui I am using PySide and for parsing files -lxml.
I had some troubles with freezing it with cx_freeze but finally succeed. Now - some parts of application simply don't work... no error message & no log created.
For example on Enter press signal in LineEdit - new dialog should be shown... but nothing happens.
I have same version in standard python files and those are running correctly. How do I debug the frozen application? | cx_freeze - how debug app | 0 | 0 | 1 | 0 | 0 | 1,843 |
18,144,810 | 2013-08-09T10:36:00.000 | 0 | 0 | 0 | 0 | 0 | python,constraints,nearest-neighbor,kdtree | 0 | 18,339,341 | 0 | 1 | 0 | false | 0 | 0 | If you are looking for the neighbours in a line of sight, couldn't use an method like
cKDTree.query_ball_point(self, x, r, p, eps)
which allows you to query the KDTree for neighbours that are inside a radius of size r around the x array points.
Unless I misunderstood your question, it seems that the line of sight is known and is equivalent to this r value. | 1 | 4 | 1 | 0 | I have a slight variant on the "find k nearest neighbours" algorithm which involves rejecting those that don't satisfy a certain condition and I can't think of how to do it efficiently.
What I'm after is to find the k nearest neighbours that are in the current line of sight. Unfortunately scipy.spatial.cKDTree doesn't provide an option for searching with a filter to conditionally reject points.
The best algorithm I can come up with is to query for n nearest neighbours and if there aren't k that are in the line of sight then query it again for 2n nearest neighbours and repeat. Unfortunately this would mean recomputing the n nearest neighbours repeatedly in the worst cases. The performance hit gets worse the more times I have to repeat this query. On the other hand setting n too high is potentially wasteful if most of the points returned aren't needed.
The line of sight changes frequently so I can't recompute the cKDTree each time either. Any suggestions? | nearest k neighbours that satisfy conditions (python) | 0 | 0 | 1 | 0 | 0 | 631 |
18,146,661 | 2013-08-09T12:26:00.000 | 3 | 0 | 1 | 0 | 0 | python,django | 0 | 18,146,782 | 0 | 2 | 0 | false | 1 | 0 | Well, this is a bit of a bad idea. The idea of having a requirements.txt is that you can perfectly replicate what you have on the machine you develop on, i.e exactly the environment it works on.
You can do what you want by just not specifying a version number in requirements.txt, but you are better off manually upgrading each module/package and confirming it works before using it in production. | 1 | 1 | 0 | 0 | When I create my requirements.txt I always want it to get the most recent package, without me having to know a version number, how can I do this?
For example I want this to get the latest version of Django:
requirements.txt
Django>=
South==0.7.6 | Django/Python requirements.txt get always recent package | 0 | 0.291313 | 1 | 0 | 0 | 107 |
18,150,858 | 2013-08-09T15:55:00.000 | 0 | 0 | 0 | 0 | 0 | python,mysql,django,mysql.sock | 1 | 66,405,102 | 0 | 5 | 0 | false | 1 | 0 | I faced this problem when connecting MySQL with Django when using Docker.
Try 'PORT':'0.0.0.0'.
Do not use 'PORT': 'db'. This will not work if you tried to run your app outside Docker. | 3 | 26 | 0 | 0 | when connecting to mysql database in Django ,I get the error.
I'm sure mysql server is running.
/var/run/mysqld/mysqld.sock doesn't exist.
When I run $ find / -name *.sock -type s, I only get /tmp/mysql.sock and some other irrelevant output.
I added socket = /tmp/mysql.sock to /etc/my.cnf. And then restared mysql, exited django shell, and connected to mysql database. I still got the same error.
I searched a lot, but I still don't know how to do.
Any help is greate. Thanks in advance.
Well, I just tried some ways. And it works.
I did as follows.
Add socket = /tmp/mysql.sock .Restart the mysql server.
ln -s /tmp/mysql.sock /var/lib/mysqld/mysqld.sock
I met an another problem today. I can't login to mysql.
I'm newbie to mysql. So I guess mysql server and client use the same socket to communicate.
I add socket = /var/mysqld/mysqld.sock to [mysqld] [client] block in my.cnf and it wokrs. | OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") | 0 | 0 | 1 | 1 | 0 | 101,165 |
18,150,858 | 2013-08-09T15:55:00.000 | 0 | 0 | 0 | 0 | 0 | python,mysql,django,mysql.sock | 1 | 56,762,083 | 0 | 5 | 0 | false | 1 | 0 | in flask, you may use that
app=Flask(__name__)
app.config["MYSQL_HOST"]="127.0.0.1
app.config["MYSQL_USER"]="root"... | 3 | 26 | 0 | 0 | when connecting to mysql database in Django ,I get the error.
I'm sure mysql server is running.
/var/run/mysqld/mysqld.sock doesn't exist.
When I run $ find / -name *.sock -type s, I only get /tmp/mysql.sock and some other irrelevant output.
I added socket = /tmp/mysql.sock to /etc/my.cnf. And then restared mysql, exited django shell, and connected to mysql database. I still got the same error.
I searched a lot, but I still don't know how to do.
Any help is greate. Thanks in advance.
Well, I just tried some ways. And it works.
I did as follows.
Add socket = /tmp/mysql.sock .Restart the mysql server.
ln -s /tmp/mysql.sock /var/lib/mysqld/mysqld.sock
I met an another problem today. I can't login to mysql.
I'm newbie to mysql. So I guess mysql server and client use the same socket to communicate.
I add socket = /var/mysqld/mysqld.sock to [mysqld] [client] block in my.cnf and it wokrs. | OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") | 0 | 0 | 1 | 1 | 0 | 101,165 |
18,150,858 | 2013-08-09T15:55:00.000 | 0 | 0 | 0 | 0 | 0 | python,mysql,django,mysql.sock | 1 | 72,389,079 | 0 | 5 | 0 | false | 1 | 0 | You need to change your HOST from 'localhost' to '127.0.0.1' and check your django app :) | 3 | 26 | 0 | 0 | when connecting to mysql database in Django ,I get the error.
I'm sure mysql server is running.
/var/run/mysqld/mysqld.sock doesn't exist.
When I run $ find / -name *.sock -type s, I only get /tmp/mysql.sock and some other irrelevant output.
I added socket = /tmp/mysql.sock to /etc/my.cnf. And then restared mysql, exited django shell, and connected to mysql database. I still got the same error.
I searched a lot, but I still don't know how to do.
Any help is greate. Thanks in advance.
Well, I just tried some ways. And it works.
I did as follows.
Add socket = /tmp/mysql.sock .Restart the mysql server.
ln -s /tmp/mysql.sock /var/lib/mysqld/mysqld.sock
I met an another problem today. I can't login to mysql.
I'm newbie to mysql. So I guess mysql server and client use the same socket to communicate.
I add socket = /var/mysqld/mysqld.sock to [mysqld] [client] block in my.cnf and it wokrs. | OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") | 0 | 0 | 1 | 1 | 0 | 101,165 |
18,168,329 | 2013-08-11T03:02:00.000 | 4 | 0 | 1 | 0 | 0 | python,macos,multiprocessing | 0 | 18,168,461 | 0 | 1 | 0 | true | 0 | 0 | You need to use the multiprocessing module.
Both modules enable concurrency, but only multiprocessing enables true parallelism. Due to Python's Global Interpreter Lock, multiple threads cannot execute simultaneously.
Keeping all 16 of your processors busy comes at the cost of a certain increased difficulty in programming since separate processes do not execute in a shared memory space, so if a spawned process needs to share data with its parent process you will need to serialize it. | 1 | 0 | 0 | 0 | Any basic information would be greatly appreciated.
I am almost completed with my project, all I have to do now is run my code to get my data. However, it takes a very long time, and it has been suggested that I make my code (python) available to multiprocess. However, I am clueless on how to do this and have had a lot of trouble running how. I use a Mac OS X 10.8.2. I know that I need a semaphore.
I have looked up the multiprocessing module and the Thread module, although I could not understand most of this. Do the Process() or Manager() functions have anything to do with this?
Lastly, I have 16 processors available for this. | Multiprocessing in python on Mac OS | 0 | 1.2 | 1 | 0 | 0 | 3,162 |
18,179,680 | 2013-08-12T04:47:00.000 | 0 | 0 | 1 | 0 | 0 | python,algorithm | 0 | 18,180,322 | 0 | 6 | 0 | false | 0 | 0 | How about,
sort by first column O(n log n)
binary search to find indices that are out of range O(log n)
throw out values out of range
sort by second column O(n log n)
binary search to find indices that are out of range O(log n)
throw out values out of range
you are left with the values in range
This should be O(n log n)
You can sort rows and cols with np.sort and a binary search should only be a few lines of code.
If you have lots of queries, you can save the first sorted copy for subsequent calls but not the second. Depending on the number of queries, it may turn out to be better to do a linear search than to sort then search. | 1 | 6 | 1 | 0 | I have a 200k lines list of number ranges like start_position,stop position.
The list includes all kinds of overlaps in addition to nonoverlapping ones.
the list looks like this
[3,5]
[10,30]
[15,25]
[5,15]
[25,35]
...
I need to find the ranges that a given number fall in. And will repeat it for 100k numbers.
For example if 18 is the given number with the list above then the function should return
[10,30]
[15,25]
I am doing it in a overly complicated way using bisect, can anybody give a clue on how to do it in a faster way.
Thanks | finding a set of ranges that a number fall in | 0 | 0 | 1 | 0 | 0 | 3,636 |
18,222,808 | 2013-08-14T03:39:00.000 | 1 | 0 | 0 | 0 | 0 | python,browser,gif | 1 | 18,229,495 | 0 | 1 | 0 | true | 0 | 0 | Use this line: webbrowser.open('file://'+os.getcwd()+'/gif_name.gif') and change the default app to view pictures to Chrome. | 1 | 0 | 0 | 0 | I have a series of local gif files. I was wondering how I would be able to open this series of local gifs using the webbrowser module. I am, by the way, running on Mac OS X Snow Leapord. Whenever I try to use the webbrowser.open('file:gif_name') snippet, my computer throws the error 0:30: execution error: Bad name for file. some object (-37). Any help would be greatly appreciated! | Opening Series of Gifs in Chrome Using webbrowser | 0 | 1.2 | 1 | 0 | 1 | 231 |
18,282,568 | 2013-08-16T21:44:00.000 | 3 | 0 | 1 | 0 | 0 | python,numpy,scipy | 1 | 18,321,537 | 0 | 1 | 0 | true | 0 | 0 | So it seems that the cause of the error was incompatibility between scipy 0.12.0 and the much older numpy 1.6.1.
There are two ways to fix this - either to upgrade numpy (to ~1.7.1) or to downgrade scipy (to ~0.10.1).
If ArcGIS 10.2 specifically requires Numpy 1.6.1, the easiest option is to downgrade scipy. | 1 | 7 | 1 | 0 | I just installed ArcGIS v10.2 64bit background processing which installs Python 2.7.3 64bit and NumPy 1.6.1. I installed SciPy 0.12.0 64bit to the same Python installation.
When I opened my Python interpreter I was able to successfully import arcpy, numpy, and scipy. However, when I tried to import scipy.ndimage I got an error that said numpy.core.multiarray failed to import. Everything I have found online related to this error references issues between scipy and numpy and suggest upgrading to numpy 1.6.1. I'm already at numpy 1.6.1.
Any ideas how to deal with this? | SciPy 0.12.0 and Numpy 1.6.1 - numpy.core.multiarray failed to import | 0 | 1.2 | 1 | 0 | 0 | 6,801 |
18,300,841 | 2013-08-18T15:43:00.000 | 3 | 0 | 1 | 0 | 0 | delphi,python4delphi | 1 | 18,300,977 | 0 | 1 | 0 | true | 0 | 0 | python4delphi is a loose wrapper around the Python API and as such relies on a functioning Python installation. Typically on Windows this comprises at least the following:
The main Python directory. On your system this is C:\Python27.
The Python DLL which is python27.dll and lives in your system directory.
Registry settings that indicate where your Python directory is installed.
When you rename the Python directory, the registry settings refer to a location that no longer exists. And so the failure you observe is entirely to be expected.
Perhaps you are trying to work out how to deploy your application in a self-contained way without requiring an external dependency on a Python installation. If so, then I suggest you look in to one of the portable Python distributions. You may need to adapt python4delphi a little to find the Python DLL which will be located under your application's directory. But that should be all that's needed. Take care of the licensing issues too if you do distribute Python with your application. | 1 | 1 | 0 | 0 | I have Python 2.7 installed in "C:\Python27". Now I run 1st demo of Python4delphi with D7, which somehow uses my Py2.7 install folder. If I rename Python folder, demo can't run (without error message). I didn't change properties of a demo form.
What part/file does py4delphi use from my Python folder? | What part of installed Python does python4delphi use? | 0 | 1.2 | 1 | 0 | 0 | 822 |
18,307,366 | 2013-08-19T06:09:00.000 | 4 | 0 | 1 | 1 | 0 | python,celery | 0 | 18,319,581 | 0 | 2 | 0 | false | 0 | 0 | Can someone tell me whether Celery executes a task in a thread or in a
separate child process?
Neither, the task will be executed in a separate process possibly on a different machine. It is not a child process of the thread where you call 'delay'. The -C and -P options control how the worker process manages it's own threading. The worker processes get tasks through a message service which is also completely independent.
How would you compare celery's async with Twisted's reactor model? Is
celery using reactor model after all?
Twisted is an event queue. It is asynchronous but it's not designed for parallel processing. | 1 | 7 | 0 | 0 | Can someone tell me whether Celery executes a task in a thread or in a separate child process? The documentation doesn't seem to explain it (read it like 3 times). If it is a thread, how does it get pass the GIL (particularly whom and how an event is notified)?
How would you compare celery's async with Twisted's reactor model? Is celery using reactor model after all?
Thanks, | Is celery's apply_async thread or process? | 0 | 0.379949 | 1 | 0 | 0 | 3,889 |
18,314,913 | 2013-08-19T13:23:00.000 | -1 | 0 | 0 | 0 | 0 | python,random-sample | 0 | 18,315,125 | 0 | 2 | 0 | false | 0 | 0 | The basic procedure is this:
1. Open the input file
This can be accomplished with the basic builtin open function.
2. Open the output file
You'll probably use the same method that you chose in step #1, but you'll need to open the file in write mode.
3. Read the input file to a variable
It's often preferable to read the file one line at a time, and operate on that one line before reading the next, but if memory is not a concern, you can also read the entire thing into a variable all at once.
4. Choose selected lines
There will be any number of ways to do this, depending on how you did step #3, and your requirements. You could use filter, or a list comprehension, or a for loop with an if statement, etc. The best way depends on the particular constraints of your goal.
5. Write the selected lines
Take the selected lines you've chosen in step #4 and write them to the file.
6. Close the files
It's generally good practice to close the files you've opened to prevent resource leaks. | 1 | 0 | 1 | 0 | I need to open a csv file, select 1000 random rows and save those rows to a new file. I'm stuck and can't see how to do it. Can anyone help? | Selecting random rows with python and writing to a new file | 0 | -0.099668 | 1 | 0 | 0 | 11,279 |
18,330,916 | 2013-08-20T08:57:00.000 | 0 | 0 | 0 | 0 | 0 | java,android,python,django,authentication | 0 | 18,334,430 | 0 | 3 | 0 | false | 1 | 0 | You may want to use the Django Sessions middleware, which will set a cookie with a django session_id. On the following requests, the sessions middleware will set an attribute on your request object called user and you can then test if user is authenticated by request.user.is_authenticated() ( or login_required decorator) . Also, you can set the session timeout to whatever you like in the settings.
This middleware is enabled in default django settings. | 1 | 4 | 0 | 0 | As of now, I have a Django REST API and everything is hunky dory for the web app, wherein I have implemented User Auth in the backend. The "login_required" condition serves well for the web app, which is cookie based.
I have an Android app now that needs to access the same API. I am able to sign in the user. What I need to know is how to authenticate every user when they make GET/POST request to my views?
My research shows a couple of solutions:
1) Cookie-backed sessions
2) Send username and password with every GET/POST request(might not be secure)
Any ideas? | How to authenticate android user POST request with Django REST API? | 0 | 0 | 1 | 0 | 0 | 9,898 |
18,342,535 | 2013-08-20T18:33:00.000 | 1 | 1 | 0 | 1 | 0 | c++,python,c,opencv,compilation | 0 | 18,342,743 | 0 | 5 | 0 | false | 0 | 1 | How to compile my project so it can be used from python? I've read
that I should create a *.so file but how to do so?
That depends on your compiler. By example with g++:
g++ -shared -o myLib.so myObject.o
Should it work like a lib, so python calls some specific functions,
chosen in python level?
Yes it is, in my opinion. It seems do be the "obvious" way, since it's great for the modularity and the evolution of the C++ code. | 1 | 2 | 0 | 0 | I've a c++ code on my mac that uses non-standard lybraries (in my case, OpenCV libs) and need to compile this so it can be called from other computers (at least from other mac computers). Runned from python. So I've 3 fundamental questions:
How to compile my project so it can be used from python? I've read
that I should create a *.so file but how to do so?
Should it work like a lib, so python calls some specific functions,
chosen in python level?
Or should it contain a main function that is executed from
command line?
Any ideas on how to do so? PS: I'm using the eclipse IDE to compile my c++ project.
Cheers, | Calling c++ function, from Python script, on a Mac OSX | 0 | 0.039979 | 1 | 0 | 0 | 3,206 |
18,369,296 | 2013-08-21T23:30:00.000 | 0 | 0 | 1 | 0 | 1 | python,python-2.7 | 0 | 18,369,413 | 0 | 2 | 1 | true | 0 | 0 | Your program should:
Check if a file (with a fixed filename) exists (or has any contents).
If it does not exist, then obtain data from the user and save it in the file.
If it does exist, read it. Display it to the user. Ask the user an input of "quit" (to exit) or a person name. If a person name, ask the user for the change in balance (positive number= a new loan; negative number= payback).
Before you start, it's better you define a data model for the application, i.e. what data you need to store, and how you will store it. Would you use lists? Dictionaries? Sets? Would you create objects? You also need to consider how to store this information in a file. You can do this by yourself or use the pickle module or similar. If you are just learning the language, I would recommend to do it yourself. | 1 | 0 | 0 | 0 | I want to make a python program that lets you track how much certain people owe you. It should ask you your name and the people's names the first time it is run. Afterwards it should say something along the lines of "Welcome back (name)" and be able to retrieve the people's names and how much they owe you, as well as allowing the user to edit names/owed money etc.
However, this wasn't mentioned in any of the tutorials I did. I have no idea how to even start. Is there a library or something for this? I tried using text files but it didn't work. What is the best way to solve this problem? | Python saving data and retrieving it | 0 | 1.2 | 1 | 0 | 0 | 165 |
18,369,347 | 2013-08-21T23:35:00.000 | 2 | 0 | 1 | 0 | 0 | python,eclipse,ide,pydev | 0 | 18,384,978 | 0 | 1 | 0 | true | 1 | 0 | You can define the templates used in PyDev (both for code-completion and for new modules) in window > preferences > pydev > editor > templates.
Anything with the context 'new module' there will be shown to you when you create a new module (and you can have many templates, such as one for unittests, empty modules, class modules, etc).
Note that the templates are only presented when you create a module with Alt+Shift+N > pydev module (or file > new > pydev module), not when you create a regular 'file' (even if it ends with .py) | 1 | 1 | 0 | 0 | I need to use a default template for my files, such as first heading : description of file, author, shebang line and so on. But PyDev and eclipse don't do it for me.
When i want to create a new file in my project, how i have them? | how to define reserved template for python file for eclipse | 0 | 1.2 | 1 | 0 | 0 | 379 |
18,386,023 | 2013-08-22T16:24:00.000 | 0 | 0 | 0 | 0 | 0 | javascript,python,web2py | 0 | 18,414,025 | 0 | 1 | 0 | true | 1 | 0 | I used a Form to achieve this. Working quite well. | 1 | 0 | 0 | 0 | I want to know how I can get content of a certain element by a dynamic id/name in embeded python codes in web2py view page?
Basically I want something like:
{{for task in tasks:}}
...
{{=TEXTAREA(task['remark'], _name='remark'+str(task['id']), _id='remark'+str(task['id']), _rows=2)}}
{{=A('OK', _class='button', _href=URL('update_remark', vars=dict(task_id=task['id'], new_remark=['remark'+str(task['id'])])))}}
What I want the ['remark'+str(task['id'])] do is to get the content automatically but obviously it won't work, I'm wondering how I can achieve this? Is there any API that can help?
Thanks in advance! | How to get content of element in embeded python codes in web2py view | 0 | 1.2 | 1 | 0 | 1 | 79 |
18,390,874 | 2013-08-22T21:08:00.000 | 1 | 0 | 1 | 0 | 0 | python,csv,wxpython | 0 | 18,390,934 | 0 | 2 | 0 | false | 0 | 0 | During a heavy operation a wx frame is "stuck" waiting on the process to finish. You're best solution is to create a worker thread and let it do the heavy job for you. | 1 | 0 | 0 | 0 | I have built a csv reader with. It iterats through a file and gives results based on search terms. I am reading 3 gig files. When I let it iterate through the file it works fine. But if I even touch the wxpython window after processing has begun the app stops responding then crashes. My best guess is I have to somehow monitor/throttle cpu usage. I have no idea how to do this or if I am on the right path. | wxpython csv reader crashing while processing | 0 | 0.099668 | 1 | 0 | 0 | 90 |
18,393,975 | 2013-08-23T03:00:00.000 | 0 | 0 | 1 | 0 | 0 | python | 1 | 18,394,654 | 0 | 3 | 0 | false | 0 | 0 | If the problem is indeed to create a new password, I explain how to do it, but no code:
Use the random.SystemRandom() if you want secure passwords.
First create N characters from the set of allowed characters, where N is the length of your password. Then check if there are at least 2 digits. If there are less than 2 digits characters then remove 1 or 2 non-digit characters and add random digits, so that there are at least those 2 digits. Finally use the shuffle() to permute your password. That way your password has maximum entropy possible. | 1 | 0 | 0 | 0 | I've been trying to make a password creator to create a password for a assessment and one of the things that's needed is if the password doesn't have at least 2 numbers in it will print a error asking for a password with at least two numbers. I do not know how to do this and I was just wondering if you could give me a little hint on how I could do this in code.
Thanks in advance | I'm trying to make a password creator | 0 | 0 | 1 | 0 | 0 | 118 |
18,407,249 | 2013-08-23T16:05:00.000 | 1 | 0 | 0 | 1 | 0 | python,google-app-engine,path,google-cloud-storage,sys.path | 0 | 18,955,756 | 1 | 1 | 0 | false | 1 | 0 | In GAE change the python path via Preferences settings, set Python Path to match your python 27 path. | 1 | 2 | 0 | 0 | I'm trying to use the GCS client library with my app engine app and I ran into this -
"In order to use the client library in your app, put the /src/cloudstorage directory in your sys.path so Python can find it."
First, does this mean I need to move the directory into my sys.path OR does it need to add the ~/src/cloudstorage/ to my PATH environment variable?
Second, when I print sys.version and sys.path from the App Engine Interactive Console, I see a Python Version of 2.7.2, but when I print from my Terminal (on a Mac), I get the Python I want to use and installed via Homebrew - 2.7.5. The sys.path in the Console shows all App Engine paths and the default Python installation - /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
On my terminal - /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/
I need help understanding how to change this.
** UPDATE **
Okay, I figured out part of this answer. "In order to use the client library in your app, put the /src/cloudstorage directory in your sys.path so Python can find it." means moving the actual directory to the App Engine project directory.
The second piece still remains - why is my Mac PATH environment variable not used in APP Engine. How can I change the default version of Python used by the App Engine (from 2.7.2 to 2.7.5)? This is not related to changing the version in the YAML file. | Google App Engine, Change which python version | 0 | 0.197375 | 1 | 0 | 0 | 1,807 |
18,435,891 | 2013-08-26T02:45:00.000 | 1 | 0 | 0 | 0 | 0 | python,com,constants,win32com | 0 | 18,492,848 | 0 | 3 | 0 | true | 0 | 0 | To find out what Com applications you can use... See http://timgolden.me.uk/pywin32-docs/html/com/win32com/HTML/QuickStartClientCom.html
Basically you can't know for sure. Sorry.
Each computer will have a different list based on the software installed, the webpage I linked suggests using pyWins ComBrowser, however I haven't ever found it that useful.
My normal approach is
'I want to interface with application X in Python... lets google "python com X" and see what comes up'
or
'I want to interface with application X in Python.. lets look through the documentation of AppX for references to COM'
Afterall you'll want to have some form of documentation to that programmes COM interface in order to be able to do anything meaningful with the program (other than opening it). | 1 | 3 | 0 | 1 | I'm currently wondering how to list the constants in win32com in python,
for example using excel win32com.client.Dispatch('Excel.Application')
Is there a way to display all constants using win32com.client.Constants ?
Or does someone know where i could find win32com's documentation ? Because all the links I found are dead ... | Python win32com constants | 0 | 1.2 | 1 | 0 | 0 | 7,331 |
18,436,903 | 2013-08-26T04:58:00.000 | 1 | 0 | 1 | 0 | 0 | python,scite | 0 | 18,437,018 | 0 | 1 | 0 | true | 0 | 0 | Highlight the block of code and press shift+tab | 1 | 0 | 0 | 0 | My English just as my programming, are not good, apologize.
I'm using SciTE to run python code. I added a while statement to the outside of a block of code. Then, in order to indent the next block of code, I selected it and pressed tab.
After some more coding, I now want to delete the while statement and dedent (unindent) the block of code that's in the while-loop. How can I dedent a block of code?
Hope people can understand my poor description, man.
Thanks! | in SciTE, how to make the whole block of code have less margin in python | 0 | 1.2 | 1 | 0 | 0 | 298 |
18,446,580 | 2013-08-26T14:30:00.000 | 2 | 0 | 1 | 0 | 0 | python,multithreading,performance,win32-process | 0 | 18,446,899 | 0 | 2 | 0 | true | 0 | 0 | Each process has a separate instance of the global variable. If you want each process to see the same value, you'll need to pass that value as an argument to each process. | 1 | 0 | 0 | 0 | With this global variable defined in the script upper focus
t0 = time.time() ## is global
and this function
def timestamp(t0):
... return ("[" + str(time.time()-t0)+ "] ") ## time stamping from initial start
I'm trying to timestamp every print() of my script with
print(timestamp(t0) + ""...whatever..."")
This works, but when i'm enterring multithreading by
for thread_id in range(win32-safe_os):
... p = Process(target=fonction, args=((thread_id),"test"))
... p.start()
... thread_list.append(p)
in order to
def fonction(thread_id,filetodo):
... print(timestamp(t0)+"Load core "+str(thread_id))
... print(timestamp(t0)+str(filetodo)+" on core "+str(thread_id))
... print(timestamp(t0)+"Free core "+str(thread_id))
i get this stdout :
[2.70299983025] 297 jpg / 36087 files
[2.75] Enterring multithreading [2.75] Win32 finds : 2 core(s) [0.0] Load core 0 [0.0] test on core 0 [0.0] Free core 0 [0.0] Load core 1 [0.0] test on core 1 [0.0] Free core 1
I can see that my call to timestamp() and t0 is working, but not in p.start(). I'm wondering how(, and why) i need to correct ?
PS : I tried with time.clock, but in win32 it refers to the beginning of a THREAD (not a script)/ | Understanding why multithreading could not read a global variable | 1 | 1.2 | 1 | 0 | 0 | 112 |
18,455,213 | 2013-08-27T00:42:00.000 | 0 | 0 | 0 | 0 | 0 | python,django,reporting,google-calendar-api | 0 | 52,007,377 | 0 | 3 | 0 | false | 1 | 0 | I'm probably going to write a Python script for this soon.
I had written a reporting app before in C#, but it's badly written and I think Google has changed their API again so it's not working anymore.
The way I did it was to use tags. I wanted my total work hours per client. I would enter them into Google Calendar as:
@clientname description of work
Where clientname can be the first few letters only and the software matches it to a full name from a list of clients. My software would then allow you to chose a time-period and one or more clients and would output them into a neat looking Word file.
PS: to by honest the suggestion of using gtimereport.com seems very bad to me. You're basically uploading all of your calendars to strangers. That's why I'm going to write a script for this. | 1 | 3 | 0 | 0 | I am planning my all day activities in Google calendar LIke
Offcie time
sleeping
playing
Gym
I am happy with Google but issue is that i don't get reporting so that i can see how much time is spent in each category.
I know python and django so i was thinking is it possible that i still log all events in Google calendar and then i have daily cron jobs which will fetch events from Google calendar and then put in mysql database.
The main issue is i want to define separate categories for different things. Like WORK, SLEEP, SHOPPING etc.
But how can i do that from event name only. DO i need to enter some words in events whicg i can grab and make them as category. ANy ideas on that | Can i generate reporting using google calendar | 1 | 0 | 1 | 0 | 0 | 3,005 |
18,455,589 | 2013-08-27T01:35:00.000 | 1 | 0 | 1 | 0 | 0 | python,numpy | 0 | 18,456,597 | 0 | 6 | 0 | false | 0 | 0 | It is possible to do the job with one pass and without loading the entire file into memory as well. Though the code itself is going to be much more complicated and mostly unneeded unless the file is HUGE.
The trick is the following:
Suppose we only need one random line, then first save first line into a variable, then for ith line, replace the currently with probability 1/i. Return the saved line when reaching end of file.
For 10 random lines, then have an list of 10 element and do the process 10 times for each line in the file. | 1 | 4 | 1 | 0 | I have a text file which is 10k lines long and I need to build a function to extract 10 random lines each time from this file. I already found how to generate random numbers in Python with numpy and also how to open a file but I don't know how to mix it all together. Please help. | Retrieve 10 random lines from a file | 0 | 0.033321 | 1 | 0 | 0 | 3,957 |
18,456,708 | 2013-08-27T04:01:00.000 | 1 | 0 | 1 | 0 | 0 | python,repository,sublimetext2 | 1 | 18,722,089 | 0 | 2 | 0 | false | 0 | 0 | You can also access the Package Control settings from the Menu bar under:
Preferences -> Package Settings -> Package Control -> Settings - User.
From there you can edit or remove the bad URL. | 1 | 2 | 0 | 0 | I have installed package control, and I use it frequently, the problem is that I added a new repository and it is wrong, and when I try to install other package, sublime throw exception, somebody know how can I remove a repository in sublime text.
Note: I have the problem in a OSX. | sublime text remove repository | 0 | 0.099668 | 1 | 0 | 0 | 1,741 |
18,462,319 | 2013-08-27T09:56:00.000 | 0 | 0 | 1 | 0 | 0 | c++,python,list,boost,reference | 0 | 18,467,078 | 0 | 1 | 0 | false | 0 | 1 | Okay so the Problem appears when the type is not declared for boost::python. ! | 1 | 0 | 0 | 0 | I have a vector of pointers to objects in c++ and want to expose it to python with a list. So far I gave a reference of a python list to c++. I figured pointers are not suitable for python so I read about how to make a pointer to a reference by (*obj) it. But when I call: myList.append((*obj)); python just crashes. Can someone tell me how to put objects I only have pointers of into a python list correctly so I can manipulate that list later?
Greetings
Chris | appending object references to python list with boost | 0 | 0 | 1 | 0 | 0 | 123 |
18,463,836 | 2013-08-27T11:14:00.000 | 2 | 0 | 0 | 1 | 0 | python,c,dbus | 0 | 18,476,891 | 0 | 1 | 0 | true | 0 | 0 | dbus-monitor "sender=org.freedesktop.Telepathy.Connection.******" | 1 | 5 | 0 | 0 | I writing Dbus service implementing some protocol. My service sends to client message with unexpected data (library i used has some bugs, that i want to overwrite).
How to inspect, trace client calls? I want to determine what client wants and locate buggy method.
Or how to trace all calls in service? I has much of logger.debug() inserted.
Service is python, client is c.
How to specify path or service to monitor in dbus-monitor with sender and reciever? | How debug or trace DBus? | 0 | 1.2 | 1 | 0 | 0 | 1,405 |
18,475,116 | 2013-08-27T20:43:00.000 | 2 | 0 | 1 | 0 | 0 | python,django,virtualenv,virtualenvwrapper | 0 | 18,475,165 | 0 | 1 | 1 | false | 1 | 0 | When i do tutorials like "Effective Django" they use the virtualenv command on an empty folder, then activate it. That works, until tomorrow when I want to work on the app again at which point the virtualenv is gone.
I strongly doubt that this is the case, unless something is deleting your directories overnight. If that is the case, stop putting your code where it is being deleted.
Assuming that is not the case, the solution is for you to go back to the directory you created as a virtualenv, and reactivate it. | 1 | 0 | 0 | 0 | Sorry if this is dumb but every piece of documentation i read doesn't ever seem to answer this question in a direct way. How do i properly use virtualenv so that I have a virtualenv i can call with workon?
When i do tutorials like "Effective Django" they use the virtualenv command on an empty folder, then activate it. That works, until tomorrow when I want to work on the app again at which point the virtualenv is gone. What do i do at this point, I've used mkvirtualenv before and that creates a "permanent" virtualenv i can call with "workon" but I don't understand how i would use mkvirtualenv on an existing project or if this is a good idea or not, as it stands i have a project I virtualenv yesterday that has a bin folder in it and I am not sure if I need to source it again or what. Ideally i want to just workon project and get to work. | virtualenv/virtualenvwrapper confusion - how to properly use | 1 | 0.379949 | 1 | 0 | 0 | 329 |
18,489,613 | 2013-08-28T13:40:00.000 | 3 | 0 | 0 | 0 | 0 | python,wxpython,glob,filebrowse | 0 | 18,489,942 | 0 | 1 | 0 | true | 0 | 1 | The documentation is not very clear. You should be using a semi-colon inside parenthesis, like so: "TXT and CSV files (*.txt; *.csv)|*.txt; *.csv"
You can also add a second line like so: "TXT and CSV files (*.txt; *.csv)|*.txt; *.csv|PNG files (*.png)|*.png" | 1 | 3 | 0 | 0 | I'm trying to make a wx.lib.filebrowsebutton.FileBrowseButton button match both txt and csv files, but it doesn't seem to support glob pattern as described, *.{txt,csv} ends up matching nothing on windows and it literally tries to look for files with extension of {txt,csv}.
So how do I make it work for both txt and csv files? | Is there a way to add multiple filemasks in wx.lib.filebrowsebutton.FileBrowseButton? | 0 | 1.2 | 1 | 0 | 0 | 157 |
18,499,338 | 2013-08-28T22:29:00.000 | 1 | 0 | 0 | 0 | 0 | python,security,lucene,debian,elasticsearch | 0 | 18,514,779 | 0 | 5 | 0 | false | 0 | 0 | There is no restriction by default, ElasticSearch expose a standard HTTP API on the port 9200.
From your third party server, are you able to: curl http://es_hostname:9200/? | 2 | 5 | 0 | 0 | I have a default installation of Elasticsearch which I am trying to query from a third party server. However, it seems that by default this is blocked.
Is anyone please able to tell me how I can configure Elasticsearch so that I can query it from a different server? | Allowing remote access to Elasticsearch | 0 | 0.039979 | 1 | 0 | 1 | 15,468 |
18,499,338 | 2013-08-28T22:29:00.000 | 3 | 0 | 0 | 0 | 0 | python,security,lucene,debian,elasticsearch | 0 | 37,047,491 | 0 | 5 | 0 | false | 0 | 0 | In config/elasticsearch.yml, put network.host: 0.0.0.0.
And also add Inbound Rule in firewall for your ElasticSearch port(9200 ByDefault).
It worked in ElasticSearch version 2.3.0 | 2 | 5 | 0 | 0 | I have a default installation of Elasticsearch which I am trying to query from a third party server. However, it seems that by default this is blocked.
Is anyone please able to tell me how I can configure Elasticsearch so that I can query it from a different server? | Allowing remote access to Elasticsearch | 0 | 0.119427 | 1 | 0 | 1 | 15,468 |
18,511,206 | 2013-08-29T12:36:00.000 | 2 | 0 | 0 | 0 | 0 | python,matplotlib,histogram2d | 0 | 18,511,409 | 0 | 1 | 0 | true | 0 | 0 | Extent defines the images max and min of the horizontal and vertical values. It takes four values like so: extent=[horizontal_min,horizontal_max,vertical_min,vertical_max]. | 1 | 1 | 1 | 0 | Im wanting to use imshow() to create an image of a 2D histogram. However on several of the examples ive seen the 'extent' is defined. What does 'extent' actually do and how do you choose what values are appropriate? | What does extent do within imshow()? | 0 | 1.2 | 1 | 0 | 0 | 128 |
18,540,987 | 2013-08-30T20:28:00.000 | 0 | 1 | 0 | 0 | 0 | python,sqlite,search,flask,typeahead | 0 | 18,541,075 | 0 | 2 | 1 | false | 1 | 0 | You are looking for "partial matches". I would load all possible names into an array, and sort them. Then I would separately create a (26x26) lookup array that shows the index of the first element in the list of names that corresponds to a combination of the first two letters; you might also have a dict (rather than an exhaustive list) of all possible three letter combinations, which would speed up your search (because it limits it to a much smaller slice of the array).
In other words - you would not really be searching at all (for the two and three letter combo's); you would be returning a slice of the array. Once you have a match of more than three, you probably can search the slice (not worth creating tables beyond three characters). | 1 | 0 | 0 | 0 | I am developing my first Flask application (with sqlite as a database). It takes a single name from user as a query, and displays information about this name as a response.
All working well, but I want to implement typeahead.js to make better user experience. Typeahead.js sends requests to server as user types, and suggests possible names in dropdown. Right now I'm searching the database with select * from table_name where name like 'QUERY%'. But this of course is not so fast as I would like it to be - it works, but with noticable input lag (less or around a second I suppose).
In order to speed up things I looked at some memory caching options (like Redis or memcached), but they are key-value store, therefore I think do not fit my needs. I think possible option would be to make list of names (["Jane", "John", "Jack"], around 200k names total), load it into ram and do searches there. But how do I load something in memory in Flask?
Anyway, my question is: What is the best way to make such search (by first few letters) faster (in Python/Flask)? | Fastest text search in Python | 1 | 0 | 1 | 0 | 0 | 1,008 |
18,546,053 | 2013-08-31T08:14:00.000 | 0 | 0 | 1 | 0 | 0 | python,regex | 0 | 61,012,316 | 0 | 4 | 0 | false | 0 | 0 | The solution I'm currently using to accept http / https only, username:password optionally and host as an IP or domain name is the following:
^(?:https?:\/\/)(?:(\w+)(?::(\w*))@)?([a-zA-Z0-9][a-zA-Z0-9-_]{0,61}[a-zA-Z0-9]{0,1}\.([a-zA-Z]{1,6}|[a-zA-Z0-9-]{1,30}\.[a-zA-Z]{2,3})|((?:\d{1,3})(?:\.\d{1,3}){3}))(?::(\d{1,5}))$
I hope it helps | 1 | 0 | 0 | 0 | I need to match both formats like: user:[email protected]:3847 and 111.23.123.78:2938, how do you do that(match valid proxy only)?
And by the way, is there such module(validate proxy formats) in python already? | How to perfectly match a proxy with regex? | 0 | 0 | 1 | 0 | 1 | 3,078 |
18,546,103 | 2013-08-31T08:21:00.000 | -1 | 0 | 1 | 0 | 0 | python,python-3.x | 0 | 18,546,144 | 0 | 2 | 0 | false | 0 | 0 | Entering multiple lines: use three quotation marks thusly:
"""hello
this is multiple
lines"""
count lines... len(text.split()) or len(text.split('\n')) etc | 1 | 1 | 0 | 0 | I have to write a code which recognizes a text line by line and reverses each line in the output, I dont know how to enter a text with multiple lines (as "input()" function will take the input after the first "Enter" but I still want to enter more lines?
second I don't know how to count the input line by line? whould "split(/n) be an option? | How to show EOF in Python? / how to identify lines? | 0 | -0.099668 | 1 | 0 | 0 | 105 |
18,546,876 | 2013-08-31T10:02:00.000 | 0 | 0 | 0 | 0 | 0 | python,tkinter | 0 | 18,548,116 | 0 | 1 | 0 | true | 0 | 1 | You can't, if you're talking about the native menubar you get when you set the menu attribute of the root window.
You can create your own menubar that behaves a little bit like a menubar by using a frame and one or more menubuttons, and place that at the bottom. | 1 | 0 | 0 | 0 | I have a program thats like a desktop enviroment with educational games and I was wondering how to put the menubar on the bottom of the window.
Thanks In Advance! | tkinter - Change menubar location | 0 | 1.2 | 1 | 0 | 0 | 269 |
18,555,139 | 2013-09-01T04:10:00.000 | 0 | 0 | 0 | 0 | 0 | python,node.js,socket.io | 0 | 18,555,399 | 0 | 1 | 1 | true | 0 | 0 | Assuming your Python objects are simple enough (not instances of classes, say), just send a JSON representation (json.dumps()) of them to the socket.io side. I am assuming you can parse JSON on the client side if needed. | 1 | 0 | 0 | 0 | Ok so what I'd like to do is have a game written in python and for all the multiplayer to be handled socket.io just because these are two things I'm fairly familiar with and I wanna keep possibilities for a web version or web app for the game open
So what I'm wondering is, how exactly do I do this and would it be better to embed a javascript parser on the client side or contact node.js from python directly | Sending python objects to node.js via socket.io | 0 | 1.2 | 1 | 0 | 1 | 347 |
18,570,143 | 2013-09-02T09:46:00.000 | 1 | 0 | 0 | 0 | 1 | python,linux,excel,shell,xlrd | 0 | 18,574,653 | 0 | 2 | 0 | false | 0 | 0 | mv file.{xls,csv}
It's a csv file, stop treating it as an excel file and things will work a lot better. :) There are nice csv manipulation tools available in most languages. Do you really need the excel library? | 1 | 0 | 0 | 0 | I have an excel file whose extension is .xls but his type is Tab Space separated Text.
When I try to open the file by MS Excel it tells me that the extension is fake. And So I have to confirm that I trust the file and so I can read it then.
But my real problem is that when I try to read my file by the xlrd library it gives me this message :
xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record;
And so to resolve this problem, I go to Save as in MS Excel and I change the type manually to .xls.
But my boss insist that I have to do this by code. I have 3 choices : Shell script under Linux, .bat file under Windows or Python.
So, how can I change the type of the excel file from Tab space separated Text to xls file by Shell script (command line), .bat or Python? | How to change automatically the type of the excel file from Tab space separated Text to xls file? | 0 | 0.099668 | 1 | 1 | 0 | 399 |
18,581,973 | 2013-09-02T23:19:00.000 | 1 | 0 | 1 | 1 | 0 | python,coderunner | 0 | 21,959,976 | 0 | 1 | 0 | false | 0 | 0 | Coderunner is more useful in testing single python files instead of larger projects, however it can run such projects. A larger project should have a setup.py or a main.py which should be run. Also, what errors are you getting? | 1 | 1 | 0 | 0 | I'm brand new to coding. I managed to figure out how to use github and I have been forking projects over to my machine in an attempt to play around with them and learn python. My problem is every single project I fork over, when I run any of the .py files in Coderunner it pops up with errors and doesn't run correctly.
Is this because coderunner is not capable of running these programs? Or do I have to run the programs through terminal to get them functioning correctly? | Unable to run any Python program using code runner | 0 | 0.197375 | 1 | 0 | 0 | 605 |
18,596,971 | 2013-09-03T16:16:00.000 | 0 | 0 | 0 | 0 | 1 | python,django,namespaces,setuptools | 1 | 18,644,769 | 0 | 3 | 0 | true | 1 | 0 | The only way I found for now is the following:
Do not use the namespace_packages parameter in setuptools.setup()
Instead, explicitly define "namespace" packages with this in the __init__.py file:
__import__('pkg_resources').declare_namespace(__name__)
I have not done a lot of testings as to if this will work if I don't install my libraries in the same order, but at least, I am able to import my django settings (and everything else).
EDIT
This ended up not being a viable solutions because if librairies are uninstalled and reinstalled, they will delete more than they should, so ending up loosing modules.
I ended up using namespace_packages in setuptools.setup() and use a different first level "namespace" for the running django project.
EDIT 2
Scrap all this, this namespace thing seems to be a good idea, but ended up just being a nightmare with django. So i reverted everything back to non-namespace code. I'm not happy that I have to do this, but that's the price to work with django. | 1 | 2 | 0 | 0 | I was asked to split a big project into some reusable libraries (packages). So the idea was to do this:
company-django-shared
company-django-shared-dev
company-python-shared
company-python-shared-dev
These are installable with setuptools and namespaces:
company
company.packagename
company.packagename.tests
company.util
etc...
All this works fine. I can start a shell and do any of the import i need. The problem arrives when I now want to use this in a django project. My settings are in:
company.foo.settings
At this point, since setuptools installed some packages, when I try to
$ ./manage.py shell
I get the error::
ImportError: Could not import settings 'company.foo.settings' (Is it on sys.path?): No module named foo.settings
I really can't figure out how to use namespace within django apps. If I fire up a shell and do:
import company
company.__path__
The installed paths are found, but not the current directory. What am I missing?
EDIT
I would like to point out that the problem is Python cannot find any package under company because setuptools-installed packages define company as a namespace.
EDIT 2
Django is just unhappy with namespaces. It seems there are no viable solutions. | ImportError: Could not import settings 'company.foo.settings' (Is it on sys.path?): No module named foo.settings | 0 | 1.2 | 1 | 0 | 0 | 1,119 |
18,600,081 | 2013-09-03T19:32:00.000 | 1 | 0 | 0 | 0 | 0 | python,resize,window,pyqt,pyqt4 | 0 | 29,042,473 | 0 | 5 | 0 | false | 0 | 1 | you could set the maximumSize and minimumSize with the same values, it'll get to dissapear maximise button | 1 | 12 | 0 | 0 | I would like to know how to disable the window Maximise button in pyqt4. I am at present using QWidget.setFixedSize (self, QSize) to prevent user window resizing, however the maximise button is still enabled and when pressed causes the application to move to the top left corner of the screen. I am basically wanting to replicate the behaviour of the Windows calculator application, where the maximise icon is greyed out. Does anyone know how to achieve this with PyQt4? | how to disable the window maximize icon using PyQt4? | 0 | 0.039979 | 1 | 0 | 0 | 20,169 |
18,600,435 | 2013-09-03T19:55:00.000 | 3 | 0 | 1 | 0 | 0 | python | 0 | 18,600,585 | 0 | 1 | 0 | false | 0 | 0 | Your best bet (besides Googling for help before posting a question on SO) might be to do something like this:
Note the time when the program starts. start = datetime.datetime.now()
Do your calculations
sleep until 100 seconds after start. (start + datetime.timedelta(seconds=100))
Note that this won't be perfect, since there is a little overhead involved with the steps between accessing the "current time" and going to "sleep" (e.g. subtracting "current time" from "wake-up time"). However, if your sleep precision only needs to be in seconds, you should be okay.
Repeat as needed.
If, after trying it out, you need additional help with the actual implementation of these steps, feel free to come back and post another question on that topic. | 1 | 0 | 0 | 0 | I am new to Python so be gentle.
I have been trying to write a program that counts or measures events in real time. At the moment I am using the sleep command but this pause event doesn't take into account the time the program takes to run. I have read up on the datetime module and can sort of see how this could be used, but I am a bit stuck in implementing this.
In short, I want a program that counts from 0 to 100 in real time seconds and milliseconds. | Real time timer | 0 | 0.53705 | 1 | 0 | 0 | 299 |
18,606,097 | 2013-09-04T05:35:00.000 | 4 | 0 | 1 | 0 | 0 | python,save | 0 | 18,606,314 | 0 | 8 | 0 | false | 0 | 1 | First, don't overthink this. You don't need to use anything complicated. As a preliminary step, research basic file input/output in python.
Second, I'm assuming you have a player class in your game? Or possibly an overall class which keeps track of game state. Well have that class store default values for your variables like health, gold etc. Then have a method which can modify this class like def load_stats(player): or def load_stats(game): something. and have it read in from a save file which can have any format you like and modify the variables of your player/game state.
First test loading of game files and make sure you can get it so that your player class gets modified.
Then all you have to do is add a save game feature that lets you output these variables back to a file in your directory system somewhere.
Try doing this and let me know if you need any help afterwards. | 1 | 5 | 0 | 0 | I am in the process of making a text based game with Python, and I have the general idea down. But I am going to make the game in depth to the point where, it will take longer than one sitting to finish it. So I want to be able to make the game to where, on exit, it will save a list of variables (player health, gold, room place, etc) to a file. Then if the player wants to load the file, they go to the load menu, and it will load the file.
I am currently using version 2.7.5 of Python, and am on Windows. | Python text game: how to make a save feature? | 0 | 0.099668 | 1 | 0 | 0 | 36,232 |
18,624,934 | 2013-09-04T22:35:00.000 | 1 | 0 | 1 | 0 | 0 | vim,python-3.x | 0 | 18,626,135 | 0 | 2 | 0 | false | 0 | 0 | You should put customized settings in to ~/.vim/ftplugin/python.vim This will be sourced when vim sees a file with a filetype python.
To make sure the settings only affect the current buffer use setlocal.
To make sure that mappings only affect the current buffer use noremap <buffer>
Just make sure to have filetype plugin indent on in ~/.vimrc | 1 | 0 | 0 | 0 | I am new to vim and I want to use it for scripting Python3. anyone knows how to customize vim for editing Python 3 scripts? (mainly for indentations, coloring and tab suggestions... )
Thanks | How to Customize vim for scripting in Python 3 ? | 0 | 0.099668 | 1 | 0 | 0 | 1,096 |
18,645,394 | 2013-09-05T20:30:00.000 | 1 | 0 | 1 | 0 | 0 | python,string | 0 | 18,645,414 | 0 | 4 | 0 | false | 0 | 0 | Enclose the entire string with """ or ''' (you would use ''' if the outermost quotation marks were ") in cases like these to make things simpler.
"""'"['BOS']"'""" | 1 | 0 | 0 | 0 | In Python how would I write the string '"['BOS']"'.
I tried entering "\"['BOS']\"" but this gives the output '"[\'BOS\']"' with added backslashes in front of the '. | Multiple Quotes in String | 0 | 0.049958 | 1 | 0 | 0 | 3,846 |
18,650,551 | 2013-09-06T05:30:00.000 | 1 | 0 | 0 | 0 | 0 | javascript,python,django,client-server,tastypie | 0 | 18,650,699 | 0 | 1 | 0 | true | 1 | 0 | A mobile client doesn't care if the Javascript comes from Django or any other web server. So go ahead and put all your JavaScript and static HTML on another server.
If you want your mobile app to see if the user is logged in, it should make an AJAX call to your Django backend (where the request is authenticated). The data returned should indicate if the session is active (user is logged in).
Another AJAX call can perform the Django logout function. | 1 | 1 | 0 | 0 | I'm using TastyPie and Django to build out my backend for an application that will have browser and mobile (native iOS) clients.
I have been through the TastyPie and Django docs, can authenticate successfully either using the TastyPie resources I set up, or using Djangos built in views. I see a lot of examples on including the CSRF token on the page and grabbing it with your JavaScript, and that works, but I don't understand now to actually determine whether a user is logged in on initial page load (from JavaScript).
Example:
If I want to serve static HTML from a separate, fast web server, and cache my application JavaScript, and only interact with Django through TastyPie views, how do I determine if the user is logged in (and know to render a login form or the app views using JavaScript), and after logout, is there any session information I need to remove from the client browser?
If I were to serve up HTML through Django's template engine, I could render the login form through there appropriately, but that seems not ideal if I want to truly decouple my JavaScript app from Django (and behave like a mobile client).
Edit: I am using Backbone.js, but I don't think that should matter.
UPDATE:
I think I figured it out reading through Django's CSRF documentation again.
If your view is not rendering a template containing the csrf_token template tag, Django might not set the CSRF token cookie. This is common in cases where forms are dynamically added to the page. To address this case, Django provides a view decorator which forces setting of the cookie: ensure_csrf_cookie().
If I do not want to render Django templates, this reads like I can still use the cookie and pull that into my Backbone or jQuery AJAX methods. I'm not sure if TastyPie ensures the cookie will be sent or how to tie into it.
If I use AJAX to logout, will the cookie automatically be removed or does it become invalid? Are these CSRF tokens unique to each user session? I'll have to test some things tomorrow with it. Is it possible to use Django decorators on TastyPie views? | How to properly decouple Django from an AJAX application? | 1 | 1.2 | 1 | 0 | 0 | 275 |
18,706,059 | 2013-09-09T20:01:00.000 | 1 | 0 | 1 | 0 | 0 | ipython-notebook | 0 | 18,712,352 | 0 | 1 | 0 | false | 0 | 0 | We want to support this in metadata at notebook top level, but nobody has taken time to write a proposal for metadata structure, how to edit it, and how to show it.
This would be usefull for view on nbviewer, but also for conversion to LaTeX, and other format. It might just be slightly more complicated that at first thought, as you probably want the Authors to be more that just first name/last name (like a full embeded vcard for example).
If you want to work on that you are welcomed, otherwise in the meantime I suggest adding a simple markdown cell at top with those info.
This should be easy to do on a buch on notebook at once as they are easy parsable json. | 1 | 3 | 0 | 0 | I'd like to pre-pend a simple author and copyright clause the beginning of newly created ipython notebooks. Is this possible? If so how can it be done? | How can I automatically add author and copyright info to newly created ipython notebooks? | 1 | 0.197375 | 1 | 0 | 0 | 1,779 |
18,711,815 | 2013-09-10T06:12:00.000 | 5 | 0 | 0 | 0 | 0 | python,html,plone | 0 | 18,714,130 | 0 | 1 | 0 | true | 1 | 1 | You can create a static text portlet in that context you need it: folder, page. | 1 | 0 | 0 | 0 | Hi want to add text box and label in plone site
but, that plone site does not display text box
how can i create text box in plone site
thanks! | How to create text box in plone site | 0 | 1.2 | 1 | 0 | 0 | 111 |
18,715,563 | 2013-09-10T09:44:00.000 | 2 | 0 | 1 | 0 | 0 | python,text-to-speech | 0 | 21,506,735 | 0 | 1 | 0 | true | 0 | 0 | Yes, neospeech is a language library. By installing it, you can just set the voice of pyttsx and tts Chinese as well. | 1 | 2 | 0 | 0 | I want to know how to text-to-speech Chinese using the python package 'pyttsx'. It seems to need some other modules like neospeech. | How to TTS Chinese using pyttsx | 0 | 1.2 | 1 | 0 | 0 | 2,532 |
18,716,623 | 2013-09-10T10:34:00.000 | 0 | 0 | 0 | 0 | 0 | python,openerp | 0 | 18,716,823 | 0 | 3 | 0 | false | 1 | 0 | In python library are available to export data in pdf and excel
For excel you can use:
1)xlwt
2)Elementtree
For pdf genration :
1)Pypdf
2)Reportlab
are available | 1 | 1 | 0 | 0 | I'm a beginner of openerp 7. i just want to know the details regarding how to generate report in openerp 7 in xls format.
The formats supported in OpenERP report types are : pdf, odt, raw, sxw, etc..
Is there any direct feature that is available in OpenERP 7 regarding printing the report in EXCEL format(XLS) | How to print report in EXCEL format (XLS) | 0 | 0 | 1 | 1 | 0 | 2,902 |
18,728,883 | 2013-09-10T21:15:00.000 | 3 | 0 | 1 | 0 | 0 | python,latex,ipython-notebook | 0 | 19,784,607 | 0 | 2 | 0 | false | 0 | 0 | You can set the author using
ipython nbconvert --to latex --SphinxTransformer.author='John Doe' file.ipynb | 1 | 3 | 0 | 0 | Using the NB convert with default options ("article") I am not getting a footer with page numbers?
I know nothing about LaTex but a brief look at the tpl files seems to indicate that I should get footers (maybe with page numbers?) The "book" option give nice footers, but is not a great format for other reasons...
I looked at the generated tex file and don't see anything for footers,, I did find that I can replace "unknown author" with my name.. :-)
Any guidence on how to modify either the generated tex file or something else? | IPython Notebook NB convert formatting Footers? | 0 | 0.291313 | 1 | 0 | 0 | 1,224 |
18,742,845 | 2013-09-11T13:39:00.000 | 0 | 0 | 1 | 1 | 0 | python | 0 | 18,743,249 | 0 | 1 | 0 | false | 0 | 0 | subprocess.check_call is used to check the returned value - use subprocess.Popen this returns a process ID, (pid), which can be used after your time limit with pid.terminate() to end the process, (kill it). | 1 | 0 | 0 | 0 | I am using "subprocess" to execute a .exe file from a Python script. I need to do this in a loop, ie start the .exe, run it for a minute, kill it, do it all over again.
I am using subprocess.check_call to execute it with arguments, but I don't know how to stop it. | In Python, how do I execute a .exe file, and stop it after n seconds? | 0 | 0 | 1 | 0 | 0 | 1,986 |
18,745,757 | 2013-09-11T15:46:00.000 | 2 | 0 | 1 | 0 | 0 | python,python-3.x | 0 | 18,745,877 | 0 | 3 | 0 | false | 0 | 0 | One method is printing the backspace escape character (\b), which will will move the text cursor one character back; however, it is your responsibility to print something afterward to replace the text.
For example, if the current text in the terminal is Time left: 4 and you print "\b", the user will see nothing has changed. However, if you print "\b5", it will replace it with 5. | 1 | 0 | 0 | 0 | Ok, I ask this question on behalf of someone else but I would also like to know if and how it is possible.
Let's say you have a given line of code producing the string
Time left: 4
Is there any way how I can then after this string has been printed edit the value of the "4" and change it to a "3" and then reprint the new string on the same line so Time left: 4 is replaced with Time left: 3 without causing a new line to be printed.
I hope you understand the question I did my best to explain it. | How to alter a string after it has been printed | 1 | 0.132549 | 1 | 0 | 0 | 131 |
18,748,060 | 2013-09-11T17:54:00.000 | 1 | 0 | 1 | 1 | 0 | python,macos,pip | 0 | 18,748,089 | 0 | 2 | 0 | true | 0 | 0 | Honestly, one way around this is to make sure that virtualenv works with the right version, and just use pip inside the virtualenv. | 1 | 1 | 0 | 0 | I went thought and installed pip and then added a bunch of libraries that I like to use and then, only after installing everything, did I realize that everything went into the 2.7.2 sit-packages directory, so the Python2.7.5 version doesn't see anything.
Now, If I type python --version in the terminal, the correct version is started. However, pip is still "tied" to the default version of Python.
How do I go about telling OSX to look at the new version of Python for everything? | noob, but I installed python 2.7.5 on my mac, how to I "target" that one rather than the built in 2.7.2? | 0 | 1.2 | 1 | 0 | 0 | 257 |
18,754,202 | 2013-09-12T02:08:00.000 | 2 | 0 | 0 | 1 | 1 | python,google-app-engine,python-2.7,server-error | 1 | 18,774,464 | 0 | 3 | 0 | false | 1 | 0 | I'm not sure if this is your formatting when you loaded your code here, but where you define app in main.py should not be part of the contacts class. If it is, your reference to main.app in your app.yaml won't work and your page won't load. | 3 | 0 | 0 | 0 | I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic "template" I downloaded from a website was old and used Python 2.5.
So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard).
I have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong.
I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong? | Upgrading to Python 2.7 Google App Engine 500 server error | 0 | 0.132549 | 1 | 0 | 0 | 198 |
18,754,202 | 2013-09-12T02:08:00.000 | 0 | 0 | 0 | 1 | 1 | python,google-app-engine,python-2.7,server-error | 1 | 18,778,368 | 0 | 3 | 0 | true | 1 | 0 | Thank you everyone for your respective answers and comments, but I recently stumbled upon GAE boilerplate and decided to use that and everything's fine. I kept having very odd problems with GAE beforehand, but the boilerplate is simple and seems to be working fine so far. Anyways, thanks again. (Note: I would delete the question but two people have already answered and received rep from +1s, and they are in fact helpful answers, so I'll leave it be). | 3 | 0 | 0 | 0 | I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic "template" I downloaded from a website was old and used Python 2.5.
So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard).
I have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong.
I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong? | Upgrading to Python 2.7 Google App Engine 500 server error | 0 | 1.2 | 1 | 0 | 0 | 198 |
18,754,202 | 2013-09-12T02:08:00.000 | 2 | 0 | 0 | 1 | 1 | python,google-app-engine,python-2.7,server-error | 1 | 18,754,606 | 0 | 3 | 0 | false | 1 | 0 | I'm submitting as an answer because I'm relatively new to SO and don't have enough rep to comment, so sorry about that... But line 7 of your new main.py uses webapp instead of webapp2, so that may be causing some troubles, but likely isn't the reason that it's not working. Could you also provide the contact.html template? | 3 | 0 | 0 | 0 | I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic "template" I downloaded from a website was old and used Python 2.5.
So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard).
I have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong.
I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong? | Upgrading to Python 2.7 Google App Engine 500 server error | 0 | 0.132549 | 1 | 0 | 0 | 198 |
18,755,024 | 2013-09-12T03:49:00.000 | 0 | 0 | 0 | 0 | 0 | python,django,list | 0 | 18,755,121 | 0 | 1 | 0 | false | 1 | 0 | If you have at least one entry in search_fields and therefore are showing a search box on your admin changelist page, if you have any filters or search terms in effect you should see information to the right of it showing the number of rows that match your current filter and search criteria. It'll be worded as something like "5 results (50 total)". The "50 total" text will be a link to an unfiltered version of the list, showing the whole set. Possibly paginated, but all filters will be cleared.
This doesn't appear to be automatically exposed without the search box. The filter settings are simple arguments in the URL querystring, so it should be easy to add a link similar to the one in the search box that just drops the querystring, but you'd have to learn a little about the admin templates to do so. Setting a search_fields entry is probably simpler, if you have anything reasonable to search over. | 1 | 3 | 0 | 0 | I have a Django admin control panel and in each list of objects there are lots and lots of list filters. I want to be able to clear all the filters with a click of a button, but can't find where this ability is, if it already exists in Django.
Routes I'm considering (but cannot figure out):
Make the last item in the breadcrumb link to the full list
Make a direct hyperlink as a filter list option
Find some way to access all the query options and remove them or simply return a blank one (queryset.all() isn't working; I'm probably barking up the wrong tree.)
That kind of thing should already exist! Find out how to use it.
Does anybody know how to accomplish this? I've been trying to figure it out all day. | Django Clear All Admin List Filters | 0 | 0 | 1 | 0 | 0 | 1,347 |
18,755,831 | 2013-09-12T05:13:00.000 | 2 | 0 | 1 | 1 | 0 | python,newline,configparser | 0 | 18,756,706 | 0 | 1 | 1 | true | 0 | 0 | You're fine, ConfigParser will still work.
The reason is that is uses fp.readline, which reads up to and including the next LF (\n). The value is then stripped of whitespace, which removes the CR (\r).
I'd say just use LF (\n) as your line separator - it will work on both systems, but using both won't cause any harm either.
Edit: In fact, if you generate a file using ConfigParser.RawConfigParser it will use \n as the line separator. | 1 | 1 | 0 | 0 | Does anyone know how Python deals with ConfigParser line endings in the different OSes? Because it follows the Windows INI format. But what about Linux?
(As you know, Windows text line endings are typically CRLF, and Unix's are CR.)
I want users of my app to take their config files (.INI files) easily from Windows to Linux and I'd like to know if that's going to be problematic.
If it does use different line endings for Unix and Windows, what do you recommend? | Python's ConfigParser: Cross platform line endings? | 1 | 1.2 | 1 | 0 | 0 | 1,432 |
18,761,985 | 2013-09-12T10:39:00.000 | 0 | 0 | 1 | 1 | 1 | python,pyinstaller | 1 | 18,767,999 | 0 | 1 | 0 | true | 0 | 0 | Looks like os.system('sudo useradd user') solved the issue. | 1 | 0 | 0 | 0 | I have a python script which adds a user using the command os.system('useradd user'). This code works fine when run like a python script like this sudo python script.py. However, once I convert it to executable with pyinstaller with the command python pyinstaller.py --onefile script.py, and run the executable like this sudo ./script, I get an error useradd: error while loading shared libraries: libselinux.so.1: failed to map segment from shared object: Permission denied. Any idea what is the issue and how to fix? | After converting python script to executable with pyinstaller I get: error while loading shared libraries... Permission denied | 0 | 1.2 | 1 | 0 | 0 | 550 |
18,773,414 | 2013-09-12T20:05:00.000 | 4 | 0 | 1 | 0 | 0 | python-3.x,pyscripter | 0 | 18,924,536 | 0 | 1 | 0 | false | 0 | 0 | In PyScripter 2.5.3 right mouse click on interpreter window and to choose in a pop-up menu 'interpreter editor option'. | 1 | 3 | 0 | 0 | I am using PyScripter as IDE for Python.
Python version 3.3.2 64 bit version.
Python interpreter in scripter is very small for visualisation.
Can anybody please help me how to increase the font of python interpreter in PyScripter? | About font of python interpreter in PyScripter | 0 | 0.664037 | 1 | 0 | 0 | 776 |
18,778,266 | 2013-09-13T04:21:00.000 | 0 | 0 | 1 | 0 | 0 | python,image,matplotlib | 0 | 18,778,542 | 0 | 2 | 0 | false | 0 | 0 | If you simply need arrows pointing up and down, use Unicode arrows like "↑" and "↓". This would be really simple if rendering in a browser. | 1 | 0 | 1 | 0 | I need to make a very simple image that will illustrate a cash flow diagram based on user input. Basically, I just need to make an axis and some arrows facing up and down and proportional to the value of the cash flow. I would like to know how to do this with matplot. | Cash flow diagram in python | 0 | 0 | 1 | 0 | 0 | 875 |
18,780,590 | 2013-09-13T07:24:00.000 | 1 | 0 | 1 | 0 | 0 | python,performance,algorithm,caching | 0 | 18,780,954 | 0 | 3 | 1 | false | 0 | 0 | Only experiments will tell you which is better.
Here's another simple idea to consider: link all the keys in a linked list in order of arrival. Each time you retrieve a key, iterate from the beginning of the list and remove all expired items, from both the list and the dictionary. | 2 | 3 | 0 | 0 | I need simple cache structure (in python, but it doesn't really matter), with some specific requirements:
Up to several millions of small objects (100 bytes on average)
Speed is the key (both put and get), I'd expect operation times at about few microseconds
Only one thread accessing this - so it can be all just in memory (do not need persistence)
Keys are MD5 hashes (if it matters)
There's an expiration time, global for the cache - every key should be removed from the cache after expiration time, counting from the time of first put
Now, the point is how to implement expiration - as everything other can be done using simple dictionary. The simplest solution - to iterate all data regularly and remove expired keys - could lock whole cache for too long. It could be improved by iterating parts of the data with every cleanup process - but still it will take some time (or won't clean it fast enough). Also removing keys one by one looks like the waste of CPU - as they could be removed in batches (don't have to be removed just after expiration - we can afford some extra RAM for keeping expired keys a little bit longer).
Checking keys during the retrieve is not enough (although it should be done nevertheless, to not return expired keys) - as many keys can be never retrieved and then they will stay forever (or just too long).
Most answers for that problem suggest using memcached, but I think this will be waste of CPU, especially as I keep objects which can be put to the dictionary by the reference, but using memcached they would have to be (de)serialized.
I have some idea how to implement this: split data into time slices, having actually several dictionaries - for example, if expire time is 60 seconds, then we have (at most) 4 dictonaries and every 20 seconds we add new one - where new keys are put, and remove the 4th one - where we'll have keys added over 60 seconds ago. This makes cleaning very fast at the cost of retrieve time, where you need to lookup in 4 dictionaries instead of one (and RAM usage increased by 33%).
So finally the question - which is: is there any better solution? Or maybe I'm wrong and some of mentioned solutions (removing keys one by one) would be better and faster? I don't want to reinvent the wheel, but didn't find any good solution in the net. | Optimal algorithm for cache with expire | 1 | 0.066568 | 1 | 0 | 0 | 1,205 |
18,780,590 | 2013-09-13T07:24:00.000 | 0 | 0 | 1 | 0 | 0 | python,performance,algorithm,caching | 0 | 18,781,248 | 0 | 3 | 1 | false | 0 | 0 | One implementation of a hashtable is to store a list of (key, value) for each hash value. You can extend this to storing a list of (key, insertion time, value) for each hash value. On both get and set, you can throw away expired items as you scan for the key you're interested in.
Yes, it may leave expired items in the hashtable for arbitrarily long, but only O(N) items on average, where N is the size of your hash table.
Good properties of this approach are that there's no concurrent cleanup going on, and the overhead is more or less constant.
You'll have to code this in C rather than Python if you care about speed. | 2 | 3 | 0 | 0 | I need simple cache structure (in python, but it doesn't really matter), with some specific requirements:
Up to several millions of small objects (100 bytes on average)
Speed is the key (both put and get), I'd expect operation times at about few microseconds
Only one thread accessing this - so it can be all just in memory (do not need persistence)
Keys are MD5 hashes (if it matters)
There's an expiration time, global for the cache - every key should be removed from the cache after expiration time, counting from the time of first put
Now, the point is how to implement expiration - as everything other can be done using simple dictionary. The simplest solution - to iterate all data regularly and remove expired keys - could lock whole cache for too long. It could be improved by iterating parts of the data with every cleanup process - but still it will take some time (or won't clean it fast enough). Also removing keys one by one looks like the waste of CPU - as they could be removed in batches (don't have to be removed just after expiration - we can afford some extra RAM for keeping expired keys a little bit longer).
Checking keys during the retrieve is not enough (although it should be done nevertheless, to not return expired keys) - as many keys can be never retrieved and then they will stay forever (or just too long).
Most answers for that problem suggest using memcached, but I think this will be waste of CPU, especially as I keep objects which can be put to the dictionary by the reference, but using memcached they would have to be (de)serialized.
I have some idea how to implement this: split data into time slices, having actually several dictionaries - for example, if expire time is 60 seconds, then we have (at most) 4 dictonaries and every 20 seconds we add new one - where new keys are put, and remove the 4th one - where we'll have keys added over 60 seconds ago. This makes cleaning very fast at the cost of retrieve time, where you need to lookup in 4 dictionaries instead of one (and RAM usage increased by 33%).
So finally the question - which is: is there any better solution? Or maybe I'm wrong and some of mentioned solutions (removing keys one by one) would be better and faster? I don't want to reinvent the wheel, but didn't find any good solution in the net. | Optimal algorithm for cache with expire | 1 | 0 | 1 | 0 | 0 | 1,205 |
18,783,390 | 2013-09-13T09:56:00.000 | -3 | 0 | 1 | 1 | 0 | python,shared-libraries,pip,include-path,pyodbc | 0 | 18,847,849 | 0 | 7 | 0 | false | 0 | 0 | Just in case it's of help to somebody, I still could not find a way to do it through pip, so ended up simply downloading the package and doing through its 'setup.py'. Also switched to what seems an easier to install API called 'pymssql'. | 1 | 88 | 0 | 0 | I am using pip and trying to install a python module called pyodbc which has some dependencies on non-python libraries like unixodbc-dev, unixodbc-bin, unixodbc. I cannot install these dependencies system wide at the moment, as I am only playing, so I have installed them in a non-standard location. How do I tell pip where to look for these dependencies ? More exactly, how do I pass information through pip of include dirs (gcc -I) and library dirs (gcc -L -l) to be used when building the pyodbc extension ? | python pip specify a library directory and an include directory | 0 | -0.085505 | 1 | 0 | 0 | 69,488 |
18,790,301 | 2013-09-13T15:43:00.000 | 1 | 0 | 1 | 0 | 0 | python,django | 0 | 18,794,763 | 0 | 2 | 0 | false | 1 | 0 | You could add a model (with a db table) that stores values for a, b and x. Then for each query, you could look for an instance with a and b and return the associated x. | 2 | 0 | 0 | 0 | I am writing an API which returns json according to queries. For example: localhost/api/query?a=1&b=2. To return the json, I need to do some pre-calculations to calculate a value, say, x. The pre-calculation takes long time (several hundred milliseconds). For example, The json file returns the value of x+a+b.
When the user query localhost/api/query?a=3&b=4, x will be calculate again and this is a waste of time since x won't change for any query. The question is how can I do this pre-calculation of x for all queries (In the real app, x is not a value but a complex object returned by wrapped C++ code). | How to avoid repeated pre-calculation in django view | 0 | 0.099668 | 1 | 0 | 0 | 161 |
18,790,301 | 2013-09-13T15:43:00.000 | 2 | 0 | 1 | 0 | 0 | python,django | 0 | 18,790,769 | 0 | 2 | 0 | false | 1 | 0 | If you are using some sort of cache (memcached, redis) you can store it there. You can try to serialize the object with pickle, msgpack etc. That you can retrieve and deserialze it. | 2 | 0 | 0 | 0 | I am writing an API which returns json according to queries. For example: localhost/api/query?a=1&b=2. To return the json, I need to do some pre-calculations to calculate a value, say, x. The pre-calculation takes long time (several hundred milliseconds). For example, The json file returns the value of x+a+b.
When the user query localhost/api/query?a=3&b=4, x will be calculate again and this is a waste of time since x won't change for any query. The question is how can I do this pre-calculation of x for all queries (In the real app, x is not a value but a complex object returned by wrapped C++ code). | How to avoid repeated pre-calculation in django view | 0 | 0.197375 | 1 | 0 | 0 | 161 |
18,799,033 | 2013-09-14T06:29:00.000 | 0 | 0 | 0 | 0 | 0 | python,flash,selenium,webdriver | 0 | 18,804,048 | 0 | 1 | 0 | false | 0 | 0 | Use flashselenium or sikuli for flash object testing. | 1 | 0 | 0 | 0 | After trying to find some help on the internet related to flash testing through selenium, all I find is FlexUISelenium package available for Selenium RC. I DO NOT find any such package available for Selenium Webdriver.
I am working with python and selenium webdriver and I do not see any packages available to automate flash applications. Is there any such package available at all for webdriver? If not, how do I start automating a flash application in webdriver? | How to perform flash object testing in selenium webdriver with python? | 0 | 0 | 1 | 0 | 1 | 2,568 |
18,799,714 | 2013-09-14T08:11:00.000 | 0 | 0 | 1 | 0 | 0 | python,python-idle | 0 | 18,799,741 | 0 | 2 | 0 | false | 0 | 0 | To check if something, you use a conditional clause (if/elif/else)
To check what letters are used in a string, you can use a set. For example, if the input is BANANA, you can do set("BANANA") to create a set of unique values ({"B", "A", "N"})
To check if certain letters are in the set, you can use the all() function. all(letter in the_set for letter in ['B', 'A', 'N']. Or, you can just compare one set to another (eg {'A', 'B', 'C'} == set('abbcacabacacba')
Finally, if the above conditional is True, then return True
Now have a go at writing some code. If you're having trouble, feel free to create another question supplying what you have tried and what errors occur/what the problem is. | 1 | 1 | 0 | 0 | Can somebody pls help me on how to write the code to check if few given letters are part of the string entered. the output must be true if the letters are present or false.
For example: Return True if and only if the name is valid (that is, it contains no characters other than 'B' 'A' 'N') if the word entered is BANANA.
Pls help me with the code. | How to if few letters are part of the string entered? | 0 | 0 | 1 | 0 | 0 | 63 |
18,805,720 | 2013-09-14T19:42:00.000 | 1 | 0 | 1 | 0 | 0 | python | 0 | 18,805,746 | 0 | 3 | 0 | false | 0 | 0 | To stay in Python afterwards you could just type 'python' on the command prompt, then run your code from inside python. That way you'll be able to manipulate the objects (lists, dictionaries, etc) as you wish. | 1 | 2 | 0 | 0 | All I know how to do is type "python foo.py" in dos; the program runs but then exits python back to dos. Is there a way to run foo.py from within python? Or to stay in python after running? I want to do this to help debug, so that I may look at variables used in foo.py
(Thanks from a newbie) | How do I run a scipt from within Python on windows/dos? | 0 | 0.066568 | 1 | 0 | 0 | 83 |
18,818,634 | 2013-09-15T23:45:00.000 | 1 | 0 | 0 | 0 | 0 | python,sql,postgresql,sqlalchemy | 0 | 18,818,835 | 0 | 2 | 0 | false | 0 | 0 | I'm not sure about the SQLalchemy part, but as far as the SQL queries I would do it in two steps:
Get the times. For example, something like.
SELECT DISTINCT valid_time FROM MyTable LIMIT 3 ORDER BY valid_time DESC;
Get the rows with those times, using the previous step as a subquery:
SELECT * FROM MyTable WHERE valid_time IN (SELECT DISTINCT valid_time FROM MyTable LIMIT 3 ORDER BY valid_time DESC); | 1 | 0 | 0 | 0 | I have a postgres DB in which most of the tables have a column 'valid_time' indicating when the data in that row is intended to represent and an 'analysis_time' column, indicating when the estimate was made (this might be the same or a later time than the valid time in the case of a measurement or an earlier time in the case of a forecast). Typically there are multiple analysis times for each valid time, corresponding to different measurements (if you wait a bit, more data is available for a given time, so the analysis is better but the measurment is less prompt) and forecasts with different lead times.
I am using SQLalchemy to access this DB in Python.
What I would like to do is be able to pull out all rows with the most recent N unique datetimes of a specified column. For instance I might want the 3 most recent unique valid times, but this will typically be more than 3 rows, because there will be multiple analysis times for each of those 3 valid times.
I am new to relational databases. In a sense there are two parts to this question; how can this be achieved in bare SQL and then how to translate that to the SQLalchemy ORM? | Selecting the rows with the N most recent unique values of a datetime | 0 | 0.099668 | 1 | 1 | 0 | 144 |
18,827,905 | 2013-09-16T12:20:00.000 | 0 | 0 | 0 | 0 | 0 | python,django | 0 | 18,838,114 | 0 | 2 | 0 | false | 1 | 0 | If you're not looking for single sign-on, then likely you want to either do the work in the view, and if you need the session to persist, store it in the (local django) session object; or outsource it to something like celery, and again, keep anything you need to keep track of in the session object. | 1 | 0 | 0 | 0 | I'm developing a backend in Django and I need to log in to another server backend with a simple POST method. So I would need to create a session object or something like that to handle that login.
Any Ideas on how to do that? | create a session to another site | 0 | 0 | 1 | 0 | 0 | 61 |
18,836,983 | 2013-09-16T20:44:00.000 | 0 | 0 | 0 | 0 | 0 | python,skype4py | 0 | 20,256,552 | 0 | 1 | 0 | false | 0 | 0 | I do not want to give you all the answer so that you can improve your coding skills but I will give you some clues:
1)Use boolean values for being activated and deactivated
2)Set a command that activates and deactivates
3) set a value that if reaceived or sent chat and true/false then reply.
Gave you a lot of clues! Good look!. | 1 | 2 | 0 | 0 | I would like to be able to read messages from a specific user in skype using skype4py then send an automated response based upon the message back to the skype chat window. That way a user could message me and get an automated response saying that I'm currently busy or whatever. I really just need to know how to read and send skype chat using skype4py in python. Thanks for your time. | Using python and skype4py to receive and send chat | 0 | 0 | 1 | 0 | 1 | 2,426 |
18,846,024 | 2013-09-17T09:25:00.000 | 6 | 0 | 0 | 0 | 0 | python,logging | 0 | 18,846,310 | 0 | 7 | 1 | true | 0 | 0 | As you are only reading values, logging._levelNames looks an appropriate solution to me. Keep going with logging.addLevelName for setting new values though. | 1 | 10 | 0 | 0 | In my application, I'm using python.logging for logging.
Now I want to control the loglevel interactively, so i created a combobox hat lets the user select "ERROR", "WARN", "INFO",...
What I don't really like is that currently the values in the combobox are hardcoded.
Instead,Ii would like to have a list of all "named" loglevels (e.g. both the system defaults, but also those added via logging.addLevelName; but not the fake generated loglevels like "Level 42")
The best I have come up with so far is to use the logging._levelNames dictionary.
But then this seems to be a private member, and I somehow have a bad feeling accessing it directly.
So my question is: what's the proper way to list all currently defined "named" loglevels in Python. | get list of named loglevels | 0 | 1.2 | 1 | 0 | 0 | 5,759 |
18,863,293 | 2013-09-18T03:18:00.000 | 0 | 0 | 0 | 0 | 0 | python,django,git,web-deployment | 0 | 18,863,822 | 0 | 1 | 0 | false | 1 | 0 | As a Django developer i can assure you that it grows on you and becomes easier to understand the development environment.
You should remember that settings.py is probably going to be where your thoughts will be for quite a while in the start; the good part is that its only once, after you got it up and running you'll only touch settings.py to add new modules or change some configuration but its unlikely.
I believe there are hosts that integrate with git so that should not be a problem since you will probably just git clone your project's url into the host (and not forget to enable/configure wsgi)
To leave the settings.py out of the mess, you will tell git not to track the file with: git rm file; and then when you add your files for commit you do it with git add -u so it refers only to your tracked files.
I'm not sure if i was clear enough. (probably not) But, i hope i could help you in some way. | 1 | 1 | 0 | 0 | I'm a freelance editor and tutor as well as a fiction writer and artist looking to transition to the latter on a full-time basis. Naturally, part of that transition involves constructing a website; a dynamic site to which new content in various forms can be added with ease. Now, I've always intended to learn how to program, and I simply haven't the money to hire someone else to do it. So, having had a good experience with my brief dabblings in Python, I decided I'd go with Django for building my site.
I set up a Fedora Virtualbox for a development environment (as I didn't want to jump through hoops to make Windows work) and went to town on some Django tutorials. Everything went swimmingly until life intervened and I didn't touch the project for three weeks. I'm in a position to return to it now, but I've realized two things in the process. First, I'm having to do a fair bit of retracing of my steps just to find where certain files are, and second, I don't know how I'd go about deploying the site after I'm done building it. My intention is to get the cheapest Linode and host off that until some theoretical point in the future where I required more.
I suspect that re: the file organization issue, that's just something I'll become more familiar with over time, though if there are any tricks I should be aware of to simplify the structure of my overall Django development space, I'm eager to know them. However, what about deployment? How viable is it to, with sufficient knowledge, automate the process of pushing the whole file structure of a site with Git? And how can I do that in such a way that it doesn't tamper with the settings of my development environment? | Simplifying development process for Django | 0 | 0 | 1 | 0 | 0 | 121 |
18,867,280 | 2013-09-18T08:25:00.000 | 2 | 1 | 0 | 0 | 1 | python,unit-testing,jenkins,pytest | 0 | 18,894,932 | 0 | 2 | 0 | false | 1 | 0 | I solved it using this line as the first line of the test:
pytest.skip("Bug 1234: This does not work")
I'd rather have used one of the pytest decorators, but this'll do. | 1 | 1 | 0 | 0 | I have a minor issue using py.test for my unit tests.
I use py.test to run my tests and output a junitxml report of the tests.
This xml report is imported in jenkins and generates nice statistics.
When I use a test class which derives from unittest.TestCase,
I skip expected failures using:
@unittest.skip("Bug 1234 : This does not work")
This message also shows up in jenkins when selecting this test.
When I don't use a unittest.TestCase class, e.g. to use py.test parametrize functionality,
I skip expected failures using:
@pytest.mark.xfail(reason="Bug 1234 : This does not work", run=False)
But then this reason is not actually displayed in jenkins, instead it will say:
Skip Message
expected test failure
How can I fix this? | Py.test skip messages don't show in jenkins | 0 | 0.197375 | 1 | 0 | 0 | 1,231 |
18,882,510 | 2013-09-18T21:17:00.000 | 1 | 0 | 1 | 0 | 0 | ipython,ipython-notebook | 0 | 35,315,482 | 0 | 1 | 0 | false | 0 | 0 | When I have a long noetbook, I create functions from my code, and hide it into python modules, which I then import in the notebook.
So that I can have huge chunk of code hidden on the background, and my notebook smaller for handier manipulation. | 1 | 6 | 1 | 0 | I have some very large IPython (1.0) notebooks, which I find very unhandy to work with. I want to split the large notebook into several smaller ones, each covering a specific part of my analysis. However, the notebooks need to share data and (unpickleable) objects.
Now, I want these notebooks to connect to the same kernel. How do I do this? How can I change the kernel to which a notebook is connected? (And any ideas how to automate this step?)
I don't want to use the parallel computing mechanism (which would be a trivial solution), because it would add much code overhead in my case. | How to share Ipython notebook kernels? | 0 | 0.197375 | 1 | 0 | 0 | 1,689 |
18,886,383 | 2013-09-19T04:49:00.000 | 0 | 0 | 0 | 0 | 0 | python | 0 | 18,897,337 | 0 | 1 | 0 | false | 0 | 0 | cat dataset.csv dataset.csv dataset.csv dataset.csv > bigdata.csv | 1 | 0 | 1 | 0 | In wakari, how do I download a CSV file and create a new CSV file with each of the rows in the original file repeated N number of times in the new CSV file. | Repeat rows in files in wakari | 0 | 0 | 1 | 0 | 0 | 61 |
18,910,200 | 2013-09-20T06:26:00.000 | 0 | 0 | 0 | 0 | 1 | python,nlp | 0 | 18,910,584 | 0 | 1 | 0 | false | 0 | 0 | Try xlrd Python Module to read and process excel sheets.
I think an appropriate implementation using this module is an easy way to solve your problem. | 1 | 0 | 1 | 0 | to provide some context: Issues in an application are logged in an excel sheet and one of the columns in that sheet contains the email communication between the user (who had raised the issue) and the resolve team member. There are bunch of other columns containing other useful information. My job is to find useful insights from this data for Business.
Find out what type of issue was that? e.g. was that a training issue for the user or access issue etc. This would mean that I analyze the mail text and figure out by some means the type of issue.
How many email conversations have happened for one issue?
Is it a repeat issue?
There are other simple statistical problems e.g. How many issues per week etc...
I read that NLP with Python can be solution to my problems. I also looked at Rapidminer for the same.
Now my Question is
a. "Am I on the right track?, Is NLP(Natural Language Processing) the solution to these problems?"
b. If yes, then how to start.. I have started reading book on NLP with Python, but that is huge, any specific areas that I should concentrate on and can start my analysis?
c. How is Rapidminer tool? Can it answer all of these questions? The data volume is not too huge (may be 100000 rows)... looks like it is quite easy to build a process in rapidminer, hence started on it...
Appreciate any suggestions!!! | Analyze Text to find patterns and useful information | 0 | 0 | 1 | 0 | 0 | 637 |
18,934,509 | 2013-09-21T15:43:00.000 | 2 | 0 | 0 | 0 | 0 | python,django,date | 0 | 18,934,550 | 0 | 1 | 0 | true | 1 | 0 | I would do it in django. Have two DateFields in your model, both that could be blank and null. On the first time someone views your page (with both dates unset), create a view for the template request that sets the one of the DateFields to today = datetime.date.today() and the other to today + datetime.timedelta(8) to be 8 days after the current date. Save your updated model and then display that model in the template. | 1 | 0 | 0 | 0 | I Need to put an expiration date in a template, it show the current date and the expiration date will be 8 days from current date.
Can someone tell me how can I do it? Is possible do it with Django or do I have to do it whit maybe Jquery or JavaScript?
And I need to send it to my database too, not just display it in the template. | Sum 7 days after current date in Django | 0 | 1.2 | 1 | 0 | 0 | 1,338 |
18,938,619 | 2013-09-21T23:09:00.000 | 1 | 0 | 1 | 0 | 1 | python,string,eof | 0 | 18,938,639 | 0 | 1 | 0 | true | 0 | 0 | AFAIK, CPython keeps track of the length and start of the string. As of CPython 3.3 it also keeps track of how many bytes per character in order to compress strings that can fit into subsets of the Unicode spectrum, such as Latin-1 strings. | 1 | 1 | 0 | 0 | I know python has inbuilt string support. But what I would like to know is how it handles the end of string construct. C has '\0' character to signify end of string. How does python do it? It would be great if someone could tell me how it works in the cpython source code. | How does python find the end of string? | 0 | 1.2 | 1 | 0 | 0 | 1,206 |
18,968,569 | 2013-09-23T20:49:00.000 | 0 | 0 | 0 | 0 | 0 | python,html,code-coverage,python-sphinx,nose | 0 | 43,797,423 | 0 | 1 | 0 | false | 1 | 0 | I have a similar problem and I could solve it by doing the following. Note this is just for the HTML output.
Create an index.rst field with just the following:
======================
Javadoc of the API XXX
======================
As I am using the extension "sphinx.ext.autosectionlabel", this becomes a "level 1" section.
Modify the Make file so, once the HTML is generated, it replaces the index.html of the section "Javadoc of the API XXX" with the Javadoc of my API.
After this change, on the toctree I have a link to "Javadoc of the API XXX" and when you click it, you see the Javadoc.
I know is not the proper way of doing it, but it is the only that I have come up with after many Google searches. | 1 | 4 | 0 | 0 | How do you include html docs generated by other tools such as nose, coverage, and pylint reports into Sphinx documentation. Should they go into the _static directory? and if so, how do you link to them?
I am trying to build a concise package of all of the code development tool documentation into a .pdf or html. | Integrate other html documentation into sphinx docs | 0 | 0 | 1 | 0 | 0 | 310 |
18,972,662 | 2013-09-24T03:49:00.000 | 1 | 0 | 1 | 1 | 1 | python,installation,setup.py | 0 | 18,973,151 | 0 | 1 | 0 | false | 0 | 0 | Instead of using --user, why not use a virtualenv? they are much more flexible, and put its bin directory on the path when activated.
Otherwise, manually putting ~/.local/bin on your PATH, as you did, is what you need to do. | 1 | 1 | 0 | 0 | Say I have a python application that I want to install and if I run python setup.py install --user, everything gets put into ~/.local as expected (on linux), and inside of that the stuff in ~/.local/lib/python2.7/site-packages/
gets seen by the PYTHONPATH as expected; however, my executables that are created by setup.py (using either entry_points via setuptools or scripts via distutils) are correctly put into ~/.local/bin, but are not seen by the PATH at the command line.
Thus, I have to add $HOME/.local/bin to my PATH (via my .zshrc) to get these executables seen by my environment. I'm assuming this is the expected behaviour, but my question is, is there some way to get my executables "registered" with my PATH when I run the installation with the --user flag during the setup?
I believe this should work, as I see that ipython does something like this, where if it's installed with the --user flag (into ~/.local), then you don't have to add to your path ~/.local/bin to get the local install of ipython seen at the command line. I just can't figure out how ipython does it. Many thanks in advance. | confusion with results of `python setup.py install --user` | 1 | 0.197375 | 1 | 0 | 0 | 2,255 |
18,973,574 | 2013-09-24T05:27:00.000 | 0 | 0 | 1 | 0 | 0 | python,applescript,iphoto | 0 | 18,975,788 | 0 | 4 | 0 | false | 0 | 0 | Simply invoke the system command which iPhoto (assuming that you can run iPhoto from a shell) and parse the output. | 1 | 0 | 0 | 0 | One of my desktop apps I need to know where the iPhoto Library is installed, programmatically. I do not want to pick it from predicted location (/Users/me/Pictures/iPhoto) since power user may have installed it somewhere else.
I'm developing app using Python and I guess Applescript might have way to figure out iPhoto location but I don't know how. | Need to know iPhoto Library location programmatically using Applescript | 0 | 0 | 1 | 0 | 0 | 444 |
18,981,428 | 2013-09-24T12:18:00.000 | 1 | 0 | 0 | 0 | 1 | python,multithreading,python-2.7,pyqt,pyqt4 | 0 | 18,983,482 | 0 | 1 | 0 | false | 0 | 1 | That depends. Your PC is idle 99.9995% of the time while you type; so it has a lot of CPU power to spend on background tasks. Most people don't notice this since the virus scanner typically eats 5-20% of the performance. But typing or clicking a button barely registers in the CPU load.
OTOH, if you run a long task in the UI thread, then the UI locks up until the task is finished. So from a user perspective, the UI will be blocking while for the serial port, the world will be OK. Overall, this will be faster but it will feel sluggish.
Multithreading is generally slower than doing everything in a single thread due to synchronization or locking. But a single thread doesn't scale. Eventually, you hit a brick wall (performance wise) and no trick will make that single thread execute faster. | 1 | 1 | 0 | 0 | My simple Python app uses PyQt4 for its GUI and clicking a QPushButton causes the app to send a message via serial. GUI elements also update frequently.
Question: I did not know how to implement multithreading. Will not having multithreaded process cause the app to be less responsive and less consistent in sending the serial communication especially when a GUI element will be updated at the same time the serial message is being sent? | Is Multi-threading required for PyQt4 and Writing to Serial | 0 | 0.197375 | 1 | 0 | 0 | 105 |
19,012,700 | 2013-09-25T18:40:00.000 | 0 | 0 | 1 | 0 | 0 | python | 0 | 19,013,035 | 0 | 5 | 0 | false | 0 | 0 | When I'm not near my own PC, I use ideone.com. I like that it is a universal IDE, which for me means both C++ and Python. | 2 | 1 | 0 | 0 | I want to teach some students basic Python programming without having to teach them how to use the terminal. Recently, I was teaching a 2 hour intro session, and not only did teaching terminal stuff take a long time, but it also intimidated a lot of the students. I would like a solution where students wouldn't have to leave graphical user interfaces that they were comfortable with.
I also want the solution to let them execute a particular Python file (eg, not just using the interactive Python interpreter) and see the output from printing things.
Thanks! | How to Run Python without a Terminal | 0 | 0 | 1 | 0 | 0 | 289 |
19,012,700 | 2013-09-25T18:40:00.000 | 8 | 0 | 1 | 0 | 0 | python | 0 | 19,012,735 | 0 | 5 | 0 | true | 0 | 0 | Surely that's what IDLE is for? It's not much good as an IDE, but it does work well for exactly what you describe - opening modules and executing them, and running commands in an interactive shell. | 2 | 1 | 0 | 0 | I want to teach some students basic Python programming without having to teach them how to use the terminal. Recently, I was teaching a 2 hour intro session, and not only did teaching terminal stuff take a long time, but it also intimidated a lot of the students. I would like a solution where students wouldn't have to leave graphical user interfaces that they were comfortable with.
I also want the solution to let them execute a particular Python file (eg, not just using the interactive Python interpreter) and see the output from printing things.
Thanks! | How to Run Python without a Terminal | 0 | 1.2 | 1 | 0 | 0 | 289 |
19,031,616 | 2013-09-26T14:54:00.000 | 0 | 0 | 1 | 0 | 0 | python,django,windows,virtualenv | 0 | 19,032,797 | 0 | 2 | 0 | false | 1 | 0 | I once faced the same problem and it took me so much time to configure another environment that I eventually had to create a VM with the same version of OS and libraries. I then made a raw copy of the project and it worked fine. | 1 | 0 | 0 | 0 | I am working on a Django project that was created by another developer on a different machine. I see that in the root of the application, there is a .virtualenv directory. Is it possible to simply setup this project locally on my Windows machine using the project settings and Python version (the app uses 2.7), so that I can run it like a local Django application so debugging is feasible?
I have access to the development web server and have copied the full source of the app down to my Win7 machine but cannot seem to get things setup correctly to run the app locally so I can debug.
I currently have Python 2.7, 2.7.5 and 3.3.2 installed on my local dev machine. I would call myself pretty new to Django and Virtualenv.
If anyone has any guidance on how I can get my environment straitened out so I can run the app with debugging, I would be very thankful.
Thank you in advance. | Importing and debugging a Python Django project made in a different environment | 1 | 0 | 1 | 0 | 0 | 69 |
19,036,197 | 2013-09-26T18:44:00.000 | 1 | 1 | 1 | 0 | 0 | php,python,hash,laravel,laravel-4 | 0 | 19,036,400 | 0 | 1 | 0 | true | 1 | 0 | you cant the best you can do is encrypt it with a reversible encryption ... but then you need to store the key somewhere ... eventually you will have some plain text somewhere (or encoded at best) that will allow decryption ... you could store the hash and do a query against a db that maps hashes to pw's but you still have the password in plaintext somewhere ... you cannot login with just a hash anywhere ... (because the hash ends up getting hashed and then no longer matches the expected hash)
an option may be to use rainbow tables to find something that results in an identical hash and use that instead ... but if they are adding salts or anything you are once again out of luck | 1 | 1 | 0 | 0 | I have a hashed password using the Hash::make() function of laravel when a user is created. I eventually need to take that hashed password, and pass it to a python script to perform a login and download of site resources. I know the hash is a one-way action, but I'd like to keep the password hashed to be security conscious if at all possible.
Any suggestions on how to accomplish this task while keeping security intact would be helpful!
Thanks,
Justin | Laravel 4 passwords and python | 0 | 1.2 | 1 | 0 | 0 | 331 |
19,058,485 | 2013-09-27T19:18:00.000 | 20 | 0 | 0 | 0 | 0 | python,matplotlib | 0 | 28,295,797 | 0 | 2 | 0 | true | 0 | 0 | For the width: legend.get_frame().set_linewidth(w)
For the color: legend.get_frame().set_edgecolor("red") | 1 | 19 | 1 | 0 | In matplotlib, how do I specify the line width and color of a legend frame? | Specifying the line width of the legend frame, in matplotlib | 0 | 1.2 | 1 | 0 | 0 | 13,797 |
19,071,286 | 2013-09-28T20:21:00.000 | 0 | 0 | 0 | 0 | 0 | python,django,web-services,qt | 0 | 19,071,331 | 0 | 1 | 1 | false | 1 | 0 | Django is a good candidate for the website, however:
It is not a good idea to run heavy functionality from a website. it should happen in a separate process.
All functions should be asynchronous, I.E. You should never wait for something to complete.
I would personally recommend writing a separate process with a message queue and the website would only ask that process for statuses and always display a result immediatly to the user
You can use ajax so that the browser will always have the latest result.
ZeroMQ or Celery are useful for implementing the functionality.
You can implement functionality in C pretty easily. I recomment however that you write that functionality as pure c with a SWIG wrapper rather that writing it as an extension module for python. That way the functionality will be portable and not dependent on the python website. | 1 | 0 | 0 | 0 | I have to setup a program which reads in some parameters from a widget/gui, calculates some stuff based on database values and the input, and finally sends some ascii files via ftp to remote servers.
In general, I would suggest a python program to do the tasks. Write a Qt widget as a gui (interactively changing views, putting numbers into tables, setting up check boxes, switching between various layers - never done something as complex in python, but some experience in IDL with event handling etc), set up data classes that have unctions, both to create the ascii files with the given convention, and to send the files via ftp to some remote server.
However, since my company is a bunch of Windows users, each sitting at their personal desktop, installing python and all necessary libraries on each individual machine would be a pain in the ass.
In addition, in a future version the program is supposed to become smart and do some optimization 24/7. Therefore, it makes sense to put it to a server. As I personally rather use Linux, the server is already set up using Ubuntu server.
The idea is now to run my application on the server. But how can the users access and control the program?
The easiest way for everybody to access something like a common control panel would be a browser I guess. I have to make sure only one person at a time is sending signals to the same units at a time, but that should be doable via flags in the database.
After some google-ing, next to QtWebKit, django seems to the first choice for such a task. But...
Can I run a full fledged python program underneath my web application? Is django the right tool to do so?
As mentioned previously, in the (intermediate) future ( ~1 year), we might have to implement some computational expensive tasks. Is it then also possible to utilize C as it is within normal python?
Another question I have is on the development. In order to become productive, we have to advance in small steps. Can I first create regular python classes, which later on can be imported to my web application? (Same question applies for widgets / QT?)
Finally: Is there a better way to go? Any standards, any references? | Python program on server - control via browser | 0 | 0 | 1 | 0 | 0 | 367 |
19,073,579 | 2013-09-29T01:43:00.000 | 1 | 0 | 1 | 0 | 0 | python,subprocess | 0 | 19,075,566 | 0 | 1 | 0 | false | 0 | 0 | The question exactly as you ask it has no general answer. There might be custom ways; e.g. on Linux a lot of things are actually file descriptors, and there are ways to pass them to subprocesses, but it's not nicely Pythonic: you have to give them as numbers on the command line of the subprocess, and then the subprocess rebuilds a file object around the file descriptor (see file.fileno() and os.fdopen() for regular files; I'm not sure there are ways to do it in Python for other things than regular files...).
In your problem, if everything is in Python, why do you need to make subprocesses instead of doing it all in a single process?
If you really need to, then one general way is to use os.fork() instead of the subprocess module: you'd fork the process (which creates two copies of it); in the parent copy you wait for the child copy to terminate; and in the child copy you proceed to run the particular submodule. The advantage is that at the end the child process terminates, which cleans up what it did --- while at the same time starting with its own copy of almost everything that the parent had (file descriptors, database cursors, etc.) | 1 | 2 | 0 | 0 | I've written a large program in Python that calls numerous custom modules' main methods one after another. The parent script creates some common resources, like logging instances, database cursors, and file references which I then pass around to the individual modules. The problem is that I now need to call some of these modules by means of subprocess.check_output, and I don't know how I can share the aforementioned resources across these modules. Is this possible? | Possible to share resources (logging, database, file etc.) across Python subproccesses? | 0 | 0.197375 | 1 | 0 | 0 | 68 |
Subsets and Splits