Re: staticmethod makes my brain hurt

2011-11-16 Thread Ian Kelly
On Wed, Nov 16, 2011 at 11:44 PM, Dotan Cohen wrote: > Try this (untested): > > class C: >   @staticmethod >   def foo(): >       pass > >   print "inside", C.foo, callable(C.foo) If you had tested this, you would have found that you get a NameError, since C is not yet bound inside the class bloc

Re: Multiple threads

2011-11-16 Thread Jack Keegan
On Wed, Nov 16, 2011 at 6:30 PM, Dave Angel wrote: > On 11/16/2011 01:22 PM, Dave Angel wrote: > >> (You're top-posting. Put your remarks AFTER what you're quoting) >> >> On 11/16/2011 12:52 PM, Jack Keegan wrote: >> >>> Ok, I thought that processes would do the same job as threads. So would >>>

problem in running script file of modeller

2011-11-16 Thread Anushree Tripathi
When I run mod9.10 model-default.py command on command window.It is showing that 'import site' failed;use -v for traceback and also error in opening alignment.ali file.Now what do i have to change.Please reply me as soon as possible. -- http://mail.python.org/mailman/listinfo/python-list

Re: staticmethod makes my brain hurt

2011-11-16 Thread Dotan Cohen
On Thu, Nov 17, 2011 at 04:30, Roy Smith wrote: > When I run this (python 2.6.1): > > class C: >    @staticmethod >    def foo(): >        pass > >    print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I get: > > inside False > outside True > > I don't understand.

Re: staticmethod makes my brain hurt

2011-11-16 Thread Devin Jeanpierre
> However, the fix is not as simple as merely making staticmethod objects > callable. This was discussed at the 2011 language summit: > > http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html > > See also this thread: > > http://mail.python.org/pipermail/python-dev/2011-

Re: staticmethod makes my brain hurt

2011-11-16 Thread Roy Smith
In article <4ec490ec$0$30003$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > This has come up before. > > http://bytes.com/topic/python/answers/34396-static-method-object-not-callable > > http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callabl > e > > > H

Re: staticmethod makes my brain hurt

2011-11-16 Thread Steven D'Aprano
On Wed, 16 Nov 2011 21:30:57 -0500, Roy Smith wrote: > When I run this (python 2.6.1): > > class C: > @staticmethod > def foo(): > pass > print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I get: > > inside False > outside True > > I don'

Monitoring/inventory client-server app

2011-11-16 Thread snorble
I'm writing a tool for monitoring the workstations and servers in our office. I plan to have a server and a client service that runs on each workstation and reports back to the server (heartbeat, disk free space, etc). So far I am considering XMLRPC, or a client service that just downloads a Pytho

Re: staticmethod makes my brain hurt

2011-11-16 Thread Ethan Furman
Roy Smith wrote: class User(Document): @staticmethod def _get_next_id(): [blah, blah, blah] return id user_id = IntField(required=True, default=_get_next_id) If you don't call '_get_next_id()' from any class methods (in other words, if you don't need to ever say 'se

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread alex23
On Nov 17, 7:09 am, Ben Finney wrote: > You can then use that functionality in your Python interactive startup > file. Here's mine: Awesome, thank you for this. I use iPython where ever possible but there are times where I just can't avoid the default shell and this will help immensely. Cheers!

Re: staticmethod makes my brain hurt

2011-11-16 Thread Roy Smith
In article , alex23 wrote: > What you're effectively trying to do is use a class before it has been > constructed to help construct itself. > > Just define it as a helper function before the class declaration. Yes, this is the workaround I ended up with. -- http://mail.python.org/mailman/lis

Re: staticmethod makes my brain hurt

2011-11-16 Thread alex23
On Nov 17, 12:30 pm, Roy Smith wrote: > class C: >     @staticmethod >     def foo(): >         pass > >     print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I don't understand.  Why is foo not callable inside of the class > definition? Consider this: >>

staticmethod makes my brain hurt

