Class list of a module

2007-01-14 Thread Laurent . LAFFONT-ST
Hi, I want to get all classes of a module in a list. I wrote this code but I wonder if there's not a simpler solution import inspect def getClassList(aModule): return [getattr(aModule, attName) \ for attName in aModule.__dict__ \ if inspect.isclass(getattr(aModule,

Re: Maths error

2007-01-14 Thread Hendrik van Rooyen
"Dennis Lee Bieber" <[EMAIL PROTECTED]>wrote: > On Sun, 14 Jan 2007 07:18:11 +0200, "Hendrik van Rooyen" > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > > I recall an SF character known as "Slipstick Libby", > > who was supposed to be a Genius - but I forget > > the s

Re: How to write code to get focuse the application which is open from server

2007-01-14 Thread vithi
Hi Paul, Since your reply I try to use pywinauto. I was able to get the control of a window that is a good news but it is not working for sub window this main window create.(popup windows) eg) File -> printwill open print window but the code is not clicking print button. I try several combinati

Re: How to write code to get focuse the application which is open from server

2007-01-14 Thread vithi
Hi Paul, Since your reply I try to use pywinauto. I was able to get the control of a window that is a good news but it is not working for sub window this main window create.(popup windows) eg) File -> printwill open print window but the code is not clicking print button. I try several combinati

Re: How naive is Python?

2007-01-14 Thread Steven D'Aprano
On Mon, 15 Jan 2007 03:25:01 +, John Nagle wrote: > How naive (in the sense that compiler people use the term) > is the current Python system? For example: > > def foo() : > s = "This is a test" > return(s) > > s2 = foo() > > How many times does the s

Re: How naive is Python?

2007-01-14 Thread Roy Smith
In article <[EMAIL PROTECTED]>, John Nagle <[EMAIL PROTECTED]> wrote: > How naive (in the sense that compiler people use the term) > is the current Python system? For example: > > def foo() : > s = "This is a test" > return(s) > > s2 = foo() > > How many times d

Re: How naive is Python?

2007-01-14 Thread skip
John> How naive (in the sense that compiler people use the term) is the John> current Python system? For example: John> def foo() : John> s = "This is a test" John> return(s) John> s2 = foo() John> How many times does the string ge

Re: Conflicting needs for __init__ method

2007-01-14 Thread Steven D'Aprano
On Mon, 15 Jan 2007 14:43:55 +1100, Steven D'Aprano wrote: >> Of course, none of this really has anything to do with rational >> numbers. There must be many examples of classes for which internal >> calls to __init__, from other methods of the same class, require >> minimal argument processing, w

on which site or Usenet group should this question be posted?

2007-01-14 Thread mirandacascade
Operating system: Win XP Version of Python: 2.4 I recognize that this question is not about Python...it has only a tangential Python connection. I'm using a Python package to run a process; that process is issuing an error, and I'm hoping that someone on this site can point me to the site that ha

Re: Conflicting needs for __init__ method

2007-01-14 Thread Steven D'Aprano
On Sun, 14 Jan 2007 15:32:35 -0800, dickinsm wrote: > Suppose you're writing a class "Rational" for rational numbers. The > __init__ function of such a class has two quite different roles to > play. First, it's supposed to allow users of the class to create > Rational instances; in this role, __

How naive is Python?

2007-01-14 Thread John Nagle
How naive (in the sense that compiler people use the term) is the current Python system? For example: def foo() : s = "This is a test" return(s) s2 = foo() How many times does the string get copied? Or, for example: s1 = "Test1" s2

Re: Conflicting needs for __init__ method

2007-01-14 Thread Gabriel Genellina
At Sunday 14/1/2007 20:32, [EMAIL PROTECTED] wrote: Of course, none of this really has anything to do with rational numbers. There must be many examples of classes for which internal calls to __init__, from other methods of the same class, require minimal argument processing, while external cal

Re: Learning Python book, new edition?

2007-01-14 Thread wesley chun
Robert Hicks wrote: > I would get "Core Python Programming" by Wesley Chun. It covers just > about everything under the sun and includes version 2.5. Robert, thanks for the plug. if the OP wants to learn more about my book and its philosophy, feel free to check out my comments on the Amazon prod

Python web app. (advice sought)

2007-01-14 Thread Duncan Smith
Hello, I find myself in the, for me, unusual (and at the moment unique) position of having to write a web application. I have quite a lot of existing Python code that will form part of the business logic. This relies on 3rd party libraries (such as numpy) which would make porting to e.g. Iro

Re: Maths error

2007-01-14 Thread Tim Roberts
"Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: >"Nick Maclaren" <[EMAIL PROTECTED]> wrote: > >> What I don't know is how much precision this approximation loses when >> used in real applications, and I have never found anyone else who has >> much of a clue, either. >> >I would suspect that this

Re: Conflicting needs for __init__ method

2007-01-14 Thread Ziga Seilnacht
Mark wrote: [a lot of valid, but long concerns about types that return an object of their own type from some of their methods] I think that the best solution is to use an alternative constructor in your arithmetic methods. That way users don't have to learn about two different factories for the

