Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

You can't have everything... where would you put it? -- Steven Wright


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

SubjectAuthor
o Re: learning python ...Chris Angelico

1
Re: learning python ...

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: learning python ...
Date: Mon, 24 May 2021 23:54:03 +1000
Lines: 111
Message-ID: <mailman.296.1621864458.3087.python-list@python.org>
References: <143d4163-faf5-3794-095d-f28e85a18c58@adminart.net>
<s8e3bn$105v$1@ciao.gmane.io>
<6730da2c-1440-ad59-7494-b5ce5b5bccae@adminart.net>
<CACFDE8bsJe2BMNwsXAiGyxsMxNE+RuENj62GtfEzqodh5O_mMA@mail.gmail.com>
<5cec7f52-a66b-608c-4816-a3d8816658b2@adminart.net>
<CAPTjJmpOXQ0m4-=uty96t+K9VCvZ_7UWdzPOKYw-vocRFq50eQ@mail.gmail.com>
<6ad46670-a0b4-d556-3b03-284ffa451c89@adminart.net>
<CAPTjJmr1z8Nyd2kbfrrc3X3wjCk80dt58-bSR=onCnALhbHjFA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 5Y0g/jeZPJbo+e3vjvRa9g98FLjehtS4g1IZDmfLBBjw==
Return-Path: <rosuav@gmail.com>
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=gmail.com header.i=@gmail.com header.b=CBU9Keq7;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python?': 0.03;
'variable': 0.05; 'subject:python': 0.06; 'else.': 0.07; 'float':
0.07; 'happened': 0.07; 'language,': 0.07; 'python.': 0.07;
'angelico': 0.09; 'check,': 0.09; 'compiler': 0.09; 'fundamental':
0.09; 'int': 0.09; 'messages.': 0.09; 'perspective': 0.09;
'posts.': 0.09; 'trivial': 0.09; 'types.': 0.09; "can't": 0.14;
'#include': 0.16; '(it': 0.16; '9:52': 0.16; 'are.': 0.16; 'by,':
0.16; 'char': 0.16; 'checks,': 0.16; 'chrisa': 0.16; 'feature.':
0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'integer': 0.16; 'python;': 0.16; 'quietly': 0.16; 're-define':
0.16; 'received:209.85.166.50': 0.16; 'received:mail-
io1-f50.google.com': 0.16; 'reuse': 0.16; 'see?': 0.16; 'useful.':
0.16; 'void': 0.16; 'wrote:': 0.16; 'says': 0.16; 'syntax': 0.16;
'python': 0.16; 'it?': 0.18; 'all,': 0.19; "aren't": 0.20;
'maybe': 0.20; 'issue': 0.20; 'programming': 0.21; 'python,':
0.21; 'language': 0.22; 'languages': 0.23; 'to:addr:python-list':
0.23; 'probably': 0.24; 'suggest': 0.25; '>>>': 0.26; 'chris':
0.26; 'examples': 0.26; 'seems': 0.26; 'perform': 0.27; 'else':
0.27; 'saying': 0.28; 'error': 0.28; 'this.': 0.29; 'there': 0.31;
'think': 0.31; 'but': 0.31; 'am,': 0.31; "doesn't": 0.32; "i'm":
0.32; 'difference': 0.32; 'else,': 0.32; 'here,': 0.32;
'to:name:python': 0.32; 'message-id:@mail.gmail.com': 0.33;
'using': 0.33; 'received:209.85.166': 0.33; 'header:In-Reply-
To:1': 0.33; 'functions': 0.34; 'particular': 0.34; 'same': 0.34;
'received:google.com': 0.34; 'well,': 0.35; '"if': 0.35;
'understood': 0.35; 'from:addr:gmail.com': 0.35; 'cases': 0.37;
'neither': 0.37; 'two': 0.37; "that's": 0.37; 'change': 0.37;
'really': 0.37; 'received:209.85': 0.38; "it's": 0.38;
'something': 0.38; 'received:209': 0.38; 'word': 0.38; 'use':
0.38; 'does': 0.38; 'means': 0.40; 'called': 0.40; 'nor': 0.40;
'example': 0.40; 'test': 0.40; 'programs': 0.40; 'all.': 0.40;
'well.': 0.61; 'simply': 0.62; 'gives': 0.63; 'rules': 0.63;
'true': 0.63; 'types': 0.63; 'ever': 0.63; 'everything': 0.64;
'your': 0.64; 'becomes': 0.65; 'depending': 0.65; 'above': 0.65;
'look': 0.66; 'bad': 0.68; 'that,': 0.68; 'did,': 0.69; 'exists':
0.69; 'above,': 0.71; 'claim': 0.71; 'manage': 0.74; 'easy': 0.75;
'caught': 0.75; 'breaking': 0.78; '2021': 0.84; '25;': 0.84;
'assumptions,': 0.84; 'one:': 0.84; 'perspective.': 0.84;
'ridiculous.': 0.84; 'type.': 0.84; 'aspects': 0.93; 'keywords':
0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=t6mRqKXcLszHuwO35Qk4qQPsBEDoIVhmbz5F6exwDDE=;
b=CBU9Keq7dDh7jQIw9yruH5ZLmC+OdGnTki3Scpi8VwZ62SevQkDlAXH91vs5LNDNiM
cFsQZMWZB+Kt0SeoQ7l2Wmlv/wfq3p+w6MpPqDuRKq1b/22zZRYhPmKGdeMDI/4JHT60
KvzFX4OK7pf9EzXGkfJ/RXwrtiL6nIYeTnZf0UhhRiNDimyV6oxpd55GpcS6KVOPWcDD
0EPfOAYMbRdgsuWSlavdh2BnqPGJ6Wf/OHmv8JyS2nC8UIXlq8HE/L+WuXG0a3sh5rIZ
1EkHrCYN0a6Pga37xldMoe3c8aHwPPXg+YA6Lykz9vOXJAhrEnK4o/P5IhZmRiBH69Ii
d90A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=t6mRqKXcLszHuwO35Qk4qQPsBEDoIVhmbz5F6exwDDE=;
b=lWkNUj1FIDW7TTrOsrUQu9o4de324NLJgCShCZy9Sgaz1JOeXM2os2G5zVGQFaYoU2
qAD7aJmFGLwpIFriiPJnDQp+PJwvU4CiHDOkZUSuJAfleisygtFzQYP9eW9vCBrdkj2g
QMEgZv2FVOPiKZGOCF3ntcIH2Y/LU8i89IgsZYjW02VV+ltK9Q41X4UR7pJVg4zU4vrY
tOHa0j3U+PjtkzKJPpKFrIPW8e1s4fN4AhJa0+H49Futb/uhC11UcVgu7ZTKz2Xt5mVx
LU/cWGH5DPo3B22jW78QGc7VM3r0wei3Mq5aZ1kEjOtuKN4wnN5+DOGpB20pi1ouzR5u
Mulg==
X-Gm-Message-State: AOAM530pRve1PjHVw0ZMwO53Gq3X51soaunBOlWCudsnurWgi/5o7+4F
HeirdVOmKui5yPAy1VXl5exm8mLycBZ2iEOC3uutjNRGrU3Kew==
X-Google-Smtp-Source: ABdhPJwqXmIuCp23+evGRI9Uj+jvw2wjdHBI6mELjVyOrehQKhTtvcmN6ezRdU5bJVX7EeBOp/8fPzv9d/IJhl7qQnc=
X-Received: by 2002:a02:b685:: with SMTP id i5mr25090406jam.114.1621864455239;
Mon, 24 May 2021 06:54:15 -0700 (PDT)
In-Reply-To: <6ad46670-a0b4-d556-3b03-284ffa451c89@adminart.net>
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: <CAPTjJmr1z8Nyd2kbfrrc3X3wjCk80dt58-bSR=onCnALhbHjFA@mail.gmail.com>
X-Mailman-Original-References: <143d4163-faf5-3794-095d-f28e85a18c58@adminart.net>
<s8e3bn$105v$1@ciao.gmane.io>
<6730da2c-1440-ad59-7494-b5ce5b5bccae@adminart.net>
<CACFDE8bsJe2BMNwsXAiGyxsMxNE+RuENj62GtfEzqodh5O_mMA@mail.gmail.com>
<5cec7f52-a66b-608c-4816-a3d8816658b2@adminart.net>
<CAPTjJmpOXQ0m4-=uty96t+K9VCvZ_7UWdzPOKYw-vocRFq50eQ@mail.gmail.com>
<6ad46670-a0b4-d556-3b03-284ffa451c89@adminart.net>
 by: Chris Angelico - Mon, 24 May 2021 13:54 UTC

