From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,43aafc250d42730f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-09 02:30:11 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!213.56.195.71!fr.usenet-edu.net!usenet-edu.net!fu-berlin.de!news.cid.net!news.enyo.de!news1.enyo.de!not-for-mail From: Florian Weimer Newsgroups: comp.lang.ada Subject: Re: controlled type in generic package? Date: 09 Feb 2001 11:39:13 +0100 Organization: Enyo's not your organization Message-ID: <871yt8rvhq.fsf@deneb.enyo.de> References: <3A7FDA9A.C667090F@stn-atlas.de> <95p2ab$463$1@nnrp1.deja.com> <95sgl2$3c8$1@wanadoo.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Xref: supernews.google.com comp.lang.ada:5049 Date: 2001-02-09T11:39:13+01:00 List-Id: Brian Rogoff writes: > Yes, C++, Java and Eiffel are fairly "flat" languages, like Python and > unlike Ada. Python permits class declarations anywhere a statement is allowed (in fact, a class declaration *is* a statement). Python classes are usually used to implement closures: def add_something(something): class Add_Something_Class: def __init__(self, something): self.something = something def __call__(self, arg): return arg + self.something return Add_Something_Class(something) add_1 = add_something(1) print add_1(2) In this particular case, you could use a function declaration as well (which is just another statement ;-), but in more complicated cases, the class approach is better. Python is not a flat language at all.