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


Groups > comp.lang.python > #75743

Re: Python Classes

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 <rosuav@gmail.com>
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 <lrqtnq$hk4$1@ger.gmane.org>
References <mailman.12627.1407141661.18130.python-list@python.org> <lrp2bp$a5d$1@reader1.panix.com> <lrqtnq$hk4$1@ger.gmane.org>
Date Wed, 6 Aug 2014 02:08:06 +1000
Subject Re: Python Classes
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12672.1407254896.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Wed, Aug 6, 2014 at 1:37 AM, Neil D. Cerutti <neilc@norwich.edu> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Python Classes Shubham Tomar <tomarshubham24@gmail.com> - 2014-08-04 14:10 +0530
  Re: Python Classes John Gordon <gordon@panix.com> - 2014-08-04 22:44 +0000
    Re: Python Classes Terry Reedy <tjreedy@udel.edu> - 2014-08-04 19:26 -0400
    Re: Python Classes "Neil D. Cerutti" <neilc@norwich.edu> - 2014-08-05 11:37 -0400
    Re: Python Classes Chris Angelico <rosuav@gmail.com> - 2014-08-06 02:08 +1000

csiph-web