On Mon, May 24, 2021 at 11:35 PM hw <hw@adminart.net> wrote:
>
> On 5/24/21 9:52 AM, Chris Angelico wrote:
> > Does C give you a warning if you create a function-local variable
> > called "printf"? No, and it shouldn't. Does any other language
> > complain if you use its scoping rules to reuse a name? Nope. Does
> > Python? As above, no.
>
> Try the equivalent of above python in C:
>
>
> void foo(void) {
> int int = 25;
> printf("int: %d\n", int);
> }
>
> int main(int argc, char **argv) {
> foo();
> }

I did specifically mention "printf", which works just fine, as you see below.

> I don't know which C compiler you're using; gcc doesn't compile this and
> gives several error messages. Python quietly allows things like this
> without any warning at all, and I'm saying that's a bad thing and that
> python seems unfinished because it doesn't even give a warning in cases
> like this.

You keep using that word "unfinished". I do not think it means what
you think it does.

Python has keywords. C has keywords. In Python, "None" is a keyword,
so you can't assign to it; in C, "int" is a keyword, so you can't
assign to it. There is no fundamental difference here, and the two
languages even have roughly the same number of keywords (35 in current
versions of Python; about 40 or 50 in C, depending on the exact
specification you're targeting). The only difference is that, in
Python, type names aren't keywords. You're getting caught up on a
trivial difference that has happened to break one particular test that
you did, and that's all.

> I don't know REXX, and I'm not sure what the equivalent would be in
> elisp. The issue doesn't exist in perl. It may be intentionally so
> that python makes it easy to defeat fundamental aspects of the language
> simply by, accidentially or intentionally, re-defining them without
> warning, and even if that is so, nobody else has to like a feature like
> that just because you do like it.

REXX doesn't have keywords at all. (It has language syntax words, but
everything is contextual, so you can quite happily say "if = 1" and
then "if if" becomes valid.) Perl has keywords, just like everything
else, but not for data types.

