On 6 August 2013 10:01, Rui Maciel <rui.mac...@gmail.com> wrote: > Ben Finney wrote: > >> Rui Maciel <rui.mac...@gmail.com> writes: >> >>> Is there any pythonic way to perform static typing? >> >> I think no; static typing is inherently un-Pythonic. >> >> Python provides strong, dynamic typing. Enjoy it! > > Bummer.
It's really not. >>> Does anyone care to enlighten a newbie? >> >> Is there some specific problem you think needs static typing? Perhaps >> you could start a new thread, giving an example where you are having >> trouble and you think static typing would help. > > It would be nice if some functions threw an error if they were passed a type > they don't support or weren't designed to handle. That would avoid having > to deal with some bugs which otherwise would never happen. > > To avoid this sort of error, I've been testing arguments passed to some > functions based on their type, and raising TypeError when necessariy, but > surely there must be a better, more pythonic way to handle this issue. Unless you have a very good reason, don't do this. It's a damn pain when functions won't accept my custom types with equivalent functionality -- Python's a duck-typed language and it should behave like one. -- http://mail.python.org/mailman/listinfo/python-list