2011-11-16 Thread Roy Smith
When I run this (python 2.6.1): class C: @staticmethod def foo(): pass print "inside", foo, callable(foo) print "outside", C.foo, callable(C.foo) I get: inside False outside True I don't understand. Why is foo not callable inside of the class definition? Where this co

How to insert my own module in front of site eggs?

2011-11-16 Thread Roy Smith
I'm trying to use a custom version of mongoengine. I cloned the git repo and put the directory on my PYTHONPATH, but python is still importing the system's installed version. Looking at sys.path, it's obvious why: $ echo $PYTHONPATH /home/roy/songza:/home/roy/lib/mongoengine >>> pprint.ppri

Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Dan Sommers
On Wed, 16 Nov 2011 17:57:27 +0100, Frederic Rentsch wrote: > I'd like to log MySQL errors. If I do: > > try: (command) > except MySQLdb.OperationalError, e: print e > > I may get something like: > > (1136, "Column count doesn't match value count at row 1") > > If I don't kno

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread David Robinow
On Wed, Nov 16, 2011 at 6:59 PM, Ben Finney wrote: > David Robinow writes: > >> On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney >> wrote: >> > I don't know about MS Windows, but the Python interactive shell can be >> > linked with the GNU Readline library for managing its command line >> > http://d

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread Ben Finney
David Robinow writes: > On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney > wrote: > > I don't know about MS Windows, but the Python interactive shell can be > > linked with the GNU Readline library for managing its command line > > http://docs.python.org/library/readline.html> […] > > Reading the d

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread David Robinow
On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney wrote: > goldtech writes: > >> Using Windows. Is there a python shell that has a history of typed in >> commands? > > I don't know about MS Windows, but the Python interactive shell can be > linked with the GNU Readline library for managing its command

pymacs?

