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


Groups > comp.lang.python > #75743

Re: Python Classes

References <mailman.12627.1407141661.18130.python-list@python.org> <lrp2bp$a5d$1@reader1.panix.com> <lrqtnq$hk4$1@ger.gmane.org>
Date 2014-08-06 02:08 +1000
Subject Re: Python Classes
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.12672.1407254896.18130.python-list@python.org> (permalink)

Show all headers | 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