[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, Tho

Re: [Tutor] primes

2005-03-18 Thread Sean Perry
Pierre Barbier de Reuille wrote: def sieve( max ): max_val = int( sqrt( max ) ) s = Set(xrange( 4, max, 2 )) for i in xrange( 3, max_val, 2 ): s.update( xrange( 2*i, max, i ) ) return [ i for i in xrange( 2, max ) if i not in s ] just for grins, here is the same (mostly) code in haskell

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 http://mail.pytho

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 scheme-progr

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] 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, bu

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 th

Re: [Tutor] stopping greedy matches

2005-03-18 Thread Mike Hall
On Mar 18, 2005, at 9:27 AM, Christopher Weimann wrote: On 03/17/2005-10:15AM, Mike Hall wrote: Very nice sir. I'm interested in what you're doing here with the caret metacharacter. For one thing, why enclose it and the whitespace flag within a character class? A caret as the first charachte

Re: [Tutor] subclassing across multiple modules

2005-03-18 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-03-18 07:35: 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 Toolki

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] 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

[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 read

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 ;-) ___ Tuto

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