learning python ...

Greg Ewing greg.ewing at canterbury.ac.nz
Tue May 25 03:42:26 EDT 2021


On 25/05/21 2:59 pm, hw wrote:
> Then what is 'float' in the case of isinstance() as the second 
> parameter, and why can't python figure out what 'float' refers to in 
> this case?  

You seem to be asking for names to be interpreted differently
when they are used as parameters to certain functions.

Python doesn't do that sort of thing. The way it evaluates
expressions is very simple and consistent, and that's a good
thing. It means there aren't any special cases to learn and
remember.

Maybe you're not aware that isinstance is just a function,
and not any kind of special syntax?

> Perhaps type names should be keywords to avoid confusion.

Python has quite a lot of built-in types, some of them in
the builtin namespace, some elsewhere. Making them all keywords
would be impractical, even if it were desirable.

And what about user-defined types? Why should they be treated
differently to built-in types? Or are you suggesting there
should be a special syntax for declaring type names?

-- 
Greg


More information about the Python-list mailing list