Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2012-02-09 23:03:26.323 | Tornado Web Production Environment | 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 ... | 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.2 | true | 1 | 1,669 |
2012-02-10 02:21:28.990 | Configuring sqlalchemy for windows | 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. | The Command pip install sqlalchemy will download the necessary files and run setup.py install for you. | 0.201295 | false | 1 | 1,670 |
2012-02-10 04:34:02.630 | automatic resizing of table in wx | 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... | 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.2 | true | 1 | 1,671 |
2012-02-11 03:11:07.187 | How to configure PyDev to use 32-bit Python Interpreter In Eclipse, on OSX Lion | 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... | 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 ... | 1.2 | true | 1 | 1,672 |
2012-02-11 10:45:13.027 | Full text search with google app engine using ndb models | 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/ga... | 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. | 0.135221 | false | 1 | 1,673 |
2012-02-12 01:32:12.857 | Is Celery as efficient on a local system as python multiprocessing is? | 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 s... | 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... | 1.2 | true | 1 | 1,674 |
2012-02-12 01:45:51.200 | How do you view/list projects within a workspace within Eclipse? | 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 projec... | 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... | 1.2 | true | 1 | 1,675 |
2012-02-12 21:43:27.323 | How do set Python path to run Django with WSGI and Apache? | 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 versio... | "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 stu... | 0 | false | 3 | 1,676 |
2012-02-12 21:43:27.323 | How do set Python path to run Django with WSGI and Apache? | 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 versio... | 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) | 0 | false | 3 | 1,676 |
2012-02-12 21:43:27.323 | How do set Python path to run Django with WSGI and Apache? | 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 versio... | 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. | 1.2 | true | 3 | 1,676 |
2012-02-13 21:53:30.813 | Similarities between tcl and Python | 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. | 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... | 1.2 | true | 2 | 1,677 |
2012-02-13 21:53:30.813 | Similarities between tcl and Python | 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. | 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 lan... | 0.986614 | false | 2 | 1,677 |
2012-02-14 18:19:12.757 | Run a python script in windows | 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 ... | Assuming Python is installed, it is usually placed in a folder prefixed with "Python" and the major/minor version. E.g. C:\Python26 | 0.201295 | false | 1 | 1,678 |
2012-02-15 05:16:50.257 | NLTK certainty measure? | 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 ... | 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. | 0.201295 | false | 2 | 1,679 |
2012-02-15 05:16:50.257 | NLTK certainty measure? | 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 ... | 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... | 1.2 | true | 2 | 1,679 |
2012-02-15 08:27:53.213 | Out of home folder .pyc files? | 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 i... | .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. | 0.201295 | false | 2 | 1,680 |
2012-02-15 08:27:53.213 | Out of home folder .pyc files? | 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 i... | 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 wil... | 0.201295 | false | 2 | 1,680 |
2012-02-15 16:57:27.377 | 2d random walk in python - drawing hypotenuse from distribution | 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 probabl... | 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, distr... | 1.2 | true | 2 | 1,681 |
2012-02-15 16:57:27.377 | 2d random walk in python - drawing hypotenuse from distribution | 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 probabl... | 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... | 0 | false | 2 | 1,681 |
2012-02-16 20:29:35.910 | How to make __repr__ to return unicode string | 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.... | repr(x).decode("utf-8") and unicode(repr(x), "utf-8") should work. | 1.2 | true | 2 | 1,682 |
2012-02-16 20:29:35.910 | How to make __repr__ to return unicode string | 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.... | The representation of an object should not be Unicode. Define the __unicode__ method and pass the object to unicode(). | 0.999329 | false | 2 | 1,682 |
2012-02-17 02:19:36.103 | How to run a script that can only write to STDOUT and read from STDIN? | 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, ho... | 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. | 0.240117 | false | 1 | 1,683 |
2012-02-17 03:18:52.663 | Set encoding in Python 3 CGI scripts | 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 va... | 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 b... | 0.229097 | false | 3 | 1,684 |
2012-02-17 03:18:52.663 | Set encoding in Python 3 CGI scripts | 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 va... | 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 ... | 0.058243 | false | 3 | 1,684 |
2012-02-17 03:18:52.663 | Set encoding in Python 3 CGI scripts | 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 va... | 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 | 0.173164 | false | 3 | 1,684 |
2012-02-17 22:00:20.087 | How to use VB6 DLL (Active X/COM) in Python? | 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 us... | 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.2 | true | 1 | 1,685 |
2012-02-18 03:35:31.183 | problems with rock paper scissors in python | 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... | 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 ... | 0 | false | 1 | 1,686 |
2012-02-18 18:57:08.220 | Function failed: Raise Exception, or return FALSE? What's the better approach? | 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 prefe... | 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 al... | 0.673066 | false | 1 | 1,687 |
2012-02-19 07:07:27.350 | Python strip with \n | 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 t... | 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... | 0.058243 | false | 2 | 1,688 |
2012-02-19 07:07:27.350 | Python strip with \n | 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 t... | 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() | 0.058243 | false | 2 | 1,688 |
2012-02-19 14:46:11.867 | Autocompletion in Pydev- Eclipse for wxpython | 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 ... | Regarding missing parameters on the constructor for wx.Button, unfortunately that's currently expected. Please create a bug report for PyDev specifying that. | 1.2 | true | 1 | 1,689 |
2012-02-19 15:21:06.460 | u'Georges Méliès' vs u'Georges M\xe9li\xe8s' | 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? | It's the same, and I would add:
u'Georges Méliès'.encode('latin1') gives 'Georges M\xe9li\xe8s' | 1.2 | true | 2 | 1,690 |
2012-02-19 15:21:06.460 | u'Georges Méliès' vs u'Georges M\xe9li\xe8s' | 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? | 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 ... | 0.998178 | false | 2 | 1,690 |
2012-02-19 15:40:57.060 | How to create a Mac .pkg from python which supports multiple versions of OSX | 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... | 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) | 0 | false | 1 | 1,691 |
2012-02-20 02:26:44.563 | Are there any guidelines to follow when choosing number of processes with multiprocessing? | 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 ... | 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... | 0.386912 | false | 1 | 1,692 |
2012-02-20 19:06:20.553 | html5 websockets OR flash sockets activated on load? | 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... | 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. | 0 | false | 1 | 1,693 |
2012-02-21 14:31:12.497 | How to keep track of all the components used by my Django app | 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. Seco... | 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.2 | true | 1 | 1,694 |
2012-02-21 19:19:16.700 | What does Python's eval() do? | 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? | 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 dire... | 1 | false | 4 | 1,695 |
2012-02-21 19:19:16.700 | What does Python's eval() do? | 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? | 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 ... | 0.992632 | false | 4 | 1,695 |
2012-02-21 19:19:16.700 | What does Python's eval() do? | 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? | 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. | 0.240117 | false | 4 | 1,695 |
2012-02-21 19:19:16.700 | What does Python's eval() do? | 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? | 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 in... | 0.240117 | false | 4 | 1,695 |
2012-02-21 19:40:48.230 | IDLE crash when opening on Mac OS X | 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 "P... | 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 ... | 0.081452 | false | 2 | 1,696 |
2012-02-21 19:40:48.230 | IDLE crash when opening on Mac OS X | 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 "P... | 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 m... | 0 | false | 2 | 1,696 |
2012-02-21 21:12:24.760 | python c extension / opencl daemon | 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 kee... | 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.). | 0 | false | 1 | 1,697 |
2012-02-22 05:08:30.940 | python cx_oracle and server information | 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 ... | 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 Ora... | 0 | false | 1 | 1,698 |
2012-02-22 12:25:18.657 | Python: how to import a bunch of similar names? | 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? | 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. | 0 | false | 1 | 1,699 |
2012-02-22 13:29:32.057 | How much memory is used by a numpy ndarray? | Does anybody know how much memory is used by a numpy ndarray? (with let's say 10,000,000 float elements). | 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 ... | 0 | false | 1 | 1,700 |
2012-02-22 14:02:32.280 | Use Python / PIL or similar to shrink whitespace | 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 ... | 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. | 0.135221 | false | 1 | 1,701 |
2012-02-23 18:53:25.587 | have local numpy override global | 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... | 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.2 | true | 1 | 1,702 |
2012-02-23 21:11:44.477 | deploying python applications | 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 ... | 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 ... | 1.2 | true | 3 | 1,703 |
2012-02-23 21:11:44.477 | deploying python applications | 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 ... | 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 diff... | 0.573727 | false | 3 | 1,703 |
2012-02-23 21:11:44.477 | deploying python applications | 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 ... | Build a web application in python. Then the world can use it via a browser with zero install. | 0.081452 | false | 3 | 1,703 |
2012-02-24 13:53:40.810 | Customize QTreeView items | 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... | 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, s... | 1.2 | true | 1 | 1,704 |
2012-02-24 16:35:47.687 | Long-lived multithreaded client for a proprietary protocol (Python, select, epoll) | 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... | 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 inde... | 0 | false | 1 | 1,705 |
2012-02-26 02:09:55.153 | find all items in list object | 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 returne... | 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. | 0.135221 | false | 1 | 1,706 |
2012-02-26 11:19:45.470 | Inverted Index System using Python | 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 w... | 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
... | 0.673066 | false | 1 | 1,707 |
2012-02-28 15:27:30.033 | How do I limit a Ubuntu machine to a Python GUI? | 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 ... | Don't start a window manager. Only start your program, e.g. from xinitrc. Make the program full-screen | 0.135221 | false | 1 | 1,708 |
2012-02-29 14:02:57.803 | Eclipse editor doesn't recognize Scipy content | 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. | Try to recreate your project in PyDev and add these new libraries. | 1.2 | true | 1 | 1,709 |
2012-03-01 13:26:27.613 | Concurrency handling in python based webapp | 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 ... | 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 acr... | 1.2 | true | 1 | 1,710 |
2012-03-01 16:11:33.563 | how do i redirect the output of nosetests to a textfile? | I've tried "nosetests p1.py > text.txt" and it is not working.
What is the proper way to pipe this console output? | parameter -s - Not capturing stdout | 0.135221 | false | 1 | 1,711 |
2012-03-01 17:47:53.437 | cursor and with_cursor() in GAE | 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... | 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. | 0 | false | 1 | 1,712 |
2012-03-01 20:02:06.500 | Website to computer communications | 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... | 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. | 0 | false | 1 | 1,713 |
2012-03-01 22:47:59.453 | PyGST and videos with multiple audio tracks | 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 ! xvimage... | 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... | 0 | false | 1 | 1,714 |
2012-03-02 05:23:08.280 | how to find the authentication used on a website | 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... | 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. | 0 | false | 1 | 1,715 |
2012-03-02 06:02:10.723 | First project what should I look out for | 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 excepti... | 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 t... | 1.2 | true | 1 | 1,716 |
2012-03-02 19:12:42.670 | python increment ipaddress | 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 ... | 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... | 0.151877 | false | 1 | 1,717 |
2012-03-02 22:31:56.233 | Global variables in Python and Apache mod_wsgi | 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 und... | 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 explici... | 1.2 | true | 1 | 1,718 |
2012-03-03 03:30:23.503 | Automate database creation with incremental name? | 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... | 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. | 0 | false | 1 | 1,719 |
2012-03-03 23:13:33.187 | Scraping with JQuery or Python? | 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 m... | 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 mecha... | 1.2 | true | 2 | 1,720 |
2012-03-03 23:13:33.187 | Scraping with JQuery or Python? | 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 m... | 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... | 0 | false | 2 | 1,720 |
2012-03-04 05:35:51.437 | python re.match group: number after \number | 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 fol... | 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. | 0.386912 | false | 2 | 1,721 |
2012-03-04 05:35:51.437 | python re.match group: number after \number | 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 fol... | 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 unnecessa... | 1.2 | true | 2 | 1,721 |
2012-03-04 10:41:17.713 | SQLAlchamy Database Construction & Reuse | 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 bot... | 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... | 0 | false | 1 | 1,722 |
2012-03-04 15:46:35.183 | Setup Cherrypy with Google App Engine | 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 webap... | 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.2 | true | 1 | 1,723 |
2012-03-04 18:17:37.477 | Redis and RDBMS coexistence (hopefully cooperation) in Flask applications | 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 pr... | 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.2 | true | 1 | 1,724 |
2012-03-05 08:59:49.743 | removing buttons/links in django admin | 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? | 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 | true | 1 | 1,725 |
2012-03-05 13:19:44.273 | Feed input of MS-DOS interactive executable with a string value | 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 does... | Have you tried merely piping the input to the command?
In cmd.exe:
C:\> echo m | p4 resolve | 0 | false | 1 | 1,726 |
2012-03-05 20:05:51.293 | How to access and modify Xcode project files from python code? | 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 ... | 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 ... | -0.386912 | false | 1 | 1,727 |
2012-03-05 22:23:32.727 | Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user? | 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 ... | 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 a... | 0 | false | 2 | 1,728 |
2012-03-05 22:23:32.727 | Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user? | 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 ... | 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. | 1.2 | true | 2 | 1,728 |
2012-03-06 01:50:28.840 | django-admin-tools : change header 'Django Administration' | 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. | 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\djan... | 1.2 | true | 1 | 1,729 |
2012-03-06 03:44:00.070 | dreamhost+django: cannot get domain name using site framework | 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. | 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.2 | true | 1 | 1,730 |
2012-03-06 05:14:31.577 | Why does Tornado take so long to die when I hit ctrl-c? | 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... | 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) | 0.265586 | false | 1 | 1,731 |
2012-03-06 23:39:29.830 | Need to send a HTTP request in Python that'll authenticate with Google Accounts | 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 ... | Can you use OAUth to authenticate with Google, then use the OAuth token to ensure the messages are legitimate? | 0.386912 | false | 1 | 1,732 |
2012-03-07 03:43:25.480 | Clustering using k-means in python | 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 ... | 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/sphe... | 0.386912 | false | 1 | 1,733 |
2012-03-07 19:10:17.687 | How do I force `setup.py test` to install dependencies into my `virtualenv`? | 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 ... | 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 te... | 1.2 | true | 1 | 1,734 |
2012-03-08 13:59:39.890 | How to ensure several Python processes access the data base one by one? | 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... | 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 ... | 0.135221 | false | 2 | 1,735 |
2012-03-08 13:59:39.890 | How to ensure several Python processes access the data base one by one? | 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... | 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. | 0 | false | 2 | 1,735 |
2012-03-09 15:06:28.283 | Is that possible to develop a ACM ONLINE JUDGE system using NODE.JS(or PYTHON)? | 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 sign... | 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 | 0 | false | 1 | 1,736 |
2012-03-10 09:33:56.270 | Dynamically reload a class definition in Python | 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.
S... | Better yet subprocess the plugins, then hypervise the subprocess, when the files change reload the plugins process.
Edit: cleaned up. | 0 | false | 1 | 1,737 |
2012-03-11 17:51:11.843 | How To Add .ui Files To Python | 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. | You need PyQt or PySide to use Qt in your Python script.
To generate python script from ui file run pyuic -x form.ui | 0 | false | 1 | 1,738 |
2012-03-12 07:44:23.143 | What are the extra capabilities Python gives when used with Java? | 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 ... | I know how to use python with java through jython, but backwards ... try to ask your question to jython community. | 0.265586 | false | 3 | 1,739 |
2012-03-12 07:44:23.143 | What are the extra capabilities Python gives when used with Java? | 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 ... | 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 ... | 0.135221 | false | 3 | 1,739 |
2012-03-12 07:44:23.143 | What are the extra capabilities Python gives when used with Java? | 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 ... | 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 i... | 0.99039 | false | 3 | 1,739 |
2012-03-12 09:49:43.067 | Python framework for task execution and dependencies handling | 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)
B... | 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 e... | 0.135221 | false | 1 | 1,740 |
2012-03-12 10:42:15.787 | Python - List issues (multiple lists?) | 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... | 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. | 0 | false | 1 | 1,741 |
2012-03-12 11:06:06.457 | How to benchmark web chat performance? | 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 identi... | 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 | true | 1 | 1,742 |
2012-03-12 11:46:02.713 | How to disable a button after clicking it in OpenERP | 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.... | If we talking about web interface then you could disable it by javascript. | 0 | false | 1 | 1,743 |
2012-03-13 08:48:19.807 | PyDev: how remove command line switch -u | 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? | 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? (ma... | 0 | false | 1 | 1,744 |
2012-03-14 02:05:02.950 | Querying (pretty) big relational data in Python in a reasonable amount of time? | 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 ... | 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 | true | 1 | 1,745 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.