Static typing
Bjorn Pettersen
BPettersen at NAREX.com
Fri Jul 25 19:02:44 EDT 2003
> From: Shane Hathaway [mailto:shane at zope.com]
>
> Bjorn Pettersen wrote:
> >>From: Shane Hathaway [mailto:shane at zope.com]
> >>def foo(bar, baz):
> >> assert isinstance(bar, int)
> >> assert isinstance(baz, str)
> >
> > [...]
> >
> > ...which means you can't use foo with unicode strings or
> UserStrings,
>
> That's right, and that's intentional. The function is
> designed to work only with byte arrays. This invites
> someone who wants to pass a unicode object to first
> verify that the function will actually work properly
> with unicode.
[...]
However, the only way said programmer can do that is by looking at
_your_ code, and then changing _your_ code. Wouldn't:
def foo(bar, baz):
"""...
Expects:
bar: integer in the range (0..65535)
baz: string (used as binary data)
...
"""
be much more useful for said programmer? Afterall, we're all adults
here.
-- bjorn
More information about the Python-list
mailing list