Re: python - process id

2007-01-14 Thread Jean-Paul Calderone
On Sun, 14 Jan 2007 16:36:58 -0800, bruce <[EMAIL PROTECTED]> wrote: >hi... > >is there a way to have a test python app, get its' own processID. i'm >creating a test python script under linux, and was wondering if this is >possible.. See the os module, the getpid function. > >also, i've tried usi

python - process id

2007-01-14 Thread bruce
hi... is there a way to have a test python app, get its' own processID. i'm creating a test python script under linux, and was wondering if this is possible.. also, i've tried using an irc client to join the irc #python channel, and for some reason i keep getting the err msg saying that the 'addr

Conflicting needs for __init__ method

2007-01-14 Thread dickinsm
Here's an example of a problem that I've recently come up against for the umpteenth time. It's not difficult to solve, but my previous solutions have never seemed quite right, so I'm writing to ask whether others have encountered this problem, and if so what solutions they've come up with. Suppos

Re: help with recursion on GP project

2007-01-14 Thread bearophileHUGS
First possible raw solution: from operator import add, sub, mul, div, neg def evaluate(expr): if isinstance(expr, list): fun, ops = expr[0], expr[1:] return fun(*map(evaluate, ops)) else: return expr example = [add, [add, [sub, 5, 4], [mul, 3, 2]], [neg, 5]] print

Re: Is it possible to get whole commandline include redirection.., etc

2007-01-14 Thread Carl Banks
[EMAIL PROTECTED] wrote: > Can I get whole commandline not only argument list. > > 1. When I command like this > $ a.py > filename > 2. sys.argv is returns only argument list > ['a.py'] > > Is there a way to find out 'redirection' information. It's not possible to find the exact command li

help with recursion on GP project

2007-01-14 Thread none
I'm trying to create a recursive function to evaluate the expressions within a list. The function uses eval() to evaluate the list. Like a lisp interpreter but very limited. What I'm looking for is a function to recursively traverse the list and provide answers in place of lists, so that ... E

Re: Threaded for loop

2007-01-14 Thread Paul Boddie
[EMAIL PROTECTED] wrote: > > There is a module in development (processing.py) that provides an API like > the threading module but that uses processes under the covers: > > http://mail.python.org/pipermail/python-dev/2006-October/069297.html > > You might find that an interesting alternative.

Re: Newbie - converting csv files to arrays in NumPy - Matlab vs. Numpy comparison

2007-01-14 Thread oyekomova
Thank you so much. Your solution works! I greatly appreciate your help. sturlamolden wrote: > oyekomova wrote: > > > Thanks for your note. I have 1Gig of RAM. Also, Matlab has no problem > > in reading the file into memory. I am just running Istvan's code that > > was posted earlier. > > You h

Re: Tkinter code (with pmw) executing to soon please help

2007-01-14 Thread Gabriel Genellina
<[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] > button[num] = Tkinter.Button(frame,text = returnstring, > command=callback(returnstring))# > > I understand this part of it > > def callback(text): > def handler(event): > print text > It stopped calling it automaticaly b

Re: Decorators inside of class and decorator parameters

2007-01-14 Thread MR
Wow. Really neat stuff there. memoize seems especially cool since you can get lots of nice dynamic programming benefits "for free" (sorry if I just stated the obvious, but I thought was was especially cool.) Michele Simionato wrote: > Gabriel Genellina wrote: > > see this article by M. Simoniato

Re: Decorators inside of class and decorator parameters

2007-01-14 Thread MR
Thanks so much for your reply. You've definitely helped me a great deal on this. Your comment about the difference between define time and instantiation time cleared things up more than anything, and that also helped clear up the confusion I was having about "self". I think the places I've seen d

Re: Decorators inside of class and decorator parameters

2007-01-14 Thread Gabriel Genellina
"Michele Simionato" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] > Gabriel Genellina wrote: >> see this article by M. Simoniato >> http://www.phyast.pitt.edu/~micheles/python/documentation.html for a >> better >> way using its decorator factory. > > Actually the name is Simio

Re: Decorators inside of class and decorator parameters

2007-01-14 Thread Gabriel Genellina
"Colin J. Williams" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] > Gabriel Genellina wrote: >> As said in the beginning, there is no use for decorators as methods >> (perhaps >> someone can find a use case?) > Except, perhaps to indicate to the script reader that the decorat

Re: Threaded for loop

2007-01-14 Thread sturlamolden
John wrote: > I want to do something like this: > > for i = 1 in range(0,N): > for j = 1 in range(0,N): >D[i][j] = calculate(i,j) > > I would like to now do this using a fixed number of threads, say 10 > threads. Why do you want to run this in 10 threads? Do you have 10 CPUs? If you are con

Re: Threaded for loop

2007-01-14 Thread skip
John> Damn! That is bad news. So even if caclulate is independent for John> (i,j) and is computable on separate CPUs (parts of it are CPU John> bound, parts are IO bound) python cant take advantage of this? It will help if parts are I/O bound, presuming the threads which block release

Re: template engine

