Namespaces are one honking great idea
Chris Angelico
rosuav at gmail.com
Fri Jul 1 13:13:21 EDT 2016
On Sat, Jul 2, 2016 at 12:49 AM, BartC <bc at freeuk.com> wrote:
> Why not just extend the capabilities of a class? I actually thought this
> would work until I tried it and it didn't:
>
> class C():
> def fn():
> print ("Hi!")
>
> C.fn()
>
> The error message suggests Python knows what's going on. So why not just
> make it work?
rosuav at sikorsky:~$ python3
Python 3.6.0a2+ (default:57f3514564f6, Jun 29 2016, 16:27:34)
[GCC 5.3.1 20160528] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class C():
... def fn():
... print ("Hi!")
...
>>> C.fn()
Hi!
>>>
But if you have two such functions, they can't call each other without
the namespace marker.
ChrisA
More information about the Python-list
mailing list