Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
13,001,913
2012-10-21T20:32:00.000
8
0
1
0
python,hash,dictionary,equality
13,001,967
3
true
0
0
First, __hash__(myNewMyClassObj) gets called. If no object with the same hash is found in the dictionary, Python assumes myNewMyClassObj is not in the dictionary. (Note that Python requires that whenever __eq__ evaluates as equal for two objects, their __hash__ must be identical.) If some objects with the same __hash__...
2
6
0
I have a class (let's call it myClass) that implements both __hash__ and __eq__. I also have a dict that maps myClass objects to some value, computing which takes some time. Over the course of my program, many (in the order of millions) myClass objects are instantiated. This is why I use the dict to keep track of those...
What happens when you call `if key in dict`
1.2
0
0
607
13,002,676
2012-10-21T22:07:00.000
0
0
0
0
python,http,post,upload,cherrypy
26,299,500
2
false
1
0
Huge file uploads always problematic. What would you do when connection closes in the middle of uploading? Use chunked file upload method instead.
1
3
0
I have a cherrypy web server that needs to be able to receive large files over http post. I have something working at the moment, but it fails once the files being sent gets too big (around 200mb). I'm using curl to send test post requests, and when I try to send a file that's too big, curl spits out "The entity sent w...
Python: sending and receiving large files over POST using cherrypy
0
0
1
4,776
13,004,359
2012-10-22T02:38:00.000
6
0
1
0
python,regex
13,004,581
3
true
0
0
If you are after a general solution, your algorithm would need to look something like: Read a chunk of the stream into a buffer. Search for the regexp in the buffer If the pattern matches, do whatever you want with the match, discard the start of the buffer up to match.end() and go to step 2. If the pattern does not m...
2
6
0
Suppose you want to do regular expression search and extract over a pipe, but the pattern may cross multiple lines, How to do it? Maybe a regular expression library work for a stream? I hope do this job using Python library? But any solution will be OK, a library not a cmd line tool of course. BTW, I know how to solve ...
regular expression on stream instead of string?
1.2
0
0
2,524
13,004,359
2012-10-22T02:38:00.000
-2
0
1
0
python,regex
13,004,594
3
false
0
0
I do not believe that it is possible to use a regular expression on a stream, because without an entire piece of data, you cant make a positive match. This means that you would only have a probable match. However, as @James Henstridge stated, you could use buffers to overcome this.
2
6
0
Suppose you want to do regular expression search and extract over a pipe, but the pattern may cross multiple lines, How to do it? Maybe a regular expression library work for a stream? I hope do this job using Python library? But any solution will be OK, a library not a cmd line tool of course. BTW, I know how to solve ...
regular expression on stream instead of string?
-0.132549
0
0
2,524
13,004,789
2012-10-22T03:56:00.000
0
0
0
0
python,mysql,passwords
16,186,975
1
false
0
0
Try to MySQLdb package, you can punctuation in password to connect database through this package.
1
2
0
I cannot get a connection to a MySQL database if my password contains punctuation characters in particular $ or @. I have tried to escape the characters, by doubling the $$ etc. but no joy. I have tried the pymysql library and the _mssql library. the code... self.dbConn = _mysql.connect(host=self.dbDetails['site'], p...
How to connect with passwords that contains characters like "$" or "@"?
0
1
0
432
13,006,151
2012-10-22T06:42:00.000
2
0
0
1
python,django,celery,django-celery
36,787,909
3
false
1
0
I think you are trying to avoid race condition of your own scripts, not asking for a method to delay a task run. Then you can create a task, and in that task, call each of your task with .apply(), not .apply_async() or .delay(). So that these tasks run sequentially
1
18
0
I have a small script that enqueues tasks for processing. This script makes a whole lot of database queries to get the items that should be enqueued. The issue I'm facing is that the celery workers begin picking up the tasks as soon as it is enqueued by the script. This is correct and it is the way celery is supposed t...
How can I defer the execution of Celery tasks?
0.132549
0
0
25,567
13,014,789
2012-10-22T15:35:00.000
0
0
0
0
python,merge,python-3.x,stata
13,016,728
2
false
0
0
Type "help shell" in Stata. What you want to do is shell out from Stata, call Python, and then have Stata resume whatever you want it to do after the Python script has completed.
1
1
1
This is probably very easy, but after looking through documentation and possible examples online for the past several hours I cannot figure it out. I have a large dataset (a spreadsheet) that gets heavily cleaned by a DO file. In the DO file I then want to save certain variables of the cleaned data as a temp .csv run s...
Calling Python from Stata
0
0
0
2,897
13,014,946
2012-10-22T15:44:00.000
0
0
1
0
python,macos,ipython
29,693,294
4
false
0
0
Following trouble in iPython and up-&-down arrows to access history, and browsing this post, a simple solution (turn off "Scroll lock") turned out to work for me.
2
6
0
In my installation of ipython I have this strange problem where I cannot reliably move through command history with up and down arrows... a lot of the time it just doesn't work (nothing happens on the key press). Also sometimes writing normal characters at the end of the command just doesn't work. My system: Mac OSX Li...
ipython up and down arrow strange behaviour
0
0
0
4,181
13,014,946
2012-10-22T15:44:00.000
7
0
1
0
python,macos,ipython
14,385,255
4
false
0
0
Make sure you installed readline before ipython. sudo pip uninstall ipython sudo pip install readline ipython (I know this question is a few months old, but for future reference)
2
6
0
In my installation of ipython I have this strange problem where I cannot reliably move through command history with up and down arrows... a lot of the time it just doesn't work (nothing happens on the key press). Also sometimes writing normal characters at the end of the command just doesn't work. My system: Mac OSX Li...
ipython up and down arrow strange behaviour
1
0
0
4,181
13,015,593
2012-10-22T16:22:00.000
0
0
0
0
python,nltk
15,627,502
2
false
0
0
This is a very late answer, but perhaps it will help someone. What you're asking about is regression. Regarding Jacob's answer, linear regression is only one way to do it. However, I agree with his recommendation of scikit-learn.
1
8
1
In the light of a project I've been playing with Python NLTK and Document Classification and the Naive Bayes classifier. As I understand from the documentation, this works very well if your different documents are tagged with either pos or neg as a label (or more than 2 labels) The documents I'm working with that are ...
NLTK: Document Classification with numeric score instead of labels
0
0
0
1,239
13,017,421
2012-10-22T18:24:00.000
2
0
0
0
python,django
13,017,620
1
false
1
0
I would image that calling sleep() should block the execution of all Django code in most cases. However it might depend on the deployment architecture (e.g. gevent, gunicorn, etc). For instance if you are using a server which fires Django threads for each request, then no it will not block all the code. In most cases h...
1
5
0
In Django, if the view uses a sleep() function while answering a request, does this block the handling of the whole queue of requests? If so, how to delay an http answer without this blocking behavior? Can we do that out-of-the-box and avoid using a job queue like Celeri?
Is sleep() blocking the handling of requests in Django?
0.379949
0
0
1,668
13,018,147
2012-10-22T19:12:00.000
16
0
0
0
python,django,django-socialauth
13,032,929
5
true
1
0
DSA doesn't logout accounts (or flush sessions) at the moment. AuthAlreadyAssociated highlights the scenario where the current user is not associated to the current social account trying to be used. There are a couple solutions that might suite your project: Define a sub-class of social_auth.middleware.SocialAuthExcep...
1
18
0
After I create a user using say Facebook(let's say fbuser) or Google(googleuser). If I create another user through the normal django admin(normaluser), and try logging again using Facebook or Google while third user(normaluser) is logged in, it throws an error exception AuthAlreadyAssociated. Ideally it should throw ...
AuthAlreadyAssociated Exception in Django Social Auth
1.2
0
0
9,224
13,018,157
2012-10-22T19:13:00.000
1
1
0
0
python,macos,mercurial,build-automation
13,667,498
1
true
0
0
You can always check exit-code of used commands hg add (if new, unversioned files appeared in WC) "Returns 0 if all files are successfully added": non-zero means "some troubles here, not all files added" hg commit "Returns 0 on success, 1 if nothing changed": 1 means "no commit, nothing to push" hg push "Returns 0 if ...
1
1
0
What I would like it is to run a script that automatically checks for new assets (files that aren't code) that have been submitted to a specific directory, and then every so often automatically commit those files and push them. I could make a script that does this through the command line, but I was mostly curious if m...
Automating commit and push through mercurial from script
1.2
0
0
448
13,018,968
2012-10-22T20:05:00.000
3
0
0
0
python,image-processing
13,019,636
2
false
0
0
You are making this way too hard. I handled this in production code by generating a histogram of the image, throwing away outliers (1 black pixel doesn't mean that the whole image has lots of black; 1 white pixel doesn't imply a bright image), then seeing if the resulting distribution covered a sufficient range of brig...
1
1
1
I want an algorithm to detect if an image is of high professional quality or is done with poor contrast, low lighting etc. How do I go about designing such an algorithm. I feel that it is feasible, since if I press a button in picassa it tries to fix the lighting, contrast and color. Now I have seen that in good pictu...
How to automatically detect if image is of high quality?
0.291313
0
0
3,360
13,021,093
2012-10-22T22:50:00.000
-1
0
1
0
python,regex
13,021,174
3
false
0
0
It means: string /actors, follow by an optional capture group, which contains a literal ., and then one or more of whatever the non-literal . is configured to match.
1
2
0
I am confused about the semantics of the following Python regular expression: r"/actors(\\..+)?" I looked through the Python documentation section on regular expressions, but couldn't make sense of this expression. Can someone help me out?
Python Regular Expression (\..+)?
-0.066568
0
0
484
13,021,375
2012-10-22T23:20:00.000
0
0
0
0
ironpython,web-hosting,shared-hosting
13,024,373
1
false
1
0
IronPython should work in shared hosting environments. I'm assuming they have some sort of partial-trust setup and not a full-trust environment; if it's full-trust, there's no issues. If not, it should still work, but it hasn't been as heavily tested. You have to deploy it with your project (in the bin directory), but ...
1
0
0
Does anyone have experience running IronPython in a shared hosting environment? Am using one hosting company but they don't support it. It's a project mixing ASP.NET MVC 4 with IronPython. I would do a VM somewhere if all else fails, but figured I give this a shot to save a few bucks. #lazystackoverflow Thanks, -rob
Using IronPython at a hosting company
0
0
0
136
13,023,103
2012-10-23T03:21:00.000
1
0
0
0
python,django,apache,mahout
13,696,473
1
false
1
0
I think you could build an independent application with mahout, and you python application is just a client.
1
1
0
I am building the web application in python/django. I need to apply some machine learning algorithms on some data. I know there are libraries available for python. But someone in my company was saying that Mahout is very good toll for that. i want to know that can i use it with python/django. or i should do that with p...
Can i use apache mahout with django application
0.197375
0
0
326
13,024,361
2012-10-23T06:01:00.000
0
0
0
0
python,django,mongodb,django-models,django-nonrel
13,031,452
1
true
1
0
After some deep digging into the Django Models i was able to solve the problem. The save() method inturn call the save_base() method. This method saves the returned results, ids in case of mongo, into self.id. This _id field can then be picked by by over riding the save() method for the model
1
0
0
I am using Django non-rel version with mongodb backends. I am interested in tracking the changes that occur on model instances e.g if someone creates/edits or deletes a model instance. Backend db is mongo hence models have an associated "_id" fields with them in the respective collections/dbs. Now i want to extract thi...
Django-Nonrel(mongo-backend):Model instance modification tracking
1.2
1
0
132
13,025,856
2012-10-23T07:56:00.000
0
0
1
0
java,python,pylucene,jcc
13,026,184
1
false
1
0
you could create a proxy class in Python that calls the Java class. Then on the proxy class you can override whatever you need.
1
0
0
I'm using JCC to create a Python wrapper for a Java library and I need to override a method from a Java class inside the Python script. Is it possible? How can you do that if it is possible?
Overriding a Java class from Python using JCC. Is that possible?
0
0
0
148
13,026,437
2012-10-23T08:35:00.000
0
0
1
0
python,multithreading,concurrency,process,multiprocess
13,026,805
2
false
0
0
There's no official Python API for killing threads -- you need to use an OS-specific method. If you spawn a new process (using multiprocessing.Process) then you can kill it with .terminate(). Of course, this will cause it to stop immediately -- it won't clean up after itself and it may pollute any shared data structure...
1
0
0
In python (2.6.6) what is the best way I can have a thread/process checking a network (message queue) for things while concurrently doing work (compiling). If i receive a command down the message queue, i must be able to kill and spawn compile threads.
Python threading - listen to network while compiling
0
0
0
137
13,027,848
2012-10-23T09:53:00.000
1
0
0
0
django,python-2.7,mod-wsgi,amazon-elastic-beanstalk
14,729,865
4
false
1
0
To get around mod_wsgi limitation, you can deploy your application under your own wsgi container like uWSGI and add configuration to apache to serve as a reverse proxy for your WSGI container. You can use container_commands to place your apache configuration files under /etc/httpd/...
1
6
0
According to the docs, AWS Elastic Beanstalk supports Python 2.6. I wonder if anyone has set up a custom AMI using the EBS backed 64 bit Linux AMI to run django under Python 2.7 on the beanstalk? While most aspects of a set up under 2.7 will probably be straightforward using virtualenv or changing the symlinks, I'm wor...
Django running under python 2.7 on AWS Elastic Beanstalk
0.049958
0
0
1,731
13,033,782
2012-10-23T15:18:00.000
1
0
1
0
python,data-structures,python-2.7
13,038,251
2
false
0
0
What is efficient would depend on what you are doing and how often you are doing it. There isn't much information in your question to hazard a guess. For example, it is not clear whether all balls in the same box have the same colour. If that is so, then you could assign the colour to the box rather than to the ball fo...
1
1
0
Here's the problem I'm trying to solve: I have boxes A, B, C, and D and have balls a ,b ,c ,d ,e, f, ... -- each of which is in one of the aforementioned boxes. So I know that, for example, balls a, b, c and d are in box A. Balls e, j, p, and w are in box B, etc. I'm trying to color each ball based on which box contain...
I need an appropriate Python data structure
0.099668
0
0
112
13,033,979
2012-10-23T15:28:00.000
0
0
0
0
python,django,django-models
13,034,305
4
false
1
0
Add a ManytoMany relationship in your article to the User model. Everytime a user likes one article add him into it. Length of that field will be the number of like in that article.
1
3
0
I have a django project using the built in user model. I need to add relationships to the user. For now a "like" relationship for articles the user likes and a "following" relationship for other users followed. What's the best way to define these relationships? The django doc recommends creating a Profile model with a ...
django add relationships to user model
0
0
0
7,527
13,034,991
2012-10-23T16:21:00.000
86
0
1
0
python,python-3.x,jit
13,035,238
7
true
0
0
First off, Python 3(.x) is a language, for which there can be any number of implementations. Okay, to this day no implementation except CPython actually implements those versions of the language. But that will change (PyPy is catching up). To answer the question you meant to ask: CPython, 3.x or otherwise, does not, ne...
2
88
0
I found that when I ask something more to Python, python doesn't use my machine resource at 100% and it's not really fast, it's fast if compared to many other interpreted languages, but when compared to compiled languages i think that the difference is really remarkable. Is it possible to speedup things with a Just In ...
Does the Python 3 interpreter have a JIT feature?
1.2
0
0
61,675
13,034,991
2012-10-23T16:21:00.000
2
0
1
0
python,python-3.x,jit
13,035,216
7
false
0
0
If you mean JIT as in Just in time compiler to a Bytecode representation then it has such a feature(since 2.2). If you mean JIT to machine code, then no. Yet the compilation to byte code provides a lot of performance improvement. If you want it to compile to machine code, then Pypy is the implementation you're looking ...
2
88
0
I found that when I ask something more to Python, python doesn't use my machine resource at 100% and it's not really fast, it's fast if compared to many other interpreted languages, but when compared to compiled languages i think that the difference is really remarkable. Is it possible to speedup things with a Just In ...
Does the Python 3 interpreter have a JIT feature?
0.057081
0
0
61,675
13,036,605
2012-10-23T18:12:00.000
0
0
0
0
python,gtk,pygtk
13,037,240
1
false
0
1
Silly me, just use GtkTreeView:Hover or GtkTreeView:Selected
1
0
0
What is the class-name in which I should use to style a TreeView's rows? I've tried GtkCellRendererText, but it doesn't work.
Styling TreeView's row using CSS
0
0
0
467
13,040,048
2012-10-23T22:04:00.000
2
0
0
0
python,json,reddit
13,040,391
1
true
1
0
Would it make sense to keep the Python scraper application running on it's own server, which then writes the scraped URL's to the database? Yes, that is a good idea. I would set up a cron job to run the program every so often. Depending on the load you're expecting, it doesn't necessarily need to be on its own serve...
1
2
0
I'm extremely new to Python, read about half a beginner book for Python3. I figure doing this will get me going and learning with something I actually want to do instead of going through some "boring" exercises. I'm wanting to build an application that will scrape Reddit for the top URL's and then post these onto my ow...
Scraping news sites with Python
1.2
0
1
570
13,040,834
2012-10-23T23:25:00.000
2
0
0
1
python,linux,networking,packet
13,040,908
2
false
0
0
No; there is no /dev/eth1 device node -- network devices are in a different namespace from character/block devices like terminals and hard drives. You must create an AF_PACKET socket to send raw IP packets.
1
3
0
I have a file which contains raw IP packets in binary form. The data in the file contains a full IP header, TCP\UDP header, and data. I would like to use any language (preferably python) to read this file and dump the data onto the line. In Linux I know you can write to some devices directly (echo "DATA" > /dev/devic...
Writing raw IP data to an interface (linux)
0.197375
0
1
2,540
13,042,897
2012-10-24T04:09:00.000
2
1
1
0
python,py2exe
16,571,073
3
false
0
0
Using os.system() will be problematic for many reasons; for example, when you have spaces or Unicode in the file names. It will also be more opaque relative to exceptions/failures. If this is on windows, using win32file.CopyFile() is probably the best approach, since that will yield the correct file attributes, dates...
1
4
0
I need an alternative to the shutil module in particular shutil.copyfile. It is a little known bug with py2exe that makes the entire shutil module useless.
Alternative to shutil.copyfile
0.132549
0
0
4,141
13,049,515
2012-10-24T12:45:00.000
1
0
0
0
python,google-app-engine,webapp2,wtforms
13,051,668
1
true
1
0
I think this will work if the routes are part of the same app. But why not using a single handler with get and put and a method _create, which can be called (self._create instead of a redirect) by get and put to render the template with the form. It is faster than a browser redirect and you can pass arguments in an eas...
1
1
0
I am having a problem with webapp2 and wtforms. More specifically I have defined two methods in two different handlers, called: create, which is a GET method listening to a specific route save, which is a POST method listening to another route In the save method I validate my form and if fails, I want to redirect to ...
Webapp2 + WTForms issue: How to pass values and errors back to user?
1.2
0
0
348
13,049,553
2012-10-24T12:48:00.000
0
0
1
0
python,coding-style,documentation,inline
13,049,627
2
false
0
0
Lines are usually limited to 80 characters in the computer world, the PEP style guide recommends a maximum of 79.
1
0
0
When writing inline documentation, is there a standard method for line breaks when it comes longer lines of text (Obviously this shouldn't happen too frequently)? For example: "This modules does blah blah blah blah blah blah blah blah blah blah blah blahblah blah blah blah blah blahblah blah blah blah blah blahblah bl...
Line Length for Inline Python Documentation
0
0
0
127
13,053,253
2012-10-24T16:13:00.000
3
0
1
0
python,multithreading
13,053,314
2
true
0
0
Run two threads and open and read file separately in both threads, you can use seek to jump to specific positions
1
0
0
I have a file onto which I have written some data. Say 8 bytes of data Now using my python script, I want to read the first four bytes using one thread and the next 4 bytes using another thread while the first thread is still running or suspended. How can I do this using python? i.e 1) Read first 4 bytes using thread1...
Concurrent reads on a file in python
1.2
0
0
360
13,054,970
2012-10-24T17:56:00.000
22
0
1
0
python,python-2.7
13,054,992
3
false
0
0
pydoc foo.bar from the command line or help(foo.bar) or help('foo.bar') from Python.
2
41
0
I know this question is very simple, I know it must have been asked a lot of times and I did my search on both SO and Google but I could not find the answer, probably due to my lack of ability of putting what I seek into a proper sentence. I want to be able to read the docs of what I import. For example if I import x b...
How to print module documentation in Python
1
0
0
50,842
13,054,970
2012-10-24T17:56:00.000
1
0
1
0
python,python-2.7
54,911,846
3
false
0
0
You can use help() function to display the documentation. or you can choose method.__doc__ descriptor. Eg: help(input) will give the documentation on input() method.
2
41
0
I know this question is very simple, I know it must have been asked a lot of times and I did my search on both SO and Google but I could not find the answer, probably due to my lack of ability of putting what I seek into a proper sentence. I want to be able to read the docs of what I import. For example if I import x b...
How to print module documentation in Python
0.066568
0
0
50,842
13,055,699
2012-10-24T18:46:00.000
0
0
0
0
python,snmp
13,191,755
1
false
0
0
what exactly you want to know. whether : python net-snmp api supports v3 or not or oid for finding request-id of a snmp packet
1
1
0
Which SNMP library offers an API to get single properties of captured (tcpdump) SNMP packets like the request-ID or the protocol version? I found that pySNMP offers such a low-level API but only for v1/v2c versions. But I need both v2c and v3.
How to get the request ID of a SNMP packet in Python
0
0
1
624
13,057,113
2012-10-24T20:24:00.000
3
0
0
0
python,machine-learning,scikit-learn
13,057,566
1
true
0
0
You probably need to derive from the KMeans class and override the following methods to use your vocabulary logic: fit_transform will only be called on the train data transform will be called on the test data Maybe class derivation is not alway the best option. You can also write your own transformer class that wraps...
1
2
1
I would like to be use GridSearchCV to determine the parameters of a classifier, and using pipelines seems like a good option. The application will be for image classification using Bag-of-Word features, but the issue is that there is a different logical pipeline depending on whether training or test examples are used....
Using custom Pipeline for Cross Validation scikit-learn
1.2
0
0
1,601
13,059,142
2012-10-24T23:00:00.000
5
1
0
0
python,ruby,sqlite
13,059,204
1
true
0
0
There is no good reason to choose one over the other as far as sqlite performance or usability. Both languages have perfectly usable (and pythonic/rubyriffic) sqlite3 bindings. In both languages, unless you do something stupid, the performance is bounded by the sqlite3 performance, not by the bindings. Neither language...
1
0
0
Which of these two languages interfaces better and delivers a better performance/toolset for working with sqlite database? I am familiar with both languages but need to choose one for a project I'm developing and so I thought I would ask here. I don't believe this to be opinionated as performance of a language is pret...
ruby or python for use with sqlite database?
1.2
1
0
150
13,059,316
2012-10-24T23:18:00.000
1
0
1
0
python,wxpython,exe,pyinstaller
13,059,522
3
false
0
1
Checking for sys.frozen is a really good approach. You can also look into img2py which will let you load the binary data for images into a .py file. Later, instead of having to open files, they can be imported.
1
2
0
I'm trying to get a wxPython app working as an exe. I've heard that PyInstaller is now superior to py2exe. I'd like to include my .ico and two .png files that the script requires to run. What would the spec file for this look like? I can't seem to find a decent example anywhere. I have PyInstaller installed, but I can'...
wxPython to exe with PyInstaller?
0.066568
0
0
2,693
13,059,891
2012-10-25T00:26:00.000
0
0
0
0
python,scroll,pygame,geometry-surface
13,068,085
3
false
0
1
I don't think so, I have an idea though. I'm guessing your background wraps horizontally and always to the right, then you could attach part of the beginning to the end of the background. Example, if you have a 10,000px background and your viewport is 1000px, attach the first 1000px to the end of the background, so you...
3
2
0
I'm coding a game where the viewport follows the player's ship in a finite game world, and I am trying to make it so that the background "wraps" around in all directions (you could think of it as a 2D surface wrapped around a sphere - no matter what direction you travel in, you will end up back where you started). I ha...
Wrapping a pygame surface around a viewport
0
0
0
1,379
13,059,891
2012-10-25T00:26:00.000
0
0
0
0
python,scroll,pygame,geometry-surface
13,096,965
3
false
0
1
I was monkeying around with something similar to what you described that may be of use. I decided to try using a single map class which contained all of my Tiles, and I wanted only part of it loaded into memory at once so I broke it up into Sectors (32x32 tiles). I limited it to only having 3x3 Sectors loaded at once. ...
3
2
0
I'm coding a game where the viewport follows the player's ship in a finite game world, and I am trying to make it so that the background "wraps" around in all directions (you could think of it as a 2D surface wrapped around a sphere - no matter what direction you travel in, you will end up back where you started). I ha...
Wrapping a pygame surface around a viewport
0
0
0
1,379
13,059,891
2012-10-25T00:26:00.000
0
0
0
0
python,scroll,pygame,geometry-surface
13,131,429
3
true
0
1
Thanks everyone for the suggestions. I ended up doing something a little different from the answers provided. Essentially, I made subsurfaces of the main surface and used them as buffers, displaying them as appropriate whenever the viewport included coordinates outside the world. Because the scrolling is omnidirectiona...
3
2
0
I'm coding a game where the viewport follows the player's ship in a finite game world, and I am trying to make it so that the background "wraps" around in all directions (you could think of it as a 2D surface wrapped around a sphere - no matter what direction you travel in, you will end up back where you started). I ha...
Wrapping a pygame surface around a viewport
1.2
0
0
1,379
13,060,069
2012-10-25T00:50:00.000
0
0
1
0
python,algorithm,colors,python-imaging-library
13,062,863
3
false
0
0
K-means is a good choice for this task because you know number of main colors beforehand. You need to optimize K-means. I think you can reduce your image size, just scale it down to 100x100 pixels or so. Find the size on witch your algorithm works with acceptable speed. Another option is to use dimensionality reduction...
1
8
1
Does anyone know a fast algorithm to detect main colors in an image? I'm currently using k-means to find the colors together with Python's PIL but it's very slow. One 200x200 image takes 10 seconds to process. I've several hundred thousand images.
Fast algorithm to detect main colors in an image?
0
0
0
4,441
13,060,146
2012-10-25T01:00:00.000
3
0
1
0
python,windows,installation,windows-installer
13,060,316
2
false
0
0
You can do this with any of the installer applications out there. Each of the dependent installers has a silent install option, so your installer just needs to invoke the installers for each of the dependencies in the right order. I won't recommend any windows installer application in particular because I don't like an...
1
1
0
I know nothing on this subject, but I need suggestions about the best tools or method for creating a setup program that installs python, some custom python modules, some other python modules such as PIL, and some EXE dependencies, all living on a network repository, on windows machines. In the repository are installers...
how to write installer (installing python, python modules and other dependencies) for windows boxes?
0.291313
0
0
2,621
13,060,254
2012-10-25T01:15:00.000
1
0
1
0
python,regex
13,060,269
4
false
0
0
Search for [^a-zA-Z] and replace with ' '
1
0
0
How can I replace any character outside of the English alphabet? For example, 'abcdükl*m' replaced with a ' ' would be 'abcd kl m'
Replace any character outside of the English alphabet in Python?
0.049958
0
0
3,730
13,060,427
2012-10-25T01:40:00.000
1
0
0
0
python,sql,sorting,select
13,060,535
2
false
0
0
This is a very general question, but there are multiple things that you can do to possibly make your life easier. 1.CSV These are very useful if you are storing data that is ordered in columns, and if you are looking for easy to read text files. 2.Sqlite3 Sqlite3 is a database system that does not require a server ...
1
0
0
I have huge tables of data that I need to manipulate (sort, calculate new quantities, select specific rows according to some conditions and so on...). So far I have been using a spreadsheet software to do the job but this is really time consuming and I am trying to find a more efficient way to do the job. I use pytho...
sorting and selecting data
0.099668
1
0
97
13,061,800
2012-10-25T04:54:00.000
1
0
0
0
python,csv,etl,sql-loader,smooks
14,449,025
3
false
0
0
Create a process / script that will call a procedure to load csv files to external Oracle table and another script to load it to the destination table. You can also add cron jobs to call these scripts that will keep track of incoming csv files into the directory, process it and move the csv file to an output/processed ...
2
3
1
I have come across a problem and am not sure which would be the best suitable technology to implement it. Would be obliged if you guys can suggest me some based on your experience. I want to load data from 10-15 CSV files each of them being fairly large 5-10 GBs. By load data I mean convert the CSV file to XML and then...
Choice of technology for loading large CSV files to Oracle tables
0.066568
1
0
2,011
13,061,800
2012-10-25T04:54:00.000
2
0
0
0
python,csv,etl,sql-loader,smooks
13,062,737
3
true
0
0
Unless you can use some full-blown ETL tool (e.g. Informatica PowerCenter, Pentaho Data Integration), I suggest the 4th solution - it is straightforward and the performance should be good, since Oracle will handle the most complicated part of the task.
2
3
1
I have come across a problem and am not sure which would be the best suitable technology to implement it. Would be obliged if you guys can suggest me some based on your experience. I want to load data from 10-15 CSV files each of them being fairly large 5-10 GBs. By load data I mean convert the CSV file to XML and then...
Choice of technology for loading large CSV files to Oracle tables
1.2
1
0
2,011
13,062,423
2012-10-25T05:55:00.000
0
0
1
0
python,coding-style,mutable,mutability
13,062,474
4
false
0
0
I suppose it depends on the use case. I don't see why returning an object from an in-place operation would hurt, other than maybe you won't use the result, but that's not really a problem if you're not being super-fastidious about pure functionalism. I like the call-chaining pattern, such as jQuery uses, so I appreci...
1
27
0
I'm talking mostly about Python here, but I suppose this probably holds for most languages. If I have a mutable object, is it a bad idea to make an in-place operation also return the object? It seems like most examples just modify the object and return None. For example, list.sort.
Is making in-place operations return the object a bad idea?
0
0
0
3,445
13,068,227
2012-10-25T12:08:00.000
1
0
0
0
python,mysql,mysql-python
13,299,592
2
true
0
0
MySQLdb-1.2.4 (to be released within the next week) and the current release candidate has support for MySQL-5.5 and newer and should solve your problem. Please try 1.2.4c1 from PyPi (pip install MySQL-python)
1
2
0
I'm using python's MySQLdb to fetch rows from a MySQL 5.6.7 db, that supports microsecond precision datetime columns. When I read a row with MySQLdb I get "None" for the time field. Is there are way to read such time fields with python?
How to read microsecond-precision mysql datetime fields with python
1.2
1
0
310
13,068,257
2012-10-25T12:10:00.000
11
0
0
0
python,multithreading,numpy,machine-learning,scikit-learn
13,084,224
2
false
0
0
For linear models (LinearSVC, SGDClassifier, Perceptron...) you can chunk your data, train independent models on each chunk and build an aggregate linear model (e.g. SGDClasifier) by sticking in it the average values of coef_ and intercept_ as attributes. The predict method of LinearSVC, SGDClassifier, Perceptron compu...
1
10
1
I got linearsvc working against training set and test set using load_file method i am trying to get It working on Multiprocessor enviorment. How can i get multiprocessing work on LinearSVC().fit() LinearSVC().predict()? I am not really familiar with datatypes of scikit-learn yet. I am also thinking about splitting sam...
Multiprocessing scikit-learn
1
0
0
11,435
13,068,300
2012-10-25T12:12:00.000
4
0
0
1
python,cloud,celery,distributed-computing
13,068,496
1
true
0
0
IMHO It's a very good idea. I have used it few times in Amazon EC2 in this manner and it was great each time. One of the big advantages is that it can handle failure of worker servers, so the dynamic nature of the infrastructure is not a problem and you still get things done. I'm sorry that this answer is so brief, but...
1
1
0
I'm going to use Celery to manage tasks in cluster. There will be one master server and some worker servers. Master sends tasks to the worker servers (any number) and gets the result. Task state should be trackable. Backend is RabbitMQ. Is using Celery in this case a good Idea? Or are there better solutions?
Is using Celery for task management in cluster good idea?
1.2
0
0
858
13,070,759
2012-10-25T14:24:00.000
1
1
0
0
php,python
13,070,806
1
false
0
0
Not at runtime - this would make no sense due to the overheads involved and the risk of the download failing.
1
0
0
Is there a way to dynamically download and install a package like AWS API from a PHP or Python script at runtime? Thanks.
Python/PHP - Downloading and installing AWS API
0.197375
0
1
42
13,073,147
2012-10-25T16:31:00.000
1
0
0
0
python
13,073,177
2
true
1
0
There are a number of tools out there for this purpose. For example, Selenium, which even has a package on PyPI with Python bindings for it, will do the job.
1
1
0
I am not sure if this is possible, but I was wondering if it would be possible to write a script or program that would automatically open up my web browser, go to a certain site, fill out information, and click "send"? And if so, where would I even begin? Here's a more detailed overview of what I need: Open browser Go...
script to open web browser and enter data
1.2
0
1
1,062
13,077,263
2012-10-25T21:04:00.000
1
1
0
0
python,image-processing,pixel,imaging
13,078,321
2
true
0
0
If you want to keep a compressed file format, you can break each image up into smaller rectangles and store them separately. Using a fixed size for the rectangles will make it easier to calculate which one you need. When you need the pixel value, calculate which rectangle it's in, open that image file, and offset the c...
1
0
0
Is there any way with Python to directly get (only get, no modify) a single pixel (to get its RGB color) from an image (compressed format if possible) without having to load it in RAM nor processing it (to spare the CPU)? More details: My application is meant to have a huge database of images, and only of images. So w...
Direct access to a single pixel using Python
1.2
0
0
693
13,078,071
2012-10-25T22:08:00.000
2
0
1
1
python,subprocess
13,078,126
2
false
0
0
When I use subprocess.Popen, it starts the separate program, but does so under the original program's Python instance... Incorrect. ... so that they share the first Python console. This is the crux of your problem. If you want it to run in another console then you must run another console and tell it to run your pro...
1
8
0
I'm trying to run an external, separate program from Python. It wouldn't be a problem normally, but the program is a game, and has a Python interpreter built into it. When I use subprocess.Popen, it starts the separate program, but does so under the original program's Python instance, so that they share the first Pytho...
Start Another Program From Python >Separately<
0.197375
0
0
13,835
13,080,270
2012-10-26T03:17:00.000
1
0
1
0
python,review-board
13,080,371
2
false
0
0
I just think before going through diff, you should reformat JSON object lets say on alphabetical and numeric order.
1
0
0
How do I create a diff of two json objects such that they are in the manual diff format which can be sent to reviewboard? I need to generate the diff from inside a python script.I think manual diffs are generated using the "diff file1 file2" command line utility. Can I generate a similar reviewboard compatible diff usi...
How to create a manual diff between two Json objects which can be sent to Reviewboard using python?
0.099668
0
0
515
13,081,659
2012-10-26T06:09:00.000
7
1
0
0
python,django,wsgi,pyc
13,081,746
1
true
0
0
The best strategy for doing deployments is to write the deployed files into a new directory, and then use a symlink or similar to swap the codebase over in a single change. This has the side-benefit of also automatically clearing any old .pyc files. That way, you get the best of both worlds - clean and atomic deploymen...
1
2
0
Seems like with ever increasing frequency, I am bit by pyc files running outdated code. This has led to deployment scripts scrubbing *.pyc each time, otherwise deployments don't seem to take effect. I am wondering, what benefit (if any) is there to pyc files in a long-running WSGI application? So far as I know, the onl...
Is there any benefit to pyc files in a WSGI app where deployments happen several times per week?
1.2
0
0
593
13,083,026
2012-10-26T07:58:00.000
2
1
1
0
python,import
13,083,221
3
false
0
0
if you don't want python to search builtin modules then search in current folder first,, you can change sys.path upon program startup, the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter sys.path[0] is the empty string, which directs Python to sear...
1
5
0
Imagine I have a script, let's say my_tools.py that I import as a module. But my_tools.py is saved twice: at C:\Python27\Lib and at the same directory from where the script is run that does the import. Can I change the order where python looks for my_tools.py first? That is, to check first if it exists at C:\Python27...
Can I change the order where python looks for a module first?
0.132549
0
0
2,883
13,084,686
2012-10-26T09:55:00.000
-1
0
0
1
python,linux,storage,hdf5,data-acquisition
13,102,233
3
false
0
0
In your case, you could just create 15 files and save each sample sequentially into the corresponding file. This will make sure the requested samples are stored continuous on disk and hence reduce the number of disk seeks while reading.
2
7
0
I'm building a system for data acquisition. Acquired data typically consists of 15 signals, each sampled at (say) 500 Hz. That is, each second approx 15 x 500 x 4 bytes (signed float) will arrive and have to persisted. The previous version was built on .NET (C#) using a DB4O db for data storage. This was fairly efficie...
What is a good storage candidate for soft-realtime data acquisition under Linux?
-0.066568
0
0
877
13,084,686
2012-10-26T09:55:00.000
2
0
0
1
python,linux,storage,hdf5,data-acquisition
13,143,593
3
false
0
0
Using the keys you described, you should able to scale via sharding if necesssary. 120kB / 30sec ist not that much, so i think you do not need to shard too early. If you compare that to just using files you'll get more sophisticated queries and build in replication for high availability, DS or offline processing (Map R...
2
7
0
I'm building a system for data acquisition. Acquired data typically consists of 15 signals, each sampled at (say) 500 Hz. That is, each second approx 15 x 500 x 4 bytes (signed float) will arrive and have to persisted. The previous version was built on .NET (C#) using a DB4O db for data storage. This was fairly efficie...
What is a good storage candidate for soft-realtime data acquisition under Linux?
0.132549
0
0
877
13,085,658
2012-10-26T11:00:00.000
1
0
0
0
python,django,postgresql,django-south
13,085,822
2
true
1
0
If you add a column to a table, which already has some rows populated, then either: the column is nullable, and the existing rows simply get a null value for the column the column is not nullable but has a default value, and the existing rows are updated to have that default value for the column To produce a non-null...
2
0
0
I see that when you add a column and want to create a schemamigration, the field has to have either null=True or default=something. What I don't get is that many of the fields that I've written in my models initially (say, before initial schemamigration --init or from a converted_to_south app, I did both) were not run ...
South initial migrations are not forced to have a default value?
1.2
1
0
107
13,085,658
2012-10-26T11:00:00.000
0
0
0
0
python,django,postgresql,django-south
13,085,826
2
false
1
0
When you have existing records in your database and you add a column to one of your tables, you will have to tell the database what to put in there, south can't read your mind :-) So unless you mark the new field null=True or opt in a default value it will raise an error. If you had an empty database, there are no valu...
2
0
0
I see that when you add a column and want to create a schemamigration, the field has to have either null=True or default=something. What I don't get is that many of the fields that I've written in my models initially (say, before initial schemamigration --init or from a converted_to_south app, I did both) were not run ...
South initial migrations are not forced to have a default value?
0
1
0
107
13,085,946
2012-10-26T11:18:00.000
0
1
0
0
python,django,gmail,gmail-imap
13,087,381
2
false
1
0
I would suggest you to look at context.io, I've used it before and it works great.
1
3
0
I'm looking for an API or library that gives me access to all features of Gmail from a Django web application. I know I can receive and send email using IMAP or POP3. However, what I'm looking for are all the GMail features such as marking emails with star or important marker, adding or removing tags, etc. I know there...
A Django library for Gmail
0
0
0
1,086
13,090,222
2012-10-26T15:51:00.000
0
0
0
0
python,user-interface,pyqt4
14,197,531
1
false
0
1
There is no need for searching fully suited library. Also, i think, it is unnecessary and waste of time. There are lots of frustrating issue, such as localization settings, number format settings, validation issue etc. I recommend, use Qt designer form layout to create quickly a form. Then use pyqt4/QValidation and u ...
1
1
0
My question is not specific to Python/PyQt4 but it's the language and api I'm currently using. I want to know if there is a library to automatically generate GUI forms from public parameters of an object. It would be very useful for automatic settings generation.
Best practice to generate the settings view of an UI
0
0
0
70
13,090,227
2012-10-26T15:52:00.000
1
0
0
0
python,user-interface,tkinter,ttk
13,090,292
2
true
0
1
okay, this might not be the best way, but for each widget in the tabs, pass through a variable in the functions which will then be used in an if statement to check which tab is currently selected, as you're only using two this could be Boolean? if more is needed more complex step will be needed, but that is a simple wa...
1
4
0
I current am making a GUI using tk, I have implemented a ttk notebook to have two separate tabs, each of these tabs hold data but call the same functions to interact with this data, is that a sane way to do this? Or should I just make more functions to call them separately? They need to know which tab is currently sele...
Two tabs using ttk notebook, but separate functions for the two?
1.2
0
0
1,005
13,090,476
2012-10-26T16:06:00.000
1
0
1
0
google-app-engine,memory-management,python-2.7,multi-tenant
13,126,025
1
false
1
0
i agree with nick. there should be no python code in the tenant specific zip. to solve the memory issue i would cache most of the pages in the datastore. to serve them you don't need to have all tenants loaded in your instances. you might also wanna look in pre generating html views on save rather then on request.
1
1
0
i have a multitenant app with a zipped package for each tenant/client which contains the templates and handlers for the public site for each of them. right now i have under 50 tenants and its fine to keep the imported apps in memory after the first request to that specific clients domain. this approach works well but i...
zipped packages and in memory storage strategies
0.197375
0
0
57
13,090,479
2012-10-26T16:06:00.000
11
0
0
0
python,django,django-admin
13,090,557
1
true
1
0
This sounds like a browser issue rather than a Django issue. To unselect an element in a multiple select, press the Ctrl key (linux / windows) or the Command key (mac) when you click on it.
1
3
0
Having A = ManyToManyField(B, null=True, blank=True), when I go in A's admin page, it seems I can't unselect every entries in the ManyToMany box after having clicked on a B element. And even if I don't click on any entry, there is a related B element selected after saving (the first B element I guess). But I want to ad...
ManyToMany in Django admin: select none
1.2
0
0
2,338
13,093,951
2012-10-26T20:25:00.000
2
0
0
0
python,django,gethostbyaddr
38,819,664
3
false
1
0
You can just print HttpRequest.META and find what you want and I think req.META['HTTP_ORIGIN'] is the thing you need, It's the same as the browser address bar value.
1
2
0
What is the easiest way to obtain the user's host/domain name, if available? Or is there a function to lookup the IP address of the user to see if it is bound to a named address? (i.e. gethostbyaddr() in PHP) HttpRequest.get_host() only returns the IP address of the user.
Django get client's domain name/host name
0.132549
0
0
10,741
13,094,941
2012-10-26T21:51:00.000
4
0
1
0
python,spyder
13,096,004
6
true
0
0
At the time this question was asked, Python 3 was not supported by Spyder (and this answer said so, giving some details of the then-incomplete porting efforts). But that's not the case any longer! Recent builds of Spyder should work with Python 3. Check out the other answers for some links to places to get it from (tho...
3
25
0
By default Spyder uses Python 2.7.2, and my question is: is there a way to set up Spyder so that it automatically uses Python 3.x? Thanks!
Switch to Python 3.x in Spyder
1.2
0
0
40,370
13,094,941
2012-10-26T21:51:00.000
2
0
1
0
python,spyder
32,678,175
6
false
0
0
On Ubuntu 14.04 I found spyder3 at official repository
3
25
0
By default Spyder uses Python 2.7.2, and my question is: is there a way to set up Spyder so that it automatically uses Python 3.x? Thanks!
Switch to Python 3.x in Spyder
0.066568
0
0
40,370
13,094,941
2012-10-26T21:51:00.000
18
0
1
0
python,spyder
17,067,938
6
false
0
0
Since end of May 2013, version v2.3.0dev1 of Spyder works for Python 3.3 and above. It is in a usable state but there are a few minor problems. Hopefully they will be resolved soon.
3
25
0
By default Spyder uses Python 2.7.2, and my question is: is there a way to set up Spyder so that it automatically uses Python 3.x? Thanks!
Switch to Python 3.x in Spyder
1
0
0
40,370
13,095,994
2012-10-27T00:11:00.000
0
0
0
1
python,linux
13,097,273
2
false
0
0
If it is the login program for X11, you can put it into ~/.xinitrc. It is X session startup script.
1
1
0
I am trying to write a custom login program for a linux system using Python 3. what is the best way to have an application automatically run at startup?
Running a Python Application at Startup
0
0
0
791
13,097,843
2012-10-27T06:25:00.000
0
0
1
0
python,plone,zope
13,676,795
2
false
1
0
If you change the content in any way (or just re-save it) a duplicate of the object is created (which allows you to undo later). If you change only the metadata (like the title) the object is usually not duplicated. These duplicated "backup" copies are removed (and the undo option for them) whenever the database is pa...
1
4
0
In plone, how many physical copies of a file (or any content) exist if it is revised say 4 times? I am using plone 4.1 wherein the files and images are stored on the file system.
Do as many copies as the number of revisions exist for a file in plone?
0
0
0
122
13,097,975
2012-10-27T06:52:00.000
5
0
0
1
python,google-app-engine,deployment
13,102,795
1
true
1
0
No, there isn't. If you change one file, you need to package and upload the whole application.
1
4
0
Is it possible to update single py file in existing GAE app.something like we update cron.yaml using, appcfg.py update_cron Is there any way to update .py file? Regrads.
Can I deploy (update) Single Python file to existing Google App Engine application?
1.2
0
0
1,137
13,098,457
2012-10-27T08:19:00.000
3
0
0
0
python,django,macos,pip
13,098,637
4
false
1
0
django-admin is not on path, you could search for it find / -name django-admin.py and add it to your .profile/.bashrc/.whatever. Let me recommend using virtualenv for everything python related you do though. Installing it in a local environment prevents this kind of problem. Each environment comes with its own Python d...
1
4
0
I installed python using: brew install python and then eventually pip install Django. However when I try to run django-admin.py startproject test I just get a file not found. What did I forget?
Installing Django with pip, django-admin not found
0.148885
0
0
7,509
13,099,032
2012-10-27T09:50:00.000
2
0
0
1
python,logging,uwsgi,gevent
13,099,158
2
true
1
0
If latency is a crucial factor for your app, undefinitely writing to disk could make things really bad. If you want to survive a reboot of your server while redis is still down i see no other solutions than writing to disk, otherwise you may want to try with a ramdisk. Are you sure having a second server with a second ...
1
1
0
I am using the gevent loop in uWSGI and I write to a redis queue. I get about 3.5 qps. On occasion, there will be an issue with the redis connection so....if fail, then write to a file where I will have a separate process do cleanup later. Because my app very latency aware, what is the fastest way to dump to disk in...
Fastest way to write to a log in python
1.2
0
0
2,514
13,099,963
2012-10-27T11:56:00.000
1
0
1
0
python,oop,class,decoupling,astronomy
13,100,096
1
true
0
1
Instead of body ID's why not add the Bodys themselves to the dictionary of pygame objects instead of an ID? After all, a Python variable is just a label, so the renderer wouldn't need to know about what the variable represents. And it might save you having to look-up IDs. A related option is to add one or multiple view...
1
1
0
I'm working on an astronomy project, making one of those gravity simulator programs. I have a Uni class, which represents a universe filled with celestial bodies (instances of the Body class). This Uni class is capable of updating itself, adding new bodies, and removing bodies by their id. It's completely math-based, a...
How to properly decouple computation from rendering
1.2
0
0
396
13,101,486
2012-10-27T15:25:00.000
1
0
0
0
python,pyqt
13,101,822
1
true
0
1
Have you considered using a QGraphicsView? This allows scrolling in addition to efficient rendering of only the visible objects (and plenty of other benefits such as hit testing).
1
0
0
I have a Widget that is huge (80,000 px long maybe? 800 elements at 100px each) because it lays out many smaller widgets. I've put the huge widget into a QScrollArea. But the scroll area still renders the entire widget. This causes manipulation of the widget to be choppy, and I want things to be smoother. Instead I wan...
How can I limit the rendering done by QScrollArea?
1.2
0
0
194
13,104,279
2012-10-27T21:19:00.000
0
0
1
1
python,python-2.7,cygwin,opencl,pyopencl
13,387,079
2
false
0
0
Did you install Python into Cygwin? If not, launch setup.exe, get to the packages screen, and do a search for python. You can install 2.6.8 and 3 side by side if you want. After that it's like using python anywhere else. You can do a $ python my.py to run my.py. You can install easy_install or pip, etc. if they'll h...
1
0
0
I cannot figure out how to install pyopencl with Cygwin. Never used Cygwin before so I am very lost as to how I initiate python and use it to run my .py setup files.
Can someone help walk me through installing PyOpenCL using Cygwin?
0
0
0
1,353
13,108,615
2012-10-28T11:56:00.000
0
1
0
0
python,sockets,smtp
13,108,630
2
false
0
0
These are simply newline characters. In GMail they'll be processed and "displayed" so you don't see them. But they are still part of the email text message so it makes sense that get_payload() returns them.
1
0
0
I am not sure if this is the right forum to ask, but I give it a try. A device is sending an E-Mail to my code in which I am trying to receive the email via a socket in python, and to decode the E-Mail with Messsage.get_payload() calls. However. I always have a \n.\n at the end of the message. If the same device sen...
Mysterious characters at the end of E-Mail, received with socket in python
0
0
1
92
13,111,899
2012-10-28T18:50:00.000
1
0
1
0
python,wxpython,exe
13,111,965
2
true
0
1
I use pyinstaller as it is very easy to use and the applications run without any problems Some Windows DDLs are needed for the included Python Compiler and for the maybe win32 api calls With Pyinstaller you can bundle everything needed (except config files and dbs of course) using the -F flag.
1
0
0
I've been trying for over a week now to make a .exe of a wxPython script. I still have a number of questions, and the process of creating an exe is still quite unclear. Which utility should be used? I've heard to use py2exe, pyinstaller, gui2exe, some combination of gui2exe and some shady .bat file, etc. Which is best...
Creating wxPython GUI .exe?
1.2
0
0
2,794
13,112,473
2012-10-28T20:00:00.000
0
0
0
0
python,windows,windows-7,emacs,python-3.3
13,112,953
1
false
0
1
here output arrives in a buffer *Python*, which is not displayed by default unfortunately. M-x list-buffers should mention it.
1
1
0
I cannot get emacs to evaluate my buffer. I put it into python mode and started the interpreter but C-c C-c does not seem to do anything. I also tried C-c C-l to load the file but after selecting the file nothing happens. Typing directly into the python shell does work. I tried it out in linux and everything worked fin...
Python Pyglet application not working in Windows Emacs
0
0
0
201
13,114,116
2012-10-28T23:30:00.000
1
0
1
1
python,software-design
13,114,163
1
true
0
0
If files logically belong together in pairs, the least error prone method is probably to require them to be entered together, e.g. mycommand -Pair FileA1,FileA1 -Pair FileB1, FileB2 That way, you can enforce the contract that files must be entered in pairs (any -Pair argument without two input files can generate an e...
1
0
0
I'm writing a Python script that takes five pairs of files as arguments. I would like to allow the user to input these files as command-line arguments, but I'm worried he will put the files in the wrong order or not put a file right after the file it's paired with. How can I design my command-line arguments to avoid ...
What is good software design practice for taking multiple pairs of files on the command line?
1.2
0
0
65
13,114,430
2012-10-29T00:17:00.000
3
0
1
0
python,regex
13,114,523
1
true
0
0
This is easiest done using two regexen. "^(a)bc(1)23" and "ab(c)12(3)$". It may be possible to merge these two, but the regular expression will get pretty unreadable.
1
0
0
I got strings which go: abc123abc123abc123 abc123 abc123abc123abc123abc123abc123abc123 etc (varying units of abc123 which I don't know the length of repeat) The task is to extract the first 1 and first a and the last c and last 3. Is it possible to do it with 1 regex and how exactly if it is possible? I kept count of...
regex to match repeating string python
1.2
0
0
167
13,115,435
2012-10-29T03:11:00.000
7
0
1
0
python,list,slice
13,115,443
6
false
0
0
Slices don't wrap like that, but a[-3:] + a[:3] would give you that list.
2
6
0
Is there any simple way to invert a list slice in python? Give me everything except a slice? For example: Given the list a = [0,1,2,3,4,5,6,7,8,9] I want to be able to extract [7,8,9,0,1,2] i.e. everything but a[3:7]. Thinking about it logically, I thought that a[-3:3] would give me what I want, but it only returns an ...
Invert slice in python
1
0
0
3,316
13,115,435
2012-10-29T03:11:00.000
0
0
1
0
python,list,slice
13,123,879
6
false
0
0
OK, so this may not be exactly what you want, but is useful in some situations where you might want a slice like that. There are two important disclaimers. It doesn't preserve order It removes repeated items list(set(a).difference(a[3:7]))
2
6
0
Is there any simple way to invert a list slice in python? Give me everything except a slice? For example: Given the list a = [0,1,2,3,4,5,6,7,8,9] I want to be able to extract [7,8,9,0,1,2] i.e. everything but a[3:7]. Thinking about it logically, I thought that a[-3:3] would give me what I want, but it only returns an ...
Invert slice in python
0
0
0
3,316
13,115,599
2012-10-29T03:42:00.000
1
1
0
0
python,google-app-engine,google-drive-api,google-api-python-client
13,125,588
1
true
1
0
There are the mock http and request classes that the apiclient package uses for its own testing. They are in apiclient/http.py and you can see how to use them throughout the test suite.
1
2
0
There are several components involved in auth and the discovery based service api. How can one test request handlers wrapped with decorators used from oauth2client (eg oauth_required, etc), httplib2, services and uploads? Are there any commonly available mocks or stubs?
How can one test appengine/drive/google api based applications?
1.2
0
1
259
13,116,301
2012-10-29T05:27:00.000
4
0
0
0
python,django
13,116,348
2
true
1
0
Model.objects.none() always gives you an empty queryset
1
0
0
Is there any way to specify a Django Queryset, which will do nothing but still be valid Queryset? Empty queryset should ideally not call DB and results would be empty.
Django Queryset for no-operation
1.2
0
0
126
13,117,502
2012-10-29T07:28:00.000
3
0
0
1
python,ssh,twisted
13,274,700
1
false
0
0
I haven't used Twisted and don't know Conch at all, but with nobody else answering, I'll give it a shot. As a general principle, you probably want to buffer very little if any in the middle of the network. (Jim Gettys' notes on "buffer bloat" are enlightening.) So it's clear that you're asking a sensible question. I as...
1
5
0
I have a Twisted Conch SSH server and the typical scenario is this: git via OpenSSH client >>--- WAN1 --->> Twisted conch svr >>--- WAN2 -->> Git server There will be occassions that the 'git push' is sending data faster over WAN1 than I can proxy it over WAN2, so I need to tell the client to slow down (well before a...
Twisted Conch - Flow control
0.53705
0
0
485
13,121,529
2012-10-29T12:20:00.000
0
0
0
0
python,excel,win32com,office-2013
42,290,194
3
false
0
0
wilywampa's answer corrects the problem. However, the combrowse.py at win32com\client\combrowse.py can also be used to get the IID (Interface Identifier) from the registered type libraries folder and subsequently integrate it with code as suggested by @cool_n_curious. But as stated before, wilywampa's answer does corre...
1
4
0
I'm using python and excel with office 2010 and have no problems there. I used python's makepy module in order to bind to the txcel com objects. However, on a different computer I've installed office 2013 and when I launched makepy no excel option was listed (as opposed to office 2010 where 'Microsoft Excel 14.0 Object...
Python Makepy with Office 2013 (office 15)
0
1
0
2,318
13,122,575
2012-10-29T13:27:00.000
3
0
1
0
python,string,compression,whitespace
13,122,949
3
false
0
0
If you don't care about the exact compressed form you may want to look at zlib.compress and zlib.decompress. zlibis a standard Python library that can compress a single string and will probably get better compression than a self implemented compression algorithm.
1
3
0
I have strings with blocks of the same character in, eg '1254,,,,,,,,,,,,,,,,982'. What I'm aiming to do is replace that with something along the lines of '1254(,16)982' so that the original string can be reconstructed. If anyone could point me in the right direction that would be greatly appreciated
How to compress by removing duplicates in python?
0.197375
0
0
253
13,124,913
2012-10-29T15:43:00.000
1
0
0
0
python,django,uwsgi,mezzanine
14,267,828
1
true
1
0
After a long time I've figured out what the problem is! I had followed some directions on how to set up uwsgi with nginx that said to include a line saying uwsgi_param SCRIPT_NAME /;. The purpose of SCRIPT_NAME is to provide the base path for the UWSGI application, so in this case it serves to double the slashes. I fo...
1
2
0
Running Django behind UWSGI, I have set up an instance of Mezzanine that is almost working perfectly. The only problem is the admin login page does not work properly. If you just try to log in normally than the browser is redirected to http://admin/. The html form action attribute is set to //admin/ instead of /admi...
UWSGI adding double slash to admin login form in Django
1.2
0
0
768
13,125,271
2012-10-29T16:03:00.000
3
0
1
0
python
13,125,435
2
false
0
0
Create a factory class which returns an implementation based on the parameter. You can then have a common base class for both DB types, one implementation for each and let the factory create, configure and return the correct implementation to the user based on a parameter. This works well when the two classes behave ve...
1
5
0
I have a class that can interface with either Oracle or MySQL. The class is initialized with a keyword of either "Oracle" or "MySQL" and a few other parameters that are standard for both database types (what to print, whether or not to stop on an exception, etc.). It was easy enough to add if Oracle do A, elif MySQL d...
Most Pythonic way to handle splitting a class into multiple classes
0.291313
1
0
126
13,127,381
2012-10-29T18:16:00.000
1
0
0
0
python,chipmunk,pymunk
13,130,409
1
true
0
1
There are a couple of unsafe methods to modify a shape. Right now (v3.0) pymunk only supports updates of the Circle shape and the Segment shapes. However, I just committed a method to update the Poly shape as well, available in latest trunk of pymunk. If you dont want to run latest trunk I suggest you instead just rep...
1
1
0
I am just getting started with pymunk, and I have a problem that I wasn't able to find a solution to in the documentation. I have a character body that changes shape during a specific animation. I know how to attach shapes to a physics body, but how do I change them? Specifically, I need to change the box to a smalle...
Changing the shape of a pymunk/Chipmunk physics body
1.2
0
0
898
13,127,708
2012-10-29T18:40:00.000
0
0
0
0
python,django,ubuntu
13,127,985
1
true
1
0
If the file size is greater than 2.5MB Django will write the uploaded file to your /tmp directory (on Linux) before saving it. After the upload is complete you can remove the file manually or you can have a cron job (or something similar) to remove the temp files automatically.
1
0
0
When I use a form to upload a large video to the server, there is a temp.upload created in the /tmp directory. Where does this .upload created? Can I remove it after the uploading is complete? I use Django and python on ubuntun. I check Django documentation for file upload. It says that: "If an uploaded file is too l...
How to remove .upload file
1.2
0
0
594
13,128,466
2012-10-29T19:41:00.000
0
0
0
0
python,tkinter
13,129,010
2
false
0
1
What you create with Tkinter is not pointless. It sounds to me like you're trying to compile a stand-alone program in Python, using the Tkinter library to provide the GUI. Once you have a script working, you can use a program to compile into a standalone program. Look into using py2app on a mac, or py2exe on Windows. G...
1
0
0
I have looked at similar questions that may answer my question but I am still very unclear on how to go about the following: I can create programs to run in the Python Shell in Idle and I can also set up windows with widgets in Tkinter, but whatever I create in Tkinter is pointless because I cannot figure out how to ta...
Porting a Python Shell Program to a Tkinter GUI
0
0
0
1,228
13,131,139
2012-10-29T23:27:00.000
1
0
1
0
python,nltk,lemmatization
50,628,168
5
false
0
0
If you are performing Machine Learning algorithms on your text, you may use n-grams instead of word tokens. It is not strictly lemmatization but it detects series of n similar letters and it is supprisingly powerful to gather words with the same meaning. I use sklearn's function CountVectorizer(analyzer='char_wb') and ...
1
29
0
I have some text in French that I need to process in some ways. For that, I need to: First, tokenize the text into words Then lemmatize those words to avoid processing the same root more than once As far as I can see, the wordnet lemmatizer in the NLTK only works with English. I want something that can return "vouloi...
Lemmatize French text
0.039979
0
0
29,989
13,131,699
2012-10-30T00:41:00.000
1
0
1
1
python,windows,path,os.system
13,140,093
1
true
0
0
I think you can add the location of the files in the PATH environment variable. Follow the steps: Go to My Computer->Right click->Properties->Advanced System Settings->Click Environmental Variables. Now click PATH and then click EDIT. In the variable value field, go to the end and append ';' (without quotes) and then a...
1
1
0
I am trying to create a Python program that uses the os.system() function to create a new process (application) based on user input... However, this only works when the user inputs "notepad.exe". It does not work, for instance, when a user inputs "firefox.exe". I know this is a path issue because the error says that th...
Python - get file path programmatically?
1.2
0
0
598
13,133,304
2012-10-30T05:41:00.000
5
0
1
0
python,django,arrays
13,134,299
2
false
0
0
You want abs(a - b), not abs(abs(a)-abs(b))
1
1
0
I have this numbers a = 7 , b= 9 Now i want to subtract the two numbers. b - a = 2. now that is ok but a -b = -2 But i only want to know the diff i.e 2 not -ve or +ve like we have mod operator How can i do that in python
How can i get unsigned magnitude of the -ve number in python
0.462117
0
0
282
13,133,986
2012-10-30T06:47:00.000
0
1
0
0
python,vb.net,heuristics
13,134,922
2
false
0
0
Heuristic can roughly be tranlated into 'rule of thumb' It's not a programming-specific concept.
1
0
0
Could I please have some ideas for a project utilising Heuristics Thankyou in advance for your help
Programming with Heuristics?
0
0
0
4,568