Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

6 May, 2024: The networking issue during the past two days has been identified and appears to be fixed. Will keep monitoring.


devel / comp.lang.python / Re: learning python ...

SubjectAuthor
o Re: learning python ...hw

1
Re: learning python ...

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: hw...@adminart.net (hw)
Newsgroups: comp.lang.python
Subject: Re: learning python ...
Date: Mon, 24 May 2021 08:21:19 +0200
Lines: 75
Message-ID: <mailman.291.1621837468.3087.python-list@python.org>
References: <CACFDE8bsJe2BMNwsXAiGyxsMxNE+RuENj62GtfEzqodh5O_mMA@mail.gmail.com>
<YKrRLP46qmZ51Nzk@cskk.homeip.net>
<7dc017ca-c0a3-c66e-8b7c-ceea1c786c73@adminart.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 8bL11wM8jkUm8FSFjevtawUEWuV08xNAQygnJdC3GvDw==
Return-Path: <hw@adminart.net>
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=adminart.net header.i=@adminart.net header.b=sZcg2Ilz;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'this:': 0.03; 'def': 0.04;
'variable': 0.05; 'subject:python': 0.06; 'lets': 0.07; 'sun,':
0.07; 'effectively': 0.09; "shouldn't": 0.09; 'situations': 0.09;
'typeerror:': 0.09; "can't": 0.14; 'import': 0.14; '_are_': 0.16;
'builtin': 0.16; 'cameron': 0.16; 'confusing.': 0.16; 'false.':
0.16; 'idiomatic': 0.16; 'inspect': 0.16; 'mentioned,': 0.16;
'naming': 0.16; 're-define': 0.16; 'received:(client did not
present a certificate)': 0.16; 'runtime': 0.16; 'simpson': 0.16;
'useful.': 0.16; 'variable.': 0.16; 'wrote:': 0.16; 'python':
0.16; 'name.': 0.20; 'object': 0.23; 'progress': 0.23; 'to:addr
:python-list': 0.23; 'lines': 0.24; 'code': 0.24; 'received:de':
0.24; 'idea': 0.25; '>>>': 0.26; 'thinking': 0.26; 'seems': 0.26;
'creating': 0.27; 'bit': 0.28; 'function': 0.28; 'saying': 0.28;
'this.': 0.29; 'local': 0.29; 'header:User-Agent:1': 0.31;
'there': 0.31; 'think': 0.31; 'code,': 0.31; 'am,': 0.31; 'wide':
0.31; "i'm": 0.32; 'ton': 0.32; 'transferring': 0.32; 'class':
0.33; 'unless': 0.33; 'header:In-Reply-To:1': 0.33; 'able': 0.36;
'cases': 0.37; 'errors': 0.37; 'inside': 0.37; 'way': 0.37;
'really': 0.37; 'those': 0.38; 'going': 0.38; 'use': 0.38;
'called': 0.40; 'example': 0.40; 'built': 0.40; 'common': 0.60;
'normal': 0.60; 'potential': 0.61; 'likely': 0.61; 'rules': 0.63;
'them,': 0.63; 'true': 0.63; 'your': 0.64; 'look': 0.66;
'similar': 0.66; 'times': 0.66; 'bad': 0.68; 'within': 0.68;
'changing': 0.69; 'global': 0.72; 'little': 0.75; 'tools': 0.75;
'name,': 0.75; 'reasons': 0.75; '2021': 0.84; 'variety': 0.84;
'activity.': 0.84; 'bars': 0.84; 'discouraged': 0.84; 'lines,':
0.84; 'maintains': 0.84; 'stuff,': 0.84; 'type,': 0.84;
'stopping': 0.91
ARC-Seal: i=1; a=rsa-sha256; t=1621837279; cv=none;
d=strato.com; s=strato-dkim-0002;
b=HL5pidVwGVL/BVjaSfxvDjtp6dZkLjav6clzWbpj+1PDgulN3yI7OiqxlBZK8DjeZm
2ZZVsAov9S8Cm8dqkXqcWd8JLXV9slw79b4YD5i3RRkIlNDDMaDpr7yLqVW4uKfv74e6
tdFOLCq6mLNawrX6tdL5Th3SMVBCmzjZOpoea2EOt801UWu79e5Hjq49DV5AiG07sTVk
oBl9SlFSJRA2jkEO5cMhllF60+eSoa7I2DYmSeSHwHEFexa3k5sBU8E54RXpErLYHpq3
htTW7lrRw78JqS+ocwd9JVfLcAw5mKarsLfl1QMhaqzS/z0Ay0azqJcxoLzXMzRk6Neg
h6hg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1621837279;
s=strato-dkim-0002; d=strato.com;
h=In-Reply-To:Date:Message-ID:From:References:To:Subject:Cc:Date:From:
Subject:Sender;
bh=W4HJar3roFAvkjBSfb1IFnuZQpZWfW6ewQK5Ph53SuU=;
b=lWrsFo3qdNKOawnGCFWbXz713p1KrfbXoSjO4OfoXAaRDRFazPkd1O0iz97ERvHP7Y
O5ndRgz7EteB46nYW7ENX7/49vgMyuPHIiTWnnWxHVQhweiZpOq3Y9ZNM0cr3XV1y7vU
tK0nRAVqNVNZZikCAfYL+huTvOXEHIjxz3PmQYlGcZz2TDvobT6DqUVXZ2UZoZIOhJcd
m2hBcR/Z9ylPoQ2/6YmF4L6bDM63BIZGpNteInjPMkGGIToR6aNZS3NQomK9SpZxL71P
P6/dfu9f+jFGGPJUiQlyh4QFpSuMiXFS8uji+brIVYVrusRxyo9QenUZOC3OYZgMpLbl
AsOQ==
ARC-Authentication-Results: i=1; strato.com;
dkim=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1621837279;
s=strato-dkim-0002; d=adminart.net;
h=In-Reply-To:Date:Message-ID:From:References:To:Subject:Cc:Date:From:
Subject:Sender;
bh=W4HJar3roFAvkjBSfb1IFnuZQpZWfW6ewQK5Ph53SuU=;
b=sZcg2IlzkN8px2rsamZh6AVuW16Qsyn1nPYIaJF/fi3RAIkX96PKjwm+gZomH63fr5
JoV2qIJosju2kc1gexzsygzQlA7XgTWNNUv/dfxQ18ZrhS5z3PyipPpukLVddTMOx4qP
ujKnNa1BTgYQxF4R7przF2C3/XfUPkJCgjveB2KfgIcjOpNzT0X1v3lUXM1pyhwFylp0
2ofVvcFgEdiQ/tInBxtVJaFz35UGoUm95Am5cd+346tAkg5qWHRpK8HmDjn2GlJIcHC2
C0h19wdrCtfxMvw7nE4Etc1T+NCqaXvGRAPG0Zsxg6sf+KbBUTlJusCIQJokW8MNqpp9
ThJg==
Authentication-Results: strato.com;
dkim=none
X-RZG-AUTH: ":O2kGeEG7b/pS1Ey9Rna9iAZFrfz26y6zbtmqiE/f0+LThi5xYO8s9RmVPkxvrwQpRPenk8HVxDf4aQ=="
X-RZG-CLASS-ID: mo00
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
In-Reply-To: <YKrRLP46qmZ51Nzk@cskk.homeip.net>
Content-Language: de-DE
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <7dc017ca-c0a3-c66e-8b7c-ceea1c786c73@adminart.net>
X-Mailman-Original-References: <CACFDE8bsJe2BMNwsXAiGyxsMxNE+RuENj62GtfEzqodh5O_mMA@mail.gmail.com>
<YKrRLP46qmZ51Nzk@cskk.homeip.net>
 by: hw - Mon, 24 May 2021 06:21 UTC

