[gull] python2.5 et type(x)

Philippe Strauss philou at philou.ch
Fri Aug 1 03:36:12 CEST 2008


On Thu, Jul 31, 2008 at 10:02:52AM +0200, Daniel Cordey wrote:
> 
> Depuis fort longtemps (< 2001... Python 2.1) il est recommande d'utiliser 
> 'isinstance()' plutot que 'type()'. On peut ecrire :
> 
> 	isinstance(3, int)
> 	isinstance(3, types.IntType)
> 	isinstance([], list)
> 	...
> 
> "This is the recommended way to perform type-checking with the built-in types, 
> as the distinction between types and classes may disappear in a future 
> release" (Python - Essential reference - Second edition - New Riders)

ah ok merci.
c'est plûtot particulier l'idée de ne pas distinguer une notion
de typage avec une notion de classe d'objet, mais bon, ca doit être cela un scripting langage.
Doit pas aider les projets tentant de compiler du python vers c/c++.

aplus

-- 
Philippe Strauss
http://philou.ch



More information about the gull mailing list