Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

What hath Bob wrought?


devel / comp.lang.python / Re: for convenience

SubjectAuthor
o Re: for conveniencedn

1
Re: for convenience

<mailman.339.1647902145.2329.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21973&group=comp.lang.python#21973

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: PythonList@DancesWithMice.info (dn)
Newsgroups: comp.lang.python
Subject: Re: for convenience
Date: Tue, 22 Mar 2022 11:04:53 +1300
Organization: DWM
Lines: 47
Message-ID: <mailman.339.1647902145.2329.python-list@python.org>
References: <A779625E-5D40-410A-83C3-BA73E4108228@paulstgeorge.com>
<CAPTjJmr04OXW4k76Xa_9xd8p93gxzARUZUyUk6ehu-x53m2=ig@mail.gmail.com>
<f9c6273c-9f67-a5b6-b3ec-6a93e94539c3@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de xlIsNA5ZmRkW3qtgTPR6MA6w3cBqalXTEJu71g4E+jng==
Return-Path: <PythonList@DancesWithMice.info>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=danceswithmice.info header.i=@danceswithmice.info
header.b=E3pBJgNM; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'this:': 0.03; '(which':
0.04; '2022': 0.05; 'variable': 0.05; 'else.': 0.07; 'mar': 0.07;
'=dn': 0.09; 'angelico': 0.09; 'from:addr:danceswithmice.info':
0.09; 'from:addr:pythonlist': 0.09; 'question:': 0.09; 'memory':
0.15; 'message-id:@DancesWithMice.info': 0.16; 'presumably': 0.16;
'print(': 0.16; 'received:51.254': 0.16; 'received:51.254.211':
0.16; 'received:51.254.211.219': 0.16; 'received:cloud': 0.16;
'received:rangi.cloud': 0.16; 'run-time': 0.16; 'shorter': 0.16;
'wrote:': 0.16; 'python': 0.16; 'uses': 0.19; 'name.': 0.19;
'tue,': 0.19; 'to:addr:python-list': 0.20; 'anything': 0.25;
'creating': 0.27; 'local': 0.27; 'chris': 0.28; 'header:User-
Agent:1': 0.30; 'code,': 0.31; 'effect': 0.31;
'header:Organization:1': 0.31; 'context': 0.32; 'happening': 0.32;
'but': 0.32; 'subject:for': 0.33; 'same': 0.34; 'header:In-Reply-
To:1': 0.34; 'question.': 0.35; "skip:' 10": 0.37; "it's": 0.37;
'received:192.168': 0.37; 'way': 0.38; 'two': 0.39; 'use': 0.39;
'happen': 0.40; 'whenever': 0.40; 'want': 0.40; 'remember': 0.61;
"there's": 0.61; 'george': 0.62; 'here': 0.62; 'between': 0.63;
'skip:b 10': 0.63; 'received:51': 0.64; 'thus': 0.64; 'your':
0.64; 'named': 0.65; 'received:userid': 0.66; 'forget': 0.67;
'mind.': 0.67; 'interpreted': 0.69; 'refers': 0.69; 'manage':
0.73; 'established': 0.80; 'paul': 0.81; 'points': 0.84;
'assignment,': 0.84; 'convenience': 0.91; 'here\xe2\x80\x99s':
0.93; 'magic': 0.93
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on vps517507.ovh.net
X-Spam-Level:
X-Spam-Status: No, score=-3.0 required=5.0 tests=ALL_TRUSTED,BAYES_00,
DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,NICE_REPLY_A,T_SCC_BODY_TEXT_LINE
autolearn=ham autolearn_force=no version=3.4.0
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud 3C1CB99EF
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1647900306;
bh=7lxu6PkIfk0NXCJCuUSik3rYP5TuyrJ3h7/8eNkrSKY=;
h=Date:Subject:To:References:From:In-Reply-To:From;
b=E3pBJgNMjFvKRO5IcLQJ+X0SAIRp+2kc0B+ZJ1XWrlZvHq3C4SVEebdUBH6VkJQa5
J1Ss+s1MVgjDwGczebSmocPdc4rQyTnFlyq7MQhiwQfrgvg/lNxb97ZTg7ehIoOBXX
FxvmmN5ofdqw/ne5OZ/8VzYQJ1V2tCLFmHPHzFb4sX6y4xXKglSCH1jxENaESjJBwY
kvVucuNB81cpjZf0IiCdHzvgw+C82BrboeX9dFZHqir1Gr86jWtBRf4qSeSdahCrcC
hFk1BEjI/vyRq22ZolfsAQdQIQvxFFVJ3jfRDpMX2yngkMrK0HZBxEetwbiViURQFz
cSO49vOL9XSVA==
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.6.2
Content-Language: en-GB
In-Reply-To: <CAPTjJmr04OXW4k76Xa_9xd8p93gxzARUZUyUk6ehu-x53m2=ig@mail.gmail.com>
X-Mailman-Approved-At: Mon, 21 Mar 2022 18:35:44 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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>
X-Mailman-Original-Message-ID: <f9c6273c-9f67-a5b6-b3ec-6a93e94539c3@DancesWithMice.info>
X-Mailman-Original-References: <A779625E-5D40-410A-83C3-BA73E4108228@paulstgeorge.com>
<CAPTjJmr04OXW4k76Xa_9xd8p93gxzARUZUyUk6ehu-x53m2=ig@mail.gmail.com>
 by: dn - Mon, 21 Mar 2022 22:04 UTC

On 22/03/2022 10.17, Chris Angelico wrote:
> On Tue, 22 Mar 2022 at 08:13, Paul St George <email@paulstgeorge.com> wrote:
>>
>>
>> When I am writing code, I often do things like this:
>>
>> context = bpy.context # convenience
>>
>> then whenever I need bpy.context, I only need to write context
>>
>>
>> Here’s my question:
>>
>> When I forget to use the convenient shorter form
>>
>> why is bpy.context not interpreted as bpy.bpy.context?
>>
>
> I don't understand the question. When you do that "for convenience"
> assignment, what you're doing is creating a local variable named
> "context" which refers to the same thing that bpy.context does (or did
> at the time of the assignment, but presumably you only do this when
> bpy.context won't get reassigned). It has no effect on any other name.
> There's no magic happening here - it's just assignment to the name
> context, like anything else.
>
> What are you expecting to happen here?

It's the way Python works.

try:

context = bpy.context # convenience
print( id(context), id(bpy.context) )

Remember that the 'relationship' between the two is established at
run-time and at the data/address 'level' - and not at compile-time. Thus
"context" points to a memory location, and does not 'stand for'
"bpy.context" anywhere other than in your mind.

(which is why we often need to use a copy() when we want 'separate data'
- see also the 'counters' Python uses to manage "garbage collection")

--
Regards,
=dn


devel / comp.lang.python / Re: for convenience

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor