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
9,220,302
2012-02-09T23:03:00.000
0
0
0
1
0
python,security,debian,tornado
0
9,826,573
0
1
0
true
0
0
You can create www user just as deploying LAMP environment lock the www user in website directory Supervisor is a good solution of running several tornado process You can use nginx as front-end of your tornado server.
1
1
0
0
I just set up a simple virtual server with Debian netinst. Now I want to use the tornado webserver to host a public website. I am quite new to Linux so I don't know how to set up a secure server environment. Which users do I need to create? Which config changes do I need to do to get a secure system? How should I run my tornado server (deamon, init.d, ... I don't know these methods...)? Are there more things I need to take care of when setting up a server from scratch? Thanks for help :)
Tornado Web Production Environment
0
1.2
1
0
0
867
9,221,888
2012-02-10T02:21:00.000
1
0
0
0
0
python,sql,database,orm,sqlalchemy
0
29,831,712
0
2
0
false
0
0
The Command pip install sqlalchemy will download the necessary files and run setup.py install for you.
1
1
0
1
Is there any tutorials about how to set-up sqlalchemy for windows? I went to www.sqlalchemy.org and they don't have clear instructions about set-up for windows. When I opened the zipped package, I see distribute_setup, ez_setup and setup.py among other files but it doesn't see to install sqlalchemy.
Configuring sqlalchemy for windows
0
0.099668
1
1
0
9,330
9,222,734
2012-02-10T04:34:00.000
1
0
0
0
0
python,user-interface,event-handling,wxpython,wxwidgets
0
9,230,043
0
1
0
true
0
1
Sadly there is no builtin way to do this that I'm aware of. You'll need to catch the frame's EVT_SIZE and then use AppendRows and AppendCols as necessary with the grid. You'll need to take into account how much the frame size has changed and only append when it gets bigger, not smaller.
1
1
0
0
When using wx.grid for creating table with wxpython, how can I automatically extend the number of rows and columns in the table once the user resizes the frame? If I create 5*5 table(grid) to fit on my frame and user resizes the frame( say, makes it bigger), how can I implement automatic increase to the number of rows and/or column which responds to increase in frame size?
automatic resizing of table in wx
0
1.2
1
0
0
522
9,237,508
2012-02-11T03:11:00.000
2
1
0
1
0
python,eclipse,osx-lion,32bit-64bit,pydev
0
9,282,173
0
1
0
true
0
0
The interpreter used in PyDev is computed from sys.executable... Now, a doubt: if you start a shell with /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-32 and do 'print sys.executable', which executable appears? Now, onto a workaround... you can try replacing the places where sys.executable appears in plugins/org.python.pydev/PySrc/interpreterInfo.py to point to '/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-32' That's the script where it decides which interpreter to actually use... (still, it's strange that sys.executable would point to a different location...)
1
3
0
0
I am running OSX Lion and have installed python2.7 from python.org (this distribution can run in both 64bit and 32bit mode). I have also installed the wxPython package. I can run python scripts that import wxPython from the Terminal by explicitly using the 32-bit version. I would like to run the same scripts in Eclipse, but cannot. I configure PyDev to use python.org's interpreter, but it defaults to 64-bit (I check this by printing sys.maxint). I cannot figure out how to make PyDev use the 32-bit interpreter. I have tried configuring the PyDev python interpreter to point to: /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-32 but it ends up using: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python How can I configure PyDev to use the 32-bit python interpreter in Eclipse on OSX Lion? I appreciate any input regarding this matter. Thank you.
How to configure PyDev to use 32-bit Python Interpreter In Eclipse, on OSX Lion
0
1.2
1
0
0
1,922
9,239,575
2012-02-11T10:45:00.000
1
0
0
1
0
python,google-app-engine,full-text-search,google-cloud-datastore
0
9,243,456
0
3
0
false
1
0
The best solution is to wait until app engine's full text search is released. They are currently in trusted tester phase, so it's coming soon. If you roll your own solution now, you may end up redoing it in a few months.
1
4
0
0
I have made a google app using next db module (ndb) to create my models. Now the problem is i want to deploy search over the fields of these models, and i have found two modules to do that: 1. The officially shipped with google app engine (appengine/google/ext/search) and 2. gae text search (http://code.google.com/p/gae-text-search/). Both of these provide the Searchable Model for the old db module properties. Is there any way i can do full text search using ndb and google app engine 1.6.2. Also i want to store those search queries to the datastore, how can i achieve that too? I am using python 2.7 for my development. Thanks in advance.
Full text search with google app engine using ndb models
0
0.066568
1
0
0
2,635
9,245,656
2012-02-12T01:32:00.000
6
0
1
1
0
python,parallel-processing,multiprocessing,celery
0
9,246,968
0
2
1
true
0
0
I have actually never used Celery, but I have used multiprocessing. Celery seems to have several ways to pass messages (tasks) around, including ways that you should be able to run workers on different machines. So a downside might be that message passing could be slower than with multiprocessing, but on the other hand you could spread the load to other machines. You are right that multiprocessing can only run on one machine. But on the other hand, communication between the processes can be very fast, for example by using shared memory. Also if you need to process very large amounts of data, you could easily read and write data from and to the local disk, and just pass filenames between the processes. I don't know how well Celery would deal with task failures. For example, task might never finish running, or might crash, or you might want to have the ability to kill a task if it did not finish in certain time limit. I don't know how hard it would be to add support for that if it is not there. multiprocessing does not come with fault tolerance out of the box, but you can build that yourself without too much trouble.
1
26
0
0
I'm having a bit of trouble deciding whatever to use python multiprocessing or celery or pp for my application. My app is very CPU heavy but currently uses only one cpu so, I need to spread it across all available cpus(which caused me to look at python's multiprocessing library) but I read that this library doesn't scale to other machines if required. Right now I'm not sure if I'll need more than one server to run my code but I'm thinking of running celery locally and then scaling would only require adding new servers instead of refactoring the code(as it would if I used multiprocessing). My question: is this logic correct? and is there any negative(performance) with using celery locally(if it turns out a single server with multiple cores can complete my task)? or is it more advised to use multiprocessing and grow out of it into something else later? Thanks! p.s. this is for a personal learning project but I would maybe one day like to work as a developer in a firm and want to learn how professionals do it.
Is Celery as efficient on a local system as python multiprocessing is?
1
1.2
1
0
0
8,882
9,245,719
2012-02-12T01:45:00.000
1
0
1
0
0
python,eclipse
0
9,245,979
0
1
0
true
0
0
The projects for the current workspace are shown in the "Package Explorer" view, which displays them as in a "Windows Explorer" fashion. Using this view you can open/close and manage your projects for a given workspace. If you currently don't have Package Explorer open, you can go to Window->Show View->Package Explorer. If package explorer is not an option there just select "Other..." and look under General. Note that projects are not shared across workspaces, so if you create a new workspace or switch to a different one you won't see the other one's projects.
1
2
0
0
I'm brand new to Eclipse (learning Python). I'm really confused about the terminology within Eclipse. I had previously created a "hello world" project and exited Eclipse. I've restarted Eclipse, but how do I list all of the projects in the current workspace? Is there a way to do that? If not how do I open a project? I tried using "Import" but it said the project was already in the workspace. What ever happened to say an option to "Open Project..."? This seems way overly complicated. I guess other questions I have are: How do you determine the currently set "workspace"? How do you see what workspaces are available?
How do you view/list projects within a workspace within Eclipse?
1
1.2
1
0
0
144
9,252,986
2012-02-12T21:43:00.000
3
0
0
0
0
python,django
0
9,253,022
0
4
0
true
1
0
You need to build mod_wsgi against python 2.7 and load this module into apache instead of the current mod_wsgi version you are using that links against python 2.4. This requires root access to the machine.
3
1
0
0
The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] I can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum
How do set Python path to run Django with WSGI and Apache?
1
1.2
1
0
0
1,793
9,252,986
2012-02-12T21:43:00.000
0
0
0
0
0
python,django
0
9,253,191
0
4
0
false
1
0
"You got peanut butter on my chocolate!" "You got chocolate in my peanut butter!" Two great tastes that go together. As Thiefmaster says, you need to use the correct version of wsgi. As Alex says, you need to run in a virtualenv for the later python so that you don't mess up everything else. Install all your python stuff, including your preferred Django, into your virtualenv and everything will be good.
3
1
0
0
The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] I can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum
How do set Python path to run Django with WSGI and Apache?
1
0
1
0
0
1,793
9,252,986
2012-02-12T21:43:00.000
0
0
0
0
0
python,django
0
9,253,152
0
4
0
false
1
0
You can run Django 1.3 in Python 2.4 without problems. I think it's the best choice for CentOS, and you won't have to upgrade Python. I've installed django on Centos 5 with Apache+mod_wsgi and Cherokee+uwsgi (I prefer the last one)
3
1
0
0
The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] I can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum
How do set Python path to run Django with WSGI and Apache?
1
0
1
0
0
1,793
9,268,611
2012-02-13T21:53:00.000
1
1
1
1
0
python,tcl
0
9,268,696
0
2
0
true
0
0
Tcl is not really very similar to Python. It has some surface similarities I guess, as it is a mostly procedural language, but its philosophy is rather different. Whereas Python takes the approach that everything is an object, Tcl's approach is sometimes described as "everything is (or can be) a string." There are some interesting things to learn from Tcl deriving from this approach, but it's one of the lesser-used languages, so maybe hold off until you have a tangible reason to use it. In any case, you have two very different languages on your plate already; no need (IMHO) to add a third just yet.
2
2
0
0
Right now, I'm learning Python and Javascript, and someone recently suggested to me that I learn tcl. Being a relative noob to programming, I have no idea what tcl is, and if it is similar to Python. As i love python, I'm wondering how similar the two are so I can see if I want to start it.
Similarities between tcl and Python
0
1.2
1
0
0
3,587
9,268,611
2012-02-13T21:53:00.000
5
1
1
1
0
python,tcl
0
9,268,859
0
2
0
false
0
0
While this question will obviously be closed as inconstructive in a short time, I'll leave my answer here anyway. Joe, you appear to be greatly confused about what should drive a person who count himself a programmer to learn another programming language: in fact, one should have a natural desire to learn different languages because only this can widen one's idea about how problems can be solved by programming (programming is about solving problems). Knowing N similar programming languages basically gives you nothing besides an immediate ability to use those programming languages. This doesn't add anything to your mental toolbox. I suggest you to at least look at functional languages (everyone's excited about them these days anyway), say, Haskell. Also maybe look at LISP or a similar thing. Tcl is also quite interesting in its concepts (almost no syntax, everything is a string, uniformity of commands etc). Python is pretty boring in this respect--it's certainly enables a programmer to do certain things quick and efficient but it does not contain anything to satisfy a prying mind. So my opinion is that your premises are wrong. Hope I was able to explain why.
2
2
0
0
Right now, I'm learning Python and Javascript, and someone recently suggested to me that I learn tcl. Being a relative noob to programming, I have no idea what tcl is, and if it is similar to Python. As i love python, I'm wondering how similar the two are so I can see if I want to start it.
Similarities between tcl and Python
0
0.462117
1
0
0
3,587
9,282,100
2012-02-14T18:19:00.000
1
0
1
1
1
python,windows
0
9,282,142
0
2
0
false
0
0
Assuming Python is installed, it is usually placed in a folder prefixed with "Python" and the major/minor version. E.g. C:\Python26
1
0
0
0
I have always used a mac to write and run python scripts. However, I have a bunch of files on a PC that I need to run a script on. I have never really used a PC and don't know how to run the script. If I go to the command program on the PC and type in python, nothing happens. How do I find where the python path is in order to get into the python prompt? Also, once I am in the prompt, is the importing of modules the same as in a Unix system?
Run a python script in windows
0
0.099668
1
0
0
2,860
9,288,221
2012-02-15T05:16:00.000
1
0
0
0
0
python,classification,nltk,probability
0
9,300,400
0
2
0
true
0
0
I am not sure about the NLTK implementation of Naive Bayes, but the Naive Bayes algorithm outputs probabilities of class membership. However, they are horribly calibrated. If you want good measures of certainty, you should use a different classification algorithm. Logistic regression will do a decent job at producing calibrated estimates.
2
1
1
0
In NLTK, if I write a NaiveBayes classifier for say movie reviews (determining if positive or negative), how can I determine the classifier "certainty" when classify a particular review? That is, I know how to run an 'accuracy' test on a given test set to see the general accuracy of the classifier. But is there anyway to have NLTk output its certainess? (perhaps on the basis on the most informative features...) Thanks A
NLTK certainty measure?
1
1.2
1
0
0
524
9,288,221
2012-02-15T05:16:00.000
1
0
0
0
0
python,classification,nltk,probability
0
9,300,932
0
2
0
false
0
0
nltk.classify.util.log_likelihood. For this problem, you can also try measuring the results by precision, recall, F-score at the token level, that is, scores for positive and negative respectively.
2
1
1
0
In NLTK, if I write a NaiveBayes classifier for say movie reviews (determining if positive or negative), how can I determine the classifier "certainty" when classify a particular review? That is, I know how to run an 'accuracy' test on a given test set to see the general accuracy of the classifier. But is there anyway to have NLTk output its certainess? (perhaps on the basis on the most informative features...) Thanks A
NLTK certainty measure?
1
0.099668
1
0
0
524
9,290,018
2012-02-15T08:27:00.000
1
1
1
1
0
python,linux
0
9,290,219
0
2
0
false
0
0
Regarding the script in /usr/bin, if you execute your script as a user that doesn't have permissions to write in /usr/bin, then the .pyc files won't be created and, as far as I know, there isn't any other caching mechanism. This means that your file will be byte compiled by the interpreter every time so, yes, there will be a performance loss. However, probably that loss it's not noticeable. Note that when a source file is updated, the compiled file is updated automatically without the user noticing it (at least most of the times). What I've seen is the common practice in Ubuntu is to use small scripts in /usr/bin without even the .py extension. Those scripts are byte compiled very fast, so you don't need to worry about that. They just import a library and call some kind of library.main.Application().run() method and that's all. Note that the library is installed in a different path and that all library files are byte compiled for different python versions. If that's not the case in your package, then you have to review you setup.py and your debian files since that's not the way it should be.
2
3
0
0
If I place my project in /usr/bin/ will my python interpreter generate bytecode? If so where does it put them as the files do not have write permission in that folder. Does it cache them in a temp file? If not, is there a performance loss for me putting the project there? I have packaged this up as a .deb file that is installed from my Ubuntu ppa, so the obvious place to install the project is in /usr/bin/ but if I don't generate byte code by putting it there what should I do? Can I give the project write permission if it installs on another persons machine? that would seem to be a security risk. There are surely lots of python projects installed in Ubuntu ( and obviously other distros ) how do they deal with this? Thanks
Out of home folder .pyc files?
0
0.099668
1
0
0
738
9,290,018
2012-02-15T08:27:00.000
1
1
1
1
0
python,linux
0
9,290,322
0
2
0
false
0
0
.pyc/.pyo files are not generated for scripts that are run directly. Python modules placed where Python modules are normally expected and packaged up have the .pyc/.pyo files generated at either build time or install time, and so aren't the end user's problem.
2
3
0
0
If I place my project in /usr/bin/ will my python interpreter generate bytecode? If so where does it put them as the files do not have write permission in that folder. Does it cache them in a temp file? If not, is there a performance loss for me putting the project there? I have packaged this up as a .deb file that is installed from my Ubuntu ppa, so the obvious place to install the project is in /usr/bin/ but if I don't generate byte code by putting it there what should I do? Can I give the project write permission if it installs on another persons machine? that would seem to be a security risk. There are surely lots of python projects installed in Ubuntu ( and obviously other distros ) how do they deal with this? Thanks
Out of home folder .pyc files?
0
0.099668
1
0
0
738
9,297,679
2012-02-15T16:57:00.000
0
0
0
0
0
python,random,trigonometry,hypotenuse
0
9,297,835
0
2
0
false
0
0
If you have a hypotenuse in the form of a line segment, then you have two points. From two points in the form P0 = (x0, y0) P1 = (x1, y1) you can get the x and y displacements by subtracting x0 from x1 and y0 from y1. If your hypotenuse is actually a vector in a polar coordinate plane, then yes, you'll have to take the sin of the angle and multiply it by the magnitude of the vector to get the y displacement and likewise with cos for the x displacement.
2
1
1
0
I'm writing a simple 2d brownian motion simulator in Python. It's obviously easy to draw values for x displacement and y displacement from a distribution, but I have to set it up so that the 2d displacement (ie hypotenuse) is drawn from a distribution, and then translate this to new x and y coordinates. This is probably trivial and I'm just too far removed from trigonometry to remember how to do it correctly. Am I going to need to generate a value for the hypotenuse and then translate it into x and y displacements with sin and cos? (How do you do this correctly?)
2d random walk in python - drawing hypotenuse from distribution
0
0
1
0
0
996
9,297,679
2012-02-15T16:57:00.000
1
0
0
0
0
python,random,trigonometry,hypotenuse
0
9,298,238
0
2
0
true
0
0
This is best done by using polar coordinates (r, theta) for your distributions (where r is your "hypotenuse")), and then converting the result to (x, y), using x = r cos(theta) and y = r sin(theta). That is, select r from whatever distribution you like, and then select a theta, usually from a flat, 0 to 360 deg, distribution, and then convert these values to x and y. Going the other way around (i.e., constructing correlated (x, y) distributions that gave a direction independent hypotenuse) would be very difficult.
2
1
1
0
I'm writing a simple 2d brownian motion simulator in Python. It's obviously easy to draw values for x displacement and y displacement from a distribution, but I have to set it up so that the 2d displacement (ie hypotenuse) is drawn from a distribution, and then translate this to new x and y coordinates. This is probably trivial and I'm just too far removed from trigonometry to remember how to do it correctly. Am I going to need to generate a value for the hypotenuse and then translate it into x and y displacements with sin and cos? (How do you do this correctly?)
2d random walk in python - drawing hypotenuse from distribution
0
1.2
1
0
0
996
9,318,574
2012-02-16T20:29:00.000
9
0
1
0
0
python,unicode,repr
0
9,318,611
0
4
0
true
0
0
repr(x).decode("utf-8") and unicode(repr(x), "utf-8") should work.
2
8
0
0
I call a __repr__() function on object x as follows: val = x.__repr__() and then I want to store val string to SQLite database. The problem is that val should be unicode. I tried this with no success: val = x.__repr__().encode("utf-8") and val = unicode(x.__repr__()) Do you know how to correct this? I'm using Python 2.7.2
How to make __repr__ to return unicode string
0
1.2
1
0
0
11,366
9,318,574
2012-02-16T20:29:00.000
16
0
1
0
0
python,unicode,repr
0
9,319,359
0
4
0
false
0
0
The representation of an object should not be Unicode. Define the __unicode__ method and pass the object to unicode().
2
8
0
0
I call a __repr__() function on object x as follows: val = x.__repr__() and then I want to store val string to SQLite database. The problem is that val should be unicode. I tried this with no success: val = x.__repr__().encode("utf-8") and val = unicode(x.__repr__()) Do you know how to correct this? I'm using Python 2.7.2
How to make __repr__ to return unicode string
0
1
1
0
0
11,366
9,322,042
2012-02-17T02:19:00.000
3
1
0
1
0
python,perl,scripting,lua,cgi
0
9,323,660
0
5
0
false
0
0
One idea that comes to my mind is to create a chroot'ed env for each of your user and run the user's script in that chroot'ed env.
1
2
0
0
I want my users to write code and run it inside a controlled environment, like for example Lua or Perl. My site runs on Perl CGI's. Is there a way to run an isolated perl/Lua/python/etc script without access to the filesystem and returns data via stdout to be saved in a database? What i need is a secure environment, how do i apply the restrictions? Thanks in advance. FYI: I want to achieve something like ideone.com or codepad.org I've been reading about sandboxes in Lua or inline code, but they don't allow me to limit resources and time, just operations. I think i'll have a virtual machine and run the code in there, any tips?
How to run a script that can only write to STDOUT and read from STDIN?
0
0.119427
1
0
0
303
9,322,410
2012-02-17T03:18:00.000
1
1
0
1
0
python,unicode,python-3.x,cgi
0
9,322,497
0
7
0
false
0
0
Your best bet is to explicitly encode your Unicode strings into bytes using the encoding you want to use. Relying on the implicit conversion will lead to troubles like this. BTW: If the error is really UnicodeDecodeError, then it isn't happening on output, it's trying to decode a byte stream into Unicode, which would happen somewhere else.
3
23
0
0
When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. It seems that open() and print() use the return value of locale.getpreferredencoding() to know what encoding to use by default. When running on the command line, that value is 'UTF-8', as it should be. But when running the script through a browser, the encoding mysteriously gets redefined to 'ANSI_X3.4-1968', which appears to be a just a fancy name for plain ASCII. I now need to know how to make the cgi script run with 'utf-8' as the default encoding in all cases. My setup is Python 3.1.3 and Apache2 on Debian Linux. The system-wide locale is en_GB.utf-8.
Set encoding in Python 3 CGI scripts
0
0.028564
1
0
0
7,021
9,322,410
2012-02-17T03:18:00.000
4
1
0
1
0
python,unicode,python-3.x,cgi
0
9,337,200
0
7
0
false
0
0
You shouldn't read your IO streams as strings for CGI/WSGI; they aren't Unicode strings, they're explicitly byte sequences. (Consider that Content-Length is measured in bytes and not characters; imagine trying to read a multipart/form-data binary file upload submission crunched into UTF-8-decoded strings, or return a binary file download...) So instead use sys.stdin.buffer and sys.stdout.buffer to get the raw byte streams for stdio, and read/write binary with them. It is up to the form-reading layer to convert those bytes into Unicode string parameters where appropriate using whichever encoding your web page has. Unfortunately the standard library CGI and WSGI interfaces don't get this right in Python 3.1: the relevant modules were crudely converted from the Python 2 originals using 2to3 and consequently there are a number of bugs that will end up in UnicodeError. The first version of Python 3 that is usable for web applications is 3.2. Using 3.0/3.1 is pretty much a waste of time. It took a lamentably long time to get this sorted out and PEP3333 passed.
3
23
0
0
When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. It seems that open() and print() use the return value of locale.getpreferredencoding() to know what encoding to use by default. When running on the command line, that value is 'UTF-8', as it should be. But when running the script through a browser, the encoding mysteriously gets redefined to 'ANSI_X3.4-1968', which appears to be a just a fancy name for plain ASCII. I now need to know how to make the cgi script run with 'utf-8' as the default encoding in all cases. My setup is Python 3.1.3 and Apache2 on Debian Linux. The system-wide locale is en_GB.utf-8.
Set encoding in Python 3 CGI scripts
0
0.113791
1
0
0
7,021
9,322,410
2012-02-17T03:18:00.000
3
1
0
1
0
python,unicode,python-3.x,cgi
0
44,271,683
0
7
0
false
0
0
Summarizing @cercatrova 's answer: Add PassEnv LANG line to the end of your /etc/apache2/apache2.conf or .htaccess. Uncomment . /etc/default/locale line in /etc/apache2/envvars. Make sure line similar to LANG="en_US.UTF-8" is present in /etc/default/locale. sudo service apache2 restart
3
23
0
0
When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. It seems that open() and print() use the return value of locale.getpreferredencoding() to know what encoding to use by default. When running on the command line, that value is 'UTF-8', as it should be. But when running the script through a browser, the encoding mysteriously gets redefined to 'ANSI_X3.4-1968', which appears to be a just a fancy name for plain ASCII. I now need to know how to make the cgi script run with 'utf-8' as the default encoding in all cases. My setup is Python 3.1.3 and Apache2 on Debian Linux. The system-wide locale is en_GB.utf-8.
Set encoding in Python 3 CGI scripts
0
0.085505
1
0
0
7,021
9,336,053
2012-02-17T22:00:00.000
1
0
1
0
0
python,com,vb6,activex
0
9,358,941
0
1
0
true
0
0
The parameter that should be in Dispatch is a string called the ProgID (Program ID). This is of the form <projectname>.<classname> . So for instance, if your VB6 project was called BusinessLib, and it contained a Public class called Formulae, the string would be BusinessLib.Formulae.
1
0
0
0
I created a VB6 DLL and it is registered on my PC. I have pywin32 and python2.7 installed. I ran makepy in the win32com\client dir and chose the appropriate DLL. I am now at a loss as to how to use this DLL in my Python program...examples on the Web show win32com.client.Dispatch(X), but what do I use for X? How do I use a human readable name to access this DLL in Python?
How to use VB6 DLL (Active X/COM) in Python?
0
1.2
1
0
0
819
9,338,289
2012-02-18T03:35:00.000
0
0
1
0
1
python
0
9,338,332
0
2
0
false
0
0
Do pseudo code for defining all the possible outcomes, and conditional statements for saying what happens "if" one has one and the other has their choice. who wins? make function modules for each specific process that happens, which is basically just what i already said. at least that's how i would do it in C, I am very new to programming myself. Chris
1
0
0
0
I am quite literally two weeks familiar with any programming whatsoever. I am currently enrolled in a class on Python. I have a programming assignment that requires me to write a program that simulates the game 'rock, paper, scissors'. It is supposed to be designed as a two player game that: 1: gets the first player's name. 2: gets the second player's name. 3: displays a 'Let's Play!' intro. 4: asks the first player for their entry. 5: asks the second player for their entry. 6: display the results. 7: ask the user if they want to play again. I have been able to write the simple programs up to this point, but I am really lost on this assignment; I can't seem to get anything to work at all. any help on how to get started would be appreciated.
problems with rock paper scissors in python
0
0
1
0
0
442
9,344,163
2012-02-18T18:57:00.000
4
0
1
0
0
python,pep8
1
9,344,207
0
2
0
false
0
0
Throw an exception, this is what they are there for. They allow the things using your code to manage the error, passing back strings provides too much opportunity for mishandling. Consider the case you return a string or an iterable normally, checking for an error message could cause problems, and may not catch them all the time, it's also not very Pythonic.
1
12
0
0
I was wondering how you guys handle functions fails. Do you raise an exception, or do you return an error message? e.G. I have a function that is supposed to connect to an external com-object. If the com-object has not been initiated through another program, the connection cannot be established. What would be the preferred python way of notifying the main program? Should I raise an exception with the detailed error message, or should I simple return the error message? Thanks!
Function failed: Raise Exception, or return FALSE? What's the better approach?
0
0.379949
1
0
0
10,315
9,347,419
2012-02-19T07:07:00.000
1
0
1
0
1
python,strip
1
9,347,524
0
7
0
false
0
0
Often, depending on the way you read the lines, in order to get rid of \n from myline, you can take myline[:-1] since \n is the last character of myline. For the '\t' you can use replace() or strip()
2
112
0
0
This is my problem. I'm trying to read a text file and then convert the lines into floats. The text file has \n and \t in it though I don't know how to get rid of it. I tried using line.strip() but it didn't take it off and I got an error when I wanted to convert the stuff to floats. I then tried line.strip("\n") but that didn't work either. My program works fine when I take out the \t and \n from the text file, but it's part of the assignment to get it to work with them. I really don't know why this isn't working. Thanks for any help.
Python strip with \n
0
0.028564
1
0
0
575,477
9,347,419
2012-02-19T07:07:00.000
1
0
1
0
1
python,strip
1
9,347,611
0
7
0
false
0
0
If you're trying to convert lines of floats separated by tab characters, then just float(line) will try to convert the whole line into one float, which will fail if there's more than one. Using strip to get rid of leading and trailing whitespace isn't going to help that fundamental problem. Maybe you need to split each line into pieces and do something with each piece?
2
112
0
0
This is my problem. I'm trying to read a text file and then convert the lines into floats. The text file has \n and \t in it though I don't know how to get rid of it. I tried using line.strip() but it didn't take it off and I got an error when I wanted to convert the stuff to floats. I then tried line.strip("\n") but that didn't work either. My program works fine when I take out the \t and \n from the text file, but it's part of the assignment to get it to work with them. I really don't know why this isn't working. Thanks for any help.
Python strip with \n
0
0.028564
1
0
0
575,477
9,350,183
2012-02-19T14:46:00.000
0
0
0
0
0
java,c++,python,eclipse,wxpython
0
9,363,014
0
1
0
true
0
1
Regarding missing parameters on the constructor for wx.Button, unfortunately that's currently expected. Please create a bug report for PyDev specifying that.
1
1
0
0
How can I activate autocompletion feature for wx classes in pyDev? I cannot find anything to prompt me to change that will activate this feature from PyDev>Preference>Autocompletion. How can I get autocompletion from packages like wx and other third-party packages? Update: I added wx path in configuration to pyDev and it now shows autocompletion for wx. However, I cannot see the method arguments and properties. For example if I seek for wx.Button, I just get autocompletion to complete writing Button but I want to know the required arguments for wx.Button as wx.Button(,....,size,pos...) etc. This works for the other methods of built-in methods when I press Ctrl+Space but I don't know how should I configure to get that from wx and other third party packages?
Autocompletion in Pydev- Eclipse for wxpython
0
1.2
1
0
0
324
9,350,430
2012-02-19T15:21:00.000
7
0
1
0
0
python,unicode
0
9,350,510
0
2
0
false
0
0
There is no difference after those strings have been parsed by the interpreter. One version simply puts the special characters, but it requires the source file to have a special encoding, such as UTF-8. The second version replaces those characters with their byte representation, so it's safe to have such strings in an ASCII-encoded file. You can't talk about "converting" between them, because they are essentially the same strings. But here is something that may be interesting. print u'Georges M\xe9li\xe8s' gives the output Georges Méliès and print repr(u'Georges Méliès') gives u'Georges M\xe9li\xe8s'
2
2
0
0
I've read a dozen pages but im still not getting it. Where is the difference between these versions: u'Georges Méliès' and u'Georges M\xe9li\xe8s' and how do convert one to the other and vice-versa?
u'Georges Méliès' vs u'Georges M\xe9li\xe8s'
0
1
1
0
0
139
9,350,430
2012-02-19T15:21:00.000
2
0
1
0
0
python,unicode
0
9,350,587
0
2
0
true
0
0
It's the same, and I would add: u'Georges Méliès'.encode('latin1') gives 'Georges M\xe9li\xe8s'
2
2
0
0
I've read a dozen pages but im still not getting it. Where is the difference between these versions: u'Georges Méliès' and u'Georges M\xe9li\xe8s' and how do convert one to the other and vice-versa?
u'Georges Méliès' vs u'Georges M\xe9li\xe8s'
0
1.2
1
0
0
139
9,350,571
2012-02-19T15:40:00.000
0
0
1
1
0
python,macos,package,packagemaker,mpkg
0
9,356,034
1
1
0
false
0
0
You don't need any scripts - you can do that with Package Manager alone - the Package Manager GUI allows you to tag packages as installable (enabled) and selected based on conditions such as OS version (in Choices under Requirements)
1
0
0
0
I am trying to create a .pkg installer for a python application (specifically Spyderlib). This is not an app but a python package and a command line executable that have to be copied to specific locations. However, the location depends on the version of OSX. I'm only targeting 10.6 and 10.7 but they come with different versions of python (2.6 and 2.7) so the install path is different. Using bdist_mpkg I was able to create a Mac mpkg in 10.7 which installs correctly and can be edited with PackageMaker. Now I want to know how I can edit this package so that it detects the version of OSX and sets the install target path correctly. I understand that I can use shell scripts to do pre and post-installation jobs, however I haven't been able to find examples of how to do this and how a script could but used to set the install target for the files in the mpkg. Alternatively, it may be that this is possible to do directly from PackageMaker, but i was not able to see anything to this effect (and the documentation seems quite superficial). So I would like to know how this could be done. It would also be really helpful to see some examples for other software packages.
How to create a Mac .pkg from python which supports multiple versions of OSX
1
0
1
0
0
514
9,355,472
2012-02-20T02:26:00.000
2
0
1
0
0
python,parallel-processing,multiprocessing
0
9,355,626
0
2
0
false
0
0
It's definitely based on what the application does. If it's CPU-heavy, the number of cores is a sane starting point. If it's IO-heavy, mulitple processes won't help performance anyway. If it's mostly CPU with occasional IO (e.g. PNG optimisation), you can run a few processes more than the number of cores. The only way to know for certain is to run your application with some realistic input and check the resource utilisation. If you have CPU time to spare, add more worker processes.
1
19
0
0
I'm just getting my feet wet with multiprocessing(and its totally awesome!), but I was wondering if there was any guidelines to selecting number of processes? Is it just based on number of cores on the server? Is it somehow based on the application your running(number of loops, how much cpu it uses,etc)? etc...how do I decide how many processes to spawn? Right now, I'm just guessing and add/removing processes but it would be great if there was some kind of guideline or best practice. Another question, I know what happens if I add too few(program is slooow) but what if I add 'too many'? Thanks!
Are there any guidelines to follow when choosing number of processes with multiprocessing?
1
0.197375
1
0
0
5,306
9,366,899
2012-02-20T19:06:00.000
0
1
0
0
0
php,python,sockets
0
9,367,348
0
1
0
false
0
0
Erm, sorry, you can't do WebSockets (at least not properly to my knowledge) without opening ports. You might be able to fake it with PHP, but the timeout would defeat it. I would recommend Comet AJAX/long-polling instead.
1
0
0
0
I want to ask you guys, how to make my php (or python) socket server to start when a client make request to a specific file and to stop, when client stops. Also, is there a way to make a php or python socket server not to open any ports (maybe to use port 80, which I think is possible, thanks to the request above). I'm using a public hosting which doesn't allow me to open ports or to use terminal commands.
html5 websockets OR flash sockets activated on load?
1
0
1
0
1
87
9,379,307
2012-02-21T14:31:00.000
7
0
0
0
0
python,django
0
9,379,383
0
1
0
true
1
0
Use virtualenv. Create a virtualenv, activate it, install what you need, then do pip freeze > requirements.txt to create a file listing all your requirements. Then on your new machine (also inside a virtualenv) you can do pip install -r requirements.txt to reinstall all those libraries.
1
1
0
0
I've been developing a Django app and in the process I installed a couple of component using pip (e.g. pip install django-ajax-selects). I just realized that those components aren't installed in my app directory but somewhere which is machine specific. First, how do I keep track of all the components I installed. Second, how do I install those component in my app directory so that I can move the code from machine to machine without having to do "pip install ...". Thanks!
How to keep track of all the components used by my Django app
0
1.2
1
0
0
100
9,383,740
2012-02-21T19:19:00.000
175
0
1
0
0
python,eval
0
9,384,005
0
10
0
false
0
0
eval() interprets a string as code. The reason why so many people have warned you about using this is because a user can use this as an option to run code on the computer. If you have eval(input()) and os imported, a person could type into input() os.system('rm -R *') which would delete all your files in your home directory. (Assuming you have a unix system). Using eval() is a security hole. If you need to convert strings to other formats, try to use things that do that, like int().
4
331
0
0
In the book that I am reading on Python, it keeps using the code eval(input('blah')) I read the documentation, and I understand it, but I still do not see how it changes the input() function. What does it do? Can someone explain?
What does Python's eval() do?
0
1
1
0
0
488,578
9,383,740
2012-02-21T19:19:00.000
6
0
1
0
0
python,eval
0
31,014,206
0
10
0
false
0
0
eval(), as the name suggests, evaluates the passed argument. raw_input() is now input() in python 3.x versions. So the most commonly found example for the use of eval() is its use to provide the functionality that input() provided in 2.x version of python. raw_input returned the user-entered data as a string, while input evaluated the value of data entered and returned it. eval(input("bla bla")) thus replicates the functionality of input() in 2.x, i.e., of evaluating the user-entered data. In short: eval() evaluates the arguments passed to it and hence eval('1 + 1') returned 2.
4
331
0
0
In the book that I am reading on Python, it keeps using the code eval(input('blah')) I read the documentation, and I understand it, but I still do not see how it changes the input() function. What does it do? Can someone explain?
What does Python's eval() do?
0
1
1
0
0
488,578
9,383,740
2012-02-21T19:19:00.000
28
0
1
0
0
python,eval
0
9,383,771
0
10
0
false
0
0
In Python 2.x input(...) is equivalent to eval(raw_input(...)), in Python 3.x raw_input was renamed input, which I suspect lead to your confusion (you were probably looking at the documentation for input in Python 2.x). Additionally, eval(input(...)) would work fine in Python 3.x, but would raise a TypeError in Python 2. In this case eval is used to coerce the string returned from input into an expression and interpreted. Generally this is considered bad practice.
4
331
0
0
In the book that I am reading on Python, it keeps using the code eval(input('blah')) I read the documentation, and I understand it, but I still do not see how it changes the input() function. What does it do? Can someone explain?
What does Python's eval() do?
0
1
1
0
0
488,578
9,383,740
2012-02-21T19:19:00.000
6
0
1
0
0
python,eval
0
9,383,854
0
10
0
false
0
0
Maybe a misleading example of reading a line and interpreting it. Try eval(input()) and type "1+1" - this should print 2. Eval evaluates expressions.
4
331
0
0
In the book that I am reading on Python, it keeps using the code eval(input('blah')) I read the documentation, and I understand it, but I still do not see how it changes the input() function. What does it do? Can someone explain?
What does Python's eval() do?
0
1
1
0
0
488,578
9,384,021
2012-02-21T19:40:00.000
1
0
1
1
1
python,macos,crash,python-idle
0
21,723,895
0
5
0
false
0
0
I had the same issue. I run OSX 10.8.5, Python 3.3.3 and IDLE 3.3.3 and reinstalling Python haven't been a solution. I solved any problem removing the ~/.idlerc directory. My problem showed for the first time when I tried to change some Preferences (IDLE->Preferences->General->Startup Preferences->At Startup Open Edit Window), so I suppose that's why resetting my Preferences deleting ~/.idlerc folder have been the solution.
2
3
0
0
I recently attempted to install python 3.2 along with IDLE 3 on my macbook pro. I successfully installed python 3.2 (as in, I can run it from the terminal), but when I attempted to install IDLE 3.2 I must have done something wrong because now both IDLE 2.7 and IDLE 3.2 crash immediately upon opening with the message "Python quit unexpectedly", no matter whether I open it through the terminal or through finder. Does anyone know how to fix this? I have installed the correct ActiveTCL package (and reinstalled) and still nothing. I have attempted to reinstall python 3.2 and IDLE 3 but I am not sure whether I did it correctly. Through a good amount of googling I found some people say that it was most likely a path issue but all of the solutions I found were using Windows so I am not sure how to apply that to my mac.
IDLE crash when opening on Mac OS X
0
0.039979
1
0
0
7,506
9,384,021
2012-02-21T19:40:00.000
0
0
1
1
1
python,macos,crash,python-idle
0
26,536,767
0
5
0
false
0
0
I had the same problem where IDLE would crash after I opened it on my MAC I ended up updating my computer to OS Yosemite. and the most updated version of python but it still would shut the reason it started was because I tried to change the preferences for certain keys. Resetting the preferences fixed it! I typed mc ~/.idlerc idlerc2 :)
2
3
0
0
I recently attempted to install python 3.2 along with IDLE 3 on my macbook pro. I successfully installed python 3.2 (as in, I can run it from the terminal), but when I attempted to install IDLE 3.2 I must have done something wrong because now both IDLE 2.7 and IDLE 3.2 crash immediately upon opening with the message "Python quit unexpectedly", no matter whether I open it through the terminal or through finder. Does anyone know how to fix this? I have installed the correct ActiveTCL package (and reinstalled) and still nothing. I have attempted to reinstall python 3.2 and IDLE 3 but I am not sure whether I did it correctly. Through a good amount of googling I found some people say that it was most likely a path issue but all of the solutions I found were using Windows so I am not sure how to apply that to my mac.
IDLE crash when opening on Mac OS X
0
0
1
0
0
7,506
9,385,251
2012-02-21T21:12:00.000
0
0
0
0
0
python,c,database,daemon,opencl
0
9,497,466
0
1
0
false
0
1
Yes, C extensions can have internal structures allocated, but be sure to destroy your data properly when needed. You can also write your code as a C/C++ DLL and use the ctypes python extension to access C functions directly and pass them C variables (ints, char *, etc.).
1
0
0
0
I am working on a proof of concept for an in-memory database. I do know about stuff like redis and love things like intersecting sets but that is not enough. I want to find out how to implement a service which is like the parstream database or the drawntoscale solutions. And therefore I like to have a daemon which keeps stuff in the memory. I did a prototype with pyro which does what it should: generate a random bitmap index and accept an bitmap mask as input from a pyro client and return all primary keys which match the bitmap mask. But iterating over the index is too slow by some magnitudes which is obvious since it is python. I would like to use an C extension which does the index scan. Therefore the bitmap index shoud be kept in memory inside the c extension. The very next step would be to keep the same data in the gpu ram iterate over inside my gpu. Having no experience writing c extensions and pyOpenCL my question is: can I keep data inside my C Extension and use python ( pyro daeomon or maybe even flask/tornado ) just for receiving and returning the queries without copying the whole bitmap index all the time? Regards Christian
python c extension / opencl daemon
0
0
1
0
0
167
9,389,381
2012-02-22T05:08:00.000
0
0
0
0
0
python,cx-oracle
0
21,155,146
0
2
0
false
0
0
With-out establishing a connection,. No you can never asking anything. It's like going to Google Page.(Internet Architecture - wether you call it sessionless or session based) As for Authentical, if no permission are set - Oracle uses a username 'nobody' as a user and thus gives every user a session. I am a user of Oracle APEX, and I use Python, PLSQL regurlary. That's one nice question. Thanks.
1
7
0
0
In order to demonstrate the security feature of Oracle one has to call OCIServerVersion() or OCIServerRelease() when the user session has not yet been established. While having the database parameter sec_return_server_release_banner = false. I am using Python cx_Oracle module for this, but I am not sure how to get the server version before establishing the connection. Any ideas?
python cx_oracle and server information
0
0
1
1
0
1,064
9,394,676
2012-02-22T12:25:00.000
0
0
1
0
0
python,import
0
9,394,920
0
6
0
false
0
0
There is no easy way to do a from foo import func_*, alas. You should import them all by name explicitly to make the code more cleaner and readable.
1
1
0
0
I have a bunch of functions defined in file foo.py, each of them has the name like func_xxx. I want import only those functions, not the other things in foo.py. How can I achieve that without list them all?
Python: how to import a bunch of similar names?
0
0
1
0
0
155
9,395,758
2012-02-22T13:29:00.000
0
0
1
0
0
python,arrays,memory,numpy,floating-point
0
62,791,902
0
3
0
false
0
0
I gauss, easily, we can compute by print(a.size // 1024 // 1024, a.dtype) it is similar to how much MB is uesd, however with the param dtype, float=8B, int8=1B ...
1
23
1
0
Does anybody know how much memory is used by a numpy ndarray? (with let's say 10,000,000 float elements).
How much memory is used by a numpy ndarray?
0
0
1
0
0
14,086
9,396,312
2012-02-22T14:02:00.000
1
0
1
0
0
python,python-imaging-library
0
9,396,440
0
3
0
false
0
0
The general algorithmn would be to find the color of the top left pixel, and then do a spiral scan inwards until you find a pixel not of that color. That will define one edge of your bounding box. Keep scanning until you hit one more of each edge.
1
6
0
0
Any ideas how to use Python with the PIL module to shrink select all? I know this can be achieved with Gimp. I'm trying to package my app as small as possible, a GIMP install is not an option for the EU. Say you have 2 images, one is 400x500, other is 200x100. They both are white with a 100x100 textblock somewhere within each image's boundaries. What I'm trying to do is automatically strip the whitespace around that text, load that 100x100 image textblock into a variable for further text extraction. It's obviously not this simple, so just running the text extraction on the whole image won't work! I just wanted to query about the basic process. There is not much available on Google about this topic. If solved, perhaps it could help someone else as well... Thanks for reading!
Use Python / PIL or similar to shrink whitespace
0
0.066568
1
0
0
4,161
9,419,327
2012-02-23T18:53:00.000
1
0
1
0
0
python,numpy,centos
0
9,419,462
0
4
0
true
0
0
Python searches the path in order, so simply put the directory where you installed your NumPy first in the path. You can check numpy.version.version to make sure you're getting the version you want.
1
1
1
0
I'm using a server where I don't have administrative rights and I need to use the latest version of numpy. The system administrator insists that he cannot update the global numpy to the latest version, so I have to install it locally. I can do that without trouble, but how do I make sure that "import numpy" results in the newer local install to be imported, as opposed to the older global version? I can adjust my PYTHONPATH, but I will want to use some of the global imports as well so I can't exclude all the global packages. I'm on CentOS 6, by the way. Thanks!
have local numpy override global
0
1.2
1
0
0
1,857
9,421,373
2012-02-23T21:11:00.000
1
1
1
0
0
python,deployment
0
9,421,431
0
5
0
false
0
0
Build a web application in python. Then the world can use it via a browser with zero install.
3
14
0
0
Is it possible to deploy python applications such that you don't release the source code and you don't have to be sure the customer has python installed? I'm thinking maybe there is some installation process that can run a python app from just the .pyc files and a shared library containing the interpreter or something like that? Basically I'm keen to get the development benefits of a language like Python - high productivity etc. but can't quite see how you could deploy it professionally to a customer where you don't know how there machine is set up and you definitely can't deliver the source. How do professional software houses developing in python do it (or maybe the answer is that they don't) ?
deploying python applications
0
0.039979
1
0
0
9,784
9,421,373
2012-02-23T21:11:00.000
19
1
1
0
0
python,deployment
0
9,421,511
0
5
0
true
0
0
You protect your source code legally, not technologically. Distributing py files really isn't a big deal. The only technological solution here is not to ship your program (which is really becoming more popular these days, as software is provided over the internet rather than fully installed locally more often.) If you don't want the user to have to have Python installed but want to run Python programs, you'll have to bundle Python. Your resistance to doing so seems quite odd to me. Java programs have to either bundle or anticipate the JVM's presence. C programs have to either bundle or anticipate libc's presence (usually the latter), etc. There's nothing hacky about using what you need. Professional Python desktop software bundles Python, either through something like py2exe/cx_Freeze/some in-house thing that does the same thing or through embedding Python (in which case Python comes along as a library rather than an executable). The former approach is usually a lot more powerful and robust.
3
14
0
0
Is it possible to deploy python applications such that you don't release the source code and you don't have to be sure the customer has python installed? I'm thinking maybe there is some installation process that can run a python app from just the .pyc files and a shared library containing the interpreter or something like that? Basically I'm keen to get the development benefits of a language like Python - high productivity etc. but can't quite see how you could deploy it professionally to a customer where you don't know how there machine is set up and you definitely can't deliver the source. How do professional software houses developing in python do it (or maybe the answer is that they don't) ?
deploying python applications
0
1.2
1
0
0
9,784
9,421,373
2012-02-23T21:11:00.000
8
1
1
0
0
python,deployment
0
9,421,442
0
5
0
false
0
0
Yes, it is possible to make installation packages. Look for py2exe, cx_freeze and others. No, it is not possible to keep the source code completely safe. There are always ways to decompile. Original source code can trivially be obtained from .pyc files if someone wants to do it. Code obfuscation would make it more difficult to do something with the code.
3
14
0
0
Is it possible to deploy python applications such that you don't release the source code and you don't have to be sure the customer has python installed? I'm thinking maybe there is some installation process that can run a python app from just the .pyc files and a shared library containing the interpreter or something like that? Basically I'm keen to get the development benefits of a language like Python - high productivity etc. but can't quite see how you could deploy it professionally to a customer where you don't know how there machine is set up and you definitely can't deliver the source. How do professional software houses developing in python do it (or maybe the answer is that they don't) ?
deploying python applications
0
1
1
0
0
9,784
9,431,870
2012-02-24T13:53:00.000
1
0
0
0
0
python,qt,customization,pyside,qtreeview
0
9,434,264
0
1
0
true
0
1
I'd recomend you use simple QTreeWidget and insert complex widgets with setItemWidget. While Qt's widhets are alien, they are not so heavy to draw, but: You shouldn't create delegates. You shouldn't handle events (If you are going to place button in view and draw it using delegates, you had to handle all its events, such as mouseOver, focus changing, etc. It is a lot of work.
1
0
0
0
I'm new to PySide and Qt at all, and now need to create an application which has a tree view with styled items. Each item needs two lines of text (different styles), and a button. Many items are supposed to be in the view, so I chose QTreeView over QTreeWidget. Now I managed to add simple text items (non-styled) to the QTreeView and have almost no idea about how to place several widgets on one item. Could you please give me an example of how to create such design? I've found some samples on the Internet, that are similar to what I want, but they all are in C++, and it's not obvious how to convert delegates and other things to Python. I'm now really confused about it all...
Customize QTreeView items
1
1.2
1
0
0
1,305
9,434,494
2012-02-24T16:35:00.000
0
0
1
0
0
python,asynchronous,client,asyncsocket
0
9,527,618
0
1
0
false
0
0
Is it possible for each thread (each client) to open their own socket? In that case, it's all a non-issue: Only the client in that one thread has a handle on that socket and so it automatically gets the correct data from the server. For the server, all of these connections from the client will look like completely independent client connections (which is exactly what they are). If one of the requirements is to limit the overall number of network connections then you could construct a special thread that maintains the connection to the server, and which locally receives communication requests from the various threads/ But using the independent sockets (one per thread) is probably much simpler. Do you absolutely have to use application level keepalive? Because TCP can do this for you, automatically. If the keepalive is not received in time then the socket is closed, thus informing the other side that the connection has timed out. Do consider this as an option, if it's possible in your case. Finally, if you don't have to do the application-level keepalive you can take advantage of one of the nice aspects of multi-threaded programming: Develop each thread as if it's the only one out there and you then don't need to worry about anything asynchronous at all. For example, you can write your client to send request and then blocking-wait for resonse, do computation and either send result or check if more data from the server has arrived. The data from the server will have accumulated in the TCP receive window on your side. This also serves as a means of flow control: If your client becomes too slow and the receive window is full then the server cannot send anymore. This might block the server, so you need to see whether the server can handle this situation.
1
2
0
0
first thing is, I'm a long time lurker but the first time user, I'd like to thank you all for creating the site! I'm in a situation that I need to implement the client part of a proprietary protocol. The protocol uses TCP/IP underneath and the message flow can be summarized as follows: Client connects to server Client expresses interest in data of a certain type If server has any such data, it it sent down to the client Client confirms the reception to the server Client now needs to tell the server that it is still interested in data of the same type Server sends the data to the client as it is coming in Client needs to send application-level keep-alive requests to the server from time to time (like each minute or so) Some messages from the server require the client to send a reply back to the server Client disconnects All of that is to happen within a single TCP session, which is to be a long-living one, sort of like WebSocket I imagine. Another thing is that the client is to be deployed on a multi-threaded server and should allow for concurrent access from several threads, which means that a single thread should be able to 'subscribe' to messages of a certain type from the server and should also be able to send the messages to it. I'm well aware of GIL hence I guess it doesn't much make to comment on that, I'm only writing a client, I can't change any other pieces of the architecture. So the thing is that I've never had to delve below the HTTP level, I've been lucky enough to always use some already existing libraries and on the other hand, I haven't done that much network programming, that would be the first time I'll be something like that myself. I'd like it to be an opportunity for me to learn more about all the asynchronous libraries/tools/toolkits like select, epoll, libev or gevent. The trouble is that most of the resources on the web deal with writing servers and I'm not even sure if that I'm to deploy the client on a multi-threaded doesn't mean all of them won't do much. All of the servers people are obviously single-threaded but it's not clear if it's because multiple threads aren't needed or if it's because things like epoll don't really like multiple threads using them. The server clearly treats all the clients like if they were single-threaded units so I think I will need to serialize the access to the client. The thing I can't quite get is how to make sure the server responses match threads and vice versa. If one thread receives a message but another thread needs to confirm a message it received prior to the former one's getting a chance of confirming it, then how I can be sure the messages simply don't get mixed up? What do you think about it all? Are asynchronous libraries a good choice in this case? Can you think of any code samples I could have a look at? I'm using Python but the question I think is generic enough that I can use C, C++ or Java for inspiration. Many, many thanks!
Long-lived multithreaded client for a proprietary protocol (Python, select, epoll)
0
0
1
0
1
494
9,449,927
2012-02-26T02:09:00.000
1
0
1
0
0
python
0
9,450,016
0
3
0
false
0
0
You may try importing pdb and doing a pdb.pprint.pprint(response) If it's a program running on your own machine, you can also do a pdb.set_trace() and play with response. The ipdb module has nicer versions, but it's not usually installed by default.
1
0
0
0
I would like to interrogate all new emails (one by one) and find the contents of them so that I can use the contents for another application. My first step was interpreting the return values from a search done via the search attr of an IMAP4 object. I'm trying to figure out what data is in a list that I have returned to me. How can I examine the object tree via print? Or, better yet, how can I get the contents of the email in a string? For ex., I am returned the following via print: unseen email content: ['3 4'] from a variable named "response". If I run print response.__class__.__name__, I get "list" returned. I know that there is other data in "3", and "4", I just don't know what. update: Specifically, this is the return of a call to an IMAP4obj.search(None, '(UNSEEN)')
find all items in list object
0
0.066568
1
0
0
176
9,452,631
2012-02-26T11:19:00.000
4
1
0
1
0
python,information-retrieval,inverted-index
0
9,452,656
0
2
0
false
0
0
Worry about optimization after the fact. Write the code, profile it, stress test it, identify the slow parts and offset them in Cython or C or re-write the code to make it more efficient, it might be faster if you load it onto PyPy as that has a JIT Compiler, it can help with long running processes and loops. Remember Premature optimization, is the root of all evil. (After threads of course)
1
2
0
0
I am working on building an inverted index using Python. I am having some doubts regarding the performance it can provide me. Would Python be almost equally as fast in indexing as Java or C? Also, I would like to know if any modules/implementations exists (and what are they, some link please?) for the same and how well do they perform compared to the something developed in Java/C? I read about this guy who optimized his Python twice as fast as C by using it with Psyco. I know for a fact that this is misleading since gcc 3.x compilers are like super fast. Basically, my point is I know Python won't be faster than C. But is it somewhat comparable? And can someone shed some light on its performance compared with Java? I have no clue about that. (In terms of inverted index implementation, if possible because it would essentially require disk write and reads.) I am not asking this here without googling first. I didn't get a definite answer, hence the question. Any help is much appreciated!
Inverted Index System using Python
1
0.379949
1
0
0
2,059
9,484,724
2012-02-28T15:27:00.000
1
0
0
1
0
python,user-interface,ubuntu,tkinter,restriction
0
9,489,644
0
3
0
false
0
1
Don't start a window manager. Only start your program, e.g. from xinitrc. Make the program full-screen
1
1
0
0
I wrote a python GUI in Tkinter for a time-clock system. The micro machine is wall mounted and the employees only have access to the touchscreen menu I programmed and a barcode swipe. I know how to get the script to start on startup, but how do I prevent them from exiting out or opening other menus? Basically the sole purpose of this console is to run the time-clock GUI. If it cant be done in Ubuntu, is there another flavor of linux it can be done in?
How do I limit a Ubuntu machine to a Python GUI?
1
0.066568
1
0
0
224
9,500,524
2012-02-29T14:02:00.000
1
0
0
0
1
python,eclipse,scipy
0
9,500,809
0
1
0
true
0
0
Try to recreate your project in PyDev and add these new libraries.
1
1
1
0
I just installed Scipy and Numpy on my machine and added them to the System Library option in eclipse. Now the program runs fine, but eclipse editor keeps giving this red mark on the side says "Unresolved import". I guess I didn't configure correctly. Any one know how to fix this ? Thanks.
Eclipse editor doesn't recognize Scipy content
0
1.2
1
0
0
611
9,517,054
2012-03-01T13:26:00.000
6
0
0
0
0
python,multithreading,postgresql,web-applications,concurrency
0
9,521,531
0
1
0
true
1
0
Flask will execute each request in a separate thread or even in separate processes. The number of threads and processes to spawn is determined by the WSGI server (for example, Apache with mod_wsgi). If you use SQLAlchemy ScopedSessions, the session is perfectly thread-safe. You must not share ORM-controlled objects across threads (but in the large majority of cases, you won't let your objects live longer than a request anyway so this is usually not a concern). In other words, as long as you don't intend to share state between requests other than through the database or cookies, you don't need to worry about concurrency issues. You don't need to create a lock for writing to the database. If you create your own long-lived objects within your application, which you most likely don't need to do, and if those objects communicate or share state with request handling code, then you must take appropriate precautions to avoid synchronization issues (race conditions, deadlocks, use of libraries that are not thread-safe, etc.)
1
1
0
0
I am developing web app on flask, python, sqlalchemy and postgresql. My question is here regarding concurrency handling in this app. How I wrote the app : I take the example of adding user in database. I post the form and a view is called. I process all the form data and then call add_user(*arg) which uses sqlalchemy code to insert user in database and returns on successful execution and I return the response from the view. What I assumed: Ok now I assumed that my web server (which I have not decided yet) will either spawn a thread or a process if two users are trying to signup at the same time and will handle all the concurreny requirements. Do i need to write threaded code here? By threaded code I mean that before writing I acquire a lock and after write release it. I am pretty new to web development and multithreading/multiprocessing programing and would like some guidance on how write web app which can handle concurrency well. Writing concurrency handling from start is right or this thought should come when a large number of concurrent users are using the webapp. Even If it should be done later I would like some pointers about it. Basically I have no idea about concurrency part of webapp development. If you can point to resources from where I can learn more about it would be really helpful.
Concurrency handling in python based webapp
0
1.2
1
0
0
2,325
9,519,717
2012-03-01T16:11:00.000
1
1
0
0
0
python,nosetests
0
9,519,888
0
3
0
false
0
0
parameter -s - Not capturing stdout
1
18
0
0
I've tried "nosetests p1.py > text.txt" and it is not working. What is the proper way to pipe this console output?
how do i redirect the output of nosetests to a textfile?
0
0.066568
1
0
0
5,685
9,521,289
2012-03-01T17:47:00.000
0
0
0
1
0
python,google-app-engine
0
9,521,520
0
3
0
false
1
0
i am not 100% sure about that but what i used to do is compare the last cursor with the actual cursor and i think i noticed that they were the same so i came to the conclusion that it was the last cursor.
1
0
0
0
I am fetching records from gae model using cursor() and with_cursor() logic as used in paging. but i am not sure how to check that there is no any other record in db that is pointed by cursor. i am fetching these records in chunks within some iterations.when i got my required results in the first iteration then in next iteration I want to check there is no any record in model but I not get any empty/None value of cursor at this stage.please let me know how to perform this check with cursors in google app engine with python.
cursor and with_cursor() in GAE
0
0
1
1
0
550
9,523,147
2012-03-01T20:02:00.000
0
1
0
0
0
php,python,web
0
9,523,459
0
2
0
false
1
0
You can set up a web server also on the remote computer, perhaps using the same software as on the public server, so you do not need to learn another technology. The public server can make HTTP requests and the remote server responds by communicating with the serial device.
1
3
0
0
I am working on my senior project at university and I have a question. My advisor and other workers don't know much more on the matter so I thought I would toss it out to SO and see if you could help. We want to make a website that will be hosted on a server that we are configuring. That website will have buttons on it, and when visitors of that website click a certain button we want to register an event on the server. We plan on doing this with PHP. Once that event is registered (this is where we get lost), we want to communicate with a serial device on a remote computer. We are confident we can set up the PHP event/listener for the button press, but once we have that registered, how do we signal to the remote computer(connected via T1 line/routers) to communicate with the serial device? What is this sequence of events referred to as? The hardest thing for us (when researching it) is that we are not certain what to search for! We have a feeling that a python script could be running on the server, get signals from the PHP listener, and then communicate with the remote PC. The remote PC could also be running a python script that then will communicate with our serial device. Again, most of this makes sense, but we are not clear on how we communicate between Python and PHP on the web server (or if this is possible). If any one could give me some advice on what to search for, or similar projects I would really appreciate it. Thanks,
Website to computer communications
0
0
1
0
1
232
9,525,437
2012-03-01T22:47:00.000
0
0
0
0
0
python,gstreamer,python-gstreamer
0
9,540,599
0
1
0
false
0
0
Instead of "pipe1. ! volume name=volume ! autoaudiosink name=audiosink" you can write pipe1.srcXX ! volume name=volume ! autoaudiosink name=audiosink" where XX is the pad you want to connect to. You will need to listen to newly added pads with a signal handler and ideally connect them all to an input-selector. This you can then use to switch tracks.
1
0
0
0
How can I switch between audio tracks in a video using PyGST, but without using playbin2? I'm using this pipeline, but I have no idea about how to select a specific audio stream in the video and connecting it to the audiosink: uridecodebin name=pipe1 pipe1. ! videobalance name=balance ! textoverlay name=text ! xvimagesink name=videosink pipe1. ! volume name=volume ! autoaudiosink name=audiosink Any example would be useful. Thank you
PyGST and videos with multiple audio tracks
0
0
1
0
0
411
9,528,395
2012-03-02T05:23:00.000
0
1
0
0
1
python,http,authentication,screen-scraping,web-scraping
0
9,542,705
0
1
0
false
1
0
It's very unlikely that any of the sites you are interested in use basic auth. You will need a library like mechanize that manages cookies and you will need to submit the login information to the site's login page.
1
0
0
0
I've been reading about beautifulSoup, http headers, authentication, cookies and something about mechanize. I'm trying to scrape my favorite art websites with python. Like deviant art which I found a scraper for. Right now I'm trying to login but the basic authentication code examples I try don't work. So question, How do I find out what type of authentication a site uses so that I know I'm trying to login the correct way? Including things like valid user-agents when they try to block bots. Bear with my ignorance as I'm new to HTTP, python, and scraping.
how to find the authentication used on a website
0
0
1
0
1
829
9,528,748
2012-03-02T06:02:00.000
2
0
1
0
0
python,django
1
9,528,803
0
1
0
true
1
0
The first thing to look out for is overplanning. This, along with overengineering, is even more true for your second project. You have lots of ideas about how this program will behave, but don't get ahead of yourself. Remember what the problem is you want to solve, and try to keep focused on the simplest way to solve that, without tons of options or cases. For example, in its simplest form you want to programmatically add a calendar event, so create a simple html form and the simplest possible back-end to take the user input and add it to a calendar. Don't worry about HIPAA up front, as you're going to make lots of security mistakes anyway, it's better to focus on the functionality for now. Also don't worry too much about the interface, because you're going to decide this version sucks and you need to throw it away at some point. Then (and not a moment sooner) will be the right time to think about the interface, json vs. soap vs. web app, etc. For now, just start building the thing and prove that you can provide the value you believe this will provide.
1
2
0
0
I want to create a program that will take user input and create a calendar using the input. example: John,Conner 1/3/10 birthday This information will also be sortable by the obvious: last name,first name, date, (other). It will be able to print this information as a list or a calendar. It will have to have exceptions like 1/3/10 is put on the 2nd (because the 3rd is a sat and weekends aren't usable dates) Security is a must as its HIPPA information Possible will be only used by myself on a work computer... but i would like to think others might use it eventually I'm new to programming and have the following under my belt: Learn python the hard way How to think like a computer scientist learn python 3 python for informatics Given what i know the programming part of this doesn't really worry me. I feel like i have done similar if not more difficult things already. with the exception being the user interface setup... err the graphical part the user see's. I don't know how to set that up at all. (i used turtle does that count?) Limitations: I'm not sure what the computers at work are running. If its a server that the computers boot into or what. They are using Internet explorer. So... i have researched some points i know i need to plan ahead about such as: GUI vs web application. --- i'm learning towards web application because I like the eventually seeing something i made get used on a more widespread basis... also i hear that GUI's area a pain. With this in mind i was going to learn Django. But as a newbie i feel I might be sailing into a storm of things i haven't envisioned. And while i understand trail by fire is a good way to learn i feel it also pays to seek advice as to limit yourself... especially when you work 9 to 5 like i do. So after all my to do. Is learning Django a logical next step for my I have in mind? What else might i want to consider..? finally maybe stackoverflow isn't the right spot for these types of questions! if so, where?
First project what should I look out for
0
1.2
1
0
0
177
9,539,006
2012-03-02T19:12:00.000
3
0
0
0
1
python,networking
0
9,539,066
0
8
0
false
0
0
Convert the last part of your IP address into a number, add 1 to it, and call ifconfig. I think the approach of incrementing the last bit will not scale well as we span across networks. –OP I thought of mentioning that in my original answer, but didn't, for various reasons. These reasons are as follows: I thought it is unlikely you would need to do this, and could not guess why you'd want to. Even if you did need to do this, you could just parse the second-to-last number. This is only valid for those bits where the netmask is 0. You also have to worry about "special" reserved IP ranges, such as 192.168.etc.etc. Also hex doublets with 0 and possibly ff/255 have special meaning. There are different rules in IPv6.
1
15
0
0
I would like to increment an ip address by a fixed value. Precisely this is what I am trying to achieve, I have an ip address say, 192.168.0.3 and I want to increment it by 1 which would result in 192.168.0.4 or even by a fixed value, x so that it will increment my ip address by that number. so, I can have a host like 192.168.0.3+x. I just want to know if any modules already exist for this conversion. I tried socket.inet_aton and then socket.inet_ntoa, but I don't know how to get that working properly. Need some help or advice on that.
python increment ipaddress
0
0.07486
1
0
1
22,989
9,541,301
2012-03-02T22:31:00.000
3
0
1
0
0
python,apache,mod-wsgi
0
9,541,433
0
2
0
true
1
0
Web-apps are generally “shared-nothing”. In the context of WSGI, that means you have no idea how many times your application (and the counter with it) will be instantiated; that choice is up to the WSGI server which acts as your app's container. If you want some notion of user sessions, you have to implement it explicitly, typically on top of cookies. If you want persistence, you need a component that explicitly supports it; that can be a shared database, or it can piggy-back on your cookie sessions.
1
4
0
0
I know there are frameworks that exist, but I am trying to use wsgi directly to improve my own understanding. I have my wsgi handler, and up at the top I have declared a variable i = 0. In my application(environ, start_response) function, I declare global i, then I increment i whenever a button is pressed. It is my understanding that the state of this variable is preserved as long as the server is running, so all users of the web app see the same i. If I declare i inside the application function, then the value of i resets to 0 any time a request is made. I'm wondering, how do you preserve i between a single user's requests, but not have it preserved across different users' sessions? So, a single user can make multiple posts, and i will increment, but if another user visits the web app, they start with i=0. And I know you could store i in a database between posts, but is it possible to just keep i in memory between posts?
Global variables in Python and Apache mod_wsgi
1
1.2
1
0
0
3,538
9,543,171
2012-03-03T03:30:00.000
0
1
0
0
0
php,python,wordpress
0
9,543,194
0
1
0
false
0
0
I did this yesterday. my process was to add a row to a master accounts table, get the auto inc id, use that along with the company name to create the db name. so in my case the db's are Root_1companyname1 Root_2companyname2 .. Root_ is optional of course. Ask if you have any questions.
1
0
0
0
I am trying to think through a script that I need to create. I am most likely going to be using php unless there would be a better language to do this with e.g. python or ror. I only know a little bit of php so this will definitely be a learning experience for me and starting fresh with a different language wouldn't be a problem if it would help in the long run. What I am wanting to do is create a website where people can sign up for WordPress hosting. Right now I have the site set up with WHMCS. If I just leave it how it is I will have manually go in and install WordPress every time a customer signs up. I would like an automated solution that creates a database and installs WordPress as soon as the customer signs up. With WHMCS I can run a script as soon as a customer signs up and so far I understand how to create a database, download WordPress, and install WordPress. The only thing is I can't figure out how to make it work with more than one customer because with each customer there will be a new database. What I need the script to do is when customer A signs up, the script will create a database name "customer_A" (that name is just an example) and when, lets say my second customer signs up, the script will create a database named "customer_B". Is there a possible solution to this? Thanks for the help
Automate database creation with incremental name?
0
0
1
1
0
90
9,550,690
2012-03-03T23:13:00.000
0
0
0
0
0
jquery,python,screen-scraping
0
9,551,356
0
2
0
false
1
0
If I'm reading your question right, you're not trying to build a web app (client- or server-side), but rather a standalone app that simply requests and downloads pages from the Web. You can write a standalone app in JavaScript, but it's not common. The primary use of JavaScript is for code that's going to run in a user's Web browser. For standalone apps, Python is the better choice. And it has very good support (in the form of the urllib2 and related libraries) for tasks like Web scraping. Of course, if your scraping task is relatively simple, you might be better off just using wget.
2
0
0
0
So lets say I'm scraping multiple pages (lets say a 1000) on a website. I want to know which language is best to use to scrape those pages with - javascript or python. Further, I've heard about javascript scrapers being faster (due to multiple get requests), but am unsure how to implement this - can anyone enlighten me? Thanks!
Scraping with JQuery or Python?
0
0
1
0
1
1,586
9,550,690
2012-03-03T23:13:00.000
3
0
0
0
0
jquery,python,screen-scraping
0
9,551,757
0
2
0
true
1
0
This is just my opinion but I would rank them like this javascript might be the best choice but only if you have a node environment already set up. The advantage of javascript scrapers is they can interpret the js in the pages you're scraping. next is a three way tie between perl python and ruby. They all have a mechanize library and do xpath and regex in a sensible way. Down at the bottom is php. It's lack of a cookie handling library like mechanize (curl isn't great) and it's clumsy dom and regex functions make it a poor choice for scraping.
2
0
0
0
So lets say I'm scraping multiple pages (lets say a 1000) on a website. I want to know which language is best to use to scrape those pages with - javascript or python. Further, I've heard about javascript scrapers being faster (due to multiple get requests), but am unsure how to implement this - can anyone enlighten me? Thanks!
Scraping with JQuery or Python?
0
1.2
1
0
1
1,586
9,552,629
2012-03-04T05:35:00.000
3
0
1
0
1
python,regex,numbers,regex-group
0
9,552,653
0
2
0
true
0
0
I noticed that I don't need the \g<1> syntax. Instead I can use one of several techniques to separate the numeric backreference like \2 from the digit like 9 that follows it. Here are three such techniques: a non-capturing group (?:\2)9 an otherwise unnecessary quantification by one \2{1}9 using an otherwise unnecessary character class to contain only the digit that follows the backreference \2[9]
2
2
0
0
In a Python match pattern, how do I match a literal digit like 1 after a backreference by number like \1? I tried the \g<1> syntax that is available in substitution patterns for this purpose, but it doesn't work in my match pattern. I have a larger problem that I want to solve using a function that will perform the following somewhat unusual task. The task is to construct patterns dynamically so that each pattern will match digit sequences that have repeated digits in certain positions and specific digits in the remaining positions.
python re.match group: number after \number
0
1.2
1
0
0
549
9,552,629
2012-03-04T05:35:00.000
2
0
1
0
1
python,regex,numbers,regex-group
0
9,552,654
0
2
0
false
0
0
Put the digit that you want to match literally in a character class \1[1] or a group \1(1) of its own so that the bracket or parentheses separates the digit from the backreference.
2
2
0
0
In a Python match pattern, how do I match a literal digit like 1 after a backreference by number like \1? I tried the \g<1> syntax that is available in substitution patterns for this purpose, but it doesn't work in my match pattern. I have a larger problem that I want to solve using a function that will perform the following somewhat unusual task. The task is to construct patterns dynamically so that each pattern will match digit sequences that have repeated digits in certain positions and specific digits in the remaining positions.
python re.match group: number after \number
0
0.197375
1
0
0
549
9,554,204
2012-03-04T10:41:00.000
0
0
0
0
0
python,database,sqlalchemy
0
9,554,925
0
2
0
false
0
0
I think you're perhaps over-thinking the situation. If you want to create the database afresh, you normally just call Base.metadata.create_all() or equivalent, and if you don't want to do that, you don't call it. You could try calling it every time and handling the exception if it goes wrong, assuming that the database is already set up. Or you could try querying for a certain table and if that fails, call create_all() to put everything in place. Every other part of your app should work in the same way whether you perform the db creation or not.
1
0
0
0
there's something I'm struggling to understand with SQLAlchamy from it's documentation and tutorials. I see how to autoload classes from a DB table, and I see how to design a class and create from it (declaratively or using the mapper()) a table that is added to the DB. My question is how does one write code that both creates the table (e.g. on first run) and then reuses it? I don't want to have to create the database with one tool or one piece of code and have separate code to use the database. Thanks in advance, Peter
SQLAlchamy Database Construction & Reuse
1
0
1
1
0
77
9,556,280
2012-03-04T15:46:00.000
1
0
0
1
0
python,google-app-engine,cgi,wsgi,cherrypy
0
15,619,684
0
1
0
true
1
0
The problem was that cherrypy was not in the root of the working directory, all of which I uploaded with the app engine tool. Not 100% sure if its the correct way to use GAE but it works.
1
1
0
0
Can someone please show me how to get cherrypy to work with Google App Engine, I have made applications with cherrypys built in server, but I have no idea how to make an app that works with WSGI and GAE. I have read the documentation for cherrypy and GAE but can't find anything. And I would prefer cherrypy to the webapp2 which is in the GAE example.
Setup Cherrypy with Google App Engine
0
1.2
1
0
0
1,132
9,557,552
2012-03-04T18:17:00.000
3
0
0
0
0
python,nosql,redis,rdbms,flask
0
9,557,895
0
1
0
true
1
0
You should have no problem using an ORM because, in the end, it just stores strings, numbers and other values. So you could have a game in progress, and keep its state in Redis, including the players' IDs from the SQL player table, because the ID is just a unique integer.
1
4
0
0
I'm developing a multi-player game in Python with a Flask frontend, and I'm using it as an opportunity to learn more about the NoSQL way of doing things. Redis seems to be a good fit for some of the things I need for this app, including storage of server-side sessions and other transient data, e.g. what games are in progress, who's online, etc. There are also several good Flask/Redis recipes that have made things very easy so far. However, there are still some things in the data model that I would prefer lived inside a traditional RDBMS, including user accounts, logs of completed games, etc. It's not that Redis can't do these things, but I just think the RDBMS is more suited to them, and since Redis wants everything in memory, it seems to make sense to "warehouse" some of this data on disk. The one thing I don't quite have a good strategy for is how to make these two data stores live happily together. Using ORMs like SQLAlchemy and/or redisco seems right out, because the ORMs are going to want to own all the data that's part of their data model, and there are inevitably times I'm going to need to have classes from one ORM know about classes from the other one (e.g. "users are in the RDBMS, but games are in Redis, and games have users participating in them.) Does anyone have any experience deploying python web apps using a NoSQL store like Redis for some things and an RDBMS for others? If so, do you have any strategies for making them work together?
Redis and RDBMS coexistence (hopefully cooperation) in Flask applications
0
1.2
1
1
0
532
9,563,935
2012-03-05T08:59:00.000
7
0
0
0
0
python,django,django-admin
0
9,564,009
0
2
0
true
1
0
Do not remove or change anything in the admin. Instead remove user's/group's permission to delete given model. If user does not have the permission to delete, the delete button won't appear at any page related to that model.
1
2
0
0
I have an apps and I am making used of django admin, but my apps does not allow deleting of data and django admin have a delete button/link. I have already removed the delete action. my question is, how can i remove the delete button/link in admin page in django?
removing buttons/links in django admin
0
1.2
1
0
0
2,890
9,567,322
2012-03-05T13:19:00.000
0
0
1
1
0
python,perforce
0
9,567,478
0
5
0
false
0
0
Have you tried merely piping the input to the command? In cmd.exe: C:\> echo m | p4 resolve
1
0
0
0
p4.exe is the perforce command line tool (git/cvs/svn like tool). I am trying to launch several ms-dos commands 'p4 resolve' in an python script. because I have a hundred files to resolve. However I cannot launch 'p4 resolve -m' as I want (which automatically opens my 3-way merge tool on the conflicting files). p4 doesn't accept the m as an executable parameter. Instead, manually, I must do 'p4 resolve', then wait for the prompt to ask me for an option, and then only type 'm' there. Do you know in python how I could feed the input since I cannot pass the 'm' parameter to the command line tool p4.exe. For the moment I use os.system(myDosCommand)
Feed input of MS-DOS interactive executable with a string value
0
0
1
0
0
373
9,573,193
2012-03-05T20:05:00.000
-1
0
1
0
0
macos,xcode4,python-3.x
0
9,573,545
0
1
0
false
0
0
Xcode projects are bundles like app bundles. So 'foo.xcodeproj' will be a directory, inside of which is project.pbxproj. There may be other files in the directory, but they are not used for the build and direct project definition; they are user configuration and window layout and things like that for the user of the project.
1
2
0
0
I am a Xcode newbie and need to programmatically access Xcode projects and methods to modify from a Python module. For example, say i have a "hello world" program in Xcode, and i need to modify the message to "Hello Python!", how do i do that from within my Python module? Please note i am talking about a Python module which is external and not in the Xcode project.
How to access and modify Xcode project files from python code?
0
-0.197375
1
0
0
461
9,574,970
2012-03-05T22:23:00.000
0
0
0
0
0
python,django
0
9,575,013
0
4
0
true
1
0
All installed apps can contribute to the database schema. django.contrib.auth.models contributes, among others, the auth_user table behind the django.contrib.auth.models.User model, therefore you do not have to worry about recreating it unless you have a specific reason to do so.
2
0
0
0
The import statement import the needed parts. but is the "user" class already made when you put that into your installed apps? or do you still need to clarify in models.py in order to make the table in the db? or can someone expand on how to use django users and sessions? I'm looking over the django docs right now and they all just go over how to use the thing once. they never put the code in a syntax where users are going to be the ones using the code through a browser and not you through a python shell.
Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user?
0
1.2
1
0
0
104
9,574,970
2012-03-05T22:23:00.000
0
0
0
0
0
python,django
0
9,575,285
0
4
0
false
1
0
There's a number of things going on here. As you're aware, Django comes with a number of "contrib" packages that can be used in your app. You "activate" these by putting them into your INSTALLED_APPS. When you run python manage.py syncdb, Django parse the models.py files of every app in INSTALLED_APPS and creates the associated tables in your database. So, once you have added django.contrib.auth to your INSTALLED_APPS and ran syncdb, the tables for User and Group are there and ready to be used. Now, if you want to use these models in your other apps, you can import them, as you mention, with something like from django.contrib.auth.models import User. You can then do something like create a ForeignKey, OneToOneField or ManyToManyField on one of your models to the User model. When you do this, no tables are created (with the exception of ManyToManyField; more on that in a bit). The same table is always used for User, just as for any of your own models that you might create relationships between. ManyToManyFields are slightly different in that an intermediary table is created (often called a "join table") that links both sides of the relationship together. However, this is purely for the purposes of that one particular relationship -- nothing about the actual User table is different or changed in any way. The point is that one table is created for User and this same table is used to store all Users no matter what context they were created in. You can import User into any and all of your apps, create as many and as varied relationships as you like and nothing really changes as far as User is concerned.
2
0
0
0
The import statement import the needed parts. but is the "user" class already made when you put that into your installed apps? or do you still need to clarify in models.py in order to make the table in the db? or can someone expand on how to use django users and sessions? I'm looking over the django docs right now and they all just go over how to use the thing once. they never put the code in a syntax where users are going to be the ones using the code through a browser and not you through a python shell.
Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user?
0
0
1
0
0
104
9,576,822
2012-03-06T01:50:00.000
1
0
0
0
0
python,django,django-admin
0
9,588,284
0
1
0
true
1
0
The django-admin-tools header is controlled by the theming.css file which is by default sitting under \admin_tools\theming\static\admin_tools\css\theming.css, and the default header should display the "Django" png that comes with django-admin-tools and is placed under \admin_tools\theming\static\admin_tools\images\django.png. I guess that if the default admin tools header doesn't display then your admin tools theme is not kicking in either. This means django can't see your theming folder of admin tools. Check that your MEDIA_ROOT, STATIS_ROOT andADMIN_MEDIA_PREFIX parameters in setting.py are set correctly. Check the PYTHONPATH env param is also set to all the needed folders. When the default admin tools theme will load you can drop a new header image in the images folders as above and edit the theming.css to load it instead of the default.
1
0
0
0
I am using django-admin-tool to customized my django admin page. my problem is, how can I change the header of 'Django Administration' with django-admin-tools? i know how to change it using base_site.html but the problem is my custom menu that i have done in django-admin-tools is not appearing.
django-admin-tools : change header 'Django Administration'
0
1.2
1
0
0
2,081
9,577,614
2012-03-06T03:44:00.000
0
0
0
0
0
python,django,web,dreamhost,domain-name
0
9,588,891
0
1
0
true
1
0
The problem waas that it was executing the old instance of webapp (that didn't use sites module) So i have resolved with pkill python command.
1
0
0
0
In my view i execute Site.objects.get_current().domain but the result is empty string. So, how can i get the domain name to compose right url? Hosting is dreamhost.
dreamhost+django: cannot get domain name using site framework
0
1.2
1
0
0
152
9,578,245
2012-03-06T05:14:00.000
2
0
0
1
1
python,tornado
0
9,578,432
0
3
0
false
0
0
I don't know why it takes so long to exit with Ctrl+C, but it worked for me in some cases to press Ctrl+\ (Linux terminal)
1
3
0
0
When developing a Tornado application, I frequently want to restart the server to pick up new changes. I hit ctrl-c to stop the server, but with Tornado, this seems to be very slow. It waits for many seconds before shutting down, or doesn't shut down at all when issued a ctrl-c. What's weird, is if, after clicking ctrl-c, I make a new request to the server (by, for example, refreshing my browser that is pointing at the server), it shuts down right away. Anyone know how to explain this or fix it? Anyone experienced something similar? (Note, this is on Windows.)
Why does Tornado take so long to die when I hit ctrl-c?
0
0.132549
1
0
0
1,548
9,593,659
2012-03-06T23:39:00.000
2
0
0
0
0
python,google-app-engine,cookies,oauth
0
9,596,143
0
2
0
false
1
0
Can you use OAUth to authenticate with Google, then use the OAuth token to ensure the messages are legitimate?
1
0
0
0
I have an app which amounts to a Python script, running on the user's phone, and a JS client, running in the user's browser. The Python script sends messages to App Engine as HTTP requests. The server then pushes the messages to the JS client. The problem is authentication: The server can easily use Google Accounts to authenticate anything coming from the JS client as being sent by a particular user, but I do not know how to get the Python script to make HTTP requests which will also authenticate. Any ideas?
Need to send a HTTP request in Python that'll authenticate with Google Accounts
0
0.197375
1
0
1
425
9,595,494
2012-03-07T03:43:00.000
4
0
0
0
0
python,tags,cluster-analysis,data-mining,k-means
0
9,597,117
0
4
0
false
0
0
Since the data you have is binary and sparse (in particular, not all users have tagged all documents, right)? So I'm not at all convinced that k-means is the proper way to do this. Anyway, if you want to give k-means a try, have a look at the variants such as k-medians (which won't allow "half-tagging") and convex/spherical k-means (which supposedly works better with distance functions such as cosine distance, which seems a lot more appropriate here).
1
3
1
0
I have a document d1 consisting of lines of form user_id tag_id. There is another document d2 consisting of tag_id tag_name I need to generate clusters of users with similar tagging behaviour. I want to try this with k-means algorithm in python. I am completely new to this and cant figure out how to start on this. Can anyone give any pointers? Do I need to first create different documents for each user using d1 with his tag vocabulary? And then apply k-means algorithm on these documents? There are like 1 million users in d1. I am not sure I am thinking in right direction, creating 1 million files ?
Clustering using k-means in python
0
0.197375
1
0
0
2,252
9,607,565
2012-03-07T19:10:00.000
13
0
1
0
0
python,virtualenv,setuptools,distribute
0
21,003,259
0
2
0
true
0
0
By design, you can't make the tests_requires or the setup_requires entries go into the virtual environment. The idea is to separate what is required for performing tests/setup and what is required to actually use the package being installed. For example, I may require that the "coverage" module be needed for running tests on my package, but it isn't used by any of my code in the package. Therefore, if I didn't have "coverage" in my environment when I go and run tests, I wouldn't want "coverage" to get installed into the environment if my package didn't need it.
1
33
0
0
In a crusade to make my application pip-installable, I'm fighting big fights with setuptools and distribute. I assume my dependencies are correct, i.e. installing with pip install myapp should probably fill the virtual environment correctly. However, I'd like to streamline development while I'm at it, so my goal is to start with an empty virtualenv and make setup.py test (and later setup.py develop, but that's a whole different fight) fill it with all defined dependencies. And now to my problem: no matter how hard I try, all I get are dependencies installed as .eggs in my project directory which is sub-optimal at the very least. I tried creating a new setuptools command which would use pip (which seems to work, even though awkwardly) but that can't seriously be the solution (subclassing and overriding that is). So how do I make setup.py test fill the virtualevn instead of my working directory?
How do I force `setup.py test` to install dependencies into my `virtualenv`?
0
1.2
1
0
0
11,234
9,618,773
2012-03-08T13:59:00.000
0
0
0
0
0
python,database,queue
0
9,618,894
0
3
0
false
1
0
You could create a function that each process must call in order to talk to the DB. You could re-write the scripts so that they must call that function rather than talk directly to the DB. Within that function, you could have a scope-based lock so that only one process would be talking to the DB at a time.
2
0
0
0
I got a lot scripts running: scrappers, checkers, cleaners, etc. They have some things in common: they are forever running; they have no time constrain to finish their job; they all access the same MYSQL DB, writting and reading. Accumulating them, it's starting to slow down the website, which runs on the same system, but depends on these scripts. I can use queues with Kombu to inline all writtings. But do you know a way to make the same with reading ? E.G: if one script need to read from the DB, his request is sent to a blocking queue, et it resumes when it got the answer ? This way everybody is making request to one process, and the process is the only one talking to the DB, making one request at the time. I have no idea how to do this. Of course, in the end I may have to add more servers to the mix, but before that, is there something I can do at the software level ?
How to ensure several Python processes access the data base one by one?
0
0
1
0
0
157
9,618,773
2012-03-08T13:59:00.000
1
0
0
0
0
python,database,queue
0
9,619,460
0
3
0
false
1
0
You say that your dataset is <1GB, the problem is CPU bound. Now start analyzing what is eating CPU cycles: Which queries are really slow and executed often. MySQL can log those queries. What about the slow queries? Can they be accelerated by using an index? Are there unused indices? Drop them! Nothing helps? Can you solve it by denormalizing/precomputing stuff?
2
0
0
0
I got a lot scripts running: scrappers, checkers, cleaners, etc. They have some things in common: they are forever running; they have no time constrain to finish their job; they all access the same MYSQL DB, writting and reading. Accumulating them, it's starting to slow down the website, which runs on the same system, but depends on these scripts. I can use queues with Kombu to inline all writtings. But do you know a way to make the same with reading ? E.G: if one script need to read from the DB, his request is sent to a blocking queue, et it resumes when it got the answer ? This way everybody is making request to one process, and the process is the only one talking to the DB, making one request at the time. I have no idea how to do this. Of course, in the end I may have to add more servers to the mix, but before that, is there something I can do at the software level ?
How to ensure several Python processes access the data base one by one?
0
0.066568
1
0
0
157
9,636,294
2012-03-09T15:06:00.000
0
0
0
0
0
javascript,python,node.js,compiler-construction
0
9,636,911
0
2
0
false
1
0
To accomplish the sandbox, it would be fairly easy to do this by simply running your code inside of a closure that reassigns all of the worrisome calls to NaN for instance, if the code executes inside a closure where eval=NaN
1
4
0
0
I'm a newer and if the question is so easy I apologize for that. Assume I want to dev a classical online judge system, obviously the core part is get users' code to a file compile it on server run it on server (with some sandbox things to prevent damage) the program exit itself, then check the answer. or get the signal of program collapsing. I wonder if it's possible to do all the things using Node.js, how to do the sandbox things. Is there any example for compile-sandbox-run-abort-check thing? additional: is it more convenient to dev a such system using PYTHON? thanks in advance.
Is that possible to develop a ACM ONLINE JUDGE system using NODE.JS(or PYTHON)?
0
0
1
0
1
1,228
9,645,388
2012-03-10T09:33:00.000
0
0
1
0
0
python,reflection,twisted
0
9,645,892
0
7
0
false
0
0
Better yet subprocess the plugins, then hypervise the subprocess, when the files change reload the plugins process. Edit: cleaned up.
1
4
0
0
I've written an IRC bot using Twisted and now I've gotten to the point where I want to be able to dynamically reload functionality. In my main program, I do from bots.google import GoogleBot and I've looked at how to use reload to reload modules, but I still can't figure out how to do dynamic re-importing of classes. So, given a Python class, how do I dynamically reload the class definition?
Dynamically reload a class definition in Python
0
0
1
0
1
6,092
9,657,333
2012-03-11T17:51:00.000
0
0
1
0
0
python
0
9,657,438
0
2
0
false
0
1
You need PyQt or PySide to use Qt in your Python script. To generate python script from ui file run pyuic -x form.ui
1
0
0
0
1: i create main window in QtCreator. how i use this form in my python code in eclipse. 2: can write python and build complete python application in QtCreator ? (How). thanks.
How To Add .ui Files To Python
0
0
1
0
0
238
9,663,321
2012-03-12T07:44:00.000
2
0
1
0
0
java,python,jython
0
9,663,378
0
3
0
false
1
0
I know how to use python with java through jython, but backwards ... try to ask your question to jython community.
3
3
0
0
I am a Java developer. I would like to know what capabilities and/or positives I can add to a Java application, by including Python as a development language. I am posting this here as I am not getting a good answer from google. I would request that you don't vote down, marking it to be a descriptive question, so that a future Java developer can understand how he can make an application better with Python.
What are the extra capabilities Python gives when used with Java?
0
0.132549
1
0
0
124
9,663,321
2012-03-12T07:44:00.000
1
0
1
0
0
java,python,jython
0
9,663,439
0
3
0
false
1
0
1st: jython is many times slower than java. 2nd: as I recall integration in direction jython -> java is not very seemless. 3rd: you get python syntax, maybe some batteries (i don't really know this). This is a plus. 4th: you get good heavy multithreading support in python instead of green thread and GIL. That can be a plus.
3
3
0
0
I am a Java developer. I would like to know what capabilities and/or positives I can add to a Java application, by including Python as a development language. I am posting this here as I am not getting a good answer from google. I would request that you don't vote down, marking it to be a descriptive question, so that a future Java developer can understand how he can make an application better with Python.
What are the extra capabilities Python gives when used with Java?
0
0.066568
1
0
0
124
9,663,321
2012-03-12T07:44:00.000
8
0
1
0
0
java,python,jython
0
9,663,494
0
3
0
false
1
0
In general, there are no (overall) benefits for doing this. You're simply adding in another language with its own set of runtime features, that, for the most part does the same things that you can do in Java. Unless you have specific reason to add Python integration into your Java application, it would be a very poor idea to do so. However, in some cases there are reasons why you might want to do this: To add scripting capabilities to your application. If you want the end users of your application (or perhaps authors of add-ons, or system administrators) to be able to script parts of your application, then Python is a reasonable choice to offer them. There are other good choices too, but Python is fairly well known, quite mature, has decent Java integration and a good set of features, so it's not a bad choice. To accommodate Python developers in your team If your team has Python developers who (for whatever reason) aren't willing/able to write in Java, then you can provide facilities to support including their code in your Java application. If you believe that writing in Python is more productive If you/your team believe that writing Python code is sufficiently more productive than writing Java code to justify the cost of integrating the Jython runtime into your Java application, then you might take that path. Personally, I'd question that decision in all by the most niche of use cases, but that's up to each team to decide. To integrate with existing Python code There may be libraries or tools that are written in Python that you want to integrate with in your application. Rather than re-writing them in Java, or trying to run them via the command-line, it might be a good idea to run them in the Jython environment in the JVM. Unless you have a specific reason like one of those listed above, then simply integrating Jython into your application isn't going to give you any benefits, it will simply be extra effort to write and support. If you have one of those reasons, then it might make sense, it will depend on your circumstances.
3
3
0
0
I am a Java developer. I would like to know what capabilities and/or positives I can add to a Java application, by including Python as a development language. I am posting this here as I am not getting a good answer from google. I would request that you don't vote down, marking it to be a descriptive question, so that a future Java developer can understand how he can make an application better with Python.
What are the extra capabilities Python gives when used with Java?
0
1
1
0
0
124
9,664,809
2012-03-12T09:49:00.000
1
0
0
1
0
python,build,build-process,build-automation,jobs
0
28,289,788
0
3
0
false
0
0
Another option is to use make. Write a Makefile manually or let a python script write it use meaningful intermediate output file stages Run make, which should then call out the processes. The processes would be a python (build) script with parameters that tell it which files to work on and what task to do. parallel execution is supported with -j it also deletes output files if tasks fail This circumvents some of the python parallelisation problems (GIL, serialisation). Obviously only straightforward on *nix platforms.
1
13
0
0
I need a framework which will allow me to do the following: Allow to dynamically define tasks (I'll read an external configuration file and create the tasks/jobs; task=spawn an external command for instance) Provide a way of specifying dependencies on existing tasks (e.g. task A will be run after task B is finished) Be able to run tasks in parallel in multiple processes if the execution order allows it (i.e. no task interdependencies) Allow a task to depend on some external event (don't know exactly how to describe this, but some tasks finish and they will produce results after a while, like a background running job; I need to specify some of the tasks to depend on this background-job-completed event) Undo/Rollback support: if one tasks fail, try to undo everything that has been executed before (I don't expect this to be implemented in any framework, but I guess it's worth to ask..) So, obviously, this looks more or less like a build system, but I don't seem to be able to find something that will allow me to dynamically create tasks, most things I've seem already have them defined in the "Makefile". Any ideas?
Python framework for task execution and dependencies handling
0
0.066568
1
0
0
4,879
9,665,586
2012-03-12T10:42:00.000
0
0
0
1
0
python,list
0
9,666,450
0
5
0
false
0
0
re.findall returns a list of matches. In your case you are getting lists with only one value. If that is always the case then @x539 answer will get the first item in the list.
1
1
0
0
The below is a part of a script i'm trying to write. The script opens my iptables log, each line in the log contains the details in the example below. #example of a single line #Mar 9 14:57:51 machine kernel: [23780.638839] IPTABLES Denied UDP: IN=p21p1 OUT= MAC=ff:ff:ff:ff:ff:ff:00:00:00:00:00:00:00:00 SRC=10.100.1.4 DST=10.100.1.63 LEN=78 TOS=0x00 PREC=0x00 TTL=128 ID=10898 PROTO=UDP$ # Read file in a line at a time for line in iptables_log.readlines(): #find time based on 4 letters, 2 spaces, up to 2 numbers, 1 space, then standard 10:10:10 time format time = re.findall('(^\w{1,4}\s\s\d{1,2}\s\d\d:\d\d:\d\d)', line) #mac lookup mac = re.findall('MAC=(?:\w\w:\w\w:\w\w:\w\w\:\w\w:\w\w:\w\w:\w\w:\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)', line) #source port src = re.findall('SRC=(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})', line) #destination port dst = re.findall('DST=(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})', line) #protocol proto = re.findall('PROTO=(?:\w{3,4})', line) #sourceport sourceport = re.findall('SPT=(?:\w{1,5})', line) #destport destport = re.findall('DPT=(?:\w{1,5})', line) print time, mac, src, dst, proto, sourceport, destport print '======================================================' I'm trying to get the script to print only the items i want, but when its output by the script it looks like this, which would seem to be a list. I want it to print without the [] ''. Looking online it seems like every variable (time, mac, src, etc) are a list themselves. I'm not sure how to combine them. I have seen reference to join but am not sure how to use it this example. Can someone assist please? ['Mar 9 14:57:51'] ['MAC=ff:ff:ff:ff:ff:ff:00:00:00:00:00:00:00:00'] ['SRC=10.100.1.4'] ['DST=10.100.1.63'] ['PROTO=UDP'] ['SPT=137'] ['DPT=137']
Python - List issues (multiple lists?)
0
0
1
0
0
189
9,665,913
2012-03-12T11:06:00.000
1
1
0
0
0
python,performance,chat,tornado,long-polling
0
9,668,433
0
1
0
true
0
0
I would run the server in a mode where you let the client tell which client they are. i.e. change the code so it can be run this way as required. This is less secure, but makes testing easier. In production, don't use this option. This will give you a realistic test from a small number of client machines.
1
2
0
0
I've just created a web chat server with Tornado over Python. The communication mechanism is to use long-polling and I/O events. I want to benchmark this web chat server at large scale, meaning I want to test this chat server (Tornado based) to see how many chatters it can withstand. Because I'm using cookies to identify sessions, presently I can only test with maximum 5 (IE, Firefox, Chrome, Safari, Opera) sessions per computer (cookie path has no use coz everything goes thru' the same web page), but in my office we only have limited number of computers. I want to test this Tornado app at the extreme, hopefully it can withstand few thousand concurrent users like Tornado is advertising, but having no clue how to do this!
How to benchmark web chat performance?
0
1.2
1
0
1
510
9,666,425
2012-03-12T11:46:00.000
0
0
0
0
0
python,openerp
0
9,667,268
0
3
0
false
1
0
If we talking about web interface then you could disable it by javascript.
1
4
0
0
This might be a simple question.but,does any one know how to disable a button after clicking it in OpenERP? Please help!!!!! Thanks for all your help....
How to disable a button after clicking it in OpenERP
0
0
1
0
1
2,267
9,680,762
2012-03-13T08:48:00.000
0
0
1
1
0
python,eclipse,command-line,pydev
0
9,687,892
0
3
0
false
0
0
Actually, so far you can't do that without grabbing the code and changing it yourself (i.e.: that's hardcoded). But still, if you don't use the unbuffered output (i.e.: -u option), the PyDev console will end up not showing the I/O output as it's printed (as it'll be buffered). So, what is it that breaks because -u? (maybe it'd be better fixing that then changing PyDev to launch without the -u as you may end up without the output until the run is finished if you do that).
1
0
0
0
My code is broken by eclipse but works normaly if I launch it from command prompt with python and no option. I need to delete -u option when the python interpreter is launched in eclipse and pydev, how can I do that?
PyDev: how remove command line switch -u
0
0
1
0
0
336
9,694,967
2012-03-14T02:05:00.000
4
0
0
0
1
python,database,sqlite,indexing,bigdata
0
9,695,095
0
3
1
true
0
0
sqlite3 is too slow, and I need something more heavyweight First, sqlite3 is fast, sometime faster than MySQL Second, you have to use index, put a compound index in (date1, date2, name) will speed thing up significantly
1
2
0
0
I have a spreadsheet with about 1.7m lines, totalling 1 GB, and need to perform various queries on it. Being most comfortable with Python, my first approach was to hack together a bunch of dictionaries keyed in a way that would facilitate the queries I was trying to make. E.g. if I needed to be able to access everyone with a particular area code and age, I would make an areacode_age 2-dimensional dict. I ended up needing quite a few of these, which multiplied my memory footprint (to the order of ~10GB), and even though I had enough RAM to support this, the process was still quite slow. At this point, it seemed like I was playing a sucker's game. "Well this is what relational databases were made for, right?", I thought. I imported sqlite3 and imported my data into an in-memory database. I figure databases are built for speed and this will solve my problems. It turns out though, that doing a query like "SELECT (a, b, c) FROM foo WHERE date1<=d AND date2>e AND name=f" takes 0.05 seconds. Doing this for my 1.7m rows would take 24 hours of compute time. My hacky approach with dictionaries was about 3 orders of magnitude faster for this particular task (and, in this example, I couldn't key on date1 and date2 obviously, so I was getting every row that matched name and then filtering by date). So, my question is, why is this so slow, and how can I make it fast? And what is the Pythonic approach? Possibilities I've been considering: sqlite3 is too slow, and I need something more heavyweight I need to somehow change my schema or my queries to be more... optimized? the approaches I've tried so far are entirely wrong and I need a whole new tool of some kind I read somewhere that, in sqlite 3, doing repeated calls to cursor.execute is much slower than using cursor.executemany. It turns out that executemany isn't even compatible with select statements though, so I think this was a red herring. Thanks.
Querying (pretty) big relational data in Python in a reasonable amount of time?
1
1.2
1
1
0
572