Re: [Tutor] primes

2005-03-18 Thread Max Noel
On Mar 18, 2005, at 02:15, Kent Johnson wrote: Max Noel wrote: #!/usr/bin/env python import math import timeit def primeConcise(limit): return [2] + [x for x in xrange(3, limit, 2) if not [y for y in [2] + range(3,x,2) if x%y==0]] def primeConciseOptimized(limit): return [2] + [x for x in

Re: [Tutor] primes

2005-03-18 Thread Pierre Barbier de Reuille
Gregor Lingl a écrit : Hi! Who knows a more concise or equally concise but more efficient expression, which returns the same result as [x for x in range(2,100) if not [y for y in range(2,x) if x%y==0]] Gregor P.S.: ... or a more beautiful one ;-) ___

[Tutor] how to initialize a class with arbitrary argument list from a file?

2005-03-18 Thread Christian Meesters
Hi How can I initialize a class like this from a file: class Some: def __init__(self,data,axis,**kwargs): pass 'data' and 'axis' should be lists of floats. Meta data can be passed to kwargs like 'name=name,date=2/3/05,...'. Right now the return value of my function reading

Re: [Tutor] subclassing across multiple modules

2005-03-18 Thread Kent Johnson
Brian van den Broek wrote: Kent Johnson said unto the world upon 2005-03-17 20:44: The multiple inheritance from MyNode and Toolkit.NodeX is a smell. I guess you do this because you want to override methods of Toolkit.Node as well as Toolkit.NodeX, or add methods to both MyNode1 and MyNode2? I

Re: [Tutor] how to initialize a class with arbitrary argument list from a file?

2005-03-18 Thread Kent Johnson
Christian Meesters wrote: Hi How can I initialize a class like this from a file: class Some: def __init__(self,data,axis,**kwargs): pass 'data' and 'axis' should be lists of floats. Meta data can be passed to kwargs like 'name=name,date=2/3/05,...'. Right now the return value of my

Re: [Tutor] stopping greedy matches

2005-03-18 Thread Christopher Weimann
On 03/18/2005-10:35AM, Mike Hall wrote: A caret as the first charachter in a class is a negation. So this [^\s]+ means match one or more of any char that isn't whitespace. Ok, so the context of metas change within a class. That makes sense, but I'm unclear on the

Re: [Tutor] stopping greedy matches

2005-03-18 Thread Mike Hall
On Mar 18, 2005, at 1:02 PM, Christopher Weimann wrote: On 03/18/2005-10:35AM, Mike Hall wrote: A caret as the first charachter in a class is a negation. So this [^\s]+ means match one or more of any char that isn't whitespace. Ok, so the context of metas change within a class. That makes sense,

Re: [Tutor] primes (generator)

2005-03-18 Thread Gregor Lingl
Hi all of you! Many thanks for your remarks, ideas and experiments. When I posted my input yesterday: [x for x in range(2,100) if not [y for y in range(2,x) if x%y==0]] my intention was indeed to find a shortest a program, disregarding efficiency. Thus range instead of xrange etc. (About one year

Re: [Tutor] primes (Cautious remark on Python and Scheme)

2005-03-18 Thread Gregor Lingl
Hi Danny! Preliminary remark: I know that beautiful and beauty are concepts very seldom applied to computer programs or programming languages. I suppose mainly because they are to a large extent a matter of taste ... Nevertheless: regardeless of the fact that I'm not a very skilled

Re: [Tutor] primes (Cautious remark on Python and Scheme)

2005-03-18 Thread Gregor Lingl
Concerning my previous posting - perhaps it would suffice to summarize: While Python is a language for the pragmatic lover, Scheme is much more fundamentalistic. (thought-) *PROVOKING*? Gregor ___ Tutor maillist - Tutor@python.org

[OT] Re: [Tutor] primes (Cautious remark on Python and Scheme)

2005-03-18 Thread Brian van den Broek
Gregor Lingl said unto the world upon 2005-03-18 19:57: Hi Danny! Preliminary remark: I know that beautiful and beauty are concepts very seldom applied to computer programs or programming languages. I suppose mainly because they are to a large extent a matter of taste ... Hi Gregor and all, Though