Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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; 'parameters': 0.04; 'importing': 0.05; 'subject:Python': 0.06; 'parameter': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'notations': 0.16; "object's": 0.16; 'subject:Classes': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'memory': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'load': 0.23; 'orientation': 0.24; 'pointer': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'holds': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'specifically': 0.29; 'am,': 0.29; 'thus': 0.29; 'related': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'languages': 0.32; 'maintaining': 0.32; 'cases': 0.33; 'could': 0.34; 'classes': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'disk': 0.36; 'done': 0.36; 'doing': 0.36; 'two': 0.37; 'level': 0.37; 'same.': 0.38; 'that,': 0.38; 'little': 0.38; 'structure': 0.39; 'how': 0.40; 'new': 0.61; 'simple': 0.61; 'first': 0.61; 'high': 0.63; '(probably': 0.84; 'actually,': 0.84; 'compare:': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=YTteX2rXps8rtCXO3k5RI706E+1Am1KA71UCauKwb9A=; b=CAJYqgokONAeaQOkwNvljvRgxjnD0GdSAAx4V0oIsKPUYdYV4YUSATy7WvRATEG6mh 7OuEpHlVSZgOTpIV5pCuTA6vGQ/DhjmOXHPylrcHrsCeRPnHPMnMBQE7M1En74I25wSF Tkonmx8kuGcWsbtiRkJocXf4upkA3MOrB+nZdAPv11uyis3LZFHfvnPuyduvbk3aT3iB ES2ZAd1bAyjNFe1XJWi6OXraSMhVbrdJ1xyps9N7mWfWSO75rqorIYhN8gnGE/pZLpd6 u7Wv4OCXrvxlk+RQbA3S2L3teNDvQ5DPg4HjS0kju8p8JD1X7zbyeuN7USIYnMuD+QlW 94Fw== MIME-Version: 1.0 X-Received: by 10.50.80.76 with SMTP id p12mr8462503igx.34.1407254886696; Tue, 05 Aug 2014 09:08:06 -0700 (PDT) In-Reply-To: References: Date: Wed, 6 Aug 2014 02:08:06 +1000 Subject: Re: Python Classes From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407254896 news.xs4all.nl 2864 [2001:888:2000:d::a6]:40773 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75743 On Wed, Aug 6, 2014 at 1:37 AM, Neil D. Cerutti wrote: > In simple cases like that, functions could do very well by including a > little bundle of data (probably a dict) as one of the parameters for each > related function. And this is exactly how object orientation is done in C. You just have a structure that holds the object's state, and the (usually) first parameter to each function is a pointer to that structure. Actually, I've done that in high level languages too, specifically to decouple the code from the state (and thus allow me to load new code from the disk while maintaining state via what's already in memory - doing this with classes and objects means importing that state explicitly). The two notations are exactly the same. Compare: list.append(l, 'spam') l.append('spam') One uses namespacing, the other uses object methods. Same thing! ChrisA