Path: csiph.com!usenet.pasdenom.info!aioe.org!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '*is*': 0.09; 'namespace': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'jan': 0.12; 'builtins': 0.16; 'dict': 0.16; 'ivan': 0.16; 'namespace.': 0.16; 'namespace;': 0.16; 'objects.': 0.16; 'optional': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:Classes': 0.16; 'subject:class': 0.16; 'unchanged': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'normally': 0.19; 'meant': 0.20; 'proposed': 0.22; 'creating': 0.23; 'header:User- Agent:1': 0.23; "i've": 0.25; 'class.': 0.26; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'restrict': 0.30; 'code': 0.31; 'getting': 0.31; "skip:' 10": 0.31; 'usually': 0.31; '3.x': 0.31; 'omitted': 0.31; 'class': 0.32; 'interface': 0.32; 'run': 0.32; 'implemented': 0.33; 'except': 0.35; 'but': 0.35; 'done': 0.36; 'step': 0.37; 'mapping': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'hope': 0.61; 'till': 0.61; 'name': 0.63; 'term': 0.63; 'thomas': 0.65; 'here': 0.66; 'between': 0.67; 'now:': 0.74; 'received:fios.verizon.net': 0.84; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Classes - converting external function to class's method. Date: Sun, 14 Dec 2014 19:11:04 -0500 References: <2082416.uXDKvNnAXg@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-108-16-203-145.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <2082416.uXDKvNnAXg@PointedEars.de> 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418602282 news.xs4all.nl 2880 [2001:888:2000:d::a6]:51009 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82536 On 12/14/2014 6:15 PM, Thomas 'PointedEars' Lahn wrote: > Ivan Evstegneev wrote: > >> I have stuck a bit with this example(took this one from the book). >> >> Here are a description steps of what I've done till now: >> >> >> Step 1 - creating an empty namespace: >> >>>>> class rec: pass > > IMHO that is not actually creating a namespace; it is just > declaring/defining an empty class. I pythonland, a namespace is a many to one mapping between names and objects. They are usually but not necessarily implemented with dicts. Some might restrict the term to a mapping with a .attribute interface for getting and setting. Others consider any string-key dict to be a namespace. The types module has a class SimpleNamespace. It has been proposed to move it to builtins with the name 'namespace'. > BTW, the recommended Python 3.x way is > > class Rec (object): > pass I hope you meant Python *2*.x, where '(object)' *is* needed to make a newstyle class. In 3.x, '(object)' is optional and normally omitted except in code meant to run unchanged in 2 and 3. -- Terry Jan Reedy