Steven D'Aprano wrote:
class Parrot:
def __init__(self, *args):
print Initialising instance...
if __debug__:
self.verify() # check internal program state, not args
if __debug__:
def verify(self):
print Verifying...
+1 It looks good to me
On Sun, 14 Dec 2008 07:41:55 +, Steven D'Aprano wrote:
I have a class with a method meant to verify internal program logic (not
data supplied by the caller). Because it is time-consuming but optional,
I treat it as a complex assertion statement, and optimize it away if
__debug__ is false:
On Sun, 14 Dec 2008 09:19:45 +, Marc 'BlackJack' Rintsch wrote:
class Parrot:
def __init__(self, *args):
print Initialising instance...
assert self.verify()
Here I meant ``assert self._verify()`` of course.
def _verify(self):
print Verifying...
On Sun, 14 Dec 2008 09:19:45 +, Marc 'BlackJack' Rintsch wrote:
On Sun, 14 Dec 2008 07:41:55 +, Steven D'Aprano wrote:
I have a class with a method meant to verify internal program logic
(not data supplied by the caller). Because it is time-consuming but
optional, I treat it as a
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
On Sun, 14 Dec 2008 10:52:25 +, Arnaud Delobelle wrote:
You could also not use the metaclass and use post_verify as a decorator
Except that self.verify doesn't exist if __debug__ is false.
OK I wrote this as an afterthought.
On Sun, 14 Dec 2008 10:52:25 +, Arnaud Delobelle wrote:
You could also not use the metaclass and use post_verify as a decorator
Except that self.verify doesn't exist if __debug__ is false.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
I have a class with a method meant to verify internal program logic (not
data supplied by the caller). Because it is time-consuming but optional,
I treat it as a complex assertion statement, and optimize it away if
__debug__ is
Steven D'Aprano wrote:
I have a class with a method meant to verify internal program logic (not
data supplied by the caller). Because it is time-consuming but optional,
I treat it as a complex assertion statement, and optimize it away if
__debug__ is false:
class Parrot:
def
I have a class with a method meant to verify internal program logic (not
data supplied by the caller). Because it is time-consuming but optional,
I treat it as a complex assertion statement, and optimize it away if
__debug__ is false:
class Parrot:
def __init__(self, *args):
print