Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Function reject.


devel / comp.lang.python / Re: Weak Type Ability for Python

SubjectAuthor
o Re: Weak Type Ability for PythonMRAB

1
Re: Weak Type Ability for Python

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!lilly.ping.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: python@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: Weak Type Ability for Python
Date: Thu, 13 Apr 2023 03:28:37 +0100
Lines: 79
Message-ID: <mailman.59.1681352921.20750.python-list@python.org>
References: <CAMpB_8R6EMj4nevu2ucjvTR5X=CL2ktYxAoVnxOZG=46koaR=Q@mail.gmail.com>
<CAPTjJmoQgJ+8Dgu-1TpM=YL4qS+8bOk=J-eLvL0k=uY=vAJ8bQ@mail.gmail.com>
<bab80f52-8ae5-ffd6-d7f2-ccee7cfdbdde@tompassin.net>
<00a201d96dad$64ef8990$2ece9cb0$@gmail.com>
<e9f694a5-dbe6-926e-085d-346cb374ae64@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de mM8/9P+a/rnMVqf/xKCBswUCqh4VSikg6Se+fkrWBa/g==
Return-Path: <python@mrabarnett.plus.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=plus.com header.i=@plus.com header.b=ENsJ4paT;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python?': 0.03; '2023':
0.07; 'string': 0.07; 'angelico': 0.09; 'be?': 0.09; 'derived':
0.09; 'fail.': 0.09; 'from:addr:python': 0.09; 'methods,': 0.09;
'numeric': 0.09; 'operators': 0.09; 'originally': 0.09;
'received:192.168.1.64': 0.09; 'subject:Python': 0.12; '>>>>>>':
0.16; 'ali': 0.16; 'chrisa': 0.16; 'conversion': 0.16;
'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16;
'integer': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'perl,':
0.16; 'presumably': 0.16; 'received:plus.net': 0.16; 'right.':
0.16; 'subject:Type': 0.16; 'wrote:': 0.16; 'python': 0.16;
'instead': 0.17; 'probably': 0.17; 'pm,': 0.19; 'thu,': 0.19;
'to:addr:python-list': 0.20; 'all,': 0.20; 'languages': 0.22;
'code': 0.23; 'command': 0.23; 'skip:- 10': 0.25; 'seems': 0.26;
'space': 0.26; 'behavior': 0.26; 'object': 0.26; 'suspect': 0.26;
'wednesday,': 0.26; '>>>': 0.28; 'chris': 0.28; 'fact': 0.28;
'thinking': 0.28; 'it,': 0.29; 'error': 0.29; 'header:User-
Agent:1': 0.30; 'question': 0.32; 'answers': 0.32; 'guess': 0.32;
'objects': 0.32; 'python-list': 0.32; 'specified': 0.32;
'received:192.168.1': 0.32; 'but': 0.32; 'subject:for': 0.33;
'there': 0.33; 'header:In-Reply-To:1': 0.34; 'automatic': 0.35;
'question.': 0.35; 'others': 0.37; 'received:192.168': 0.37;
'way': 0.38; 'could': 0.38; 'two': 0.39; 'quite': 0.39; 'added':
0.39; 'use': 0.39; 'neither': 0.39; 'define': 0.40; 'double':
0.40; 'wants': 0.40; 'want': 0.40; 'should': 0.40; 'method': 0.61;
'from:': 0.62; 'to:': 0.62; 'received:212': 0.62; 'subject': 0.63;
'email addr:gmail.com': 0.63; 'simply': 0.63; 'between': 0.63;
're:': 0.64; 'your': 0.64; 'named': 0.65; 'types': 0.67; 'forget':
0.67; 'generally': 0.67; 'accept': 0.67; 'choose': 0.67;
'ability': 0.71; 'addition': 0.71; 'easy': 0.74; 'sent:': 0.78;
'left': 0.83; 'happens': 0.84; '(such': 0.84; 'converts': 0.84;
'posed': 0.84; 'strings': 0.84; 'sure.': 0.84; 'weak': 0.84;
'written,': 0.84; 'of:': 0.91; 'padding': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1681352918; bh=UOZplMhAvv85cy9CcByx4aWEya12nQ0omLPgzrsc7oQ=;
h=Date:Subject:To:References:From:In-Reply-To;
b=ENsJ4paTr1weiE6VdCMIja2OdhTsTR2A+j67KweS7ZEs7VuN2xGCkfJs28jWimrCo
9KK2sc8C539JvItrQUPWvCDps0eFhfSJ7etFfMvrqqszuITaFmxW8YMz9Sdcwdylep
Q7yKQwylG32DNCuOtC5mk+nUiK2hv8zRE5zLbjg2YiRiEnfcrUGBb57BfURYdu3awU
GOjqwfgaQKYKJmoPNi1v4Um8SEeEg0NZ7H8HlIRpXfsl8KucsRKlNngEqs95dlwueo
/cCI3pN4T6P1eK8dG2PpwN8vTqU3DrfGj7Clmiplk4+KoSEi8pmB4H84OfsjNDvDOq
5Yb3jmUeYEtGw==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=Y9vrDzSN c=1 sm=1 tr=0 ts=643768d6
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=pGLkceISAAAA:8 a=8AHkEIZyAAAA:8 a=wN1x2I8yDiXF4kqOeMUA:9
a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-GB
In-Reply-To: <00a201d96dad$64ef8990$2ece9cb0$@gmail.com>
X-CMAE-Envelope: MS4xfOZZ6sJxqNP/qJ8Jx0RKrZkTwpzRFGMBNTFqqdVO62zRNgMdGnaaQo/B/wp6AohWwooQsyNuQwwd14q5B/U4zgrR+hoopb+ZZfwUtox7WHergTyhsCtO
BROZoHEO845aXbECX2bBxRULTZxFcm7w4wU5cpmGpY78huOIfzSdgs/Zwln/KnvyqQa4S495e0AhTDIEVjZXQVEvuypvw3V8NfA=
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: <e9f694a5-dbe6-926e-085d-346cb374ae64@mrabarnett.plus.com>
X-Mailman-Original-References: <CAMpB_8R6EMj4nevu2ucjvTR5X=CL2ktYxAoVnxOZG=46koaR=Q@mail.gmail.com>
<CAPTjJmoQgJ+8Dgu-1TpM=YL4qS+8bOk=J-eLvL0k=uY=vAJ8bQ@mail.gmail.com>
<bab80f52-8ae5-ffd6-d7f2-ccee7cfdbdde@tompassin.net>
<00a201d96dad$64ef8990$2ece9cb0$@gmail.com>
 by: MRAB - Thu, 13 Apr 2023 02:28 UTC

