On Apr 24, 10:11 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> In python, use attributes starting with a single underscore (such as
> _name). It tells users that they shouldn't mess with them. By
> design, python doesn't include mechanisms equivalent to the Java / C++
> 'private'.
Arnaud, G
Ok, so thanks everyone for the helpful hints. That *was* a typo on my
part (should've been super(B...) not super(A..), but I digress)
I'm building a public API. Along with the API I have a few custom
types that I'm expecting API users to extend, if they need too. If I
don't use name mangling, i
My example:
class A(object):
def __init__(self, name):
self.__name = name
def getName(self):
return self.__name
class B(A):
def __init__(self,name=None):
super(A,self).__init__()
def setName(self, name):
On Apr 2, 2:26 pm, 7stud <[EMAIL PROTECTED]> wrote:
>
> You don't need that helper function, which is a little tricky to
> follow:
>
Well, I appreciate the code sharing you did, but the helper function
is nice and compact, and I didn't have much trouble following it. I
ended up doing the followi
On Apr 2, 12:33 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
>
> Why not do the import here, so you store a real module instead of a
> name ?
>
Right now I'm still in the prototyping phase and haven't really
thought everything through. I needed the names because I am
populating a GUI sele
On Apr 2, 12:07 pm, Brian Munroe <[EMAIL PROTECTED]> wrote:
>
> This gives me ['system1','system2'] - which I can then use __import__
> on.
>
Addendum, thanks Bruno!
I also required the helper function (my_import) from the Python docs
you pointed me to
On Apr 2, 11:04 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
>
> More seriously: the answer is in the
> doc.http://www.python.org/doc/2.3.5/lib/built-in-funcs.html
>
> read about the __import__ function, experiment in your interactive
> python shell, and you should be done in a couple minut
I'm struggling with an architectural problem and could use some
advice.
I'm writing an application that will gather statuses from disparate
systems. Because new systems show up all the time, I'm trying to
design a plugin architecture that will allow people to contribute new
backends by just dropp
On Dec 15, 11:04 am, Fabian Braennstroem <[EMAIL PROTECTED]>
wrote:
>
> thanks for your ideas! I actually thought of something like
> a python parser, which just converts the nsf structure to an
> mbox; could that work!?
>
Well, If you wish to go that route, I believe you will have to reverse
eng
On Sep 3, 6:34 am, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> The underscore versions are for customizing the lookup process, not for
> dynamically looking up names. If your class needs to do something non-
> standard when you write obj.name, you might need to write methods
>
On Sep 2, 3:33 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
>
> In a nutshell, like all double-underscore methods, __setattr__ are for
> overriding behaviour in your own classes. With very few exceptions, you
> shouldn't need to directly call double-underscore methods (althoug
On Sep 2, 11:46 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> If you want to pass the attributes list it's simpler to do that
> directly, avoiding *a and **k constructs. E.g.:
>
> def __init__(self, a, b, attrs):
> self.a = a
> self.b = b
> for attr in attrs:
> name, value =
12 matches
Mail list logo