On Thu, 29 Jul 2010 21:43:05 +0300, Nick Raptis wrote: > On 07/29/2010 09:12 PM, wheres pythonmonks wrote: >> How do I build an "int1" type that has a default value of 1? > You mean something like: > >>> x = int() > >>> x > 0 > >>> def myint(value=1): > ... return int(value) > ... > >>> myint() > 1 > >>> > >>> > That's ugly on so many levels..
Why do you think it's ugly? It's a function that returns an int, and it provides a default value which is different from the default value of the int constructor. It's a really simple function, and it has an equally simple implementation, and it's an obvious way to do it. Not the *one* obvious way, because subclassing int is equally obvious, but still obvious. -- Steven -- http://mail.python.org/mailman/listinfo/python-list