problems with Methods in Python 3.4.2

André Roberge andre.roberge at gmail.com
Thu Dec 18 12:44:03 EST 2014


On Thursday, 18 December 2014 13:28:33 UTC-4, Marcus Lütolf  wrote:
> Hello Dears,
> 1)I am trying to do this:
>  
> >>> dir(_builtins_)
You need two underscore characters on each sides:

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
>  
> 2)I am trying to do this:
>  
> >>> 'TTA',_add_('GGA')
Same; magic methods have two underscore characters on each side.
>  
> 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
>  
> 3)I am trying to do this:
>  
> >>> -3  .abs()
abs(-3)      abs is a function in Python.

See http://lucumr.pocoo.org/2011/7/9/python-and-pola/ for a good explanation...

>  
> 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'
>  
> 4) finally, after printing
>  
> >>>abs._doc_()
>  

Guess why!  ;-)

> 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_'
> 
> What did I do wrong ? Thanks for help, Marcus Luetolf, M.D., 90 Bondastreet, CH-7000 Chur, Switzerland.
>  
> 
> 
> 
> 
> 
> 	
> 		
> 			
> 				
> 			
> 		
> 		
> 			
> 
> 				Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
> 				
> www.avast.com



More information about the Python-list mailing list