2011-11-16 Thread Andrea Crotti
After a long time, and since it was included iin python-mode, I wanted to try if I can get ropemacs working finally. I have tried many possible things, also in Emacs -Q, and I actually got it working only once, apparently by pure luck with Emacs -Q: (setq py-load-python-mode-pymacs-p nil) (se

Re: Multiple threads

2011-11-16 Thread Miki Tebeka
You can see an example on how to use multiprocessing.Pool at http://pythonwise.blogspot.com/2011/03/convert-oggs-to-mp3-fast-way.html This is ogg -> mp3 but the same idea. -- http://mail.python.org/mailman/listinfo/python-list

Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Terry Reedy
On 11/16/2011 11:57 AM, Frederic Rentsch wrote: If I don't know in advance which error to expect, but on the contrary want to find out which error occurred, I can catch any error by omitting the name: except: (handle) But now I don't have access to the error message 'e'. I'm sure there

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread Ben Finney
goldtech writes: > Using Windows. Is there a python shell that has a history of typed in > commands? I don't know about MS Windows, but the Python interactive shell can be linked with the GNU Readline library for managing its command line http://docs.python.org/library/readline.html> including e

Re: redis beginner question

2011-11-16 Thread Rafael Durán Castañeda
El 16/11/11 03:22, Jabba Laci escribió: Hi, I'm reading the redis documentation and there is one thing that bothers me. For redis, you need to start a server on localhost. Is there an easy way that my Python script starts this server automatically? Before using my script, I don't want to start r

Re: (n00b) Tkinter trouble

2011-11-16 Thread Jason Swails
On Tue, Nov 15, 2011 at 10:49 PM, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 2:02 PM, Jason Swails > wrote: > > Apparently I could not do what I was wanting to (state=DISABLED is not a > > valid option to Toplevel). What I wanted to do was something similar to > > what the dialogs were doi

Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread MRAB
On 16/11/2011 17:09, Chris Kaynor wrote: On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch wrote: Hi all, I'd like to log MySQL errors. If I do: try: (command) except MySQLdb.OperationalError, e: print e I may get something like: (1136, "Column count doesn't match

Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Christian Heimes
Am 16.11.2011 19:39, schrieb Frederic Rentsch: >> py>import sys >> py>try: >> py> raise RuntimeError >> py> except: >> py> print sys.exc_info() >> py> >> (, RuntimeError(), > at 0x02371588>) > > Chris, Thanks very much! Great help! How about using the excellent logging framework instead o

Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Frederic Rentsch
On Wed, 2011-11-16 at 09:09 -0800, Chris Kaynor wrote: > On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch > wrote: > > Hi all, > > > > > > I'd like to log MySQL errors. If I do: > > > >try: (command) > >except MySQLdb.OperationalError, e: print e > > > > I may get something like:

Re: Multiple threads

2011-11-16 Thread Dave Angel
On 11/16/2011 01:22 PM, Dave Angel wrote: (You're top-posting. Put your remarks AFTER what you're quoting) On 11/16/2011 12:52 PM, Jack Keegan wrote: Ok, I thought that processes would do the same job as threads. So would the general rule be some thing like so: If I want another piece of wor

Re: Multiple threads

2011-11-16 Thread Dave Angel
On 11/16/2011 12:55 PM, Michael Hunter wrote: On Wed, Nov 16, 2011 at 9:27 AM, Dave Angel wrote: On 11/16/2011 12:00 PM, Jack Keegan wrote: [...] Processes [...] and the OS is generally better at scheduling them than it is at scheduling threads within a single process. If you have multiple co

How to use pySerial under Windows 7 without administrator rights

2011-11-16 Thread furoscame
Hello together, currently I try to use pySerial under Windows 7. But it is not possible to open a serial port without running the script under adminstrator rights. Other programs like Terraterm are able to so without adminstrator rights. What is the reason for that and is it possible open a p

Re: Multiple threads

2011-11-16 Thread Michael Hunter
On Wed, Nov 16, 2011 at 9:27 AM, Dave Angel wrote: > On 11/16/2011 12:00 PM, Jack Keegan wrote: >[...] Processes [...] and the OS is generally better at scheduling them than >it is at > scheduling threads within a single process.  If you have multiple cores, the > processes can really run simulta

Re: Multiple threads

2011-11-16 Thread Dave Angel
On 11/16/2011 12:00 PM, Jack Keegan wrote: Hi Chris, On Wed, Nov 16, 2011 at 1:55 PM, Chris Angelico wrote: First off, it's better in CPython (the most popular Python) to use multiple processes than multiple threads. I had been looking into treads and process/subprocess myself a while ago a

Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Chris Kaynor
On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch wrote: > Hi all, > > > I'd like to log MySQL errors. If I do: > >        try: (command) >        except MySQLdb.OperationalError, e: print e > > I may get something like: > >        (1136, "Column count doesn't match value count at row 1") > > If I

Re: Multiple threads

2011-11-16 Thread Jack Keegan
Hi Chris, On Wed, Nov 16, 2011 at 1:55 PM, Chris Angelico wrote: > First off, it's better in CPython (the most popular Python) to use > multiple processes than multiple threads. I had been looking into treads and process/subprocess myself a while ago and couldn't decide which would suit what I

try - except. How to identify errors unknown in advance?

2011-11-16 Thread Frederic Rentsch
Hi all, I'd like to log MySQL errors. If I do: try: (command) except MySQLdb.OperationalError, e: print e I may get something like: (1136, "Column count doesn't match value count at row 1") If I don't know in advance which error to expect, but on the contrary want to f

Re: Multiple threads

2011-11-16 Thread Thomas Rachel
Am 16.11.2011 14:48 schrieb Eduardo Oliva: Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line. What I want to do is: I need my script to run 2 separated threads, and then when the first has finished, starts the next one

Re: Multiple threads

2011-11-16 Thread Christian Heimes
Am 16.11.2011 14:48, schrieb Eduardo Oliva: > Hello, I have a py script that reads for all "m2ts" video files and convert > them to "mpeg" using ffmpeg with command line. > > What I want to do is: > > I need my script to run 2 separated threads, and then when the first has > finished, starts

Re: Got some problems when using logging Filter

2011-11-16 Thread Peter Otten
sword wrote: > Thanks for your reply. I tried to edit the source a bit, now the > main.py looks like this: > #main.py > import logging > from logging import Filter > import a > import b > > logging.basicConfig(level=logging.DEBUG) > root = logging.getLogger() > root.addFilter(Filter("GoneWithTheW

Re: redis beginner question

2011-11-16 Thread Roy Smith
In article , Jabba Laci wrote: > > Why do you want to stop redis after your program terminates?  Generally, > > you just start redis up when the system boots and leave it running. > > Hi, > > OK, so it's more like MySQL or PostgeSQL, i.e. leave the server > running in the background. That's h

Re: unit-profiling, similar to unit-testing

2011-11-16 Thread Roy Smith
In article <95bcp8-bft@satorlaser.homedns.org>, Ulrich Eckhardt wrote: > Hi! > > I'm currently trying to establish a few tests here that evaluate certain > performance characteristics of our systems. As part of this, I found > that these tests are rather similar to unit-tests, only that t

Re: Multiple threads

2011-11-16 Thread Henrik Faber
On 16.11.2011 14:48, Eduardo Oliva wrote: > I need my script to run 2 separated threads, and then when the first has > finished, starts the next onebut no more than 2 threads. > I know that Semaphores would help with that. > But the problem here is to know when the thread has finished i

Re: Multiple threads

2011-11-16 Thread Chris Angelico
On Thu, Nov 17, 2011 at 12:48 AM, Eduardo Oliva wrote: > Hello, I have a py script that reads for all "m2ts" video files and convert > them to "mpeg" using ffmpeg with command line. > > What I want to do is: > >  I need my script to run 2 separated threads, and then when the first has > finished

Multiple threads

2011-11-16 Thread Eduardo Oliva
Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line. What I want to do is: I need my script to run 2 separated threads, and then when the first has finished, starts the next onebut no more than 2 threads. I know that

Re: redis beginner question

2011-11-16 Thread Jabba Laci
> Why do you want to stop redis after your program terminates?  Generally, > you just start redis up when the system boots and leave it running. Hi, OK, so it's more like MySQL or PostgeSQL, i.e. leave the server running in the background. I wanted to use it like SQLite, i.e. let it run only when

Re: Got some problems when using logging Filter

2011-11-16 Thread sword
On Nov 16, 7:40 pm, Jean-Michel Pichavant wrote: > sword wrote: > > The logging cookbook gives an Filter example, explainning how to add > > contextural info to log. I can't figure out how to filter log from it. > > > Suppose I have 3 file, a.py, b.py and main.py > > #file: a.py > > import logging

Re: Got some problems when using logging Filter

2011-11-16 Thread Jean-Michel Pichavant
sword wrote: The logging cookbook gives an Filter example, explainning how to add contextural info to log. I can't figure out how to filter log from it. Suppose I have 3 file, a.py, b.py and main.py #file: a.py import logging logger=logging.getLogger(__name__) def print_log(): logger.debug(

Re: suppressing import errors

2011-11-16 Thread Andreea Babiuc
Loving the offtopic guys, sorry I have to go back to my problem now.. In the module I want to import I have a few import statements for Maya commands that don't work outside Maya unless I use the Maya standalone interpreter. So before I import this module I need to make sure I import maya and maya

Re: (don't bash me too hard) Python interpreter in JavaScript

2011-11-16 Thread Amirouche Boubekki
Héllo I am looking for a way how to bring Python interpreter to JavaScript, in > order to provide a web-based application with python scripting > capabilities. The app would have basic IDE for writing and debugging the > python code, but the interpretation, of course, would be done in > JavaScript

unit-profiling, similar to unit-testing

2011-11-16 Thread Ulrich Eckhardt
Hi! I'm currently trying to establish a few tests here that evaluate certain performance characteristics of our systems. As part of this, I found that these tests are rather similar to unit-tests, only that they are much more fuzzy and obviously dependent on the systems involved, CPU load, ne

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread Tim Golden
On 16/11/2011 03:38, goldtech wrote: Hi, Using Windows. Is there a python shell that has a history of typed in commands? Have a look at DreamPie: http://dreampie.sourceforge.net/ TJG -- http://mail.python.org/mailman/listinfo/python-list