Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3937
| From | harrismh777 <harrismh777@charter.net> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: learnpython.org - an online interactive Python tutorial |
| References | (1 earlier) <201104211710.19587.akabaila@pcug.org.au> <BANLkTimCG4v8j+St0aSaqkMomhyHp5VYhA@mail.gmail.com> <mailman.687.1303371055.9059.python-list@python.org> <yn9sp.39116$yp3.16271@newsfe09.iad> <4db3720a$0$29978$c3e8da3$5496439d@news.astraweb.com> |
| Message-ID | <XwMsp.3030$I64.813@newsfe04.iad> (permalink) |
| Date | 2011-04-23 22:10 -0500 |
Steven D'Aprano wrote:
> If that's a "serious" flaw, it's a flaw shared by the vast majority of
> programming languages.
Yes, agreed.
> As for the question of "consistency", I would argue the opposite: that
> auto-promoting strings to numbers arguably is useful, but that is what is
> inconsistent, not the failure to do so.
I see your point... but I'll push back just a little, in a minute...
>
> Consider...
>
> "one" + 1
>
> "[1, 2, 3]" + [4]
>
> "[2, 40, 10, 3]".sort()
Yes, maybe problems all. Again, I see the point of your argument,
and I do not necessarily disagree...
I've been giving this some more thought. From the keyboard, all I am
able to enter are character strings (not numbers). Presumably these are
UTF-8 strings in python3. If I enter the character string 57 then
python converts my character string input and returns an reference to
object 57. If I enter the keyboard character string 34567 then the
python interpreter converts my character string input into an object
(creates a new object) (34567) returning a reference to that object (a
type int). If I enter the keyboard character string 3.14 the python
interpreter creates a float object (converts my string into a float) and
returns a reference to the object. In any event, keyboard character
strings that just happen to be numbers, are converted into int or float
objects by the interpreter, from the keyboard, automatically.
My idea for consistency is this: since the interpreter converts int
to float, and float to imaginary (when needed), then it does (at least
in a limited way) type promoting. So, it is consistent with the input
methods generally to promote numeric string input to int --> float -->
imaginary, as needed, therefore it is also consistent to promote a
numeric string (that which I used to call a REXX number) into an int -->
float --> imaginary, as implied by the statement(s). I am not asking for
weak typing generally... nor am I thinking that all promotions are a
good thing... just numeric string to int --> float --> imaginary when it
makes sense. In any event, the programmer should be able to overide the
behavior explicitly. On the other hand, I do see your point regarding
performance. Otherwise,...
... type promotions really would not cause any more confusion for
programmers who now know that int will be converted to float and use
that knowledge conveniently....
I do believe that explicit is better than implicit (generally)...
but not in this case. I am noticing a pattern in some of the responses,
and that pattern is that some folks would find this appealing if not
overtly convenient. The question IS, which I am not able to answer at
this point, whether the convenience would actually cause other
difficulties that would be worse...?
kind regards,
m harris
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
learnpython.org - an online interactive Python tutorial Ron <ron.reiter@gmail.com> - 2011-04-20 10:15 -0700
Re: learnpython.org - an online interactive Python tutorial Matty Sarro <msarro@gmail.com> - 2011-04-20 13:57 -0400
Re: learnpython.org - an online interactive Python tutorial Terry Reedy <tjreedy@udel.edu> - 2011-04-20 18:12 -0400
Re: learnpython.org - an online interactive Python tutorial Chris Angelico <rosuav@gmail.com> - 2011-04-21 14:07 +1000
Re: learnpython.org - an online interactive Python tutorial Algis Kabaila <akabaila@pcug.org.au> - 2011-04-21 17:10 +1000
Re: learnpython.org - an online interactive Python tutorial harrismh777 <harrismh777@charter.net> - 2011-04-21 02:29 -0500
Re: learnpython.org - an online interactive Python tutorial Chris Angelico <rosuav@gmail.com> - 2011-04-21 17:19 +1000
Re: learnpython.org - an online interactive Python tutorial Heiko Wundram <modelnine@modelnine.org> - 2011-04-21 09:30 +0200
Re: learnpython.org - an online interactive Python tutorial harrismh777 <harrismh777@charter.net> - 2011-04-22 01:38 -0500
Re: learnpython.org - an online interactive Python tutorial Chris Angelico <rosuav@gmail.com> - 2011-04-22 17:08 +1000
Re: learnpython.org - an online interactive Python tutorial harrismh777 <harrismh777@charter.net> - 2011-04-23 19:37 -0500
Re: learnpython.org - an online interactive Python tutorial Cameron Simpson <cs@zip.com.au> - 2011-04-24 12:23 +1000
Re: learnpython.org - an online interactive Python tutorial harrismh777 <harrismh777@charter.net> - 2011-04-23 21:39 -0500
Re: Re: learnpython.org - an online interactive Python tutorial Dave Angel <davea@ieee.org> - 2011-04-24 07:16 -0400
Re: learnpython.org - an online interactive Python tutorial harrismh777 <harrismh777@charter.net> - 2011-04-25 01:14 -0500
Re: learnpython.org - an online interactive Python tutorial Mel <mwilson@the-wire.com> - 2011-04-22 09:07 -0400
Re: learnpython.org - an online interactive Python tutorial Roy Smith <roy@panix.com> - 2011-04-22 09:22 -0400
Re: learnpython.org - an online interactive Python tutorial Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-04-22 23:28 -0700
Re: learnpython.org - an online interactive Python tutorial flebber <flebber.crue@gmail.com> - 2011-04-23 05:49 -0700
Re: learnpython.org - an online interactive Python tutorial Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-04-23 11:01 -0700
Re: learnpython.org - an online interactive Python tutorial rantingrick <rantingrick@gmail.com> - 2011-04-23 08:16 -0700
Re: learnpython.org - an online interactive Python tutorial rantingrick <rantingrick@gmail.com> - 2011-04-23 08:21 -0700
Re: learnpython.org - an online interactive Python tutorial Dotan Cohen <dotancohen@gmail.com> - 2011-04-23 19:51 +0300
Re: learnpython.org - an online interactive Python tutorial Tim Chase <python.list@tim.thechases.com> - 2011-04-23 12:25 -0500
Re: learnpython.org - an online interactive Python tutorial Westley Martínez <anikom15@gmail.com> - 2011-04-23 12:38 -0700
Re: learnpython.org - an online interactive Python tutorial Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-24 00:42 +0000
Re: learnpython.org - an online interactive Python tutorial Chris Angelico <rosuav@gmail.com> - 2011-04-24 11:35 +1000
Re: learnpython.org - an online interactive Python tutorial Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-24 08:13 +0000
Re: learnpython.org - an online interactive Python tutorial Chris Angelico <rosuav@gmail.com> - 2011-04-24 18:21 +1000
Re: learnpython.org - an online interactive Python tutorial harrismh777 <harrismh777@charter.net> - 2011-04-23 22:10 -0500
Re: learnpython.org - an online interactive Python tutorial Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-24 09:18 +0000
Re: learnpython.org - an online interactive Python tutorial harrismh777 <harrismh777@charter.net> - 2011-04-25 01:20 -0500
Re: learnpython.org - an online interactive Python tutorial Terry Reedy <tjreedy@udel.edu> - 2011-04-25 11:43 -0400
Re: learnpython.org - an online interactive Python tutorial Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-26 13:06 +1200
Re: learnpython.org - an online interactive Python tutorial jmfauth <wxjmfauth@gmail.com> - 2011-04-24 08:15 -0700
Re: learnpython.org - an online interactive Python tutorial Westley Martínez <anikom15@gmail.com> - 2011-04-21 07:14 -0700
Re: learnpython.org - an online interactive Python tutorial MRAB <python@mrabarnett.plus.com> - 2011-04-21 17:13 +0100
Re: learnpython.org - an online interactive Python tutorial Dotan Cohen <dotancohen@gmail.com> - 2011-04-23 16:45 +0300
csiph-web