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


Groups > comp.lang.python > #32607

Re: Organisation of python classes and their methods

References <mailman.3177.1351840590.27098.python-list@python.org> <7xa9v0wj2g.fsf@ruckus.brouhaha.com> <EC7A64A6-D853-4738-92FC-673877C42513@mac.com>
Date 2012-11-02 20:15 +1100
Subject Re: Organisation of python classes and their methods
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3189.1351847720.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Nov 2, 2012 at 7:08 PM, Martin Hewitson <martinhewitson@mac.com> wrote:
>
> On 2, Nov, 2012, at 08:38 AM, Paul Rubin <no.email@nospam.invalid> wrote:
>
>> Martin Hewitson <martinhewitson@mac.com> writes:
>>> So, is there a way to put these methods in their own files and have
>>> them 'included' in the class somehow? ... Is there an official python
>>> way to do this? I don't like having source files with 100's of lines
>>> of code in, let alone 1000's.
>>
>> That code sounds kind of smelly... why are there so many methods per
>> class?
>
> Simply because there are many different ways to process the data. The class encapsulates the data, and the user can process the data in many ways. Of course, one could have classes which encapsulate the algorithms, as well as the data, but it also seems natural to me to have algorithms as methods which are part of the data class, so the user operates on the data using methods of that class.

Are these really needing to be methods, or ought they to be
module-level functions? Remember, Python code doesn't have to be
organized into classes the way Java code is.

ChrisA

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


Thread

Organisation of python classes and their methods Martin Hewitson <martinhewitson@mac.com> - 2012-11-02 07:16 +0100
  Re: Organisation of python classes and their methods Paul Rubin <no.email@nospam.invalid> - 2012-11-02 00:38 -0700
    Re: Organisation of python classes and their methods Martin Hewitson <martinhewitson@mac.com> - 2012-11-02 09:08 +0100
      Re: Organisation of python classes and their methods Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-11-02 11:18 +0100
        Re: Organisation of python classes and their methods Martin Hewitson <martinhewitson@me.com> - 2012-11-02 15:49 +0100
        Re: Organisation of python classes and their methods Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-02 17:02 +0000
      Re: Organisation of python classes and their methods Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-03 01:38 +0000
    Re: Organisation of python classes and their methods Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-02 08:40 +0000
      Re: Organisation of python classes and their methods Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-02 10:20 +0000
    Re: Organisation of python classes and their methods Chris Angelico <rosuav@gmail.com> - 2012-11-02 20:15 +1100
    Re: Organisation of python classes and their methods Martin Hewitson <martinhewitson@mac.com> - 2012-11-02 09:45 +0100
    Re: Organisation of python classes and their methods Peter Otten <__peter__@web.de> - 2012-11-02 11:21 +0100
    Re: Organisation of python classes and their methods Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-02 10:48 +0000
    Re: Organisation of python classes and their methods Robert Kern <robert.kern@gmail.com> - 2012-11-02 10:55 +0000
    Re: Organisation of python classes and their methods Robert Kern <robert.kern@gmail.com> - 2012-11-02 11:07 +0000
  Re: Organisation of python classes and their methods Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-03 01:06 +0000
    Re: Organisation of python classes and their methods Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-03 01:08 +0000

csiph-web