Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82643 > unrolled thread
| Started by | Marcus Lütolf <marcus.luetolf@bluewin.ch> |
|---|---|
| First post | 2014-12-18 18:27 +0100 |
| Last post | 2014-12-18 18:45 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
problems with Methods in Python 3.4.2 Marcus Lütolf <marcus.luetolf@bluewin.ch> - 2014-12-18 18:27 +0100
Re: problems with Methods in Python 3.4.2 André Roberge <andre.roberge@gmail.com> - 2014-12-18 09:44 -0800
Re: problems with Methods in Python 3.4.2 John Gordon <gordon@panix.com> - 2014-12-18 18:45 +0000
| From | Marcus Lütolf <marcus.luetolf@bluewin.ch> |
|---|---|
| Date | 2014-12-18 18:27 +0100 |
| Subject | problems with Methods in Python 3.4.2 |
| Message-ID | <mailman.17037.1418923700.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
Hello Dears,
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
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
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'
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_'
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.
http://www.avast.com
[toc] | [next] | [standalone]
| From | André Roberge <andre.roberge@gmail.com> |
|---|---|
| Date | 2014-12-18 09:44 -0800 |
| Message-ID | <a13c48dd-4fef-4a5e-ad48-c3f08a97b44a@googlegroups.com> |
| In reply to | #82643 |
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
[toc] | [prev] | [next] | [standalone]
| From | John Gordon <gordon@panix.com> |
|---|---|
| Date | 2014-12-18 18:45 +0000 |
| Message-ID | <m6v7bf$904$1@reader1.panix.com> |
| In reply to | #82643 |
In <mailman.17037.1418923700.18130.python-list@python.org> =?iso-8859-1?Q?Marcus_L=FCtolf?= <marcus.luetolf@bluewin.ch> writes:
> >>> dir(_builtins_)
> >>> 'TTA',_add_('GGA')
> >>>abs._doc_()
These errors are due to using single underscores instead of double
underscores. I.e. use __builtins__ instead of _builtins_.
> >>> -3 .abs()
> AttributeError: 'int' object has no attribute 'abs'
Integer objects don't have a built-in function named abs(). If you
want the absolute value of an integer, call abs directly, like so:
abs(-3)
--
John Gordon Imagine what it must be like for a real medical doctor to
gordon@panix.com watch 'House', or a real serial killer to watch 'Dexter'.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web