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: 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 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: In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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.