On 12/18/2014 12:27 PM, Marcus Lütolf wrote:
Learn to use dir to fine valid names.
1)I am trying to do this:
>>> dir(_builtins_)
I am getting this:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
dir(_builtins_)
NameError: name '_builtins_' is not defined
>>> dir()
['__builtins__', '__doc__', '__loader__', '__name__', '__package__',
'__spec__']
shows the defined names.
2)I am trying to do this:
'TTA',_add_('GGA')
I’am getting this :
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
'TTA',_add_('GGA')
NameError: name '_add_' is not defined
>>> dir('a') shows string attribute names
3)I am trying to do this:
-3 .abs()
I’am getting this
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
-3 .abs()
AttributeError: 'int' object has no attribute 'abs'
dir(3) shows int attributes
4) finally, after printing
>>>abs._doc_()
I am getting this (and so on) :
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
abs._doc_()
AttributeError: 'builtin_function_or_method' object has no attribute '_doc_'
dir(abs) ditto
What did I do wrong ?
You did not use the interactive help already available. help(<object>)
is also very useful.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list