Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Kevin Conway Newsgroups: comp.lang.python Subject: Re: Namespaces are one honking great idea Date: Sat, 02 Jul 2016 15:34:08 +0000 Lines: 54 Message-ID: References: <57767a97$0$1606$c3e8da3$5496439d@news.astraweb.com> <577693AC.6090807@stoneleaf.us> <5776a3ef$0$1608$c3e8da3$5496439d@news.astraweb.com> <5776C4A4.5000407@stoneleaf.us> <577713c6$0$1587$c3e8da3$5496439d@news.astraweb.com> <1467435593.1705568.654776673.4D901A33@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de xCxjTsz3KwhMT5Vndrj/MA8M5fppi9u7veI305fMKiHg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'static': 0.03; '"class"': 0.09; 'instances.': 0.09; 'namespace': 0.09; 'def': 0.13; 'appropriate': 0.14; 'variables': 0.15; '(well,': 0.16; '*should*': 0.16; '@classmethod': 0.16; 'magic': 0.16; 'namespace,': 0.16; 'namespace.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Namespaces': 0.16; 'wrote:': 0.16; '>': 0.18; 'language': 0.19; 'proposed': 0.20; 'to:2**1': 0.21; 'referring': 0.22; 'defined': 0.23; '(or': 0.23; 'kevin': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'classes': 0.30; 'url:mailman': 0.30; 'creating': 0.30; 'code': 0.30; 'class.': 0.30; 'class': 0.33; 'url:python': 0.33; 'instances': 0.33; 'point,': 0.33; 'url:listinfo': 0.34; 'received:google.com': 0.35; 'skip:c 30': 0.35; 'instance': 0.35; "isn't": 0.35; 'url:org': 0.36; 'cases': 0.36; 'modules': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'method': 0.37; 'seem': 0.37; 'no,': 0.38; 'skip:p 20': 0.38; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'called': 0.40; 'term': 0.60; 'provide': 0.61; 'more': 0.63; 'within': 0.64; 'believe': 0.66; 'skip:\xc2 10': 0.67; '8bit%:100': 0.70; 'covers': 0.72; 'jul': 0.72; 'directly.': 0.76; 'satisfied': 0.83; 'change?': 0.84; 'decorators.': 0.84; 'carries': 0.91; 'technically': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=R7oWYDgS2OmGuaX0oSQujBTjsNnK1ObjbHZM5icgttk=; b=J5H8y6Im+m1wnpie4xZoup054+ztbKiynMnL0UBqMffPekVUszH8sDiWD63gqcZHpq keyCG4f5m3W5xkSof0EbfQjZFw2A84pf/2gfDKlS2i1JaTX3SzTzwUu+vjGeWBn3xwfB Oab/Pw+f9d6kfY6AABN/rNF31ACC2RTRDZGEXBs0GC//PBNClkQo5KmNIUIU8Wjhj+E7 kEvY8Qc2RF2zQaJCrUvTiEXMLsj3O6oyinuJkBkzVhJ+V1Uc+YciV5ORN/GZRsc55mRw 4aCpSjcNGpuWbBKih0lmZoNH/OZ0vBwYIsMnmf+IQu84byBeT4ZA8f1Djzu22NIk8dvB KPYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=R7oWYDgS2OmGuaX0oSQujBTjsNnK1ObjbHZM5icgttk=; b=Bgaqc4S/SqAdUL6TkY2sZXvymRDYd0tdPoBOQLDP7YQaLTUABUnR79L20g4pf2MtK4 njC+ZTVkqJjcfB3HlfaRJXWqeP39dZEpis6UAhd8Ieav/1QIBh5b0s/yNCRWl2SQ9at4 smln3pwhd5ZrDYUxfUol3e7XuOOXxDobNyWogl+PGhMDR/NMN+Bh+OTJUlXy05ckrOEH CYdK3YXr87DOyOZ0iu/NQeQOtE3GuVMDcXpO27r8O+qHQrZV77/H2E59KftHNdHeb7RA E1FbtHh2VY678NFpQokZodnhdW1jZK1UKqU8ohQmzRKZAZp7RofVtlSk9pidC6eR3o76 paig== X-Gm-Message-State: ALyK8tK08WTsXH/CBRCPZcpBLuGPPjAbtBKRyxY6dQdV4C1DlhbbX+0lfbvOPgk1UUmi6i3+cyyb0c2qUSL4yw== X-Received: by 10.176.5.161 with SMTP id e30mr156211uae.92.1467473657607; Sat, 02 Jul 2016 08:34:17 -0700 (PDT) In-Reply-To: <1467435593.1705568.654776673.4D901A33@webmail.messagingengine.com> X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <57767a97$0$1606$c3e8da3$5496439d@news.astraweb.com> <577693AC.6090807@stoneleaf.us> <5776a3ef$0$1608$c3e8da3$5496439d@news.astraweb.com> <5776C4A4.5000407@stoneleaf.us> <577713c6$0$1587$c3e8da3$5496439d@news.astraweb.com> <1467435593.1705568.654776673.4D901A33@webmail.messagingengine.com> Xref: csiph.com comp.lang.python:110960 > staticmethod isn't technically required to use a method through the class (or subclasses), it simply provides the appropriate magic to allow it to be called through instances. For example, the following code covers all described use cases of the proposed namespace. Methods are invoked without creating instances and state is managed on the class object directly. class CustomNs: stateful_data = 1 @staticmethod def echo(text): print(text) @classmethod def mutate(cls): cls.stateful_data += 1 print(cls.stateful_data) CustomNs.echo("test") print(CustomNs.stateful_data) CustomNs.mutate() print(CustomNs.stateful_data) For the proponents of namespace, what is deficient in the above example that necessitates a language change? On Sat, Jul 2, 2016, 00:02 Random832 wrote: > On Fri, Jul 1, 2016, at 21:50, Kevin Conway wrote: > > I believe the namespace object you are referring to is exactly a > > class. IIRC, classes came about as a "module in a module". > > No, because classes have instances. And conceptually they seem like they > *should* have instances. Just using the term "class" carries > expectations. > > More to the point, what modules do that classes do not is provide a > global namespace for functions defined within them, so that variables > within them can be used (well, read - writing them requires a > declaration) by the functions without extra qualification. > > > Regardless, all use cases you've listed are already satisfied by use > > of the static and class method decorators. Methods decorated with > > these do not require an instance initialization to use. > > staticmethod isn't technically required to use a method through the > class (or subclasses), it simply provides the appropriate magic to allow > it to be called through instances. > -- > https://mail.python.org/mailman/listinfo/python-list >