osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dunder variables


"Frank Millman"  wrote in message news:p321rb$9ct$1 at blaine.gmane.org...

"Peter Otten"  wrote in message news:p31v3m$pji$1 at blaine.gmane.org...

> Frank Millman wrote:
>
> > Hi all
> >
> > I have read that one should not call dunder methods in application code.
> >
> > Does the same apply to dunder variables? I am thinking of the instance
> > attribute __dict__, which allows access to the contents of the instance.
> >
> > I only want to read from __dict__, not update it. Is this frowned upon?
>
> Why would you care whether it is "frowned upon" if it's the best way to
> achieve something useful?
>
> So the real question is /what/ you are trying to do and what your options
> are.
>
> Here is a brief history of how I have got to where I am now.
>

[...]

>
> My solution is to use __dict__ to get at the data. If there are any other 
> options, I will be interested to hear them.

Now that I have read yours and Steve's replies properly, I realise that you 
were telling me the answer all along.

I just have to use vars(...) and it gives me the information I am looking 
for.

Thank you

Frank