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
4,995,336
2011-02-14T17:40:00.000
0
1
1
0
0
python,embed,python-c-api
1
4,995,435
0
1
0
true
0
1
You need the encodings/__init__.py file, otherwise encodings is a folder and not a python package. Chances are that you'll need a lot of stuff from within the python standard library. To make everything just work you'll need to include the entire standard library along with your program. You can make this a bit better by putting the library in a zip file and adding that to sys.path. Also, you can include only pyc not the original py files.
1
2
0
0
I'm trying to make a small game that supports Python scripting. I've no problems with using the Python C-API, but I don't know how to ensure that the game will run on a computer with no Python installed. I know I need pythonXY.dll -- what else is there? When I try to run the program it tells me it cannot find encodings.utf_8. I tried copying the encodings/utf_8.py file in the same directory as my program, but the error still pops up.
C++ Python embedding: Run on machine with no Python?
0
1.2
1
0
0
258
4,999,078
2011-02-15T01:20:00.000
2
0
1
0
0
python,json,pyjamas
0
5,659,587
0
1
0
true
0
0
I've played with pyjamas a little and am currently implementing json-rpc with django. Have you considered using ssl to secure the site. Short of implementing your own (basic) encryption routine, its probably the best way forward.
1
2
0
0
What's the simplest way to set up a JSON-RPC server in python and make it secure? I'm very interested Pyjamas for python/javascript - but the documentation doesn't explain how to implement security with the JSON-RPC.
Easy secure JSON-RPC in python
0
1.2
1
0
0
934
5,002,986
2011-02-15T11:22:00.000
0
1
0
0
1
python,automated-tests,web-scraping,urllib2,mechanize-python
0
5,462,848
0
3
0
true
1
0
I actually went without using mechanize and used the Threading module. This allowed for fairly quick transactions, and I also made sure not to have too much inside of each thread. Login information, and getting the webapp in the state necessary before I threaded helped the threads to run shorter and therefore more quickly.
2
2
0
0
I have a web app that needs both functionality and performance tested, and part of the test suite that we plan on using is already written in Python. When I first wrote this, I used mechanize as my means of web-scraping, but it seems to be too bulky for what I'm trying to do (either that or I'm missing something). The basic layout of what I'm trying to do is as follows. All are objects. User has Comm (used to be the interface between my stuff and mechanize) Comm has Browser (holds my CookieJar, urllib2, and BeautifulSoup objects, used to be mechanize) Browser has Form(s) (used to be mechanize-handled) Now, as far as threading goes, I have that down. Adjustment between dealing with the GIL and having separate instances of Python running will be made as needed, but suggestions will be taken. So what I need to do is thread users hitting the application and doing various things (logging in, filling out forms, submitting forms for processing, etc.) while not making the testing box scream too loudly. My current problem with mechanize seems to be RAM. Part of what's causing the RAM issue is the need for separate browser instances for each user to keep from overwriting the JSESSIONID cookie every time I do something with a different user. Much of this might seem trivial, but I'm trying to run thousands of threads here, so little tweaks can mean a lot. Any input is appreciated.
Python web-scraping threaded performance
0
1.2
1
0
0
929
5,002,986
2011-02-15T11:22:00.000
0
1
0
0
1
python,automated-tests,web-scraping,urllib2,mechanize-python
0
5,236,735
0
3
0
false
1
0
Have you considered Twisted, the asynchronous library, for at least doing interaction with users?
2
2
0
0
I have a web app that needs both functionality and performance tested, and part of the test suite that we plan on using is already written in Python. When I first wrote this, I used mechanize as my means of web-scraping, but it seems to be too bulky for what I'm trying to do (either that or I'm missing something). The basic layout of what I'm trying to do is as follows. All are objects. User has Comm (used to be the interface between my stuff and mechanize) Comm has Browser (holds my CookieJar, urllib2, and BeautifulSoup objects, used to be mechanize) Browser has Form(s) (used to be mechanize-handled) Now, as far as threading goes, I have that down. Adjustment between dealing with the GIL and having separate instances of Python running will be made as needed, but suggestions will be taken. So what I need to do is thread users hitting the application and doing various things (logging in, filling out forms, submitting forms for processing, etc.) while not making the testing box scream too loudly. My current problem with mechanize seems to be RAM. Part of what's causing the RAM issue is the need for separate browser instances for each user to keep from overwriting the JSESSIONID cookie every time I do something with a different user. Much of this might seem trivial, but I'm trying to run thousands of threads here, so little tweaks can mean a lot. Any input is appreciated.
Python web-scraping threaded performance
0
0
1
0
0
929
5,006,424
2011-02-15T16:30:00.000
0
0
1
0
0
python,nltk
0
5,009,683
0
2
0
false
0
0
Where's the input paragraph coming from? File? Console? That's more of a python issue than NLTK. For the rest, look at the nltk.tokenize module & nltk.probability.FreqDist.
1
2
0
0
I have just started using Natural Language Toolkit (NLTK) as a part of my Engineering college project. Can anybody please tell me how do I read an input paragraph text and 1) break it down into textual components i.e into number of sentences, number of words, number of characters and number of polysyllabic or complex words in the given paragraph and 2) Also print the above determined values
How do I find text features and print them?
0
0
1
0
0
255
5,009,112
2011-02-15T20:26:00.000
0
0
0
0
0
python,sqlalchemy,nosetests
0
10,268,378
0
1
0
false
0
0
It is my understanding that this plugin is only meant for unit testing SQLAlchemy itself and not as a general tool. Perhaps that is why there are no examples or documentation? Posting to the SQLAlchemy mailing list is likely to give you a better answer "straight from the horse's mouth".
1
3
0
0
The python unit testing framework called nosetest has a plugin for sqlalchemy, however there is no documentation for it that I can find. I'd like to know how it works, and if possible, see a code example.
How does the nosetests sqlalchemy plugin work?
1
0
1
1
0
340
5,011,135
2011-02-16T00:25:00.000
1
1
0
1
0
python,tornado
0
12,342,342
0
5
0
true
0
0
Use Django. I'm a hardcore Tornado fan but if you need to ask, Django is the best tool for you. Tornado is great but Django is much easier to build when you need a MySQL database thanks to its awesome ORM.
4
5
0
0
I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely) Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?
python tornado setup
0
1.2
1
0
0
4,348
5,011,135
2011-02-16T00:25:00.000
0
1
0
1
0
python,tornado
0
31,242,703
0
5
0
false
0
0
If you are using tornado follow nginx.
4
5
0
0
I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely) Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?
python tornado setup
0
0
1
0
0
4,348
5,011,135
2011-02-16T00:25:00.000
1
1
0
1
0
python,tornado
0
8,414,532
0
5
0
false
0
0
if you using tornado for websockets you can use ha-proxy for proxying socket request to tornado (ngnix not support this)
4
5
0
0
I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely) Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?
python tornado setup
0
0.039979
1
0
0
4,348
5,011,135
2011-02-16T00:25:00.000
0
1
0
1
0
python,tornado
0
7,278,376
0
5
0
false
0
0
If you setup tornado via LAMP (apache with mod_wsgi for example) you will lose every single async option in tornado, significant amount of memory and speed. It's highly recomended to use nginx for serving static files and proxying dynamic requests to the tornado application instance.
4
5
0
0
I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely) Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?
python tornado setup
0
0
1
0
0
4,348
5,012,257
2011-02-16T03:31:00.000
1
0
0
0
0
python,wxpython,boxsizer
0
5,018,264
0
1
0
false
0
1
For complex layouts, I sketch it out on a piece of paper. Then I draw boxes around the widgets in different ways to decide what sizers to use. You can nest pretty much any sizer inside another one. If the controls naturally fit in a grid, then using a grid sizer of some sort is probably alright. If not, then use BoxSizers. I tend to use those the most.
1
1
0
0
I have a wxPython app with one frame and one panel. On that panel are a number of static boxes, each of which has buttons and textboxes. I have just begun reading about sizers, but they seem like they might be more than what I need, or it could that they are exactly what I need but I don't know how to use them correctly! The frame currently opens at 1920 x 1080. If the user drags the bottom right corner to resize the app, I just want everything to get smaller or larger as needed to keep the same size ratio. Is this possible? Thank you! edit: additional info: I used wxPython 2.8 and Boa to construct the GUI. I am contemplating trying another gui ide. So after reading some more about sizers, I am thinking about doing the following: add a gridsizer and basically divide my window's elements into rows and columns, then set each row and column's size as necessary until I achieve the original layout. Then I guess set the rows and columns to resize correctly? Is this a decent idea?
Simple wxPython Frame Contents Resizing - Ratio?
0
0.197375
1
0
0
301
5,012,560
2011-02-16T04:32:00.000
2
0
1
0
0
python,random,seed
0
5,012,654
0
7
1
false
0
0
The seed is an internal variable in the random package which is used to create the next random number. When a new number is requested, the seed is updated, too. I would simple use 0 as a seed if you want to be sure to have the same random numbers every time, or make i configurable. CorelDraw once had a random pattern generator, which was initialized with a seed. Patterns varied drastically for different seeds, so the seed was important configuration information of the pattern. It should be part of the config options for your runs. EDIT: As noted by ephemient, the internal state of a random number generator may be more complex than the seed, depending on its implementation.
1
59
0
0
Is there any way to find out what seed Python used to seed its random number generator? I know I can specify my own seed, but I'm quite happy with Python managing it. But, I do want to know what seed it used, so that if I like the results I'm getting in a particular run, I could reproduce that run later. If I had the seed that was used then I could. If the answer is I can't, then what's the best way to generate a seed myself? I want them to always be different from run to run---I just want to know what was used. UPDATE: yes, I mean random.random()! mistake... [title updated]
how to query seed used by random.random()?
0
0.057081
1
0
0
41,980
5,014,993
2011-02-16T10:02:00.000
0
0
0
0
0
python,scroll,zooming,transform,pygame
0
13,349,846
0
3
0
false
0
1
For a game that I have never finished I used trigonometry to get the new drawing positions with a freely zoomed and turned camera (bit complicated). It didn't really take to much time to calculate but I think it is more efficient to use other libraries. But if you want some examples just ask.
2
5
0
0
Im currently working on a project with pygame and am in need of being able to view part of a surface, moving around, zooming in and out ect Can anyone recommend a way of achieving this efficently, i have it working in a convoluted method at the moment but it is too slow and reduces the game to about 1fps when zoomed out to view the whole area. (my version of only scrolling and no zooming works fine with no lagging) Looking though the docs pygame.transform.scroll looks promising but i am unsure how i would correctly implement it with pygame.transform.scale for zooming in and out Any help welcome update: I fiddled around for a bit and got it working scaleing objects and their positions before bliting them. I have now hit the problem that the scaling looks unatural because of the low resolution of the pygame scroll wheel events so I am now trying to impliment some kind of smoothing.
Pygame zooming/scrolling window
0
0
1
0
0
7,328
5,014,993
2011-02-16T10:02:00.000
0
0
0
0
0
python,scroll,zooming,transform,pygame
0
7,509,780
0
3
0
false
0
1
You can use pygame with OpenGL, since you are already familiar with pygame. Otherwise pyglet is a similar opengl library.
2
5
0
0
Im currently working on a project with pygame and am in need of being able to view part of a surface, moving around, zooming in and out ect Can anyone recommend a way of achieving this efficently, i have it working in a convoluted method at the moment but it is too slow and reduces the game to about 1fps when zoomed out to view the whole area. (my version of only scrolling and no zooming works fine with no lagging) Looking though the docs pygame.transform.scroll looks promising but i am unsure how i would correctly implement it with pygame.transform.scale for zooming in and out Any help welcome update: I fiddled around for a bit and got it working scaleing objects and their positions before bliting them. I have now hit the problem that the scaling looks unatural because of the low resolution of the pygame scroll wheel events so I am now trying to impliment some kind of smoothing.
Pygame zooming/scrolling window
0
0
1
0
0
7,328
5,021,921
2011-02-16T20:48:00.000
3
0
0
0
0
python,numpy,scipy,data-fitting
0
5,022,089
0
4
0
false
0
0
Except, a spline does not give you a "formula", at least not unless you have the wherewithal to deal with all of the piecewise segments. Even then, it will not be easily written down, or give you anything that is at all pretty to look at. A simple spline gives you an interpolant. Worse, for 3000 points, an interpolating spline will give you roughly that many cubic segments! You did say interpolation before. OF course, an interpolating polynomial of that high an order will be complete crapola anyway, so don't think you can just go back there. If all that you need is a tool that can provide an exact interpolation at any point, and you really don't need to have an explicit formula, then an interpolating spline is a good choice. Or do you really want an approximant? A function that will APPROXIMATELY fit your data, smoothing out any noise? The fact is, a lot of the time when people who have no idea what they are doing say "interpolation" they really do mean approximation, smoothing. This is possible of course, but there are entire books written on the subject of curve fitting, the modeling of empirical data. You first goal is then to choose an intelligent model, that will represent this data. Best of course is if you have some intelligent choice of model from physical understanding of the relationship under study, then you can estimate the parameters of that model using a nonlinear regression scheme, of which there are many to be found. If you have no model, and are unwilling to choose one that roughly has the proper shape, then you are left with generic models in the form of splines, which can be fit in a regression sense, or with high order polynomial models, for which I have little respect. My point in all of this is YOU need to make some choices and do some research on a choice of model.
2
1
1
0
I am looking for a "method" to get a formula, formula which comes from fitting a set of data (3000 point). I was using Legendre polynomial, but for > 20 points it gives not exact values. I can write chi2 test, but algorithm needs a loot of time to calculate N parameters, and at the beginning I don't know how the function looks like, so it takes time. I was thinking about splines... Maybe ... So the input is: 3000 pints Output : f(x) = ... something I want to have a formula from fit. What is a best way to do this in python? Let the force would be with us! Nykon
large set of data, interpolation
0
0.148885
1
0
0
2,988
5,021,921
2011-02-16T20:48:00.000
0
0
0
0
0
python,numpy,scipy,data-fitting
0
5,022,008
0
4
0
false
0
0
The only formula would be a polynomial of order 3000. How good does the fit need to be? What type of formula do you expect?
2
1
1
0
I am looking for a "method" to get a formula, formula which comes from fitting a set of data (3000 point). I was using Legendre polynomial, but for > 20 points it gives not exact values. I can write chi2 test, but algorithm needs a loot of time to calculate N parameters, and at the beginning I don't know how the function looks like, so it takes time. I was thinking about splines... Maybe ... So the input is: 3000 pints Output : f(x) = ... something I want to have a formula from fit. What is a best way to do this in python? Let the force would be with us! Nykon
large set of data, interpolation
0
0
1
0
0
2,988
5,022,891
2011-02-16T22:25:00.000
1
0
0
0
1
python,python-imaging-library,cairo
0
5,024,687
0
2
0
true
0
1
You can do this entirely with PIL if you start with a single pre-made white-to-black gradient image (that you've made in some other program) and then use the ImageChops module to manipulate this together with your primary image to get what you want. For example to if you want to fade from red to blue: multiply red by the gradient, flip the gradient and multiply blue by this, and add these together. If your images vary in size, you can scale the gradient image appropriately in PIL.
1
1
0
0
I am trying automatically generate buttons to a menu using PIL in python. The button should be small rectangular and have a little gradient from one color to another, and a little text in it. Is PIL the best way to do this, or is Cairo a better alternative? Any suggestion to how I can accomplish this without having a image to start with..?
Generating a shaded button using PIL
0
1.2
1
0
0
413
5,028,075
2011-02-17T11:02:00.000
1
0
0
1
0
python,installation,distutils
0
7,715,650
0
2
0
false
0
0
For distutils, we are working on support to install scripts into prefix/sbin.
1
5
0
0
Commonly on most unix systems there is a distinction between $PREFIX/bin and $PREFIX/sbin. When installing a piece of software the administrator decides about what $PREFIX is, but the author decides which programs are suitable for regular users and which are not. With Python's distutils a set of scripts can be defined and they are installed to $PREFIX/bin. So how to install a script to the corresponding sbin directory? Note that in this case solutions targeting only Linux are welcome, because other parts of the software in question depend on iptables.
How to install scripts to sbin with python's distutils?
0
0.099668
1
0
0
2,055
5,030,586
2011-02-17T14:58:00.000
1
0
0
1
0
python,winforms,global-variables
0
5,031,228
0
2
0
true
0
0
Easiest solution is probably to just have the python script print to stdout: say each time an item is processed, print a line with a number representing how many items have been processed (or a percentage). Then have the forms application read the output line by line, updating the progressbar based on that information.
1
3
0
0
I am trying to figure out an elegant way to share a variable between a windows form app and a python script running in the background. The variable would be used solely to update a progress bar in the windows form based on the the long running process in the python script. More specifically, a windows timer will fire every n seconds, check the variable, then update the progress bar value. Sound stupid enough yet? I'll try to explain the need for this below. I have a windows app that lets a user define a number of parameters to fire off a long running process (python script). Without getting into unnecessary detail, this long running process will insert many (100k+ records) into a sqlite database over a significant period of time. In order to make the python script as performant as possible, I don't call commit on the sqlite database until the very end of the python script. Trying to query the sqlite database from the windows app (via System.Data.Sqlite) before the commit occurs always yields 0 records, regardless of far along the process is. The windows app will know how many total records will be inserted by the python process, so determining progress will be straight-forward enough, assuming I can get access to a record count in the python script. I know I could do this with a text file, but is there any better way?
Elegant Way To Share Variable Between Windows Form and Python Script Running In Background Process
1
1.2
1
0
0
580
5,048,515
2011-02-19T02:49:00.000
1
0
1
0
0
python,process
0
5,048,580
0
2
0
false
0
0
You need to communicate using a shared resource. In the simplest sense, you use the resource as a mutex. Lock or pid files are commonly used this way on *nix by using the filesystem as that shared resource. Depending on need, you can use a shared resource that allows communication; e.g. a web browser executed to open a given URL will communicate the URL to an existing process, if there is one. The type of shared resources available is platform-specific.
1
5
0
0
I need to add a function to my python script that checks if the current script is already running. If it is then it will quit, if not it continues running the script. I've looked into methods of doing this but I cant figure out how to do it.
Check if current process is running using Python?
0
0.099668
1
0
0
5,538
5,050,817
2011-02-19T12:40:00.000
0
0
0
0
1
python,qt4,pyqt,pyqt4,qlistwidget
0
18,070,801
0
2
0
false
0
1
More than likely this functionality exists because the multitouch event is being interpreted by your operating system as a scroll of some type and QT is recieving the scroll action, rather than the multitouch action directly.
1
3
0
0
I'm having a problem with a simple Notepad application I'm writing to teach myself basic Python/PyQt. Specifically, I want to know how to change the multi-touch pan gesture sensitivity on a QListWidget. As it is now, when I drag up and down with 2 fingers, it seems like the list is moving up/down one step for each pixel I move with my fingers. This is nothing I've implemented myself, it seems to work out of the box for list widgets I want the movement to mimic the speed of my fingers i.e one move up/down of the widget items for every x*height_of_item_in_pixels. Is this doable without major hacking into the gesture system? How would I go about this? I'm using PyQt 4.8.3 with Python 2.6
Customize PyQt multi-touch pan gestures on QListWidget
0
0
1
0
0
1,586
5,058,333
2011-02-20T16:30:00.000
1
0
0
0
0
python,google-app-engine
0
17,245,724
0
2
0
false
1
0
If you are presenting the survey question in a browser, I would definitely go with one model (in one datastore as noted by Peter) having questions and answers properties. Serialize the questions and answers into two TextProperties (be sure to escape them first). From this point, everything can be done inside Javascript by splitting the text into an array, and building any type of innerHTML you want. You may want to include a third field with meta-data about whether the question is single-answer only (radio buttons or dropdown list), or multi-select (checkboxes). One GAE entity, one get_by_id, auto-memcache if you use ndb, no additional processing costs (e.g. Django template). This is fastest and cheapest, and very flexible imho. HTH. -stevep.
1
0
0
0
Hey I am trying to create a survey that asks the users to create his own question and list 5 multiple choices. My first sense is that I create two datastores and one to store the user quesiton and one to to store 5 choices mapping to the question just created. but i dont know how exactly I should do with the 5 multiple choices and how to map them with the question. anybody has an idea? Thank you a lot
how to create a survey that has 5 multiple choices
0
0.099668
1
0
0
2,507
5,059,567
2011-02-20T19:49:00.000
1
0
1
0
1
documentation,python-3.x,documentation-generation
1
5,059,933
0
1
0
true
0
0
Apparently in Jinja, something is doing X.next(). In Python 3 that's next(x) instead. It should be a simple fix.
1
3
0
1
I recently felt the urge to generate documentation for my little project. I thought it would be fairly easy since I had a set of nice docstrings. Turns out the whole process is much more complicated in python 3.1. Here's what I tried: epydoc: Fails because it's for python 2. 2to3 didn't solve the problems pydoc: I can't find any information how can you generate documentation for your own modules, seems like a server for reading python docs offline sphinx: Most promising so far, I have built it from their repository however it fails with a very cryptic error message (jinja2.exceptions.UndefinedError: b'b"\'sphinx.jinja2glue.idgen object\' has no attribute \'next\'") My question is: what should I do now? Are there any other non-commercial documentation generators that work with python3?
Documentation generator for python3
0
1.2
1
0
0
872
5,059,883
2011-02-20T20:43:00.000
2
0
0
0
0
python,mysql,django
0
5,412,380
0
1
0
true
1
0
I found that the key was actually generated under HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE. Thanks.
1
5
0
0
I am trying to MySQL for Python (MySQLdb package) in Windows so that I can use it in the Django web frame. I have just installed MySQL Community Server 5.5.9 and I have managed to run it and test it using the testing procedures suggested in the MySQL 5.5 Reference Manual. However, I discovered that I still don't have the MySQL AB folder, the subsequent MySQL Server 5.5 folder and regkey in the HKEY_LOCAL_MACHINE, which is needed to build the MySQLdb package. From the MySQL 5.5 Reference Manual, it says that: The MySQL Installation Wizard creates one Windows registry key in a typical install situation, located in HKEY_LOCAL_MACHINE\SOFTWARE\MySQL AB. However, I do have the Start Menu short cut and all the program files installed. I have used the msi installation and installed without problems. Should I be getting the MySQL AB folder? Does anyone know what has happened and how I should get the MySQL AB/MySQL Server 5.5 folder and the regkey?
MySQL AB, MySQL Server 5.5 Folder in HKEY_LOCAL_MACHINE not present
0
1.2
1
1
0
854
5,063,658
2011-02-21T08:17:00.000
1
0
0
0
0
python,database,django,django-models,coding-style
0
5,064,564
0
2
0
true
1
0
I recommend extending Django's Model-Template-View approach with a controller. I usually have a controller.py within my apps which is the only interface to the data sources. So in your above case I'd have something like get_all_parties_and_people_for_user(user). This is especially useful when your "data taken from several tables in the database" becomes "data taken from several tables in SEVERAL databases" or even "data taken from various sources, e.g. databases, cache backends, external apis, etc.".
2
3
0
0
I'm creating a small website with Django, and I need to calculate statistics with data taken from several tables in the database. For example (nothing to do with my actual models), for a given user, let's say I want all birthday parties he has attended, and people he spoke with in said parties. For this, I would need a wide query, accessing several tables. Now, from the object-oriented perspective, it would be great if the User class implemented a method that returned that information. From a database model perspective, I don't like at all the idea of adding functionality to a "row instance" that needs to query other tables. I would like to keep all properties and methods in the Model classes relevant to that single row, so as to avoid scattering the business logic all over the place. How should I go about implementing database-wide queries that, from an object-oriented standpoint, belong to a single object? Should I have an external kinda God-object that knows how to collect and organize this information? Or is there a better, more elegant solution?
Correct way of implementing database-wide functionality
0
1.2
1
1
0
110
5,063,658
2011-02-21T08:17:00.000
0
0
0
0
0
python,database,django,django-models,coding-style
0
5,065,280
0
2
0
false
1
0
User.get_attended_birthday_parties() or Event.get_attended_parties(user) work fine: it's an interface that makes sense when you use it. Creating an additional "all-purpose" object will not make your code cleaner or easier to maintain.
2
3
0
0
I'm creating a small website with Django, and I need to calculate statistics with data taken from several tables in the database. For example (nothing to do with my actual models), for a given user, let's say I want all birthday parties he has attended, and people he spoke with in said parties. For this, I would need a wide query, accessing several tables. Now, from the object-oriented perspective, it would be great if the User class implemented a method that returned that information. From a database model perspective, I don't like at all the idea of adding functionality to a "row instance" that needs to query other tables. I would like to keep all properties and methods in the Model classes relevant to that single row, so as to avoid scattering the business logic all over the place. How should I go about implementing database-wide queries that, from an object-oriented standpoint, belong to a single object? Should I have an external kinda God-object that knows how to collect and organize this information? Or is there a better, more elegant solution?
Correct way of implementing database-wide functionality
0
0
1
1
0
110
5,066,530
2011-02-21T13:28:00.000
1
1
0
1
0
python,project,upgrade,pylons
1
5,067,114
0
1
0
false
1
0
might be obvious but did you run "python setup.py develop" on the application package so that the dependencies could be installed?
1
2
0
0
I have an old project, it written under Python 2.5/2.6, Windows. We had Python 2.6/Win7/x64 now, and I tried to start it. I got the old project that running nondebug mode in a server, and copied into local folder. When I tried to yesterday start it, I got this error: 15:44:58,038 DEBUG [pylons.configuration] Loaded None template engine as the default template renderer I see the google, but they are points to config.init_app, that is does not exists. TOday I reinstalled Python, but with Py2.7, pylons and mako. But when I tried to stat it, I got only this message: 07:36:36,377 DEBUG [pylons.configuration] Initializing configuration, package: 'x' And no more information about die... :-( So what do you meaning, how can I raise this "undead" project to debug some things? ( it was good experience with Python/Pylons, but I'm sad now that I not choose PHP previously, because of package changes). Thanks: dd
Pylons - how to use an old project in a new environment?
1
0.197375
1
0
0
68
5,074,537
2011-02-22T05:52:00.000
1
0
0
0
0
python,django,django-authentication,django-apps
0
5,085,483
0
1
0
true
1
0
There shouldn`t be any problems there. Django-Socialauth adda new auth backends, and it should works fine with permissions and decorators. And Django resistration just register a user on site, so unless you remove standard auth backend, it will work fine too.
1
0
0
0
Have anyone used these 2 django apps together? I want to know how well these 2 gel together along with Django's User Authentication system. When I mean Django's User Authentication System, I mean I should be able to use decorators like @login_required or grant permission to specific views (or functions in views.py) based on who the user is.
Django-registration & Django-Socialauth
0
1.2
1
0
0
529
5,081,501
2011-02-22T17:19:00.000
2
0
1
0
1
python
0
5,081,579
0
1
0
true
0
0
The PATH doesn't affect where data files are found. (And your script is a data file as far as Windows is concerned). You should cd C:\Path\to\folder\with\your\scripts when you open your command prompt, and then you'll be able to python myscript.py from there. (You might like to make a dedicated shortcut to the command prompt with "Start in" set to your script directory, so you don't have to cd every time.) The same should apply to Console2.
1
0
0
0
I'm "new school" meaning that i've never really used the command prompt(they didn't teach us anything but IDE's in school). I would like to setup Python using Notepad++ for the editor, and winpdb as my debugger. I want stuff to work really easy from the cmd prompt but it is not. This is what I put in my System Environment: C:\PYTHON27;C:\PYTHON27\DLLs;C:\PYTHON27\LIB;C:\PYTHON27\LIB\LIB-TK;C:\PYTHON27\LIB\SITE-PACKAGES; This is what i want to have happen (but it doesn't work, doesn't load python or the script): python myscript.py Then it should run the interpreter. I'd like it to find my script file wherever it may be. Can someone baby-step me through this command line setup (the docs expect the user to know how to fluently use the cmd prompt) I just don't want to have to manually put in path every single time I want to do something Also I have Console2, I would rather use this than the standard cmd. How do i get it to have the same functionality that i'm looking for?
Python command line SETUP for ABSOLUTE BEGINNER with Python
0
1.2
1
0
0
548
5,084,578
2011-02-22T22:07:00.000
1
0
0
0
0
python,nlp,nltk,named-entity-recognition
0
6,637,984
0
2
0
false
0
0
I haven't used NLTK enough recently, but if you have words that you know are skills, you don't need to do NER- just a text search. Maybe use Lucene or some other search library to find the text, and then annotate it? That's a lot of work but if you are working with a lot of data that might be ok. Alternatively, you could hack together a regex search which will be slower but probably work ok for smaller amounts of data and will be much easier to implement.
1
4
1
0
I try to do named entity recognition in python using NLTK. I want to extract personal list of skills. I have the list of skills and would like to search them in requisition and tag the skills. I noticed that NLTK has NER tag for predefine tags like Person, Location etc. Is there a external gazetter tagger in Python I can use? any idea how to do it more sophisticated than search of terms ( sometimes multi words term )? Thanks, Assaf
Named Entity Recognition from personal Gazetter using Python
0
0.099668
1
0
0
2,226
5,085,099
2011-02-22T23:02:00.000
0
0
0
0
0
python,django,production-environment
0
48,786,643
0
3
0
false
1
0
Steps to get your Django App from development to Production open your project folder then find settings.py find the following line, SECURITY WARNING: don't run with debug turned on in production! DEBUG = False Change the debug to false. Change your db credentials with the actual production server db credentials in your settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'seocrawler', 'USER': '', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '' } } once done upload your project folder to the folder in server open putty enter your server credentials, then a terminal or cmd will pop up. check python is installed on your server by executing below command in terminal python -V then check whether django is installed by running django-admin --version, make sure that the django version you used to develop the project matches the one on server if not the install the specific version. now using the cd command to go to the project folder which contains manage.py file. now run python manage.py showmigrations this will list if any db migration is pending for your project. now run python manage.py makemigrations this will migrate the db tables to production server database. now run python manage.py runserver 0.0.0.0:8000 then go to your domain like www.example.com:8000 in browser, to test whether your site is working. once your site is up and working we want python manage.py runserver command to run even after the terminal is closed (means python manage.py runserver command in as background task/process). to do that run nohup python manage.py runserver & this will run command in background and will never die the process even when putty terminal is closed. All done! now your server is up and your site too. Enjoy!
1
1
0
0
I've been developing a django web-application for three months now, and I'd like to set it to production. I'm currently using South as database schema manager and I haven't got any clue on how to export my application databases schemas and content, and my project code to another directory; in order to set my production environment. Any clue on how to do this? Thank you.
Exporting a development django application to production
0
0
1
0
0
2,805
5,086,524
2011-02-23T02:54:00.000
0
0
0
0
1
asp.net,python,selenium-rc
0
5,086,635
0
1
1
true
1
0
Ok, I upgrade my selenium-server to 2.0b2, now it's ok.
1
0
0
0
I use selenium-rc to test an asp.net website, test script is written in Python and the browser is Firefox 3.6. But When selenium open the first page of the website, A download dialog appear, not the web page, seems the page is proccessed as application/octet-stream, this cause my test script can not run successfully. Seems this behavior happened on some asp.net websites, I select other asp sites to test, and found some asp sites have the same issue. My question is why this happend? and how to fix this? Edit: I use IE to do this test again, seems it's ok. So is this an issue of Firefox?
Why selenium can not open some asp page?
0
1.2
1
0
1
218
5,090,870
2011-02-23T12:23:00.000
3
0
0
0
0
python,mysql
0
5,090,944
0
1
0
true
0
0
Just open your CMD/Console, type python, press Enter, type import MySQLdb and then press Enter again. If no error is shown, you're ok!
1
0
0
0
I have installed MySqldb through .exe(precompiled). Its is stored in site-packages. But now i don't know how to test, that it is accessable or not. And major problem how to import in my application like import MySqldb. Help me i am very new techie in python i just want to work with my existing Mysql. Thanks in advance...
how to import mysqldb
0
1.2
1
1
0
165
5,093,153
2011-02-23T15:41:00.000
1
0
0
0
0
python,user-interface,macros,recorder
0
5,093,338
0
3
0
false
0
1
Thinking in high level, this is what I'd do: Develop a decorator function, with which I'd decorate every event-handling functions. This decorator functions would take note of thee function called, and its parameters (and possibly returning values) in a unified data-structure - taking care, on this data structure, to mark Widget and Control instances as a special type of object. That is because in other runs these widgets won't be the same instances - ah, you can't even serialize a toolkit widget instances, be it Qt or otherwise. When the time comes to play a macro, you fill-in the gaps replacing the widget-representating object with the instances of the actually running objects, and simply call the original functions with the remaining parameters. In toolkits that have an specialized "event" parameter that is passed down to event-handling functions, you will have to take care of serializing and de-serializing this event as well. I hope this can help. I could come up with some proof of concept code for that (although I am in a mood to use tkinter today - would have to read a lot to come up with a Qt4 example).
2
2
0
0
I'm wondering how to go about implementing a macro recorder for a python gui (probably PyQt, but ideally agnostic). Something much like in Excel but instead of getting VB macros, it would create python code. Previously I made something for Tkinter where all callbacks pass through a single class that logged actions. Unfortunately my class doing the logging was a bit ugly and I'm looking for a nicer one. While this did make a nice separation of the gui from the rest of the code, it seems to be unusual in terms of the usual signals/slots wiring. Is there a better way? The intention is that a user can work their way through a data analysis procedure in a graphical interface, seeing the effect of their decisions. Later the recorded procedure could be applied to other data with minor modification and without needing the start up the gui.
Implementing a macro recorder for a python gui?
0
0.066568
1
0
0
1,816
5,093,153
2011-02-23T15:41:00.000
1
0
0
0
0
python,user-interface,macros,recorder
0
5,093,408
0
3
0
false
0
1
You could apply the command design pattern: when your user executes an action, generate a command that represents the changes required. You then implement some sort of command pipeline that executes the commands themselves, most likely just calling the methods you already have. Once the commands are executed, you can serialize them or take note of them the way you want and load the series of commands when you need to re-execute the procedure.
2
2
0
0
I'm wondering how to go about implementing a macro recorder for a python gui (probably PyQt, but ideally agnostic). Something much like in Excel but instead of getting VB macros, it would create python code. Previously I made something for Tkinter where all callbacks pass through a single class that logged actions. Unfortunately my class doing the logging was a bit ugly and I'm looking for a nicer one. While this did make a nice separation of the gui from the rest of the code, it seems to be unusual in terms of the usual signals/slots wiring. Is there a better way? The intention is that a user can work their way through a data analysis procedure in a graphical interface, seeing the effect of their decisions. Later the recorded procedure could be applied to other data with minor modification and without needing the start up the gui.
Implementing a macro recorder for a python gui?
0
0.066568
1
0
0
1,816
5,095,117
2011-02-23T18:13:00.000
1
0
0
1
0
java,python,google-app-engine
0
5,271,776
0
2
0
true
1
0
There is an API only available to Google Apps Resellers, if you are one of them you should get access to it.
1
1
0
0
I am currently working on a project that involves the google apps provisioning api. Without getting too detailed about the purpose or inner workings of the project, I would like to ask a very simple question: Is there a way to programmatically create a google apps for business domain (especially as a reseller)? After tooling around the provisioning api for a while all i could find are ways to add and remove users but nothing pertaining to whole domains.
Programmatically create Google Apps Domain
0
1.2
1
0
0
671
5,099,012
2011-02-24T00:23:00.000
1
0
0
0
0
python,google-app-engine,sorting
0
5,099,184
0
3
0
false
1
0
You could get the count of number of entities that have total_value less than or equal to the current users total_value. You could use the count() method to do so (on a Query object).
1
2
0
0
In my Main model I have a total_value and I sort with this value. When a user enters a value I wish to tell the user the order of his total_value. How do I do this? In other words, if total_values in database are 5,8,10,25 and a user enters a total_value of 15 how do I tell him that he will be in the 4th place? Thanks!
Google App Engine: how to tell sort location for a user value?
0
0.066568
1
0
0
95
5,107,675
2011-02-24T16:43:00.000
2
0
0
1
0
python,http,google-app-engine,asynchronous,request
0
5,111,470
0
4
0
false
1
0
Use the taskqueue. If you're just pushing data, there's no sense in waiting for the response.
2
4
0
0
Does anybody know how to make http request from Google App Engine without waiting a response? It should be like a push data with http without latency for response.
async http request on Google App Engine Python
0
0.099668
1
0
1
1,253
5,107,675
2011-02-24T16:43:00.000
0
0
0
1
0
python,http,google-app-engine,asynchronous,request
0
5,111,384
0
4
0
false
1
0
I've done this before by setting doing a URLFetch and setting a very low value for the deadline parameter. I put 0.1 as my value, so 100ms. You need to wrap the URLFetch in a try/catch also since the request will timeout.
2
4
0
0
Does anybody know how to make http request from Google App Engine without waiting a response? It should be like a push data with http without latency for response.
async http request on Google App Engine Python
0
0
1
0
1
1,253
5,112,248
2011-02-25T00:26:00.000
1
0
0
0
1
python,c,rgb
0
5,112,349
0
3
0
false
0
0
One option is to use OpenCV. Their Python bindings are pretty good (although not amazing). The upside is that it is a very powerful library, so this would just be the tip of the iceberg. You could probably also do this very efficiently using numpy.
1
3
1
0
well i've seen some code to convert RGB to HSL; but how to do it fast in python. Its strange to me, that for example photoshop does this within a second on a image, while in python this often takes forever. Well at least the code i use; so think i'm using wrong code to do it In my case my image is a simple but big raw array [r,g,b,r,g,b,r,g,b ....] I would like this to be [h,s,l,h,s,l,h,s,l .......] Also i would like to be able to do hsl to rgb the image is actually 640x 480 pixels; Would it require some library or wrapper around c code (i never created a wrapper) to get it done fast ?
Python RGB array to HSL and back
0
0.066568
1
0
0
6,609
5,113,791
2011-02-25T04:57:00.000
1
0
0
1
1
python,windows,winapi,pywin32
0
5,114,093
0
3
0
true
0
0
win32api.TerminateProcess(handle, 0) works, but i'm concerned it may cause memory leaks because i won't have the opportunity to close the handle (program immediately stops after calling TerminateProcess). note: Yup, I am force quitting it so there are bound to be some unfreed resources, but I want to minimize this as much as possible (as I will only do it only if it is taking an unbearable amount of time, for better user experience) but i don't think python will handle gc if it's force-quit. If a process self-terminates, then you don't need to worry about garbage collection. The OS will automatically clean up all memory resources used by that process, so you don't have to worry about memory leaks. Memory leaks are when a process is running and using more and more memory as time goes by. So yes terminating your process this way isn't very "clean", but there wont be any ill side-effects.
2
1
0
0
Edit: Looks like a duplicate, but I assure you, it's not. I'm looking to kill the current running process cleanly, not to kill a separate process. The problem is the process I'm killing isn't spawned by subprocess or exec. It's basically trying to kill itself. Here's the scenario: The program does cleanup on exit, but sometimes this takes too long. I am sure that I can terminate the program, because the first step in the quit saves the Database. How do I go about doing this? cannot use taskkill, as it is not available in some Windows installs e.g. home editions of XP tskill also doesn't work win32api.TerminateProcess(handle, 0) works, but i'm concerned it may cause memory leaks because i won't have the opportunity to close the handle (program immediately stops after calling TerminateProcess). note: Yup, I am force quitting it so there are bound to be some unfreed resources, but I want to minimize this as much as possible (as I will only do it only if it is taking an unbearable amount of time, for better user experience) but i don't think python will handle gc if it's force-quit. I'm currently doing the last one, as it just works. I'm concerned though about the unfreed handle. Any thoughts/suggestions would be very much appreciated!
In Windows using Python, how do I kill my process?
1
1.2
1
0
0
2,588
5,113,791
2011-02-25T04:57:00.000
1
0
0
1
1
python,windows,winapi,pywin32
0
14,405,624
0
3
0
false
0
0
TerminateProcess and taskkill /f do not free resources and will result in memory leaks. Here is the MS quote on terminateProcess: { ... Terminating a process does not cause child processes to be terminated. Terminating a process does not necessarily remove the process object from the system. A process object is deleted when the last handle to the process is closed. ... } MS heavily uses COM and DCOM, which share handles and resources the OS does not and can not track. ExitProcess should then be used instead, if you do not intend to reboot often. That allows a process to properly free the resources it used. Linux does not have this problem because it does not use COM or DCOM.
2
1
0
0
Edit: Looks like a duplicate, but I assure you, it's not. I'm looking to kill the current running process cleanly, not to kill a separate process. The problem is the process I'm killing isn't spawned by subprocess or exec. It's basically trying to kill itself. Here's the scenario: The program does cleanup on exit, but sometimes this takes too long. I am sure that I can terminate the program, because the first step in the quit saves the Database. How do I go about doing this? cannot use taskkill, as it is not available in some Windows installs e.g. home editions of XP tskill also doesn't work win32api.TerminateProcess(handle, 0) works, but i'm concerned it may cause memory leaks because i won't have the opportunity to close the handle (program immediately stops after calling TerminateProcess). note: Yup, I am force quitting it so there are bound to be some unfreed resources, but I want to minimize this as much as possible (as I will only do it only if it is taking an unbearable amount of time, for better user experience) but i don't think python will handle gc if it's force-quit. I'm currently doing the last one, as it just works. I'm concerned though about the unfreed handle. Any thoughts/suggestions would be very much appreciated!
In Windows using Python, how do I kill my process?
1
0.066568
1
0
0
2,588
5,120,558
2011-02-25T17:31:00.000
0
1
0
0
0
python,mime,zip
0
5,120,702
0
2
0
false
0
0
This question does not make any sense. Files are stored as binary content inside the ZIP archive together with the filesize (and flags afaik). But there is absolutely no mimetype information involved here.
2
0
0
0
When creating zip archive using python ZipFile, how can i set file mime types?
Set ZipInfo mime type
0
0
1
0
0
1,396
5,120,558
2011-02-25T17:31:00.000
3
1
0
0
0
python,mime,zip
0
5,120,648
0
2
0
true
0
0
The ZIP format doesn't carry MIME content-type for the individual files contained in the archive, though the ZIP format itself has a MIME content-type: application\zip. The only way you've got to determine the appropriate MIME content-type for a file contained in a ZIP archive is by examination of the file name and using its file extension to determine the likely MIME content-type.
2
0
0
0
When creating zip archive using python ZipFile, how can i set file mime types?
Set ZipInfo mime type
0
1.2
1
0
0
1,396
5,123,363
2011-02-25T22:22:00.000
1
0
0
0
0
python,computer-science
0
5,123,398
0
2
0
false
0
0
Do you mean you want to calculate the distance between the two points? If so, you just use the Pythagorean theorem: √((y1-y2)2+(x1-x2)2).
1
0
0
0
I'm constructing a program where the user clicks two points in the graphics window and the length of x and y must be shown. I've creating a clone and multiplying it by itself, but no luck. Any ideas? Thanks! Edit: My program is supposed to create a 'money bin' based off the users data and 2 point clicks in the graphics window. I need help figuring out how to get the 'length in x direction' after the user clicks 2 points on the graphics window. -Here's the example inputs- Enter shape of money bin: 1 cube/prism 2 cylinder 3 cone 4 pyramid Shape: 4 Enter height of money bin: 96.5 Enter cost per cubic foot to build: 2.75 After clicking on the window, click the mouse at two points in the window to determine the money bin base point 1 coordinates: 16.5258215962 45.7202505219 point 2 coordinates: 60.2190923318 13.4029227557 Length in x direction: 43.6932707355 feet Length in y direction: 32.3173277662 feet Volume: 45420.9336744 cubic feet Cost to build money bin rounded to nearest dollar: 124908 Press to quit
How do I calculate the length of an x/y coordinate in Python?
0
0.099668
1
0
0
1,821
5,125,544
2011-02-26T06:58:00.000
4
1
0
0
0
python,django,email,smtp,email-confirmation
0
5,126,778
0
1
0
true
1
0
List of delivered emails is outside of the scope of Django, which is a web framework and not a replacement for services like Mailchimp.
1
1
0
0
I want use send_mass_mail() in django and then want receive list of delivery mail list with email address and problem for failed or delivered ok status how i can make this modules ?
receive delivery list of send mail in django
0
1.2
1
0
0
415
5,127,921
2011-02-26T15:57:00.000
17
0
1
0
0
python,gzip,mmap
0
5,127,976
0
2
0
false
0
0
Well, not the way you want. mmap() can be used to access the gzipped file if the compressed data is what you want. mmap() is a system call for mapping disk blocks into RAM almost as if you were adding swap. You can't map the uncompressed data into RAM with mmap() as it is not on the disk.
1
13
0
0
I'm trying to figure how to use mmap with a gzip compressed file. Is that even possible ? import mmap import os import gzip filename = r'C:\temp\data.gz' file = gzip.open(filename, "rb+") size = os.path.getsize(filename) file = mmap.mmap(file.fileno(), size) print file.read(8) The output data is compressed.
Can mmap and gzip collaborate?
0
1
1
0
0
4,463
5,128,454
2011-02-26T17:18:00.000
0
0
1
0
0
javascript,python,json
0
5,128,524
0
5
0
false
0
0
I don't know Javascript or json, but... if you've ever seen an Unix-like operating system, you know about pipes. Like program1 | program2 | program3 ... Why don't you just connect Python and Javascript programs with pipes? The first one writes to stdout, and the next one reads from stdin.
3
1
0
0
the same problem haunting me a month ago is still haunting me now. i know ive asked several questions regarding this on this site and i am truly sorry for that. your suggestions have all been excellent but the answer is still elusive. i now realize that this is a direct result of me not being able to phrase my question properly and for that i am sorry. to give you guys a generalized view of things, here i go: the situation is like this, i have 2 server side scripts that i want to run. a python program/script that continuously spouts some numbers based on the output from that python script, a javascript script will perform some action on a webpage (e.g., change background color, display alert message, change some text) ive studied the replies to my previous posts and have found that what i want to accomplish is more or less accomplished by json. it is my understanding that json transforms 'program-specific' variables into a format that is more 'standard or general or global'. two different programs therefore now have the means to 'talk' with each other because they are now speaking the same 'language'. the problem is then this, how do i actually facilitate their communication? what is the 'cellphone' between these server side scripts? do they even need one? thank you!
is json the answer to this: python program will talk and javascript will listen?
0
0
1
0
0
950
5,128,454
2011-02-26T17:18:00.000
0
0
1
0
0
javascript,python,json
0
5,128,547
0
5
0
false
0
0
This probably isn't the answer that you are looking for, and without links to your previous posts, I don't have much to go on, but nonetheless... javascript is client side. I can interpret your question 2 different ways... Your python script is running on your computer, and you want a script to actually alter your current browser window. Not too sure, but writing a browser plugin may be the answer here. Your python script is running on the server, and as a result of the script running, you want the display of your site to be changed for viewing persons. In this case, you will could use ajax polling (or similar) on your site. Have your site be polling the server with ajax, call a server method that checks the output of the script (maybe written to a file?), and see if it has changed.
3
1
0
0
the same problem haunting me a month ago is still haunting me now. i know ive asked several questions regarding this on this site and i am truly sorry for that. your suggestions have all been excellent but the answer is still elusive. i now realize that this is a direct result of me not being able to phrase my question properly and for that i am sorry. to give you guys a generalized view of things, here i go: the situation is like this, i have 2 server side scripts that i want to run. a python program/script that continuously spouts some numbers based on the output from that python script, a javascript script will perform some action on a webpage (e.g., change background color, display alert message, change some text) ive studied the replies to my previous posts and have found that what i want to accomplish is more or less accomplished by json. it is my understanding that json transforms 'program-specific' variables into a format that is more 'standard or general or global'. two different programs therefore now have the means to 'talk' with each other because they are now speaking the same 'language'. the problem is then this, how do i actually facilitate their communication? what is the 'cellphone' between these server side scripts? do they even need one? thank you!
is json the answer to this: python program will talk and javascript will listen?
0
0
1
0
0
950
5,128,454
2011-02-26T17:18:00.000
1
0
1
0
0
javascript,python,json
0
5,128,601
0
5
0
false
0
0
I assume you mean: Python is on the web server, and Javascript is running in the client's web browser. Because browsers are all different (IE6 is terrible, Chrome is great), there are a huge number of ways people found to "hack" this "cellphone" into place. These techniques are called AJAX and COMET techniques. There is no one "cellphone", but a whole bunch of them! Hopefully, you can find a library to select the right technique for the browser, and you just have to worry about the messages. Comet is harder to do, but lets the server "push" messages to the client. Ajax can be easier - you just periodically "pull" messages from the server. Start with Ajax, then look at comet if you really need it. Just start by have the client (javascript) make a "GET" request, to see if the number has changed.
3
1
0
0
the same problem haunting me a month ago is still haunting me now. i know ive asked several questions regarding this on this site and i am truly sorry for that. your suggestions have all been excellent but the answer is still elusive. i now realize that this is a direct result of me not being able to phrase my question properly and for that i am sorry. to give you guys a generalized view of things, here i go: the situation is like this, i have 2 server side scripts that i want to run. a python program/script that continuously spouts some numbers based on the output from that python script, a javascript script will perform some action on a webpage (e.g., change background color, display alert message, change some text) ive studied the replies to my previous posts and have found that what i want to accomplish is more or less accomplished by json. it is my understanding that json transforms 'program-specific' variables into a format that is more 'standard or general or global'. two different programs therefore now have the means to 'talk' with each other because they are now speaking the same 'language'. the problem is then this, how do i actually facilitate their communication? what is the 'cellphone' between these server side scripts? do they even need one? thank you!
is json the answer to this: python program will talk and javascript will listen?
0
0.039979
1
0
0
950
5,130,057
2011-02-26T22:05:00.000
0
0
1
0
0
python,jython,gstreamer
0
5,130,162
0
2
0
true
0
0
I suspect that it uses c bindings so you can not use in jython, sorry.
1
3
0
1
Does anyone know where I can find a tutorial on how to use GStreamer with Jython? I have tried searching but with no luck. Using the Gstreamer-Python bindings I can get a python file to run with python but jython gives me ImportError: No module named pygst.
Jython Gstreamer
0
1.2
1
0
0
278
5,132,648
2011-02-27T10:26:00.000
39
1
0
0
0
python,django,twisted,rabbitmq
0
19,206,575
0
7
0
false
0
0
Let me tell you a few reasons that makes using MOM (Message Oriented Middleware) probably the best choice. Decoupling: It can decouple/separate the core components of the application. There is no need to bring all the benefits of the decoupled architecture here. I just want to point it out that this is one of the main requirement of writing a quality and maintainable software. Flexibility: It is actually very easy to connect two totally different applications written on different languages together by using AMQP protocol. These application will talk to each other by the help of a "translator" which is MOM. Scalability: By using MOM we can scale the system horizontally. One message producer can transmit to unlimited number of message consumers a task, a command or a message for processing and for scaling this system all we need to do is just create new message consumers. Lets say we are getting 1000 pictures per second and we must resize them. Solving this problem with traditional methods could be a headache. With MOM we can transmit images to the message consumers which can do their job asynchronously and make sure data integrity is intact. They are other benefits of using MOM as well but these 3 are the most significant in my opinion.
3
68
0
1
Why do we need RabbitMQ when we have a more powerful network framework in Python called Twisted. I am trying to understand the reason why someone would want to use RabbitMQ. Could you please provide a scenario or an example using RabbitMQ? Also, where can I find a tutorial on how to use RabbitMQ?
Why do we need to use rabbitmq
1
1
1
0
0
20,812
5,132,648
2011-02-27T10:26:00.000
6
1
0
0
0
python,django,twisted,rabbitmq
0
27,416,485
0
7
0
false
0
0
RabbitMQ is a bit more than mere messaging... It's a common platform that has ability to inter-connect applications. Using RabbitMQ a Java application can speak to a Linux server and/or a .NET app, to a Ruby & rails + almost anything that finds its place in the corporate web development. And most importantly it implements the "fire and forget" model proposed by AMQP. Its just a perfect replacement for JMS or ESB, especially if you are dealing with cross platform architecture, with a guaranty of reliability. There is even a special feature called RPC (Remote procedure call) that adds to the ease of development in the distributed arch. Apart from all these, in the world financial services like Stock-exchange or share-market where a lot of reliable and efficient routing is required (suppose you don't know the actual number of people subscribed to your services, but want to ensure that who ever does so, receives your pings whether they are connected in this moment, or will connect later), RabbitMQ rules because it's based on ERLANG & the Open-telecom platform that assures high performance while using minimum resources. For the most convenient introduction to RabbitMQ, see rabbitmq.com/getstarted.html for your native development language.
3
68
0
1
Why do we need RabbitMQ when we have a more powerful network framework in Python called Twisted. I am trying to understand the reason why someone would want to use RabbitMQ. Could you please provide a scenario or an example using RabbitMQ? Also, where can I find a tutorial on how to use RabbitMQ?
Why do we need to use rabbitmq
1
1
1
0
0
20,812
5,132,648
2011-02-27T10:26:00.000
14
1
0
0
0
python,django,twisted,rabbitmq
0
5,132,740
0
7
0
false
0
0
Twisted is not a queue implementation. Apart from that RabbitMQ offers enterprise-level queuing features and implements the AMQP protocol which is often needed in an enterprise world.
3
68
0
1
Why do we need RabbitMQ when we have a more powerful network framework in Python called Twisted. I am trying to understand the reason why someone would want to use RabbitMQ. Could you please provide a scenario or an example using RabbitMQ? Also, where can I find a tutorial on how to use RabbitMQ?
Why do we need to use rabbitmq
1
1
1
0
0
20,812
5,134,860
2011-02-27T18:00:00.000
1
0
1
0
0
python,list,hash,md5,checksum
0
5,134,890
0
2
0
false
0
0
You don't have 4 lists. You're printing the contents of the md5s each time after you call getmd5 which adds one md5 hash to the list. You just happen to be doing this 4 times, because you have 4 items in your files list. This means you have one list and it contains all the digests at the end of last for loop. You are printing inside the for loop constructing the list and hence you are not able to understand it. Remove the indent before the print to see the result in the format that you want.
1
0
0
0
I'm working on a bit of a project in Python. I have a list of files that I want to get the md5checksums for. Then it stores the checksums in another list. Then it checks again and checks to see if they're different. I have the function for getting the checksums working but now I can't figure out how I'd add them to a list. Here is what I'm trying import sys, hashlib files = ['/home/file1', '/home/file2', '/home/file3', '/etc/passwd'] md5s = [] def getmd5(file, ex="", inc=""): m = hashlib.md5() try: fd = open(file,"rb") except IOError: print "Can't retrieve MD5sum for ", file pass content = fd.readlines() fd.close() for eachLine in content: if ex and eachLine.startswith(ex): continue m.update(eachLine) m.update(inc) a = m.hexdigest() md5s.append(a) for i in lists: getmd5(i) print md5s But when I try this I get 4 lists like so: ['729aebf5b3a841d3ef815e297ae2ce07'] ['729aebf5b3a841d3ef815e297ae2ce07', '1c9bc3339234fa7d551bdb8da004c8ad'] ['729aebf5b3a841d3ef815e297ae2ce07', '1c9bc3339234fa7d551bdb8da004c8ad', '0c01d98119386db13beb1bfdbae7ba2b'] ['729aebf5b3a841d3ef815e297ae2ce07', '1c9bc3339234fa7d551bdb8da004c8ad', '0c01d98119386db13beb1bfdbae7ba2b', 'b51c93a2f965b75de903d159720dd6e6'] What I'd like to do is store each hash checksum in the md5s list and then read to see if they're different.
Computing MD5 checksums for files in a list
0
0.099668
1
0
0
2,384
5,136,266
2011-02-27T21:54:00.000
3
0
1
0
0
python,function,time,sleep
0
10,023,537
0
3
0
false
0
0
If you're running your script on command line, try using the -u parameter. It runs the script in unbuffered mode and did the trick for me. For example: python -u my_script.py
1
8
0
0
Hey I need to know how to sleep in Python without interfering with the current script. I've tried using time.sleep() but it makes the entire script sleep. Like for example import time def func1(): func2() print("Do stuff here") def func2(): time.sleep(10) print("Do more stuff here") func1() I want it to immediately print Do stuff here, then wait 10 seconds and print Do more stuff here.
Python sleep without interfering with script?
0
0.197375
1
0
0
14,596
5,148,790
2011-02-28T23:23:00.000
0
0
1
0
1
python,casting
0
5,148,795
0
2
0
false
0
0
ord(val) will give you the integer value of a character. int(val) will cast a value into an integer.
1
0
0
0
I had a postgresql query where I need to take column defined as character from table and then pass this value to the function where it only accepts integer.So in this case, how can i solve the problem??Can anyone help??
how to convert value of column defined as character into integer in python
0
0
1
1
0
126
5,154,479
2011-03-01T12:25:00.000
0
0
0
1
0
python,django,ubuntu-10.10
0
5,154,551
0
1
0
true
1
0
Install python2.5 with synaptic, then you will be able to use easy_install2.5 to install django. If you don't have the python2.5 in your package list you can put django on your python2.5 system path and be with it to view the system path do: python2.5 import sys sys.path
1
0
0
0
AppEngine needs Python2.5. Ubuntu 2010.10 comes with Python 2.6.6 and I didn't want to interfere with it, so I downloaded and compiled Python 2.5 in my home directory. Then I downloaded Django-1.2.5.tar.gz, and ran "sudo python setup.py install". Problem: "import django" says "ImportError: No module named django" I guess django got installed to the system's Python2.6.6, how to install it into my local Python2.5 directory?
Django on python2.5
0
1.2
1
0
0
238
5,164,307
2011-03-02T06:50:00.000
0
0
0
0
0
python,django
0
5,164,550
0
3
0
false
1
0
Post.objects.all(catagory__title="My catagory title")?
1
1
0
0
how in django find list of post related with special many to many field? for example catagory have title post have many to many relation to catagory how find all post from category title
many to many problem django
0
0
1
0
0
352
5,168,207
2011-03-02T13:36:00.000
0
0
0
0
0
python,django
0
5,168,529
0
6
0
false
1
0
I'd go for separate boolean columns. It'll be a lot easier for you to then query, say, for users that are available on mondays; or to count the number of users that available through every weekday, or whatever.
2
5
0
0
I want to store users preferences for day(s) of week he might be available. e.g. A user can be available on saturday, sunday but not on other days. Currently I am using array of 7 checkboxes(values=1,2,...7) so that user can select individual days of his availability. Now the first question is how can i store this in database. I am thinking of using a string(length=7) and storing preferences like 1100010 where 1 will signify available and 0 not available. Is it good practice? Second question, how can I convert POST data (["1","2","7"]) into string (1100010)
Best way to save availability of user over days of week in python/django
0
0
1
0
0
1,639
5,168,207
2011-03-02T13:36:00.000
1
0
0
0
0
python,django
0
5,168,522
0
6
0
false
1
0
One other option is the more-or-less obvious one: define a table of the days of the week, and have a ManyToManyField map one to the other. The admin would just work, you can do searches based on dates, and it works on SQLite unlike some of the functions in django-bitfield. Searches can be fast, since they're within the database and you don't have to use SQL's LIKE (which ignores indexes if there are wildcards at the start of the string, which would be the case for CommaSeparatedIntegerField or a seven-character string). Sure, it takes more storage, but how many users do you have, anyway? Millions? P.S. if you have an ordering field in your weekday table, you can also make the database sort by day of week for you with something like queryset.order_by('available__order').
2
5
0
0
I want to store users preferences for day(s) of week he might be available. e.g. A user can be available on saturday, sunday but not on other days. Currently I am using array of 7 checkboxes(values=1,2,...7) so that user can select individual days of his availability. Now the first question is how can i store this in database. I am thinking of using a string(length=7) and storing preferences like 1100010 where 1 will signify available and 0 not available. Is it good practice? Second question, how can I convert POST data (["1","2","7"]) into string (1100010)
Best way to save availability of user over days of week in python/django
0
0.033321
1
0
0
1,639
5,172,735
2011-03-02T20:02:00.000
0
0
0
0
0
python,facebook,facebook-graph-api,facebook-fql
0
5,365,134
0
1
0
true
0
0
I don't think it's possible to edit a Video object at all with the Graph API at the moment. You can't create objects through the API, therefore I don't think you can edit or modify existing ones either.
1
1
0
0
How can I update the title/description of a previously updated video? I am using python and pyfacebook... but any starting point would be fine and I can write it in python.
how do I use the facebook api to modify a video title or description?
0
1.2
1
0
0
137
5,174,269
2011-03-02T22:22:00.000
4
0
0
0
0
python,sql,sql-server
0
5,174,307
0
2
0
false
0
0
You could just run them using sqlcmd. Sqlcmd is a command line utility that will let you run .sql scripts from the command line, which I'm sure you can kick off through python.
1
1
0
0
As part of artifacts delivery, our developers give the data and structure scripts in .sql files. I usually "double click" on these files to open in "Microsoft SQL Server Management Studio". Management studio will prompt me for entering database server and user/pwd. I enter them manually and click on Execute button to execute these scripts. These scripts contain structure and data sql commands. Each script may contain more than one data command (like select, insert, update, etc). Structure and data scripts are provided in separate .sql files. These scripts also contain stored procedures and functions, etc. They also contain comments / description. I want to automate execution of these scripts through python. I looked at pyodbc and pymssql but they dont look like solve my issue. Through pyodbc, i need to read each .sql file and read the sql commands and execute them one by one. As the files may have comments / description / SPs / etc, reading the files will be little difficult. Can anyone give suggestion on how to automate this? Thanks in advance.
Execute .sql files that are used to run in SQL Management Studio in python
0
0.379949
1
1
0
3,938
5,174,810
2011-03-02T23:25:00.000
9
0
0
1
0
python,text-cursor,command-window
0
70,550,803
0
4
0
false
0
0
I'm surprised nobody mentioned that before, but you actually don't need any library to do that. Just use print('\033[?25l', end="") to hide the cursor. You can show it back with print('\033[?25h', end=""). It's as easy as that :)
1
16
0
0
I have a Python script that sends output to a DOS command window (I am using Windows 7) using the print() function, but I would like to prevent (or hide) the cursor from blinking at the next available output position. Has anyone any idea how I can do this? I have looked at a list of DOS commands but I cannot find anything suitable. Any help would be appreciated. Alan
How to turn off blinking cursor in command window?
0
1
1
0
0
16,984
5,179,743
2011-03-03T10:53:00.000
0
0
1
0
1
python,windows-server-2003,py2exe,pywin32,x86-64
0
6,172,840
0
1
0
false
0
0
You might want to check out the subprocess and threading modules that come with the standard Python library with regards to your multi-core issue. As for the 64bit issue, are you sure you need the additional memory space? I've never had any issue with 32bit python.
1
0
0
0
My problem is my python binaries not running as 64bits program on my amd64(Opteron 8214, 4 cpu) server. The machine is a Dual-Core, so there are 8 core shown in taskmgr. It shown no "*32" in taskmgr(so it probably already in 64bits mode), but use only one core. And I take same code(project) to compiled and executed on an Intel Xeon machine, it will use all of processor core. So how do I fix this? Anyone have some other idea? I need to make it running 64bit to use mutli-core to get job done ASAP. It's a data parser, it took most of runtime to parsing data records(via regex) then insert into mssql db. Any comment is welcome. I've been working on this many weeks. Official & third-party packages I used listed here. python-2.7.1.amd64.msi pywin32-214.win-amd64-py2.7.exe pyodbc-2.1.8.win-amd64-py2.7.exe py2exe-0.6.9.win64-py2.7.amd64.exe wxPython2.8-win64-unicode-2.8.11.0-py27.exe build binary via GUI2exe-0.5.0.zip On Windows Server 2003 Standard x64 Edition SP2 I ever built exactly same code(project) on Intel Xeon CPU machine(win2003x64 of course), And it was worked(work means no "*32" tailing on process name of taskmgr, and also use each of CPU/Core). p.s. I cannot provide whole source code since it is a large project.
My python build binaries not really running as 64bit program in AMD Win2003r2x64 machine
0
0
1
0
0
197
5,185,563
2011-03-03T19:34:00.000
1
0
0
0
0
python,django
0
5,185,748
0
4
0
false
1
0
I've had a similar problem and I've ended up adding a counter into the Album equivalent. If the count is 0 and the operation is delete(), then the album object is delete()d. Other solution os to overload the delete() method in the song model, or use post-delete to delete the album.
1
6
0
0
I am writing a small music database. Learning SQL lies quite a long time in my past and I always wanted to give Django a try. But there is one thing I couldn't wrap my head around. Right now, my models only consist of two Classes, Album and Song. Song has a foreign key pointing to the album it belongs to. Now if I would delete that Album, all Songs "belonging" to it, would be deleted due to the cascading effect. Albums are kinda virtual in my database, only songs are actually represented on the filesystem and the albums are constructed according to the songs tags, therefore I can only know an album doesn't exist anymore if there are no more songs pointing to it (as they no longer exist in the filesystem). Or in short, how can I achieve a cascade in reverse, that means, if no more songs are pointing to an album, the album should be deleted as well?
What is the reverse equivalent of cascade?
1
0.049958
1
0
0
1,807
5,190,030
2011-03-04T05:25:00.000
0
0
1
1
0
python,macos,terminal
0
5,190,101
0
6
0
false
0
0
The statements which represent a block of code below end with a colon(:) in Python. By doing that way, you can add extra statements under a single block and execute them at once.
2
12
0
0
I'm using Python in Terminal on Mac OSX latest. When I press enter, it processes the code I've entered, and I am unable to figure out how to add an additional line of code e.g. for a basic loop.
How do I create a line-break in Terminal?
0
0
1
0
0
43,483
5,190,030
2011-03-04T05:25:00.000
1
0
1
1
0
python,macos,terminal
0
25,158,836
0
6
0
false
0
0
The answer here is far more simple. If you want to continue in the next line after a loop like while b<1: when you press enter you get prompted with ... then you "have to make an indent" by space of tab and only then you can put more code after the three dots like ... (tab or space) print b then when you press enter the code is not going to be executed but you get another ... where you can keep typing you code by making the new indent keep the indent the same that is it
2
12
0
0
I'm using Python in Terminal on Mac OSX latest. When I press enter, it processes the code I've entered, and I am unable to figure out how to add an additional line of code e.g. for a basic loop.
How do I create a line-break in Terminal?
0
0.033321
1
0
0
43,483
5,194,343
2011-03-04T13:30:00.000
0
0
1
1
0
python,osx-snow-leopard,virtualenv,homebrew
0
5,195,551
0
2
1
false
0
0
I use the python_select utility to switch between versions (it takes care of all the paths and links). It's easy to install with MacPorts or fink, so I would guess you can install the same utility with Homebrew.
2
0
0
0
whats is the current best practice for installing multiple versions of python on snow leopard? have setup python 2.7.1 via Homebrew, very easy process, all great. but now I need to setup python 2.5 to develop an appengine project.. Initially created a new virtualenv against system python2.5 .. but finding I have all kinds of PATH issues. Seems at this point it would be better not to use Homebrew and go with a more standard setup? any thoughts ?
how to install multiple python versions on snow leopard?
0
0
1
0
0
1,005
5,194,343
2011-03-04T13:30:00.000
2
0
1
1
0
python,osx-snow-leopard,virtualenv,homebrew
0
5,194,593
0
2
1
true
0
0
Snow leopard already contains python 2.5 and python 2.6, no issues there. If you require obscure modifications to the python installations, just compile your own, and put it in some place where it won't conflict with the system python. (I suggest /opt/your-pythonx.y). As an aside, check: "man python" on mac to see how to use the 32-bit, or 64-bit options if that turns out to be neccessary. (Sometimes it is for c modules)
2
0
0
0
whats is the current best practice for installing multiple versions of python on snow leopard? have setup python 2.7.1 via Homebrew, very easy process, all great. but now I need to setup python 2.5 to develop an appengine project.. Initially created a new virtualenv against system python2.5 .. but finding I have all kinds of PATH issues. Seems at this point it would be better not to use Homebrew and go with a more standard setup? any thoughts ?
how to install multiple python versions on snow leopard?
0
1.2
1
0
0
1,005
5,209,003
2011-03-06T06:00:00.000
0
1
0
0
0
python,api,twitter
0
5,209,588
0
1
0
true
0
0
A tweet itself comes with a geo tag. But it is a new feature and majority tweets do not have it. So it is not possible to search for all tweets containing "Gaddafi" from a city given the city name. What you could do is the reverse, you search for "Gaddafi" first (regardless of geo location), using search api. Then, for each tweet, find the location of the poster (either thru the RESTful api or use some sort of web scraping). so basically you can classify the tweets collected according to the location of the poster. I think only tweepy have access to both twitter search API as well as RESTful API.
1
0
0
0
I have little working knowledge of python. I know that there is something called a Twitter search API, but I'm not really sure what I'm doing. I know what I need to do: I need point data for a class. I thought I would just pull up a map of the world in a GIS application, select cities that have x population or larger, then export those selections to a new table. That table would have a key and city name. next i randomly select 100 of those cities. Then I perform a search of a certain term (in this case, Gaddafi) for each of those 100 cities. All I need to know is how many posts there were on a certain day (or over a few days depending on amount of tweets there were). I just have a feeling there is something that already exsists that does this, and I'm having a hard time finding it. I've dowloaded and installed python-twitter but have no idea how to get this search done. Anyone know where I can find or how I can make this tool? Any suggestions would really help. Thanks!
Performing multiple searches of a term in Twitter
0
1.2
1
0
1
268
5,211,338
2011-03-06T15:26:00.000
0
0
0
0
0
python,django,rendering
0
5,216,170
0
3
0
false
1
0
By default mod_python decides when to reload, so you'll get what you get when you get it. Maybe I am mistaken, but I thought there was a directive you could send that would explicitly force the python reload now. That should (in theory) help with achieving consistent but perhaps not ideal, behavior. Off topic, this sounds like a good opportunity to enhance your app's logging so you'll have better breadcrumbs to follow next time things hang.
1
0
0
0
Well main question of the day will django work correctly under python 2.5.2 ? So why i am asking this question? First of all i have some test class written , nothing special which renders a page. The problem is that everytime i access this page i get random 3 different responses : 1)exceptions must be classes, instances, or strings (deprecated), not type 2) Http404 3) page renders normally . And generally i can refresh until i get the result i want , well in my case normally rendered page. I am a little bit confused what even to think . Because my written class does pretty much nothing.Just a test class to test some things. I run Django 1.2.3 under python 2.5.2 on Debian . Also what i noticed . I use PyCharm 1.1.1 through remote host with auto upload every time change is made , it uploads but somehow changes are not always applied after initial upload . What i mean is that it feels like files are not compiled ~~ if u can say it this way ... What's teh chance that it has basically nothing to do with python and django O_O and that are some other weird bugz ?
Django 1.2.3 compatible with python 2.5.2 ? Weird django behaviour
0
0
1
0
0
180
5,211,340
2011-03-06T15:26:00.000
3
0
0
0
1
python,django,sqlite
1
5,211,417
0
3
0
false
1
0
As always, syncdb does not migrate the existing schema.
1
4
0
0
I'm not sure if this is an issue specific to sqlite databases but after adding some properties I executed syncdb successfully but still the the columns were not added to the database and when I try the access the model in admin I get no such column error. Why is this happening and how do I overcome this issue? Details: Django 1.3, Python 2.6, OSX 10.6, PyCharm.
Django manage.py syncdb doing nothing when used with sqlite3
0
0.197375
1
1
0
5,639
5,214,369
2011-03-06T23:52:00.000
12
0
1
0
0
python,matlab,ide
0
6,088,759
0
11
0
false
0
0
I've been getting on very well with the Spyder IDE in the Python(x,y) distribution. I'm a long term user of Matlab and have known of the existence of Python for 10 years or so but it's only since I installed Python(x,y) that I've started using Python regularly.
5
26
1
0
I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read). Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler? When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.
Python vs Matlab
0
1
1
0
0
47,020
5,214,369
2011-03-06T23:52:00.000
2
0
1
0
0
python,matlab,ide
0
10,388,279
0
11
0
false
0
0
after long long tryouts with many editors, i have settled for aptana ide + ipython (including notebook in internet browser) great for editing, getting help easy, try fast new things aptana is the same as eclipse (because of pydev) but aptana has themes and different little things eclipse lacks about python a little, don't forget pandas, as it's (i believe) extremely powerful tool for data analysis it will be a beast in the future, my opinion i'm researching matlab, and i see some neat things there, especially gui interfaces and some other nice things but python gives you flexibility and ease, anyway, you still have to learn the basics of python, matplotlib, numpy (and eventually pandas) but from what i see, numpy and matplotlib are similar to matplotlib concepts (probably they were created with matlab in mind, right?)
5
26
1
0
I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read). Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler? When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.
Python vs Matlab
0
0.036348
1
0
0
47,020
5,214,369
2011-03-06T23:52:00.000
6
0
1
0
0
python,matlab,ide
0
41,910,220
0
11
0
false
0
0
I've been in the engineering field for a while now and I've always used MATLAB for high-complexity math calculations. I never really had an major problems with it, but I wasn't super enthusiastic about it either. A few months ago I found out I was going to be a TA for a numerical methods class and that it would be taught using Python, so I would have to learn the language. What I at first thought would be extra work turned out to be an awesome hobby. I can't even begin to describe how bad MATLAB is compared to Python! What used to to take me all day to code in Matlab takes me only a few hours to write in Python. My code looks infinitely more appealing as well. Python's performance and flexibility really surprised me. With Python I can literally do anything I used to do in MATLAB and I can do it a lot better. If anyone else is thinking about switching, I suggest you do it. It made my life a lot easier. I'll quote "Python Scripting for Computational Science" because they describe the pros of Python over MATLAB better than I do: the python programming language is more powerful the python environment is completely open and made for integration with external tools, a complete toolbox/module with lots of functions and classes can be contained in a single file (in contrast to a bunch of M-files), transferring functions as arguments to functions is simpler, nested, heterogeneous data structures are simple to construct and use, object-oriented programming is more convenient, interfacing C, C++, and fortran code is better supported and therefore simpler, scalar functions work with array arguments to a larger extent (without modifications of arithmetic operators), the source is free and runs on more platforms.
5
26
1
0
I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read). Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler? When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.
Python vs Matlab
0
1
1
0
0
47,020
5,214,369
2011-03-06T23:52:00.000
2
0
1
0
0
python,matlab,ide
0
5,214,892
0
11
0
false
0
0
almost everything is covered by others .. i hope you don't need any toolboxes like optimizarion toolbox , neural network etc.. [ I didn't find these for python may be there are some .. i seriously doubt they might be better than Matlab ones..] if u don't need symbolic manipulation capability and are using windows python(x,y) is the way to go[they don't have much activity on their linux port (older versions are available)] (or need some minor symbolic manipulations use sympy , i think it comes with EPD and python(x,y) supersedes/integrates EPD) if you need symbolic capabilities sage is the way to go, IMHO sage stands up good with Matlab as well as Mathematica .. i'm also trying to make a switch ...(need for my engg projs) i hope it helps ..
5
26
1
0
I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read). Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler? When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.
Python vs Matlab
0
0.036348
1
0
0
47,020
5,214,369
2011-03-06T23:52:00.000
1
0
1
0
0
python,matlab,ide
0
9,317,942
0
11
0
false
0
0
I have recently switched from MATLAB to Python (I am about 2 months into the transition), and am getting on fairly well using Sublime Text 2, using the SublimeRope and SublimeLinter plugins to provide some IDE-like capabilities, as well as pudb to provide some graphical interactive debugging capabilities. I have not yet explored profilers or variable editors. (I never really used the MATLAB variable editor, anyway).
5
26
1
0
I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read). Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler? When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.
Python vs Matlab
0
0.01818
1
0
0
47,020
5,215,883
2011-03-07T04:38:00.000
3
0
1
0
0
python,bdd,lettuce
0
5,665,792
0
2
0
true
0
0
There is a "behave_as" feature for Lettuce which should do this. Though there were some bugs with it last time I tried to use it. May be fixed now. I opened a bug on it with Gabriel, the author.
1
3
0
0
I am using Lettuce BDD framework for python, and I am wondering how to run one scenario from within another scenario.. For example, say there is a "registration" scenario that establishes some pre-conditions which will be used by a subsequent scenario (say "action" scenario") - how do I refer and call the "registration" scenario from "action" scenario?
Lettuce BDD : How to refer scenarios?
0
1.2
1
0
0
822
5,217,033
2011-03-07T07:34:00.000
1
0
0
1
0
python,date
0
5,217,076
0
2
0
false
0
0
If you use Windows, you should be able to do that in the time and date control panel (should be self explaining). If you use Linux, use the date command, and maybe hwclock (more info in the man pages). If you use AmigaOS, use the appropriate settings window in the system Preferences folder. If you use any other OS, you should have mentioned here which one you use...
2
0
0
0
I need to change my computer's local date to an earlier date (e.g. 2010). I couldnt do that in BIOS. Does anybody know how to do this task, for example by writing a Python snippet? Thanks.
Change system date
0
0.099668
1
0
0
666
5,217,033
2011-03-07T07:34:00.000
1
0
0
1
0
python,date
0
5,375,660
0
2
0
false
0
0
If you are not permitted to do this via the operating system, then you will not be permitted to do it from a scripting language like Python, either.
2
0
0
0
I need to change my computer's local date to an earlier date (e.g. 2010). I couldnt do that in BIOS. Does anybody know how to do this task, for example by writing a Python snippet? Thanks.
Change system date
0
0.099668
1
0
0
666
5,221,977
2011-03-07T16:12:00.000
6
0
0
1
0
python,google-app-engine,caching,memcached,google-cloud-datastore
0
5,222,081
0
3
0
true
1
0
This is a recipe for lost data. I have a hard time believing that a guest book is causing enough write activity to be an issue. Also, the bookkeeping involved in this would be tricky, since memcache isn't searchable.
1
2
0
0
I am trying to modify the guestbook example webapp to reduce the amount of database writes. What I am trying to achieve is to load all the guestbook entries into memcache which I have done. However I want to be able to directly update the memcache with new guestbook entries and then write all changes to the database as a batch put.() every 30 seconds. Has anyone got an example of how I could achieve the above? it would really help me! Thanks :)
Limit amount of writes to database using memcache
0
1.2
1
1
0
1,124
5,225,780
2011-03-07T22:00:00.000
12
0
0
0
0
python,postgresql,sqlalchemy
0
5,331,129
0
2
0
false
0
0
the warning means you did a table or metadata reflection, and it's reading in postgresql indexes that have some complex condition which the SQLAlchemy reflection code doesn't know what to do with. This is a harmless warning, as whether or not indexes are reflected doesn't affect the operation of the application, unless you wanted to re-emit CREATE statements for those tables/indexes on another database.
1
35
0
0
I'm using sqlalchemy with reflection, a couple of partial indices in my DB make it dump warnings like this: SAWarning: Predicate of partial index i_some_index ignored during reflection into my logs and keep cluttering. It does not hinder my application behavior. I would like to keep these warnings while developing, but not at production level. Does anyone know how to turn this off?
Turn off a warning in sqlalchemy
0
1
1
1
0
14,820
5,240,646
2011-03-09T02:27:00.000
5
0
0
0
0
python,web2py
0
5,240,964
0
1
0
true
1
0
Yes, it works fine with svn, hg, whatever source control you need to use. Sometimes people think that you have to code with web2py's admin interface, but that really is not the case, once you realize it can be edited with any of your regular tools, you will see that you don't have to treat it any differently when it comes to source control either. If you use the source version of web2py, you'll have a single folder on disk that contains an entire web2py application server (that in turn contains your 'application' folders). Just check that whole folder into source control. Now, on the machine that is running web2py, you can make changes either with web2py's web interface, or by just editing the python files directly with another editor (I use WingIDE for example). You'll have the normal svn update/modify/commit cycle at this point. If multiple people are editing code using web2py's admin interface, all of their changes will be made on the machine running web2py... just periodically do a commit from that system and you are all set. Using the admin interface to modify the source code is convenient, but for for bigger changes, each member of your team should have their own local copy of the svn branch. They make changes to their local files and commit them. Then from the server running web2py, just do an 'svn up' to get modifications from the rest of the team.
1
1
0
0
I just start to learn python and web2py. Because of web2py's web interface development, I am wondering how can web2py work with svn? If a team wants to build a website,how do they work together? How to control the iteration of source code?
Can web2py work with svn?
0
1.2
1
0
1
742
5,242,230
2011-03-09T06:37:00.000
0
0
0
0
0
python,django,web-applications,django-models
0
5,245,050
0
2
0
false
1
0
i think better to use `memcached (http://memcached.org/) in mem cached server and each server see this server also you can serialize your data and send it like udp and other method
2
0
0
1
I have a TCP server, a Python app, that gets the information from the connected devices. This information I am trying to show using Django web app. So, basically my model objects reside within the TCP server process. I can modify the TCP server to put the information into SQLite database and have my Django web app take it from there. But, it is not the most natural way of sharing information in this case because this information is not persistent i.e. not suitable for database. When my TCP server exists, it has to clear this information. How do I model this scenario using Django?
django - how to get model objects from another process instead of database
0
0
1
0
0
246
5,242,230
2011-03-09T06:37:00.000
1
0
0
0
0
python,django,web-applications,django-models
0
5,244,998
0
2
0
true
1
0
You may be able to serialise your model and pass the serialised data.
2
0
0
1
I have a TCP server, a Python app, that gets the information from the connected devices. This information I am trying to show using Django web app. So, basically my model objects reside within the TCP server process. I can modify the TCP server to put the information into SQLite database and have my Django web app take it from there. But, it is not the most natural way of sharing information in this case because this information is not persistent i.e. not suitable for database. When my TCP server exists, it has to clear this information. How do I model this scenario using Django?
django - how to get model objects from another process instead of database
0
1.2
1
0
0
246
5,246,856
2011-03-09T14:01:00.000
0
1
1
0
0
python,algorithm,math
0
5,246,963
0
6
0
false
0
0
Python uses C math libraries for general cases and its own logic for some of its concepts (such as infinity).
1
56
0
0
I have to write a program to calculate a**b % c where b and c are both very large numbers. If I just use a**b % c, it's really slow. Then I found that the built-in function pow() can do this really fast by calling pow(a, b, c). I'm curious to know how does Python implement this? Or where could I find the source code file that implement this function?
How did Python implement the built-in function pow()?
0
0
1
0
0
37,922
5,258,623
2011-03-10T10:52:00.000
5
0
1
0
0
python
0
5,258,931
0
3
0
false
0
0
For example using the encode method: u"Mikael Håfström".encode("ascii", "ignore")
1
10
0
0
i have a string "Mikael Håfström" which contains some special characters how do i remove this using python?
remove special characters from string
0
0.321513
1
0
0
12,590
5,264,414
2011-03-10T18:58:00.000
0
0
0
1
0
python,django,unix,tcp,communication
0
5,264,700
0
2
0
false
0
0
Some general ideas for you: You could have a master-client approach. Requests would be inserted in the master, stored in a database. Master knows the state of each client (same db). Whenever there is a request, the master redirects it to a free client. The client reports back when has finished the task (including answers if any), making it able to receive a new task from the master (this removes the need for pooling). Communication could be done using web-services. An HTTP request/post should solve every cases. No need to actually go down to the TCP level. Just general ideas, hope they're useful.
1
0
0
0
Mornink! I need to design, write and implement wide system consisting of multiple unix servers performing different roles and running different services. The system must be bullet proof, robust and fast. Yeah, I know. ;) Since I dont know how to approach this task, I've decided to ask you for your opinion before I leave design stage. Here is how the workflow is about to flow: users are interacting with website, where they set up demands for service this demand is being stored (database?) and some kind of message to central system (clustered) is being sent about new demand in database/queue central system picks up the demand and sends signals to various other systems (clusters) to perform their duties (parts of the demanded service setup) when they are done, they send up message to central system or the website that the service is now being served Now, what is the modern, robust, clean and efficient way of storing these requests in some kind of queue, and executing them? Should I send some signals, or should I let all subsystems check the queue/db of any sort for new data? What could be that queue, should it be a database? How to deal with the messages? I thought about opening single tcp connection and sending data over that, along with comands triggering actions/functions on the other end, but at closer inspection, there has to be other, better way. So I found Spring Python, that has been criticized for being so 90's-ish. I know its a very wide question, but I really hope you can help me wrap my head around that design and not make something stupid here :) Thanks in advance!
What is best pythonic way to communicate between spreaded services/unix machines?
0
0
1
0
0
219
5,266,425
2011-03-10T21:59:00.000
2
0
0
0
0
jquery,python,django,forms
0
5,266,823
0
3
0
true
1
0
Create a Django view which renders just the HTML for the form using your preferred template. Then use $.ajax() with dataType: "html" to get the code for the form for use in your overlay.
1
1
0
0
I've installed the django-newsletter application, and customized the subscribing form. But, right now, I'd like to print it through a Jquery Overlay, instead of a flatpage containing that form. Problem is I don't know how to include this flatpages elements into every page where the link calling the overlay will be present; and I don't know which approach would be the most performant. Please light my way :) Thank you!
How to call django template in order to use it through Jquery?
0
1.2
1
0
0
830
5,275,488
2011-03-11T16:21:00.000
0
0
1
1
0
python,timezone,tornado
0
5,275,903
0
3
0
false
0
0
Pardon my dimness but why do you mean to format the date based on the user in the context of Tornado? Tornado is a server. The user is a client.
1
2
0
0
How do people handle timezones in Tornado so that users see time formatted relative to their timezone? I know there's locale.format_date which defaults to GMT, but how do I set the right timezone based on the user?
Setting timezone in Tornado
0
0
1
0
0
1,179
5,283,506
2011-03-12T15:44:00.000
0
0
0
1
0
python,google-app-engine
0
5,283,536
0
3
0
false
1
0
When you log in (the blue box where you enter the email) there is a checkbox to apply the administrator flag to your session.
1
3
0
0
I want to create an Admin-only page for my GAE application. But I found there's no way to set a Admin user, so I cannot log on the page I created and test the function. I tried the local Admin console, but no luck. How can I do this?
how to set the admin user with GAE dev app server?
0
0
1
0
0
924
5,287,113
2011-03-13T03:02:00.000
1
1
0
0
1
python,apache,cgi
0
5,287,233
0
1
0
false
1
0
I think I figured it out. I need to use the environ variable passed to the application function by mod_wsgi. Thanks!
1
0
0
0
I am trying to get the query string in a CGI python script because for some reason the .FieldStorage and .getvalue functions are returning "None". The query is being generated correctly. I checked it in Wireshark and it is correctly produced. Any ideas on how I can just get the string itself correctly? I was trying to use os.environ('QUERY_STRING') but that didn't work either. Josh
Get the GET query in a Python CGI script (Apache, mod_cgi)
0
0.197375
1
0
0
669
5,291,479
2011-03-13T18:36:00.000
0
0
1
0
1
python,indentation,prompt
0
26,475,538
0
2
0
false
0
0
I recently observed this behavior too, on Windows, using cmd.exe. It also happens with Console2 - an alternate shell I sometimes use. Though I do always use spaces in normal code in an editor, I had been accustomed to using the Tab key to indent in short multi-line inputs in the interactive python.exe interpreter. Recently that stopped working - pressing the Tab key flashes the cursor and doesn't indent. Using spaces does work fine here, though it's not as convenient past a couple of indentations. I suspect (but am not certain) that the cause was installation of pyreadline or rlcompleter - I had been messing with trying to get tab completion in an interpreter in an embedded application on Windows. Of course in your case another installation could have included those packages.
2
2
0
0
hi everyone :) my problem is, up until now, i have exclusively used tabs to indent python, as i find it easier than spaces, but for no reason i know, python interactive prompt, the basic python.exe one, suddenly refuses to accept the tab button, all it does is flash the cursor. all i can think of is that my computer in suddenly treading the window like any other, using tab to cycle input things, in this case the single one. also, before now, i could use the up button to reach previously typed code, the if i submit that line with no changes, use the down button to access the line that came after it, but now up works, but as if i had changed the line, eg moves me back to the "bottom" of the list of inputs, so down doesn't work.... my question simply is: how do i get my good old tab and down button to work like i want them to again? :( thanks xxx
indent with 'tab' button in python commandline
0
0
1
0
0
5,644
5,291,479
2011-03-13T18:36:00.000
1
0
1
0
1
python,indentation,prompt
0
5,291,864
0
2
0
false
0
0
If you are using Windows with the standard cmd.exe console (and it would have been helpful for you to have stated this up front) then you can use the TAB and arrow keys exactly as you desire.
2
2
0
0
hi everyone :) my problem is, up until now, i have exclusively used tabs to indent python, as i find it easier than spaces, but for no reason i know, python interactive prompt, the basic python.exe one, suddenly refuses to accept the tab button, all it does is flash the cursor. all i can think of is that my computer in suddenly treading the window like any other, using tab to cycle input things, in this case the single one. also, before now, i could use the up button to reach previously typed code, the if i submit that line with no changes, use the down button to access the line that came after it, but now up works, but as if i had changed the line, eg moves me back to the "bottom" of the list of inputs, so down doesn't work.... my question simply is: how do i get my good old tab and down button to work like i want them to again? :( thanks xxx
indent with 'tab' button in python commandline
0
0.099668
1
0
0
5,644
5,299,280
2011-03-14T13:35:00.000
1
0
0
0
0
python,algorithm,variations
0
5,299,434
0
3
0
false
0
0
I'd solve this exercise with dynamic programming. You should be able to get the optimal solution in O(m*n) operations (n beeing the number of cars, m beeing the total mass). That will only work however if the masses are all integers. In general you have a binary linear programming problem. Those are very hard in general (NP-complete). However, both ways lead to algorithms which I wouldn't consider to be beginners material. You might be better of with trial and error (as you suggested) or simply try every possible combination.
1
2
1
0
I need to make a program in python that chooses cars from an array, that is filled with the mass of 10 cars. The idea is that it fills a barge, that can hold ~8 tonnes most effectively and minimum space is left unfilled. My idea is, that it makes variations of the masses and chooses one, that is closest to the max weight. But since I'm new to algorithms, I don't have a clue how to do it
Program, that chooses the best out of 10
0
0.066568
1
0
0
230
5,322,445
2011-03-16T08:00:00.000
5
0
0
1
0
python,gevent
0
5,338,718
0
3
0
true
0
0
first instance of StreamServer could be started with: server.start() and second with server2.serve_forever()
2
3
0
0
I have daemon which has connection pool to handlerSocket. I have 2 types of clients and their protocol differs. I want to setup 2 listeners which handles each protocol and shares connection pool between them. In twisted this is relatively easy to accomplish, but couldn't find out how to do this in gevent. Thanks!
gevent multiple StreamServer listeners
0
1.2
1
0
0
1,772
5,322,445
2011-03-16T08:00:00.000
0
0
0
1
0
python,gevent
0
8,439,364
0
3
0
false
0
0
I think the problem will come from the StreamServer's stop() method. It kills the pool, so, finishing one of listeners will drop all connections, from both listeners. If this is does not frighten you, you can simply pass the same Pool object to both StreamServers, running each of them in the separate greenlet.
2
3
0
0
I have daemon which has connection pool to handlerSocket. I have 2 types of clients and their protocol differs. I want to setup 2 listeners which handles each protocol and shares connection pool between them. In twisted this is relatively easy to accomplish, but couldn't find out how to do this in gevent. Thanks!
gevent multiple StreamServer listeners
0
0
1
0
0
1,772
5,335,845
2011-03-17T06:57:00.000
0
0
0
0
0
python,mysql,django
0
5,336,126
0
2
0
false
1
0
I have a feeling your database schema knows this is a date, right? In that case it's not being stored in the format you describe, but as some representation such as seconds since the era. This means that when you retreave it your code has to do something with it to make it look right. If you don't tell it how to look it'll default to the format you see, but if you use strftime in your python code and a filter in your templates you can make it look however you like, including the original format how you saw it. Of course the easy way out is to store it in the db as text...
1
0
0
0
my datetime property is saving in mysql in this format 2011-03-17 00:00:00 but after fetchind the data with filter function it is giving March 17,2011 midnight but i have not say to do any this type of task. My question is how can i insist django to stic to show same value what is saved in MYSQL.
django autoconverting datetime property
0
0
1
0
0
699
5,344,641
2011-03-17T20:10:00.000
0
0
0
1
0
python,linux,centos,cassandra,yum
0
5,344,716
0
2
0
false
0
0
Try installing rrdtool via yum, that should contain librrd.so.2 and correct your issue.
1
2
0
0
I am attemping to install OpsCenter for Cassandra, and using the the standard REHL image. I can't figure out how to get this to work. Another version of EPEL perhaps? yum install opscenter.... Error: Package: python26-rrdtool-1.2.27-1.i386 (opscenter) Requires: librrd.so.2
Amazon Linux AMI EC2 - librrd.so.2 dependency issue
0
0
1
1
0
410