L
Lee Harr
Hi;
I am wondering if this is a reasonable thing to do:
class Pinger:
def go(self, repeat=False):
if repeat is True:
repeat = -1
elif repeat is False:
repeat = 1
self.repeat = repeat
self.ping()
def ping(self):
while self.repeat:
print 'ping!'
if self.repeat > 0:
self.repeat -= 1
Won't work with 2.1, clearly, but it seems ok in a
recent 2.2 or in 2.3.
I guess my only qualm is that
p = Pinger()
p.go(repeat=0)
may be a bit confusing, since it will not ping at all...
What do you think?
I am wondering if this is a reasonable thing to do:
class Pinger:
def go(self, repeat=False):
if repeat is True:
repeat = -1
elif repeat is False:
repeat = 1
self.repeat = repeat
self.ping()
def ping(self):
while self.repeat:
print 'ping!'
if self.repeat > 0:
self.repeat -= 1
Won't work with 2.1, clearly, but it seems ok in a
recent 2.2 or in 2.3.
I guess my only qualm is that
p = Pinger()
p.go(repeat=0)
may be a bit confusing, since it will not ping at all...
What do you think?