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


Groups > comp.lang.python > #32639

Re: Organisation of python classes and their methods

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: Organisation of python classes and their methods
References <B16BD7AC-F860-4A30-A08D-A0235CC25F20@mac.com> <k6vuis$j5b$1@ger.gmane.org> <mailman.3181.1351844460.27098.python-list@python.org>
Date 2012-11-02 10:24 -0700
Message-ID <7xhap7dijb.fsf@ruckus.brouhaha.com> (permalink)
Organization Nightsong/Fort GNOX

Show all headers | View raw


Martin Hewitson <martinhewitson@mac.com> writes:
> Well, here we disagree. Suppose I have a class which encapsulates
> time-series data. Below is a list of the absolute minimum methods one
> would have to process that data. ... 
>     'abs'
>     'acos'
>     'asin'
> ...

Ok, THERE is your problem.  Why do you have separate implementations of
all those functions?  Does the abs of a time series simply mean the abs
of each element of the series?  In that case you want just ONE method,
something like "map", which applies an arbitrary function to all
elements of the series.  Then for time series ts, instead of saying
ts.abs(), you'd say ts.map(abs) where abs is the existing, built-in
absolute value function.  You could similarly say ts.map(acos) etc.
That gets rid of almost all of those methods.

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


Thread

Re: Organisation of python classes and their methods Martin Hewitson <martinhewitson@mac.com> - 2012-11-02 09:20 +0100
  Re: Organisation of python classes and their methods Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-11-02 11:49 +0100
    Re: Organisation of python classes and their methods Martin Hewitson <martinhewitson@mac.com> - 2012-11-02 15:47 +0100
  Re: Organisation of python classes and their methods Paul Rubin <no.email@nospam.invalid> - 2012-11-02 10:24 -0700
    Re: Organisation of python classes and their methods Martin Hewitson <martinhewitson@mac.com> - 2012-11-02 18:40 +0100
      Re: Organisation of python classes and their methods Paul Rubin <no.email@nospam.invalid> - 2012-11-02 11:29 -0700

csiph-web