This is NOT something fundamental to the language that is "defeated".
You have made it harder to perform isinstance checks, but that's
neither fundamental nor defeated by this shadowing. The integer type
still exists - you just made a new variable with the name "int". The
float type still exists - you just made a new variable with the name
"float".

> Maybe you can show how this is a likeable feature. I already understood
> that you can somehow re-define functions in python and I can see how
> that can be useful. You can do things like that in elisp as well. But
> easily messing up built-in variable types like that is something else.
> Why would I want that in a programming language, and why would I want to
> use one that allows it?

Because all you did was mess with the *name* of the type. It's not
breaking the type system at all. Most Python programs manage just fine
without ever doing an isinstance check, and even if you do have to,
it's possible to refer to the type in other ways:

>>> (1).__class__
<class 'int'>

>>> int = 42
>>> isinstance(int, (1).__class__)
True

See? Not broken. All you did was change the meaning of the name "int",
by assigning to it.

> Your claim that I'm insulting python or anoyone is ridiculous.
> According to your logic, C is insulting python. I suggest you stop
> making assumptions.

The C language never says that Python is "unfinished". I'm not making
assumptions, I'm reading your posts.

> The example you want is probably this one:
>
>
> #include <stdio.h>
>
> void foo(void) {
> int printf = 25;
> printf("int: %d\n", printf);
> }
>
> int main(int argc, char **argv) {
> foo();
> }
>
>
> Perhaps you can't see how both examples are different because you're
> looking at things from a python perspective.

Well, look at them from a language design perspective and tell me how
different they really are.

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor