As Kent said, redemo.py is a script that you run (e.g. from the
command line), rather than something to import into the python
interpretor. On my OSX machine it's located in the directory:
/Applications/MacPython-2.3/Extras/Tools/scripts
Cheers, Michael
___
C Smith wrote:
Here's an example that
cycles through 3 number, 0, 1, and 2:
###
>>> j=0
>>> for i in range(10):
.. print j
.. j = (j+1)%3
..
0
1
2
0
1
2
0
1
2
0
###
A nice way to do this is with itertools.cycle():
>>> import itertools
>>> cyc = itertools.cycle(range(3))
>>> for i in range
kevin parks wrote:
Hi folks,
I am trying to cyclically rotate a seq until it reached the beginning
stage again.
I would like to be able
BTW collections.deque supports most list methods and rotate():
http://docs.python.org/lib/module-collections.html
Kent
__
Kent Johnson wrote:
Shitiz Bansal wrote:
In the code you have shown, I don't see any need for
the queue. Just create the thread and start it. I don't think you
have to keep a reference to it.
I'm not sure, but I think the thread will be garbage collected when
it completes. (Can anyone
else confi
Hi list.
I have downloaded some code from useless python that was writen buy a
guy named Sammy Mannaert. The code should show that python can be
unreadable, and it really is...
Can anyone explain to me how does this thing works ??
Here is the code (it prints "python readable ?"):
f=lambda x="8<:47
Mark Kels wrote:
Hi list.
I have downloaded some code from useless python that was writen buy a
guy named Sammy Mannaert. The code should show that python can be
unreadable, and it really is...
Can anyone explain to me how does this thing works ??
Here is the code (it prints "python readable ?"):
Can Python work like the SAS (Data Step), where you read in external data (sequential, ms access, sql) define file layout to Python and be able to write code where you produce a customize report with title and columns headings, subtotals and totals and write that report out has a file?
And if it
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? Does this not traditionally
mean you want to strip a metacharacter of it's special meaning?
On Mar 16, 2005, at 8:00 PM, Christo
On Mar 16, 2005, at 8:32 PM, Kent Johnson wrote:
"in (.*?)\b" will match against "in " because you use .* which will
match an empty string. Try "in (.+?)\b" (or "(?<=\bin)..+?\b" )to
require one character after the space.
Another working example, excellent. I'm not too clear on why the back
to
I don't have that script on my system, but I may put pythoncard on here
and run it through that:
http://pythoncard.sourceforge.net/samples/redemo.html
Although regexPlor looks like it has the same functionality, so I may
just go with that. Thanks.
On Mar 17, 2005, at 1:31 AM, Michael Dunn wrote
Mike Hall wrote:
On Mar 16, 2005, at 8:32 PM, Kent Johnson wrote:
"in (.*?)\b" will match against "in " because you use .* which will
match an empty string. Try "in (.+?)\b" (or "(?<=\bin)..+?\b" )to
require one character after the space.
Another working example, excellent. I'm not too clear on
On Mar 17, 2005, at 11:11 AM, Kent Johnson wrote:
The first one matches the space after 'in'. Without it the .+? will
match the single space, then \b matches the *start* of the next word.
I think I understand. Basically the first dot advances the pattern
forward in order to perform a non-greedy m
Mike Hall wrote:
On Mar 17, 2005, at 11:11 AM, Kent Johnson wrote:
The first one matches the space after 'in'. Without it the .+? will
match the single space, then \b matches the *start* of the next word.
I think I understand. Basically the first dot advances the pattern
forward in order to perf
Hello again!
Well, I promise this is not a bad habit of mine. I've actually bought myself a
few books about the lovely snake (did I just spend a year learning Java, why's
that?).
I thought I should brag a little for my fellow developer colleagues though, so
i spent yetserday putting together a
I use:
Python 2.3.4 (#2, Aug 19 2004, 15:49:40) [GCC 3.4.1 (Mandrakelinux (Alpha
3.4.1-3mdk)] on linux2 ... IDLE 1.0.3
I was trying to wr
Yes, it is:
http://python.fyxm.net/peps/pep-0237.html
Robert Storey wrote:
This book is a few years old and was written for Python version 1.5, and
of course I'm using version 2.3, so I'm just wondering if this whole
issue of big numbers is now being handled automatically?
This is my first post - s
> I use:
>
> Python 2.3.4 (#2, Aug 19 2004, 15:49:40) [GCC 3.4.1 (Mandrakelinux (Alpha
> 3.4.1-3mdk)] on linux2 ... IDLE 1.0.3
>
> I wa
On Mon, 14 Mar 2005, Stefan Elwesthal wrote:
> I'm swedish, our databae is full of horrible characters with strange
> dots on top and Python won't have none of it. it falls apart telling me
> that it can't decode that sort of thingy!
>
> So.. will I have to do some terrible magic storing all sin
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 maillist - Tutor@py
Hi all,
I'm uncertain of how to make use of OOP design across multiple
modules. (Actually, on reflection, I'm not certain the multiple
modules aspect is central.) I'm also uncertain of how to frame the
question well, so please bear with me :-)
A schematic of what I have (with fake names for eas
On Mar 17, 2005, at 22:28, Gregor Lingl wrote:
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 ;-)
Hmm... I don't have "beauti
Quoting Gregor Lingl <[EMAIL PROTECTED]>:
> [x for x in range(2,100) if not [y for y in range(2,x) if x%y==0]]
Heh. That's quite neat.
I can only offer one suggestion --- if you replace range with xrange, you get a
small speed improvement.
eg: On my system, it took 415 seconds to generate a li
On Thu, 17 Mar 2005, Gregor Lingl wrote:
> 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]]
Hi Gregor,
Here is one that's traduced... er... adapted from ma
[EMAIL PROTECTED] wrote:
Quoting Gregor Lingl <[EMAIL PROTECTED]>:
[x for x in range(2,100) if not [y for y in range(2,x) if x%y==0]]
Heh. That's quite neat.
I can only offer one suggestion --- if you replace range with xrange, you get a
small speed improvement.
eg: On my system, it took 415 sec
On Mar 17, 2005, at 23:54, Danny Yoo wrote:
Hi Gregor,
Here is one that's traduced... er... adapted from material from the
classic textbook "Structure and Interpretation of Computer Programs":
Ooh, nifty.
Okay, I decided to learn how to use the timeit module, so I used it to
compare my algor
You want a method in a base class to parse input and create instances of
certain derived classes. Your sample code looks like:
if some_condition_on_chunk_contents:
node = Node1(chunk_contents)
else:
node = Node2(chunk_contents)
I'd suggest changing the method to use a variable to determ
Brian van den Broek wrote:
A schematic of what I have (with fake names for ease of example) is a
base module Toolkit.py and I want to write a module Application.py which
specializes the behaviour of the Toolkit.py classes. (I'm using
old-style classes, but don't feel committed to that choice.)
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 xrange(3, limit, 2) if not [y for y in [2]
+
Hi all,
Thanks for the reply, Lloyd.
Lloyd Kvam said unto the world upon 2005-03-17 20:36:
You want a method in a base class to parse input and create instances of
certain derived classes.
Not quite. One class (Tree) parses a file and creates instances of
Node1 and Node2 (derived from Node). None o
Kent Johnson said unto the world upon 2005-03-17 20:44:
Brian van den Broek wrote:
A schematic of what I have (with fake names for ease of example) is a
base module Toolkit.py and I want to write a module Application.py
which specializes the behaviour of the Toolkit.py classes. (I'm using
old-st
On Thursday, Mar 17, 2005, at 17:49 America/Chicago,
[EMAIL PROTECTED] wrote:
On my system, it took 415 seconds to generate a list of primes < 50,000
using range, but only 386 seconds if I use the same code, but with
xrange instead.
If you only calculate y up to sqrt(x) you will see a dramatic
Danny Yoo wrote:
Here is one that's traduced... er... adapted from material from the
classic textbook "Structure and Interpretation of Computer Programs":
##
from itertools import ifilter, count
def notDivisibleBy(n):
... def f(x):
... return x % n != 0
... return f
...
def siev
32 matches
Mail list logo