On 2023-04-13 03:12, avi.e.gross@gmail.com wrote:
> As originally written, the question posed has way too many possible answers
> but the subject line may give a hint. Forget printing.
>
> The Python statement
> 1 + "a"
>
> SHOULD fail. The first is an integer and the second is string. These two
> are native Python objects that neither define what to do if they are paired
> with an object of the other type on the left or the right.
>
> In any case, what should the answer be? Since "a" has no integer value, it
> presumably was intended to be the string "1a".
>
> So why NOT use the built-in conversion and instead of:
>
> print(x+y) # where x=1, y='a'
>
> It should be:
>
> print(str(x) + y)
>
> Could this behavior be added to Python? Sure. I wonder how many would not
> like it as it often will be an error not caught!
>
> If you defined your own object derived from string and added a __radd__()
> method then the method could be made to accept whatever types you wanted
> (such as integer or double or probably anything) and simply have code that
> converts it to the str() representation and then concatenates them with, or
> if you prefer without, any padding between.
>
> I suspect the OP is thinking of languages like PERL or JAVA which guess for
> you and make such conversions when it seems to make sense.
>
In the case of Perl, there are distinct operators for addition and
string concatenation, with automatic type conversion (non-numeric
strings have a numeric value of 0, which can hide bugs).

> Python does not generally choose that as it is quite easy to use one of so
> many methods, and lately an f-string is an easy way as others mentioned.
>
>
> -----Original Message-----
> From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
> Behalf Of Thomas Passin
> Sent: Wednesday, April 12, 2023 2:52 PM
> To: python-list@python.org
> Subject: Re: Weak Type Ability for Python
>
> On 4/12/2023 1:11 PM, Chris Angelico wrote:
>> On Thu, 13 Apr 2023 at 03:05, Ali Mohseni Roodbari
>> <ali.mohseniroodbari@gmail.com> wrote:
>>>
>>> Hi all,
>>> Please make this command for Python (if possible):
>>>
>>>>>> x=1
>>>>>> y='a'
>>>>>> wprint (x+y)
>>>>>> 1a
>>>
>>> In fact make a new type of print command which can print and show strings
>>> and integers together.
>>>
>>
>> Try:
>>
>> print(x, y)
>>
>> ChrisA
>
> It puts a space between "1" and "a", whereas the question does not want
> the space. print(f'{x}{y}') would do it, but only works for variables
> named "x" and "y".
>
> As happens so often, the OP has not specified what he actually wants to
> do so we can only answer the very specific question.
>


devel / comp.lang.python / Re: Weak Type Ability for Python

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor