Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76433
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'explicit': 0.07; 'level,': 0.07; 'sys': 0.07; 'classes.': 0.09; 'definition,': 0.09; 'subject:module': 0.09; 'def': 0.12; 'arg):': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'properties,': 0.16; 'semantics': 0.16; 'subject:type': 0.16; 'obviously': 0.18; 'module': 0.19; 'basically': 0.19; 'import': 0.22; 'to:name:python-list@python.org': 0.22; 'question': 0.24; 'equivalent': 0.26; 'function': 0.29; 'on,': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'implicit': 0.31; 'class': 0.32; 'stuff': 0.32; 'option': 0.32; 'subject:the': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'break': 0.61; 'kind': 0.63; 'here': 0.66; 'bless': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=2aYBnQ+M54/MgJOT5YfPT2pg60PBvk0X4fckV7+uw0o=; b=nzzielhP9zctaDW9wzO/W6jZVA71GAnijBNFD5gPQyqSlLv03PdopgNQLYnEWcf4ra 6S7YgG6UMu+L77yNlc4fPnmGyUWjsaianR33OqgehFBkrwcu7bKAWUGSvtQIEmmR00sV w7jBYo+nh+588fn1DNe8jZ6uE293Xr9PtocBjOEKc81eGA7N3RqDSVsRVdj1Inaw5lCl 5R5kBXupPOT3l6TnYY38K26Nu6pGugjigFkvgJHAIeGm1+u4LDWCogkxPMIoFJ9uO/YC gE9pYDxLbqL98aliU6LswfBvgHm2WFW6f541fBeegk2BNmmseFp2/qTDf1smM3CW8GQi G7sw== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.80.76 with SMTP id p12mr37347386igx.34.1408288557729; Sun, 17 Aug 2014 08:15:57 -0700 (PDT) |
| Date | Mon, 18 Aug 2014 01:15:57 +1000 |
| Subject | Module-level functions and the module type |
| From | Chris Angelico <rosuav@gmail.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13070.1408288560.18130.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1408288560 news.xs4all.nl 2915 [2001:888:2000:d::a6]:52027 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:76433 |
Show key headers only | View raw
In a class definition, you have explicit state parameters on your
functions - 'self':
class C:
def foo(self, arg):
# blah blah
At module level, there's equivalent state - the function "knows" what
module it came from - but it's implicit:
def foo(arg):
# blah blah
print(foo.__globals__)
How hard would it be to unify these, and make modules into classes?
This would then allow stuff like properties, metaclasses, and so on,
all with exactly the same semantics as they have in classes.
Obviously this would be a huge backward-compatibility break if it
happened everywhere, but what I'm looking at here is a way to
basically bless this kind of concept:
# spam.py
class RealSpam:
# module contents here
import sys
sys.modules[__name__] = RealSpam()
So the question is: Why is state implicit in one and explicit in the
other? Which option is really the better way to do things?
ChrisA
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Module-level functions and the module type Chris Angelico <rosuav@gmail.com> - 2014-08-18 01:15 +1000
Re: Module-level functions and the module type Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-18 01:59 +1000
Re: Module-level functions and the module type Chris Angelico <rosuav@gmail.com> - 2014-08-18 02:20 +1000
csiph-web