[Tutor] Operator Overloading

2005-04-03 Thread Kevin Reeder
Following an example from a book, I'm getting an unexpected outcome. The point of exercise is to extend operator overloading methods from a superclass and track the method calls. Here's the code, class MyList: def __init__(self, start): self.wrapped = [ ] for x in start: self.w

Re: [Tutor] Operator Overloading

2005-04-04 Thread Kevin Reeder
On Mon, 04 Apr 2005 21:14:21 +1200 John Fouhy <[EMAIL PROTECTED]> wrote: > Are you sure you've giving us all the code? No, I was trying to keep it simple. Anyway, here it is, class MyList: def __init__(self, start): self.wrapped = [ ] for x in start: self.wrapped.append(x)

Re: [Tutor] Operator Overloading

2005-04-04 Thread Kevin Reeder
On Tue, 05 Apr 2005 10:56:40 +1200 (NZST) [EMAIL PROTECTED] wrote: > Fine, but always test the simplified version, unless you're > absolutely certain what you're throwing out! Point taken. > When you do 'A + [4, 5, 6]', python first calls > A.__getattr__('__coerce__'). Everything's working fine

[Tutor] Calling a function

2005-06-08 Thread Kevin Reeder
I'm having trouble with this code which is meant to run a time comparison between two similar functions. The first module is makezeros.py def lots_of_appends(): zeros = [] for i in range(1): zeros.append(0) def one_multiply(): zeros = [0] * 10

Re: [Tutor] Calling a function

2005-06-09 Thread Kevin Reeder
Ewald & John, thanks for the help. i'll work on it some more with your ideas in mind (after getting some sleep). Kevin ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] fileinput problem

2005-06-24 Thread Kevin Reeder
I'm getting unexpected behaviour from this module. My script is meant to count the number of occurences of a term in one or more files. --- import sys, string, fileinput searchterm, sys.argv[1:] = sys.argv[1], sys.argv[2:] for line in fileinput.input(): num_matches = string.count(line,

Re: [Tutor] fileinput problem

2005-06-25 Thread Kevin Reeder
On Sat, 25 Jun 2005 06:41:01 -0400 Kent Johnson <[EMAIL PROTECTED]> wrote: > You named your program fileinput.py, so when you import fileinput > you are getting your own program again instead of the library > module. Change the name of your program and try again. Doh! I do remember reading that s

[Tutor] Single Underscore

2005-07-10 Thread Kevin Reeder
What's the significance of naming a variable with a single underscore as its first character? For example, I'm looking at find.py in the standard library and it has variables named _debug and _prune. Kevin ___ Tutor maillist - Tutor@python.org http://

Re: [Tutor] Single Underscore

2005-07-10 Thread Kevin Reeder
Thanks for the info. I'll look into the links provided. > http://jaynes.colorado.edu/PythonGuidelines.html > http://www.python.org/peps/pep-0008.html Kevin ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor