[Cascavel-pm] Várias Variações de Variáveis...

Nelson Ferraz nferraz em gmail.com
Quarta Junho 20 08:28:06 PDT 2007


> Outra dúvida: o Champs comentou sobre introspecção, mas Perl  
> precisa disso? Posso estar com conceitos errados, mas a manipulação  
> da tabela de símbolos já não atende isso?

Não... introspecção é muito mais do que uma tabela de símbolos --  
implica ser capaz de obter informações complexas sobre a estrutura e  
o comportamento de cada símbolo.

Por exemplo, para obter informações sobre o comando "dir" em Python:


 >>> print dir.__doc__
dir([object]) -> list of strings

Return an alphabetized list of names comprising (some of) the attributes
of the given object, and of attributes reachable from it:

No argument:  the names in the current scope.
Module object:  the module attributes.
Type or class object:  its attributes, and recursively the attributes of
     its bases.
Otherwise:  its attributes, its class's attributes, and recursively the
     attributes of its class's base classes.


 >>> dir(dir)
['__call__', '__class__', '__cmp__', '__delattr__', '__doc__',
'__getattribute__', '__hash__', '__init__', '__module__', '__name__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__',
'__setattr__', '__str__']


 >>> dir("foo") # string
['__add__', '__class__', '__contains__',
'__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__',
'__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__',
'__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__',
'__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
'__rmod__', '__rmul__', '__setattr__', '__str__', 'capitalize',
'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs',
'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower',
'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip',
'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 'split', 'splitlines',
'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper',
'zfill']



Mais detalhes sobre a lista de discussão Cascavel-pm