I've been going through Steven D'Aprano's pyprimes
(<http://pypi.python.org/pypi/pyprimes/0.1.1a>) and have many
questions. One is why begin a function name with an underscore. He has
several functions that do this. Two are:
def _validate_int(obj):
"""Raise an exception if obj is not an integer."""
m = int(obj + 0) # May raise TypeError.
if obj != m:
raise ValueError('expected an integer but got %r' % obj)
def _validate_num(obj):
"""Raise an exception if obj is not a finite real number."""
m = obj + 0 # May raise TypeError.
if not isfinite(m):
raise ValueError('expected a finite real number but got %r' % obj)
I'm stealing these for their usefulness. But why the underscores?
I think I've also seen elsewhere variable names that also begin with
an underscore, e.g., _a .
Dick Moores
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor