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


Groups > comp.lang.python > #12706

Re: Functions vs OOP

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.134.4.91.MISMATCH!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; ':-)': 0.06; 'something,': 0.07; 'suggesting': 0.07; 'arguments,': 0.09; 'from:addr:python': 0.09; "object's": 0.09; 'object?': 0.09; 'oop,': 0.09; 'argument': 0.15; 'called,': 0.16; 'constructor,': 0.16; 'constructor.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; "function's": 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr :python-list': 0.16; 'subject:OOP': 0.16; 'wrote:': 0.16; 'functions,': 0.18; 'programming': 0.20; 'seems': 0.20; 'compatible': 0.21; 'header:In-Reply-To:1': 0.22; 'somehow': 0.23; 'suggests': 0.23; 'input': 0.24; 'creating': 0.25; 'function': 0.27; 'depends': 0.28; 'received:84': 0.28; 'arguments.': 0.30; '(e.g.': 0.31; 'functional': 0.31; 'objects': 0.32; 'too': 0.33; 'to:addr:python-list': 0.33; 'header:User-Agent:1': 0.34; 'things': 0.34; 'reply-to:addr:python.org': 0.34; 'rather': 0.35; 'object': 0.35; 'skip:" 10': 0.36; 'using': 0.37; 'think': 0.38; 'programming,': 0.38; 'some': 0.38; 'should': 0.38; 'subject:: ': 0.39; "there's": 0.39; 'missing': 0.39; 'to:addr:python.org': 0.39; 'sense': 0.39; 'raw': 0.40; "it's": 0.40; 'taking': 0.66; 'william': 0.68; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; 'hand,': 0.76; 'research,': 0.82; 'strings)': 0.84
X-IronPort-Anti-Spam-Filtered true
X-IronPort-Anti-Spam-Result AskGALJUYk5UXebj/2dsb2JhbABCmTyPMHiBRgEBBAE4QAYLCwgQCRYPCQMCAQIBDTgTCAEBh28CtweGagSLckmMAot/
Date Sat, 03 Sep 2011 17:29:11 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: Functions vs OOP
References <j3tjov$c30$1@dont-email.me>
In-Reply-To <j3tjov$c30$1@dont-email.me>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.736.1315067353.27778.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1315067353 news.xs4all.nl 2474 [2001:888:2000:d::a6]:54730
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12706

Show key headers only | View raw


On 03/09/2011 17:15, William Gill wrote:
> During some recent research, and re-familiarization with Python, I
> came across documentation that suggests that programming using
> functions, and programming using objects were somehow opposing
> techniques.
>
> It seems to me that they are complimentary.

I think you mean "complementary". :-)

> It makes sense to create objects and have some functions that take
> those objects as arguments. Are they suggesting that any function
> that takes an object as an argument should always be a method of that
> object? Conversely I can see creating functions that take raw input
> (e.g. strings) and return it in a format compatible with an object's
> constructor, rather than have objects accept any conceivable format
> for its constructor.
>
> Am I missing something, or am I taking things too literally?

I think that it's all about "state".

In functional programming, there's no state; a function's result
depends solely on its arguments, so it will always return the same
result for the same given arguments.

In OOP, on the other hand, an object often has a state; a method may
return a different result each time it's called, even for the same
given arguments.

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


Thread

Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 12:15 -0400
  Re: Functions vs OOP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-04 02:25 +1000
    Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-03 15:15 -0400
      Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 17:34 -0400
        Re: Functions vs OOP Ben Finney <ben+python@benfinney.id.au> - 2011-09-04 07:39 +1000
          Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-03 17:58 -0400
        Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-03 21:51 -0400
          Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 22:18 -0400
    Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-05 14:58 -0400
  Re: Functions vs OOP MRAB <python@mrabarnett.plus.com> - 2011-09-03 17:29 +0100
    Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 17:09 -0400
  Re: Functions vs OOP Ian Kelly <ian.g.kelly@gmail.com> - 2011-09-03 12:50 -0600
    Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 17:13 -0400
    Re: Functions vs OOP tinnews@isbd.co.uk - 2011-09-04 09:13 +0100
      Re: Functions vs OOP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-04 21:18 +1000
      Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-04 14:32 -0400
        Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-04 15:43 -0400
          Re: Functions vs OOP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-05 09:41 +1000
            Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-04 20:46 -0400
            Re: Functions vs OOP Chris Angelico <rosuav@gmail.com> - 2011-09-05 10:59 +1000
  Re: Functions vs OOP rusi <rustompmody@gmail.com> - 2011-09-04 06:13 -0700
    Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-05 13:45 -0400
      Re: Functions vs OOP Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-09-05 21:04 +0200
        Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-05 20:30 -0400
      Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-05 18:55 -0400

csiph-web