2007-01-14 Thread [EMAIL PROTECTED]
> > > $title > > > #if user > hello $user/name > #else > hello guest > #endif > > This example code would work in cheetah with only 2 changes... www.cheetahtemplate.org Pete -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing a matrix (list[][]) ?

2007-01-14 Thread Colin J. Williams
jairodsl wrote: > Hi, > > How can I find the minus element greater than zero in a matrix, my > matrix is > > matrix= > [9,8,12,15], > [0,11,15,18], > [0,0,10,13], > [0,0,0,5] > > I dont want to use "min" function because each element in the matrix is > associated to (X,Y) position. > > Thanks a

Re: Tkinter code (with pmw) executing to soon please help

2007-01-14 Thread Peter Otten
[EMAIL PROTECTED] wrote: > Scott David Daniels wrote: >> Gabriel Genellina wrote: >> >... So `callback` should return a function, like this: >> > >> > def callback(text): >> > def handler(event): >> > print text >> > >> >> Even better than that: >> def callback(text): >> def ha

Announcing: Spiff Guard (Generic Access Lists for Python)

2007-01-14 Thread Samuel
Introduction Spiff Guard is a library for implementing access lists in Python. It provides a clean and simple API and was implemented with performance and security in mind. It was originally inspired by phpGACL (http://phpgacl.sourceforge.net/), but features an API that is significantl

Re: Decorators inside of class and decorator parameters

2007-01-14 Thread Colin J. Williams
Gabriel Genellina wrote: [snip] > As said in the beginning, there is no use for decorators as methods (perhaps > someone can find a use case?) Except, perhaps to indicate to the script reader that the decorator only applies within the class? Colin W. > If you move the example above inside the cl

Fixed-point [was Re: Rational Numbers]

2007-01-14 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, "Hendrik van Rooyen" <[EMAIL PROTECTED]> writes: |> |> Ok I will throw in a skewed ball at this point - use integer arithmetic, |> and work in tenths of cents or pennies or whatever, and don't be too |> lazy to do your own print formatting... If anyone is interes

Re: Rational Numbers

2007-01-14 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, "Hendrik van Rooyen" <[EMAIL PROTECTED]> writes: |> |> > Financial calculations need decimal FIXED-point, with a precisely |> > specified precision. It is claimed that decimal FLOATING-point |> > helps with providing that, but that claim is extremely dubious. |> >

Re: Maths error

2007-01-14 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, "Hendrik van Rooyen" <[EMAIL PROTECTED]> writes: |> > |> I would suspect that this is one of those questions which are simple |> to ask, but horribly difficult to answer - I mean - if the hardware has |> thrown it away, how do you study it - you need somehow two |

Re: Maths error

2007-01-14 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, "Hendrik van Rooyen" <[EMAIL PROTECTED]> writes: |> "Tim Peters" <[EMAIL PROTECTED]> wrote: |> |> > What you will still see stated is variations on Kahan's telegraphic |> > "binary is better than any other radix for error analysis (but not very |> > much)", list

Re: Maths error

2007-01-14 Thread Hendrik van Rooyen
"Tim Peters" <[EMAIL PROTECTED]> wrote: > [Nick Maclaren] > >> ... > >> Yes, but that wasn't their point. It was that in (say) iterative > >> algorithms, the error builds up by a factor of the base at every > >> step. If it wasn't for the fact that errors build up, almost all > >> programs coul

Re: Threaded for loop

2007-01-14 Thread parallelpython
John wrote: > Thanks. Does it matter if I call shell commands os.system...etc in > calculate? > > Thanks, > --j The os.system command neglects important changes in the environment (redirected streams) and would not work with current version of ppsmp. Although there is a very simple workaround: pri

Re: Threaded for loop

2007-01-14 Thread Paul Rubin
"John" <[EMAIL PROTECTED]> writes: > Damn! That is bad news. So even if caclulate is independent for > (i,j) and is computable on separate CPUs (parts of it are CPU bound, > parts are IO bound) python cant take advantage of this? Not at the moment, unless you write C extensions that release the gl

Re: Decorators inside of class and decorator parameters

2007-01-14 Thread Michele Simionato
Gabriel Genellina wrote: > see this article by M. Simoniato > http://www.phyast.pitt.edu/~micheles/python/documentation.html for a better > way using its decorator factory. Actually the name is Simionato ;) I have just released version 2.0, the new thing is an update_wrapper function similar to th

Re: Python 2.5 install on Gentoo Linux: failed dmb and _tkinter

2007-01-14 Thread Sorin Schwimmer
# ldconfig -p | grep "/usr/local/lib" libtk8.4.so (libc6) => /usr/local/lib/libtk8.4.so libtcl8.4.so (libc6) => /usr/local/lib/libtcl8.4.so Sorin Now that's room service! Choose from over 150,

threads - was:Is there a way to protect a piece of critical code?

2007-01-14 Thread Ray Schumacher
"Hendrik van Rooyen" wrote: > Similarly discrete background thread jobs can be used > in a functional style this way: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491280 > ( an alternative for the laborious OO-centric threading. With the various options available, many of which I