Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.06; '2004': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:skip:a 10': 0.09; 'finney': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:object': 0.16; 'subject:simple': 0.16; 'subject:type': 0.16; 'module': 0.19; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'class.': 0.26; 'right.': 0.26; 'header:X-Complaints-To:1': 0.27; "d'aprano": 0.31; 'steven': 0.31; 'writes:': 0.31; 'class': 0.32; 'url:python': 0.33; 'subject: (': 0.35; 'common': 0.35; 'instances': 0.36; 'url:org': 0.36; 'wrong': 0.37; 'ben': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'url:3': 0.61; 'skip:n 10': 0.64; 'more': 0.64; 'subjectcharset:utf-8': 0.72; 'subject:For': 0.78; 'received:125': 0.84; 'sacred': 0.91; 'subject:Make': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Correct type for a simple =?utf-8?Q?=E2=80=9Cbag?= of =?utf-8?Q?a?= =?utf-8?Q?ttributes=E2=80=9D?= namespace object (was: 3 Suggestions to Make Python Easier For Children) Date: Sun, 03 Aug 2014 05:58:59 +1000 References: <7ef67ccc-3fc3-47dd-b858-09ef3b57a497@googlegroups.com> <87r40zmkhr.fsf@elektro.pacujo.net> <53dd0717$0$29973$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:H0bQh508KMM0OwWIQsCRE/KOPgs= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407009552 news.xs4all.nl 2945 [2001:888:2000:d::a6]:38938 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75545 Steven D'Aprano writes: > If you need instances which carry state, then object is the wrong > class. Right. The ‘types’ module provides a SimpleNamespace class for the common “bag of attributes” use case:: >>> import types >>> foo = types.SimpleNamespace() >>> foo.x = 3 >>> foo namespace(x=3) -- \ “Nothing is more sacred than the facts.” —Sam Harris, _The End | `\ of Faith_, 2004 | _o__) | Ben Finney