Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Correct type for a simple "bag of attributes" namespace object Date: Sun, 03 Aug 2014 18:52:36 +0300 Organization: A noiseless patient Spider Lines: 46 Message-ID: <87egwxlge3.fsf@elektro.pacujo.net> References: <7ef67ccc-3fc3-47dd-b858-09ef3b57a497@googlegroups.com> <87r40zmkhr.fsf@elektro.pacujo.net> <53dd0717$0$29973$c3e8da3$5496439d@news.astraweb.com> <70e5f2f1-661f-40f2-bb7a-76e569c4d092@googlegroups.com> <1407057464.64980.YahooMailNeo@web163806.mail.gq1.yahoo.com> <1407063072.46317.YahooMailNeo@web163803.mail.gq1.yahoo.com> <87wqaplj8h.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx05.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="25290"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/K634/Q1RjsIgFI2W88zKd" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:bue/1qmPa+dYlNAabR2Z73ci+X8= sha1:INEynzjuKFwnQHqE7tFW/Hszn6Q= Xref: csiph.com comp.lang.python:75608 Roy Smith : > Marko Rauhamaa wrote: > >> I've reached a point where I think classes are a superfluous OO >> concept. You only need objects. > > comp.lang.javascript is over that way --> Thanks for the insight. I'm currently more absorbed by comp.lang.scheme, though. Now, Python is ducktyped. It is (rightly) considered bad taste to consult the datatype (class) of an object. Compare these two definitions: class Point: def __init__(self, x, y): self.x = x self.y = y def x(self): return self.x def y(self): return self.y and: class Object: pass def Point(x, y): self = Object() self.__dict__ = dict(x=lambda: x, y=lambda: y) return self For all practical purposes, the two definitions are identical even though the latter doesn't specify any class. Inheritance needs to be addressed, but that can be taken care of without classes as well. Obviously, Python's syntax makes it convenient to deal with classes, and there's no practical downside to it. However, conceptually, classes are unnecessary baggage and at odds with ducktyping. Marko