|
![](/i/fill.gif) |
Warp <war### [at] tag povray org> wrote:
> Aydan <hes### [at] hendrik-sachse net> wrote:
> > [begin code]
> > class vector(object):
> > def __init__(self,x,y,z):
> > self.__x=x
> > self.__y=y
> > self.__z=z
>
> Is that really how you write OO code in Python? Is it just me, or does it
> look like Python hasn't actually been specifically designed to be an OO
> language?
>
> --
> - Warp
What do you mean?
Python doesn't have private variables per se and is completely dynamic.
Everything in Python is an object. Functions, classes, modules even integers are
objects.
So python is very much designed for OO.
if you define a variable with "__" it won't be acessible from outside it's scope
without difficulty. For example you can't see it with introspection and you
can't access it even if you know it's declaration. I think it gets prepended
with a hash value on instantiation.
Post a reply to this message
|
![](/i/fill.gif) |