I figured out why you have var in instance __dict__.
It was after you added it. But why var is in class __dict__?
Does @property make it a class attribute?
Thank you
Monika
-- Original Message --
From: Steven D'Aprano
To: tutor@python.org
Subject: Re:
For both old and new classes I have var only in GetSet class, but not in
instance me. Why?
print me.__dict__
print GetSet.__dict__
{'attrval': 5}
{'__weakref__': , '__doc__': None,
'__module__': '__main__', '__init__': ,
'__dict__': , 'var': }
>>>
Thank you very much
Monika
--
Thank you both for your explanations but they were too difficult for me to
understand.
What is descriptor protocol? Can you please explain?
I checked for var in both instance and class __dict__ but it was only in class,
not in the instance. I checked for it after I instantiated me, before
Basically, what that said is the global interpreter lock is something that
allows only one thread at a time to be executed when you launch a python
program in opposition of executing multiple threads at the same time
(parallelism). when you launch a python program it create a process in
memory.
> Can someone explain global interpreter lock with some source code examples?
Watch this youtube video.
Gilectomy
https://www.youtube.com/watch?v=fgWUwQVoLHo
--
Joaquin
This email is confidential and may be subject to privilege. If you are not the
intended recipient, please do not copy or
On Thu, Sep 15, 2016 at 04:40:22AM +, monik...@netzero.net wrote:
> Could somebody please explain what is going on for old style classes for the
> below code:
The important part is that the descriptor protocol doesn't get used for
old style classes. If that statement means something to
On Thu, Sep 15, 2016 at 02:08:12PM +, eryk sun wrote:
> Getting attributes also prefers the instance dict. However, to support
> bound methods (e.g. __init__), it falls back on a class lookup and
> calls the descriptor __get__ method if defined.
Is that documented anywhere? When was it
On Thu, Sep 15, 2016 at 4:40 AM, monik...@netzero.net
wrote:
> class GetSet():
>
> def __init__(self, value):
> self.attrval = value
>
> @property
> def var(self):
> print "getting the var attribute"
> return self.attrval
> @var.setter
On Thu, Sep 15, 2016 at 12:30:34PM +0200, ingo wrote:
> Rather stuck with this one, I'd like to automatically (re)set the
> propery "relaystate" when one of the others (Tm, Tset, Th) is set,
> regardless of wether their value has changed.
The obvious way is to make Tm, etc properties, and have
ingo wrote:
> Rather stuck with this one, I'd like to automatically (re)set the
> propery "relaystate" when one of the others (Tm, Tset, Th) is set,
> regardless of wether their value has changed.
The easiest way to achieve your goal seems to be a read-only property:
# this creates a class that
Rather stuck with this one, I'd like to automatically (re)set the
propery "relaystate" when one of the others (Tm, Tset, Th) is set,
regardless of wether their value has changed.
Ingo
My code so far:
from collections import namedtuple
import logging
logger = logging.getLogger()
Hi:
Im studying @property, @var.setter and @var.deleter.
I understand how they work in new style classes. Even though I do not use old
style classes it would be interesting to understand what is going on behind the
scenes. I can try to make assumptions but I do not want to because they might
Can someone explain global interpreter lock with
some source code examples?
I didn't understand explanation offered here:
https://docs.python.org/3/glossary.html#term-global-interpreter-lock
___
Tutor maillist - Tutor@python.org
To unsubscribe or
13 matches
Mail list logo