On 5/24/21 12:03 AM, Cameron Simpson wrote:
> On 23May2021 21:02, Stestagg <stestagg@gmail.com> wrote:
>> On Sun, 23 May 2021 at 20:37, hw <hw@adminart.net> wrote:
>>> I don't know about shadowing.
>>
>> Shadowing is effectively saying “within this bit of code, (scope) I’m going
>> to use an already-used name for my own value”
>
> An example might make this clearer:
>
> x = 1 # global variable
>
> def f(a):
> x = a * 2
> return x
>
> Inside the function f() the name 'x" shadows the global "x"; references
> to "x" are to the function's local vairable. Which is very desireable.

If it works that way, I would consider it an entirely different
variable. Is there a way to access the global x from within a function
without transferring it through parameters of the function? Than can
also sometimes be useful.

>> If I have defeated a whole variable type
>>> by naming a variable like a variable type, I would think it is a bad
>>> idea for python to allow this without warning.
>>
>> There are some reasons why allowing this is quite nice. And there’s
>> actually a ton of corner cases to consider when thinking about changing the
>> rules
>
> As Stestagg has mentioned, there are also tools called linters which
> warn you about issues like this. Tools like pyflakes, pylint,
> pycodestyle all inspect your code for a wide variety of potential errors
> and discouraged habits. Not to mention tools like mypy which do type
> validation.

So you're saying one can't really go without those unless you want to
take the risk?

>> Interestingly python 3 made this a little bit better by stopping you from
>> rebinding (shadowing) a number of built ins, such as True and False.
>>
>> In your case, I agree that it is super confusing. One thing to learn to
>> look out for is if you assign to line 9, in <module>
print(type(str))
TypeError: 'int' object is not callablea name, then use that name on a
different
>> context, expecting it to be different, then that’s not likely to work as
>> you expect.
>>
>> It seems like a recipie
>>> for creating chaos.
>
> The runtime lets you do all sorts of things. Linters and type checkers
> exist to help you notice if you're writing such a recipe.
>
> There _are_ times when it is useful to shadow a builtin name. Not being
> able to prevents a useful activity.
>
> A common example in my own code is this:
>
> from cs.upd import Upd, print
>
> which shadows the print() builtin. The Upd class maintains status lines
> such as progress bars and so forth. It provides a print() function which
> withdraws the status lines, runs the builtin print, then restores them,
> allowing normal idiomatic use of print() in scripts making use of the
> status lines.
>
> Similar situations abound.

I'm not saying it shouldn't be allowed to defeat or to re-define stuff,
only that it shouldn't go through quietly.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor