As a fallback, you can always use the isinstance() and type() functions to check what type of variable you have on hand.
Generally, isinstance is what you want to use because it returns true for subclasses. If the subclass doesn't do everything you'd expect of it's superclass, then either your or the subclass writer have broken their contract.
If you absotively posolutely must know that a variable is a certain class, not a subclass and nothing but the bona fide variable type you expected, then use type(). This, however, is seldom the case because using type() could prevent future programmers from extending your code.
> > Hi > > It is possible to declare some variables as int, long... ? , or something > > like visual basic option explicit. > > In some situations could be usefull. > > Thanks
> Well, in python, that is left to programmer's discretion. > Once you get used to it, it's less of a hassle and danger zone than you'd > expect.
The main reason for this is that, in Python, using an unassigned variable gives you a friendly NameError. In BASIC, it implicitly creates a new variable (with a value of zero) whether you wanted it to or not.
> As a fallback, you can always use the isinstance() and type() functions to > check what type of variable you have on hand.
Or more accurately, what type of *object* you have on hand.