Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95969
| Path | csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; 'prefix': 0.07; 'variable,': 0.07; 'global,': 0.09; 'high-level': 0.09; 'okay': 0.09; 'def': 0.13; "hasn't": 0.15; 'thu,': 0.15; '"global"': 0.16; 'all):': 0.16; 'declaration': 0.16; 'opposite': 0.16; 'scope.': 0.16; 'wrote:': 0.16; "shouldn't": 0.18; 'typing': 0.18; 'variable': 0.18; '2015': 0.20; 'developer': 0.20; 'names.': 0.22; 'sep': 0.22; 'shifting': 0.22; 'code.': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'chris': 0.26; 'possibility': 0.27; 'least': 0.27; 'message-id:@mail.gmail.com': 0.27; 'moved': 0.27; 'var': 0.27; 'correct': 0.28; 'function': 0.28; 'skip:( 20': 0.28; 'another.': 0.29; 'referenced': 0.29; 'them?': 0.29; "i'm": 0.30; 'creating': 0.30; "i'd": 0.31; 'probably': 0.31; 'anyone': 0.32; 'point': 0.33; 'foo': 0.33; 'rule': 0.33; 'open': 0.33; 'file': 0.34; 'received:google.com': 0.35; 'so,': 0.35; 'something': 0.35; 'level': 0.35; 'but': 0.36; 'possible': 0.36; 'keyword': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'wanted': 0.37; 'names': 0.38; 'mean': 0.38; 'sure': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'high': 0.60; 'your': 0.60; 'skip:u 10': 0.61; 'entire': 0.61; 'per': 0.62; 'safe': 0.63; 'sample': 0.63; 'dont': 0.64; 'elsewhere': 0.66; 'superior': 0.67; 'local,': 0.84; 'to:name:python': 0.84; 'whereby': 0.84; 'adopt': 0.91; 'technically': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Rgn8AbTiP/bWFJ5S5+TKJ0keCRJJhXXJFwo4bbS7c7M=; b=rxfB6M9rS7jm2IWWrWimmBNkDc0DK29k7OQPWn9wfukj1E/rzcTK7Sf0GxAaxZSr5R n7h7fXKJQP1dz8lwAfCnEcBOrIds1fIFBemXBSW4KDhxffLsVknIxvyCfxBZkJXm3enC e43fav9ezC8yXARM3VxKQIQXkUUhg4R0ZK51cTY+0+bQ2HT5pSRghnCWyuMb8EqZbHEH TlaYQyQLLJrkQGb+g2Rd0T/MlN6AuisqDGzIOaI6EW91jbDO0Q5Ad3Hv6PWsrt61J4Dt F+Eba8G2Cykdl7g6LDhlqmgxx/7auqQVcMNP+FOpxnMCKqiCsn8vAKeQCrVbEWuX/yLi vAqw== |
| X-Received | by 10.129.48.201 with SMTP id w192mr11567057yww.147.1441309691639; Thu, 03 Sep 2015 12:48:11 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <4602a32c-5109-47dd-95bb-b9723738f07f@googlegroups.com> |
| References | <c3363$547e74fe$5419aafe$24179@news.ziggo.nl> <4602a32c-5109-47dd-95bb-b9723738f07f@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Thu, 3 Sep 2015 13:47:32 -0600 |
| Subject | Re: Python handles globals badly. |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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.94.1441309694.8327.python-list@python.org> (permalink) |
| Lines | 59 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1441309694 news.xs4all.nl 23842 [2001:888:2000:d::a6]:40853 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:95969 |
Show key headers only | View raw
On Thu, Sep 3, 2015 at 1:05 PM, <tdev@freenet.de> wrote:
> If this would be under the developer responsibility than this
> is simply achieved by giving well-written var names.
So, adopt a rule whereby you prefix all your global variable names
with "global" or "g_"? How is this superior to just declaring them
once per function that needs to set them? You're just shifting the
extra typing from one place to another.
> Or does anyone really name a global var xxx and a function var xxx?
> I am sure no one at all will do it. I dont want read such a code.
Intentionally, it's probably rare. But if I'm adding a new variable, I
shouldn't need to first make sure that it's safe to do so by scanning
over the entire file to make sure that the name hasn't already been
used elsewhere in the opposite scope.
> Function calls (?) -
> I have to admit I did not really get the problematic from
> the sample provided by Chris Angelico.
>
> What I can see or mean to see is:
> it has nothing to do with global-keyword from the high level point of
> view: give write access, probably to the vars word and otherword.
>
> And yes, I see the vars independant.
> And cause you set no "global" they are simple local vars
> (readable+writeable)
So in order for something to be global, it would have to be referenced
at least once in the global scope? Currently it's possible to do this:
def set_foo(value):
global foo
foo = value
def get_foo():
return foo
With your proposal that would change to:
foo = None
def set_foo(value):
foo = value
def get_foo():
return foo
So again the declaration has just been moved from one place to another.
> But then I ask you from high-level point of view
> (if my high level view is correct at all):
> Would you remove this keyword if it would be technically possible
> or is good for you from high level point of view to have a keyword "global"?
Provided that the proposal doesn't open up the possibility of
unintentionally creating a global variable where I wanted a local, I'd
be okay with it.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Python handles globals badly. tdev@freenet.de - 2015-09-03 12:05 -0700
Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-03 13:47 -0600
Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-03 13:51 -0600
Re: Python handles globals badly. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-03 23:13 +0100
Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-03 16:45 -0600
Re: Python handles globals badly. Michael Torrie <torriem@gmail.com> - 2015-09-03 18:06 -0600
Re: Python handles globals badly. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-04 01:47 +0100
Re: Python handles globals badly. Steven D'Aprano <steve@pearwood.info> - 2015-09-04 12:27 +1000
Re: Python handles globals badly. Steven D'Aprano <steve@pearwood.info> - 2015-09-04 12:33 +1000
Re: Python handles globals badly. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-09-08 11:07 +0200
Re: Python handles globals badly. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-09-08 10:59 +0200
Re: Python handles globals badly. Steven D'Aprano <steve@pearwood.info> - 2015-09-09 13:27 +1000
Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-08 23:08 -0600
Re: Python handles globals badly. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-09-09 17:04 +0200
Re: Python handles globals badly. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-09 17:46 +0100
Re: Python handles globals badly. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-08 10:22 +0100
Re: Python handles globals badly. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-09-08 11:59 +0200
Re: Python handles globals badly. Laura Creighton <lac@openend.se> - 2015-09-08 12:07 +0200
csiph-web