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
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)
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
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
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
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,
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
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://
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