Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82651

Re: problems with Methods in Python 3.4.2

From Terry Reedy <tjreedy@udel.edu>
Subject Re: problems with Methods in Python 3.4.2
Date 2014-12-18 15:59 -0500
References <329c01d01ae7$dc8d9c20$95a8d460$@bluewin.ch>
Newsgroups comp.lang.python
Message-ID <mailman.17040.1418936392.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: problems with Methods in Python 3.4.2 Terry Reedy <tjreedy@udel.edu> - 2014-12-18 15:59 -0500

csiph-web