Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107739 > unrolled thread

Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

Started byChristopher Reimer <christopher_reimer@icloud.com>
First post2016-04-27 18:27 -0700
Last post2016-04-27 18:27 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Differences between Class(Object) and Class(Dict) for dictionary usage? Christopher Reimer <christopher_reimer@icloud.com> - 2016-04-27 18:27 -0700

#107739 — Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

FromChristopher Reimer <christopher_reimer@icloud.com>
Date2016-04-27 18:27 -0700
SubjectRe: Differences between Class(Object) and Class(Dict) for dictionary usage?
Message-ID<mailman.157.1461806845.32212.python-list@python.org>
On 4/27/2016 7:33 AM, Ian Kelly wrote:

> This class definition looks muddled. Because Test2 inherits from dict,
> the object referred to by "self" will be a dict, and self.__dict__ is
> actually a *different* dict, containing the attributes of self. The
> line:
>
>      self.__dict__ = {'key', 'value'}
>
> is essentially equivalent to:
>
>      self.key = value
>
> and will be regardless of whether you inherit from object or dict. If
> you find this distinction confusing, then I recommend not inheriting
> from dict.

Which expression is Pythonic? I've seen both used in various examples on 
the Internet.

Thank you,

Chris R.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web