Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

It is easier to write an incorrect program than understand a correct one.


devel / comp.lang.python / RE: RE: Which more Pythonic - self.__class__ or type(self)?

SubjectAuthor
o RE: RE: Which more Pythonic - self.__class__ or type(self)?<avi.e.gross

1
RE: RE: Which more Pythonic - self.__class__ or type(self)?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From:
Newsgroups: comp.lang.python
Subject: RE: RE: Which more Pythonic - self.__class__ or type(self)?
Date: Sat, 4 Mar 2023 16:46:44 -0500
Lines: 79
Message-ID: <mailman.2169.1677966409.20444.python-list@python.org>
References: <e3fa13c6-83fa-891e-ca6b-d3c80e940c21@gmail.com>
<7e9518b0-8e97-bcaf-24ba-e7f013690659@yahoo.co.uk>
<005801d94e01$1f9850f0$5ec8f2d0$@gmail.com>
<20230304074732.mdifd4r2bgfers62@hjp.at>
<001901d94ec0$1e587020$5b095060$@gmail.com>
<c87d0555-b5a1-9cf1-3331-e2f3d45bc9c3@yahoo.co.uk>
<003101d94ee2$d051d6a0$70f583e0$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de 1V1/SrH3FHGSIdhJr08YfAmHZczMHahMW2cnrB4TA93g==
Return-Path: <avi.e.gross@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=oY7NyhBA;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.111
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.78; '*S*': 0.00; '2023': 0.07; 'modules':
0.07; 'string': 0.07; 'suggestion': 0.07; 'used.': 0.07;
'better,': 0.09; 'construct': 0.09; 'received:108': 0.09; 'then.':
0.09; 'trivial': 0.09; 'problem.': 0.15; '"idiomatic"': 0.16;
'alan,': 0.16; 'c++': 0.16; 'calculations': 0.16; 'dominate':
0.16; 'drastically': 0.16; 'evaluated': 0.16; 'flickr': 0.16;
'gauld': 0.16; 'idiomatic': 0.16; 'labs.': 0.16; 'nested': 0.16;
'photo-blog': 0.16; 'pythonic': 0.16; 'received:209.85.160.170':
0.16; 'received:mail-qt1-f170.google.com': 0.16; 'statements.':
0.16; 'subject:Pythonic': 0.16; 'targets': 0.16; 'url-
ip:79.170.44.132/32': 0.16; 'url-ip:79.170.44/24': 0.16; 'url-
ip:79.170/16': 0.16; 'url-ip:79/8': 0.16; 'url:alan-g': 0.16;
'url:alan_gauld': 0.16; 'url:alangauldphotos': 0.16; 'wrote:':
0.16; 'python': 0.16; 'reached': 0.17; 'probably': 0.17; 'message-
id:@gmail.com': 0.18; "aren't": 0.19; 'url:amazon': 0.19; 'to:addr
:python-list': 0.20; 'language': 0.21; 'languages': 0.22;
'version': 0.23; 'code': 0.23; 'skip:- 10': 0.25; 'saying': 0.25;
'library': 0.26; 'normally': 0.26; 'output': 0.28; 'environment':
0.29; 'received:209.85.160': 0.31; 'community': 0.31; 'program':
0.31; 'think': 0.32; 'amounts': 0.32; 'half': 0.32; 'point,':
0.32; 'rapidly': 0.32; 'but': 0.32; 'there': 0.33; 'march': 0.33;
'someone': 0.34; 'core': 0.34; 'package': 0.34; 'header:In-Reply-
To:1': 0.34; 'received:google.com': 0.34; 'from:addr:gmail.com':
0.35; 'guide': 0.37; 'using': 0.37; 'received:209.85': 0.37;
'author': 0.37; 'way': 0.38; 'received:209': 0.39; 'changes':
0.39; 'quite': 0.39; 'least': 0.39; 'text': 0.39; 'ago': 0.39;
'mentioned': 0.39; 'use': 0.39; 'methods': 0.39; 'still': 0.40;
'alan': 0.40; 'match': 0.40; 'situation': 0.40; 'url-ip:99/8':
0.61; 'gave': 0.61; 'inline': 0.61; 'url-ip:99.86/16': 0.61;
'from:': 0.62; 'to:': 0.62; 'seen': 0.62; 'forward': 0.62;
'follow': 0.62; 'email addr:gmail.com': 0.63; 'once': 0.63;
'everything': 0.63; 'ago.': 0.64; 'becomes': 0.64; 'lost': 0.64;
're:': 0.64; 'subject:(': 0.64; 'your': 0.64; 'parts': 0.65;
'saw': 0.65; 'documents': 0.65; 'similar': 0.65; 'less': 0.65;
'let': 0.66; 'back': 0.67; 'caught': 0.67; 'accept': 0.67;
'subject:skip:s 10': 0.69; 'url:author': 0.69; 'within': 0.69;
'site': 0.70; 'ability': 0.71; 'ignore': 0.71; 'interesting':
0.71; 'addition': 0.71; 'longer': 0.71; 'features': 0.75; 'near':
0.76; 'religious': 0.76; 'sent:': 0.78; 'major': 0.78; 'left':
0.83; 'known': 0.84; 'ages': 0.84; 'art,': 0.84; 'assemble': 0.84;
'became': 0.84; 'catch': 0.84; 'crowd': 0.84; 'dozen': 0.84;
'saturday,': 0.84; 'similarly': 0.84; 'statement.': 0.84;
'stressed': 0.84; 'glad': 0.86; 'behind.': 0.91; 'formerly': 0.91;
'subject:type': 0.91; 'aspects': 0.93; 'subject:more': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112; t=1677966406;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=VGTkW4SIW3lI6x1hG0f4L8xG8tiuMYARVeE+VU/s14Y=;
b=oY7NyhBAYpLbn8TLF2TAgx4qmTOTHzgOrKt13jgePowpXAD7VWL/9T5/qFqfXwSMyD
Mfhk2k1LBB+ikh76iI6/sFjJCito8Qx78aE/bAfqGUaPj0l8u7OlCSHO0yNwNkzxEFxY
FgkTIpbBWmAVTIPg3pX0lnXqkk3JifZiomxsxrTMiZOAcV8WlhWPWD115DxGWjzSRzVa
fxGdskjXoD2PrHRhreHYyzlDraTIHg6W6QRiaRNl9EIxY+bDDUDWEr2Qz5z074+Ma8kI
A73o0hpRtzMKxHOQzPNoS4IxvLxjwQjo/rA+D4zFkOzELJs5xRD8U2p4Zs8M5sUSsxoy
D7cw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112; t=1677966406;
h=thread-index:content-language:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=VGTkW4SIW3lI6x1hG0f4L8xG8tiuMYARVeE+VU/s14Y=;
b=5SQPajLIeJKBczZxgBfpkDg7m2GwmcPaQhmMToVWsG+PFKKJmphV4sQKGU5+VxpaNH
GeZfCSJ6xCoew0Zkr5X77yM68FWckAOlIvOQ4hdgQ36zavd6SfuoUtkarE6njREA6PRR
jCLc5nggJ3DDN8OPqkYk4leb5AW7q3Rc6EGzafUBAcaMgFuk6YYfw01mfFSyCTctWARZ
lVdQyvSTZgZ7xUcpIwmw/GmKUPvvEDqgpTzwjv6DumKuUdQHI5rbWxwPMYfJ58cKf1WQ
MtBSGyxsbyGsPNrVqIPaRXBGJDpQSiDNm1OdQg1zbq+nFa9Lfb1zyDj+DMKfwOiB0v7l
pnRA==
X-Gm-Message-State: AO0yUKULMf92NTBHmaEGjj8VdaMAJhG3YuKmFBDvDh5IG9lu32AB6fXz
XCZlvIrB/PBYpX4eIHcseuZmkOykVik=
X-Google-Smtp-Source: AK7set9xoJdWhwZkCr8kp7iMjJnSz/PbxFlPxNyfQ8QUwSyJRqKrvdgHL90JXqNuD0c0SqUINhStMQ==
X-Received: by 2002:a05:622a:1b8a:b0:3bf:aa39:982b with SMTP id
bp10-20020a05622a1b8a00b003bfaa39982bmr10357230qtb.32.1677966406347;
Sat, 04 Mar 2023 13:46:46 -0800 (PST)
In-Reply-To: <c87d0555-b5a1-9cf1-3331-e2f3d45bc9c3@yahoo.co.uk>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQIhnTawdMEPaSLCQZ9+zauIBzeR4gL7siwGAjcUYuQBo5gJ5gJ8R0VPAit7Y1it/pSF4A==
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: <003101d94ee2$d051d6a0$70f583e0$@gmail.com>
X-Mailman-Original-References: <e3fa13c6-83fa-891e-ca6b-d3c80e940c21@gmail.com>
<7e9518b0-8e97-bcaf-24ba-e7f013690659@yahoo.co.uk>
<005801d94e01$1f9850f0$5ec8f2d0$@gmail.com>
<20230304074732.mdifd4r2bgfers62@hjp.at>
<001901d94ec0$1e587020$5b095060$@gmail.com>
<c87d0555-b5a1-9cf1-3331-e2f3d45bc9c3@yahoo.co.uk>
 by: - Sat, 4 Mar 2023 21:46 UTC

