• Re: Python (was Re: Recent history of vi)

    From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.os.linux.misc,alt.folklore.computers,comp.lang.python on Sun Dec 14 02:05:54 2025
    From Newsgroup: comp.lang.python

    On 13 Dec 2025 11:55:35 GMT, Stéphane CARPENTIER wrote:

    Everything else is just a lot of lies. They pretend it's not strongly
    typed, but in the real world you will only encounter a lot of issue if
    you believe that.

    Think about why both JavaScript and PHP need a “===” operator, while Python does not.

    It’s because Python is strongly typed.

    ... there are a lot of libraries helping developers.

    Other languages have done that before. Why do you think Python has been
    able to leapfrog every prior language in this regard? Perl had a lot of libraries to its name (still does), and yet that no longer seems to be a
    good enough reason to continue using Perl, simply because Python now does
    it better.

    It’s because Python has such a strong core language on which to build extensions. The libraries tend to make heavy use of this.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From candycanearter07@candycanearter07@candycanearter07.nomail.afraid to comp.os.linux.misc,alt.folklore.computers,comp.lang.python on Fri Dec 19 13:30:03 2025
    From Newsgroup: comp.lang.python

    Lawrence D’Oliveiro <ldo@nz.invalid> wrote at 02:05 this Sunday (GMT):
    On 13 Dec 2025 11:55:35 GMT, Stéphane CARPENTIER wrote:

    Everything else is just a lot of lies. They pretend it's not strongly
    typed, but in the real world you will only encounter a lot of issue if
    you believe that.

    Think about why both JavaScript and PHP need a “===” operator, while Python does not.

    It’s because Python is strongly typed.

    I thought it was because JS was too liberal with type-casting to make
    things true, and the JS devs didn't want to break compatibility.

    ... there are a lot of libraries helping developers.

    Other languages have done that before. Why do you think Python has been
    able to leapfrog every prior language in this regard? Perl had a lot of libraries to its name (still does), and yet that no longer seems to be a good enough reason to continue using Perl, simply because Python now does
    it better.

    It’s because Python has such a strong core language on which to build extensions. The libraries tend to make heavy use of this.


    It is quite nice, yeah.
    --
    user <candycane> is generated from /dev/urandom
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.os.linux.misc,alt.folklore.computers,comp.lang.python on Fri Dec 19 20:58:10 2025
    From Newsgroup: comp.lang.python

    On Fri, 19 Dec 2025 13:30:03 -0000 (UTC), candycanearter07 wrote:

    Lawrence D’Oliveiro <ldo@nz.invalid> wrote at 02:05 this Sunday (GMT):

    Think about why both JavaScript and PHP need a “===” operator, while
    Python does not.

    It’s because Python is strongly typed.

    I thought it was because JS was too liberal with type-casting to make
    things true, and the JS devs didn't want to break compatibility.

    Is there some other interpretation of “strongly typed”?
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From rbowman@bowman@montana.com to comp.os.linux.misc,alt.folklore.computers,comp.lang.python on Sat Dec 20 05:48:58 2025
    From Newsgroup: comp.lang.python

    On Fri, 19 Dec 2025 20:58:10 -0000 (UTC), Lawrence D’Oliveiro wrote:

    On Fri, 19 Dec 2025 13:30:03 -0000 (UTC), candycanearter07 wrote:

    Lawrence D’Oliveiro <ldo@nz.invalid> wrote at 02:05 this Sunday (GMT):

    Think about why both JavaScript and PHP need a “===” operator, while >>> Python does not.

    It’s because Python is strongly typed.

    I thought it was because JS was too liberal with type-casting to make
    things true, and the JS devs didn't want to break compatibility.

    Is there some other interpretation of “strongly typed”?

    I haven't worked with them enough to know if type hints are useful or if they're like TypeScript's attempt to rein in JavaScript. It's like the
    dunders that are like saying 'Please mugger, don't take my IPad' rather
    than something that is enforced.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Richard Kettlewell@invalid@invalid.invalid to comp.os.linux.misc,alt.folklore.computers,comp.lang.python on Sat Dec 20 10:12:49 2025
    From Newsgroup: comp.lang.python

    candycanearter07 <candycanearter07@candycanearter07.nomail.afraid>
    writes:
    Lawrence D’Oliveiro <ldo@nz.invalid> wrote at 02:05 this Sunday (GMT):
    On 13 Dec 2025 11:55:35 GMT, Stéphane CARPENTIER wrote:
    Everything else is just a lot of lies. They pretend it's not
    strongly typed, but in the real world you will only encounter a lot
    of issue if you believe that.

    Think about why both JavaScript and PHP need a “===” operator, while
    Python does not.

    It’s because Python is strongly typed.

    I thought it was because JS was too liberal with type-casting to make
    things true, and the JS devs didn't want to break compatibility.

    “No implicit type conversion” is one of the definitions of strong
    typing, at least back to the 1970s[1]. And JavaScript is certainly
    weakly typed in that sense:

    > 'a' + 1
    'a1'
    > 1/false
    Infinity

    What dividing by a boolean could possibly mean is a mystery, but
    JavaScript will do it anyway.

    Python fits this definition of strong typing up to a point:

    >>> 'a' + 1
    Traceback (most recent call last):
    File "<python-input-0>", line 1, in <module>
    'a' + 1
    ~~~~^~~
    TypeError: can only concatenate str (not "int") to str

    However it only goes so far, for example many things will implicitly
    convert to bool:

    >>> not ''
    True
    >>> not {}
    True

    When you define your own classes, you can arrange for them to perform arithmetic with other types without explicit conversions too.

    Another property suggested in [1] for ‘strong typing’ is that functions
    can only be called with with arguments matching a declared type. In
    Python, function arguments do not have declared types[2] and does not
    even infer them; anything goes. You will only hit an exception if you
    try to use the arguments in the wrong way.

    >>> def f(a,b):
    ... return a + b
    ...
    >>> f("a", "a")
    'aa'
    >>> f(0,0)
    0
    >>> f("a", 0)
    Traceback (most recent call last):
    File "<python-input-4>", line 1, in <module>
    f("a", 0)
    ~^^^^^^^^
    File "<python-input-0>", line 2, in f
    return a + b
    ~~^~~
    TypeError: can only concatenate str (not "int") to str

    [1] https://dl.acm.org/doi/epdf/10.1145/942572.807045

    [2] you can put in type annotations but the language implementation
    ignores them - you need to run a separate static checker.

    I would say that although Python does have some aspects of strong
    typing, it is mostly weakly typed.
    --
    https://www.greenend.org.uk/rjk/
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From c186282@c186282@nnada.net to comp.os.linux.misc,alt.folklore.computers,comp.lang.python on Sat Dec 20 05:25:25 2025
    From Newsgroup: comp.lang.python

    On 12/20/25 05:12, Richard Kettlewell wrote:
    candycanearter07 <candycanearter07@candycanearter07.nomail.afraid>
    writes:
    Lawrence D’Oliveiro <ldo@nz.invalid> wrote at 02:05 this Sunday (GMT):
    On 13 Dec 2025 11:55:35 GMT, Stéphane CARPENTIER wrote:
    Everything else is just a lot of lies. They pretend it's not
    strongly typed, but in the real world you will only encounter a lot
    of issue if you believe that.

    Think about why both JavaScript and PHP need a “===” operator, while >>> Python does not.

    It’s because Python is strongly typed.

    I thought it was because JS was too liberal with type-casting to make
    things true, and the JS devs didn't want to break compatibility.

    “No implicit type conversion” is one of the definitions of strong
    typing, at least back to the 1970s[1]. And JavaScript is certainly
    weakly typed in that sense:

    > 'a' + 1
    'a1'
    > 1/false
    Infinity

    What dividing by a boolean could possibly mean is a mystery, but
    JavaScript will do it anyway.

    Python fits this definition of strong typing up to a point:
    Well, I kind of liked PICK system ... everything was
    equal, always represented as a string. Numbers, chars,
    whatever - instantly/easily converted between each other.
    NO 'types'.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.os.linux.misc,alt.folklore.computers,comp.lang.python on Sat Dec 20 22:28:19 2025
    From Newsgroup: comp.lang.python

    On Sat, 20 Dec 2025 10:12:49 +0000, Richard Kettlewell wrote:

    Another property suggested in [1] for ‘strong typing’ is that
    functions can only be called with with arguments matching a declared
    type. In Python, function arguments do not have declared types[2]
    and does not even infer them; anything goes. You will only hit an
    exception if you try to use the arguments in the wrong way.

    Python calls this “duck typing”. The called code expects the passed
    objects to have certain members; so long as they have those, they can
    be of any type. E.g. a function might be written to write to an output
    file object, but anything passed that has a suitable “.write()” method
    on it will work.

    In other words, if it looks like a duck and quacks like a duck, then
    it is acceptable in place of a duck.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From rbowman@bowman@montana.com to comp.os.linux.misc,alt.folklore.computers,comp.lang.python on Sun Dec 21 04:22:02 2025
    From Newsgroup: comp.lang.python

    On Sat, 20 Dec 2025 05:25:25 -0500, c186282 wrote:

    Well, I kind of liked PICK system ... everything was equal, always
    represented as a string. Numbers, chars, whatever - instantly/easily
    converted between each other.
    NO 'types'.

    iirc Perl had 5 copies of a scalar just in case you wanted a string or character instead of an integer or float.


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From rbowman@bowman@montana.com to comp.os.linux.misc,alt.folklore.computers,comp.lang.python on Sun Dec 21 04:25:26 2025
    From Newsgroup: comp.lang.python

    On Sat, 20 Dec 2025 10:12:49 +0000, Richard Kettlewell wrote:

    I would say that although Python does have some aspects of strong
    typing, it is mostly weakly typed.

    Type hints sort of address that. Like TypeScript there is a temptation to
    say 'foo: Any' to preserve duck typing.
    --- Synchronet 3.21a-Linux NewsLink 1.2