POV-Ray : Newsgroups : povray.off-topic : OO theory? Python. : Re: OO theory? Python. Server Time
28 Jul 2024 22:26:03 EDT (-0400)
  Re: OO theory? Python.  
From: Aydan
Date: 15 Oct 2012 15:00:01
Message: <web.507c5c6a7215dcd9363b2100@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Aydan <hes### [at] hendrik-sachsenet> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.