Alan,

I got divorced from the C++ crowd decades ago when I left Bell Labs. You are making me glad I did!

I do accept your suggestion that you can be idiomatic if you follow the common methods of whatever language you use. That will take you quite far as long as you are not a total slave to it.

But I note some idioms catch on and some are imposed and some become almost moot. I am not sure which aspects of C++ have changed drastically and may go re-study the modern version as I was a very early adoptee within AT&T and saw changes even back then.

But I consider something like the half dozen or so major print variants in python and wonder how much longer some of them will be seen as worth using, let alone idiomatic. Something like an fstring may dominate for many purposes.

I know in R, that I used to use some convoluted methods to assemble output that I often now ignore once a "glue" package gave me something similar to fstring abilities where all kinds of variables and calculations can now be embedded withing a string to be dynamically evaluated in your current environment. Some of the documents I write now similarly embed parts of programs and also have an inline ability to evaluate small amounts of code in one of many languages that inserts directly into the text as it is being typeset.

So I see moving targets where what was formerly at or near the state of the art, becomes passé. So much of my early work rapidly became trivial or irrelevant or never caught on or became lost in an environment I no longer used. To keep going forward often involves leaving things behind.

Some new features in Python will be interesting to watch. I mentioned the match statement. I was using a similar construct in a JVM language called SCALA ages ago. There it was a sort of core part of the language and often replaced constructs normally used by other languages such as many simple or nested IF statements. I am sure someone will point out where they borrowed parts from or who did it better, but what I am saying is that I want to see if it becomes an exotic addition to Python in a way that loosely melds, or if it becomes the PYTHONIC way ...

-----Original Message-----
From: Alan Gauld <learn2program@gmail.com>
Sent: Saturday, March 4, 2023 1:38 PM
To: avi.e.gross@gmail.com; python-list@python.org
Subject: Re: RE: Which more Pythonic - self.__class__ or type(self)?

On 04/03/2023 17:38, avi.e.gross@gmail.com wrote:
>
> Of course each language has commonly used idioms
>

That's the point, the correct term is probably "idiomatic"
rather than "pythonic" but it is a defacto standard that
idiomatic Python has become known as Pythonic. I don't
think that's a problem. And at least we aren't in the C++
situation where almost everything that was idiomatic up
until 1999 is now deemed an anti-pattern and they have
standard library modules to try and guide you to use the
"correct" idioms!

But being Pythonic is still a much more loose term and
the community less stressed about it than their C++
cousins where it has almost reached a religious fervour!

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor