[Python-Dev] functions vs methods (was Re: trunc()) (original) (raw)
Raymond Hettinger python at rcn.com
Tue Jan 29 04:19:38 CET 2008
- Previous message: [Python-Dev] functions vs methods (was Re: trunc())
- Next message: [Python-Dev] trunc()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
No, using trunc(x) makes it clear that the argument and return value are numbers. Using x.trunc() doesn't.
Not sure where this is notion comes from. Terry Reedy's post provides a datapoint to the contrary. Besides, there is no problem along these lines that can't be cured by a better method name:
f.integer_portion()
Also, if you go the method route, then the API can easily be expanded to cover all the normal rounding methods:
f.round_to_even() f.round_half_up() ...
These are all specific and explicit.
Also, we can take advantage of the ABC mixin capabilities to automatically provide all of these given one or two of them as primitives.
Raymond
P.S I get no shortage of hits for searches like: http://www.google.com/search?q=truncate+string
- Previous message: [Python-Dev] functions vs methods (was Re: trunc())
- Next message: [Python-Dev] trunc()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]