[Tutor] declarations

dman dman@dman.ddts.net
Mon, 8 Apr 2002 00:15:55 -0500


On Sun, Apr 07, 2002 at 05:53:07PM -0500, Cameron Stoner wrote:
| Hi all,
| 
| Can you declare variable types like in C++ in Python.
| example:
| 
| int variableName = 0
| float variableName = 0.0
| char variableName = " "
| 
| Python must take care of these declarations for you, but I want to
| know if you can still make the declarations or not.

Nah, everything is a PyObject* :-).  Python checks the type when you
actually use the object somewhere.  If the object supports the
operation you attempt, its type "matches" and there's no problem.
Kinda like C++ templates, but the check is runtime instead of
compile-time.

-D

-- 

Religion that God our Father accepts as pure and faultless is this: to
look after orphans and widows in their distress and to keep oneself from
being polluted by the world.
        James 1:27