OT Why Germany? [was Re: Guido van Rossum resigns as Python leader]

2018-07-14 Thread Steven D'Aprano
On Sat, 14 Jul 2018 07:41:43 +, Bob Martin wrote:

> in 796624 20180714 064331 Gregory Ewing 
> wrote:
>>Larry Martell wrote:
>>> And while we're talking about the Dutch, why is the country called
>>> Holland, but then also The Netherlands, but the people are Dutch?
>>
>>And Germany is called Deutchland?
> 
> The real question is why do English speakers refer to Deutschland as
> Germany.

It comes from the Roman name for the region, which they may have got from 
the Gauls.

https://en.wikipedia.org/wiki/Germania



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guido van Rossum resigns as Python leader

2018-07-14 Thread Marko Rauhamaa
Bob Martin :

> in 796624 20180714 064331 Gregory Ewing  wrote:
>>Larry Martell wrote:
>>> And while we're talking about the Dutch, why is the country called
>>> Holland, but then also The Netherlands, but the people are Dutch?
>>
>>And Germany is called Deutchland?
>
> The real question is why do English speakers refer to Deutschland as
> Germany.

And the answer is near:

   "The War that Changed the English Language"
   https://www.youtube.com/watch?v=Jl3K63Rbygw>


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guido van Rossum resigns as Python leader

2018-07-14 Thread Jan van den Broek
On 2018-07-13, ElChino  wrote:
>> The important question we should ask ourselves: Do we have a replacement
>> Dutch person to figure out the one obvious way to do things that may not
>> be obvious at first?
>
> Skybuck?! Also Dutch.

We try to deny that.
It'll probably lead to ending every statement in your code with "lol !".

-- 
Jan v/d Broek
balgl...@dds.nl
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Kindness

2018-07-14 Thread Steven D'Aprano
On Sat, 14 Jul 2018 05:19:36 +0300, Mikhail V wrote:

> From Marko's check-list:
> [ ] The group has a polarized us-versus-them mentality

Many Python programmers -- perhaps the majority -- know more than one 
programming language, enjoy some of them, and can appreciate their 
strengths and the differences between them. Most of the core devs are 
competent C programmers. I don't know what percentage of Python 
programmers know only Python, and no other language, but my guess is that 
outside of school kids learning the language because their school makes 
it compulsory, it's probably a small percentage.

The Python community has a long and glorious history of borrowing ideas 
from other languages, without slavishly following them. Neither "not 
invented here" nor "never invented here".

These are not the characteristics of "us-versus-them".


-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guido van Rossum resigns as Python leader

2018-07-14 Thread Jan van den Broek
On 2018-07-13, Larry Martell  wrote:

[Schnipp]

> And while we're talking about the Dutch, why is the country called
> Holland, but then also The Netherlands, but the people are Dutch?

Be careful here, this is a somewhat delicate matter. Strictly speaking
Holland is part of Nederland (the Netherlands). Nederland is divided in 
twelve provinces[1], Noord- and ZuidHolland are two of them. Calling 
the Netherlands Holland is an guaranteed to annoy people from the 
other then.
Historical speaking, Holland was (along with Zeeland) one of the more
powerfull members in the Republic.

[1] https://nl.wikipedia.org/wiki/Bestand:NederlandseProvinciesLarge.png
-- 
Jan v/d Broek
balgl...@dds.nl
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Marko Rauhamaa
Steven D'Aprano :
> Apparently Marko didn't notice the irony of suggesting that we display
> excessive commitment to GvR

The object of the "cult" isn't GvR, it's Python itself.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Christian Gollwitzer

Am 14.07.18 um 10:00 schrieb Marko Rauhamaa:

Steven D'Aprano :

Apparently Marko didn't notice the irony of suggesting that we display
excessive commitment to GvR


The object of the "cult" isn't GvR, it's Python itself.



I agree with this observation and it feels quite strange to me. I 
regularly use three languages (C++, Python and Tcl), all three are under 
active development, and IMHO all of them have flaws, there are is always 
something which is elegantly solved in one system but needs more work in 
another.


But only in the Python community I have seen a strange "worship" of the 
language of choice, the believe it is 100% perfect. If something isn't 
available, then "Python doesn't need it. It's missing for a reason! 
You're holding ot wrong!" This opinion is not so prevalent in other 
communities. Of course, C++ programmers also think that C++ is the best 
language, but they regularly admit that Python does have an edge in 
clear syntax sometimes.


Typical conversation on this list / newsgroup:

Q: "I could need a ?: operator just like in C. Is there something like 
that in Python?"


A1: "No. You don't want it. It makes the code confusing. You said, you 
have a problem, you tried ?: - now you have two problems."


A2: "Are you crazy? You want to make Python like Java?"

A3: "Guido left it out for a reason. Guido's time machine has seen that 
in 5 years you'll wonder what the hell ?: means"


A4: "?: is unpythonic, because there is already One Obvious Way To Do It"

- in the meantime, PEP 308 passes 
A1: "Oh, nice, Python has invented a new feature! We're the leading edge 
in language development!"


A2: "All hail to Guido. In 5 years, you'll ned that, and then His 
Time-Machine has struck again!"


Q: "But isn't this the same as ?: in Java or C?"

A3: "Never. There is a HUGE difference! ?: is sooo confusing. But a if c 
else b, look, the order is reversed. This is much more natural! And not 
strange punctuation, English words. Python is executable pseudocode!"



Christian
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Abdur-Rahmaan Janhangeer
@ChristianGollwitzer

Naa your type of qna is called pep and a pep is not rejected without a
valid reason

Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ



>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Chris Angelico
On Sat, Jul 14, 2018 at 7:47 PM, Abdur-Rahmaan Janhangeer
 wrote:
> @ChristianGollwitzer
>
> Naa your type of qna is called pep and a pep is not rejected without a
> valid reason
>

I have no idea what you mean here. Can you please clarify?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Kindness

2018-07-14 Thread Bart

On 14/07/2018 07:04, Gregory Ewing wrote:

Joe Pfeiffer wrote:

He once went on for *weeks* about C's (yes, this was in c.l.c) failure
to have what he regards as a "proper" for-loop.


That could only have happened if there were people willing
to keep replying to him about it for weeks. So, if it was
a bad thing, you can't say it was entirely his fault.


Exactly. Someone even admitted that 99% of the time he only needed 
exactly the simple loop I suggested, but was still 100% against the idea!


Another example of people over-defending /their/ language's lack of 
something so fundamental (this one was even part of Fortran in the 
1950s), for no other reason than the language not having it, and the 
language is always right.


Perhaps cult-like behaviour with the object of worship being a language 
rather than an individual.



--
bart
--
https://mail.python.org/mailman/listinfo/python-list


Re: OT Why Germany? [was Re: Guido van Rossum resigns as Python leader]

2018-07-14 Thread Larry Martell
On Sat, Jul 14, 2018 at 3:11 AM Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Sat, 14 Jul 2018 07:41:43 +, Bob Martin wrote:
>
> > in 796624 20180714 064331 Gregory Ewing 
> > wrote:
> >>Larry Martell wrote:
> >>> And while we're talking about the Dutch, why is the country called
> >>> Holland, but then also The Netherlands, but the people are Dutch?
> >>
> >>And Germany is called Deutchland?
> >
> > The real question is why do English speakers refer to Deutschland as
> > Germany.
>
>
> And then there’s the Pennsylvania Dutch. They make good egg noodles.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guido van Rossum resigns as Python leader

2018-07-14 Thread Thomas Jollans
On 13/07/18 00:20, Roel Schroeven wrote:
> Yes, you read that right: Guido van Rossum resigns as Python leader.
> 
> See his mail:
> (https://mail.python.org/pipermail/python-committers/2018-July/005664.html)

Thanks for posting this here, Roel. Much appreciated.

Guido has been fantastic, and he will be missed in his well-deserved
retirement.

Of course I have complete faith that the core devs will do a great job
in the future steering Python forward. The Python community is sure to
prosper even if this unexpected change creates some minor temporary
challenges.

Threads like this, on the other hand, can make you worry for the soul of
Python.


> 
>> Now that PEP 572 is done, I don't ever want to have to fight so hard
>> for a PEP and find that so many people despise my decisions.
>>
>> I would like to remove myself entirely from the decision process.
>> I'll still be there for a while as an ordinary core dev, and I'll
>> still be available to mentor people -- possibly more available. But
>> I'm basically giving myself a permanent vacation from being BDFL, and
>> you all will be on your own.
>>
>> After all that's eventually going to happen regardless -- there's
>> still that bus lurking around the corner, and I'm not getting
>> younger... (I'll spare you the list of medical issues.)
>>
>> I am not going to appoint a successor.
>>
>> So what are you all going to do? Create a democracy? Anarchy? A
>> dictatorship? A federation?
>>
>> I'm not worried about the day to day decisions in the issue tracker
>> or on GitHub. Very rarely I get asked for an opinion, and usually it's > 
> not actually important. So this can just be dealt with as it has
>> always been.
>>
>> The decisions that most matter are probably
>> - How are PEPs decided
>> - How are new core devs inducted
>>
>> We may be able to write up processes for these things as PEPs (maybe
>> those PEPs will form a kind of constitution). But here's the catch.
>> I'm going to try and let you all (the current committers) figure it
>> out for yourselves.
>>
>> Note that there's still the CoC -- if you don't like that document
>> your only option might be to leave this group voluntarily. Perhaps
>> there are issues to decide like when should someone be kicked out
>> (this could be banning people from python-dev or python-ideas too,
>> since those are also covered by the CoC).
>>
>> Finally. A reminder that the archives of this list are public (
>> https://mail.python.org/pipermail/python-committers/) although
>> membership is closed (limited to core devs).
>>
>> I'll still be here, but I'm trying to let you all figure something
>> out for yourselves. I'm tired, and need a very long break.
>>
>> --
>> --Guido van Rossum (python.org/~guido)
> 
> 
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Bart

On 14/07/2018 10:09, Christian Gollwitzer wrote:

Am 14.07.18 um 10:00 schrieb Marko Rauhamaa:

Steven D'Aprano :

Apparently Marko didn't notice the irony of suggesting that we display
excessive commitment to GvR


The object of the "cult" isn't GvR, it's Python itself.



I agree with this observation and it feels quite strange to me. I 
regularly use three languages (C++, Python and Tcl), all three are under 
active development, and IMHO all of them have flaws, there are is always 
something which is elegantly solved in one system but needs more work in 
another.


But only in the Python community I have seen a strange "worship" of the 
language of choice, the believe it is 100% perfect. If something isn't 
available, then "Python doesn't need it. It's missing for a reason! 
You're holding ot wrong!" This opinion is not so prevalent in other 
communities. Of course, C++ programmers also think that C++ is the best 
language, but they regularly admit that Python does have an edge in 
clear syntax sometimes.


Typical conversation on this list / newsgroup:

Q: "I could need a ?: operator just like in C. Is there something like 
that in Python?"


A1: "No. You don't want it. It makes the code confusing. You said, you 
have a problem, you tried ?: - now you have two problems."


A2: "Are you crazy? You want to make Python like Java?"

A3: "Guido left it out for a reason. Guido's time machine has seen that 
in 5 years you'll wonder what the hell ?: means"


A4: "?: is unpythonic, because there is already One Obvious Way To Do It"

- in the meantime, PEP 308 passes 
A1: "Oh, nice, Python has invented a new feature! We're the leading edge 
in language development!"


A2: "All hail to Guido. In 5 years, you'll ned that, and then His 
Time-Machine has struck again!"


Q: "But isn't this the same as ?: in Java or C?"

A3: "Never. There is a HUGE difference! ?: is sooo confusing. But a if c 
else b, look, the order is reversed. This is much more natural! And not 
strange punctuation, English words. Python is executable pseudocode!"


Yeah...

(And I have some issues with both of those 2-way selection operators, 
but I won't go into details here...)


--
bart
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Abdur-Rahmaan Janhangeer
@ChrisAngelico

py's dev is not mere whims here and there

py does not assume, it waits for peps.
peps are not flown direct dustbin, they are reviewed

the qna gives the impression of hey python is weird and just brushes
suggestions with the back of the hand or defends some parts without
justification

we'll long story short :

*proposes to qna author to write a pep about what he thinks should be
changed in python*

Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
-- 
https://mail.python.org/mailman/listinfo/python-list


logging from time critical tasks -- QueueListener().stop() takes the whole CPU

2018-07-14 Thread Gerlando Falauto
Hi,

I'm adding logging to a time critical task running resource-constrained 
hardware (Raspberry Pi).

I read about the QueueListener/QueueHandler in:
https://docs.python.org/3/howto/logging-cookbook.html#dealing-with-handlers-that-block

and I'm trying to understand how it really works and what's happening under the 
hood, and what the impact would be.
So I wrote a test program (here at the bottom) that logs 50 times and then 
waits for the listener to terminate. I ran it on a PC:

$ python3 logtest.py 0
PID= 5974
[  0.000] Logging like crazy 50 times with que = queue.Queue
[ 18.038] Done logging, waiting for completion
[ 37.824] Test finished
---

Here's the output while it's logging (within the first 18 seconds):

$ ps um -L 5974
USERPIDLWP %CPU NLWP %MEMVSZ   RSS TTY  STAT START   TIME 
COMMAND
iurly  5974  - 96.32  2.1 264232 170892 pts/2   -15:30   0:07 
python3 logtest.py 0
iurly -   5974 72.8--  - - -Rl+  15:30   0:05 -
iurly -   5975 23.3--  - - -Sl+  15:30   0:01 -

So the main thread is taking most of the CPU while the background thread is 
writing to disk, and that's reasonable.
However, as soon as I start waiting for the logger terminate, I get something 
like this:

$ ps um -L 5974
USERPIDLWP %CPU NLWP %MEMVSZ   RSS TTY  STAT START   TIME 
COMMAND
iurly  5974  -  1002  3.9 406724 313588 pts/2   -15:30   0:31 
python3 logtest.py 0
iurly -   5974 45.2--  - - -Sl+  15:30   0:14 -
iurly -   5975 54.8--  - - -Rl+  15:30   0:17 -

Why is the main thread taking up so much CPU?
I believe at this point listener.stop() should only be waiting for the helper 
thread to terminate, which I reckon would be implemented by waiting on a 
semaphore or something (i.e. iowait i.e. 0% CPU).

Thank you,
Gerlando

RANGE=50
import logging
import logging.handlers
import multiprocessing as mp
import queue
import time
import gc
import sys
import os

if len(sys.argv) > 1:
  testlist = [int(q) for q in sys.argv[1:]]
else:
  print ("no test list given, defaulting to 0 1 0 1")
  testlist = [0, 1, 0, 1]

print("PID=", os.getpid())
for i, qtype in enumerate(testlist):
  handlers = []
  if qtype == 0:
que = queue.Queue(-1)
qstring = "queue.Queue"
  else:
que = mp.Queue(-1)
qstring = "mp.Queue"
  handlers.append(logging.handlers.RotatingFileHandler("test%d.log" % (i), 
maxBytes=10, backupCount=5))
  #handlers.append(logging.lastResort)

  listener = logging.handlers.QueueListener(que, *handlers)
  formatter = logging.Formatter('%(asctime)s:%(threadName)s: %(message)s')
  for handler in handlers:
  handler.setFormatter(formatter)
  listener.start()
  
  queue_handler = logging.handlers.QueueHandler(que)
  logger = logging.getLogger()
  logger.setLevel(logging.DEBUG)
  logger.addHandler(queue_handler)
  start = time.time()

  print("[%7.03f] Logging like crazy %d times with que = %s" % 
(time.time()-start, RANGE, qstring))
  for i in range(0,RANGE):
logger.info("AA")
if i % 2000 == 0:
  print(i, "/", RANGE, end='\r')


  print("[%7.03f] Done logging, waiting for completion" % (time.time() - start))
  listener.stop()
  print("[%7.03f] Test finished" % (time.time() - start))
  gc.collect()
  print("---")
-- 
https://mail.python.org/mailman/listinfo/python-list


FYI apparmor and lxc in Ubuntu

2018-07-14 Thread CFK
Hi all, this is just an FYI in case anyone else has the same issue I just
ran into. If you use python 3.6 or 3.7 under Ubuntu with lxc, you may
discover that your site-packages aren't being imported correctly within the
container, but when you SSH in, everything works correctly. If that
happens, check the config file for apparmor; on my system (Ubuntu 16.0.4),
it disallowed python 3.6+.

You will also need to set the language environment variable for lxc to use
UTF-8, or your strings may get discarded (it defaults to ASCII). SSH goes
through a different path for setting up the environment, so sshing in won't
trigger the error.

Thanks,
Cem Karan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Ian Kelly
On Sat, Jul 14, 2018 at 3:12 AM Christian Gollwitzer  wrote:
> Typical conversation on this list / newsgroup:
>
> Q: "I could need a ?: operator just like in C. Is there something like
> that in Python?"
>
> A1: "No. You don't want it. It makes the code confusing. You said, you
> have a problem, you tried ?: - now you have two problems."
>
> A2: "Are you crazy? You want to make Python like Java?"
>
> A3: "Guido left it out for a reason. Guido's time machine has seen that
> in 5 years you'll wonder what the hell ?: means"
>
> A4: "?: is unpythonic, because there is already One Obvious Way To Do It"
>
> - in the meantime, PEP 308 passes 
> A1: "Oh, nice, Python has invented a new feature! We're the leading edge
> in language development!"
>
> A2: "All hail to Guido. In 5 years, you'll ned that, and then His
> Time-Machine has struck again!"
>
> Q: "But isn't this the same as ?: in Java or C?"
>
> A3: "Never. There is a HUGE difference! ?: is sooo confusing. But a if c
> else b, look, the order is reversed. This is much more natural! And not
> strange punctuation, English words. Python is executable pseudocode!"

I think you're conflating dissenting voices. When the debate period
ends and a feature gets adopted, the people who were opposed to it no
longer have much reason to talk about their opposition (the ship has
sailed). Meanwhile, the people who like the feature and are now able
to start using it are more likely to bring it up, e.g. as the solution
to a problem. So it's natural that the overall tone of the community
shifts while individual opinions might not. And of course, sometimes
people might change their opinion as a result of actually using the
feature.

I think we all can name things we don't like about Python. For
example, you're not likely to ever convince me that piggybacking
coroutines onto generators was anything but a terrible hack that
results in added complexity and leaky abstraction now that the feature
has been stretched even further into an async framework. I don't see
much point in arguing about it though since it's highly unlikely to
change.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guido van Rossum resigns as Python leader

2018-07-14 Thread Skip Montanaro
> Is it irrational to wonder whether projects should be looking to migrate to
> new languages? This kind of announcement makes me worry for the future.

Umm, yeah. The language is stable, widely used packages are stable.
Guido actually has little involvement in the larger Python ecosystem.
It's not like NumPy, Django, Pandas, Flask, PyPI, Conda, or other
popular packages or subsystems built with/for Python are suddenly
going to crumble because Guido is no longer BDFL.

But, by all means, if rewriting your applications in a different
language floats your boat, go right ahead...

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Kindness

2018-07-14 Thread Terry Reedy

On 7/14/2018 3:35 AM, Steven D'Aprano wrote:

On Sat, 14 Jul 2018 05:19:36 +0300, Mikhail V wrote:


 From Marko's check-list:
[ ] The group has a polarized us-versus-them mentality


Many Python programmers -- perhaps the majority -- know more than one
programming language, enjoy some of them, and can appreciate their
strengths and the differences between them.


Though I mostly only use Python now, I have used over 20 languages.


Most of the core devs are competent C programmers.


A good thing.  I once was but to focus on Python instead.  To work on 
IDLE, I had to learn tkinter, which is effective a different language. 
Numpy and Django, for instance, are also effectively different languages 
implemented in Python.


 I don't know what percentage of Python

programmers know only Python, and no other language, but my guess is that
outside of school kids learning the language because their school makes
it compulsory, it's probably a small percentage.

The Python community has a long and glorious history of borrowing ideas
from other languages, without slavishly following them. Neither "not
invented here" nor "never invented here".


A review of other languages is a routine part of PEP discussions, and 
sometimes included in the PEP.



These are not the characteristics of "us-versus-them".


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Jim Lee



On 07/14/18 02:09, Christian Gollwitzer wrote:

Am 14.07.18 um 10:00 schrieb Marko Rauhamaa:

Steven D'Aprano :

Apparently Marko didn't notice the irony of suggesting that we display
excessive commitment to GvR


The object of the "cult" isn't GvR, it's Python itself.



I agree with this observation and it feels quite strange to me. I 
regularly use three languages (C++, Python and Tcl), all three are 
under active development, and IMHO all of them have flaws, there are 
is always something which is elegantly solved in one system but needs 
more work in another.


But only in the Python community I have seen a strange "worship" of 
the language of choice, the believe it is 100% perfect. If something 
isn't available, then "Python doesn't need it. It's missing for a 
reason! You're holding ot wrong!" This opinion is not so prevalent in 
other communities. Of course, C++ programmers also think that C++ is 
the best language, but they regularly admit that Python does have an 
edge in clear syntax sometimes.


Typical conversation on this list / newsgroup:

Q: "I could need a ?: operator just like in C. Is there something like 
that in Python?"


A1: "No. You don't want it. It makes the code confusing. You said, you 
have a problem, you tried ?: - now you have two problems."


A2: "Are you crazy? You want to make Python like Java?"

A3: "Guido left it out for a reason. Guido's time machine has seen 
that in 5 years you'll wonder what the hell ?: means"


A4: "?: is unpythonic, because there is already One Obvious Way To Do It"

- in the meantime, PEP 308 passes 
A1: "Oh, nice, Python has invented a new feature! We're the leading 
edge in language development!"


A2: "All hail to Guido. In 5 years, you'll ned that, and then His 
Time-Machine has struck again!"


Q: "But isn't this the same as ?: in Java or C?"

A3: "Never. There is a HUGE difference! ?: is sooo confusing. But a if 
c else b, look, the order is reversed. This is much more natural! And 
not strange punctuation, English words. Python is executable pseudocode!"



Christian


+1000 !!

-Jim

--
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Marko Rauhamaa
Ian Kelly :

> I think we all can name things we don't like about Python. For
> example, you're not likely to ever convince me that piggybacking
> coroutines onto generators was anything but a terrible hack that
> results in added complexity and leaky abstraction now that the feature
> has been stretched even further into an async framework. I don't see
> much point in arguing about it though since it's highly unlikely to
> change.

Having gone through a recent 2to3 effort that left my conscience
stained, I can only lament for the lost paradise which was Python 2.7.
There *was* one real gain: MemoryBIO, but that's not enough to bring a
smile to my face.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Chris Angelico
On Sun, Jul 15, 2018 at 4:44 AM, Marko Rauhamaa  wrote:
> Ian Kelly :
>
>> I think we all can name things we don't like about Python. For
>> example, you're not likely to ever convince me that piggybacking
>> coroutines onto generators was anything but a terrible hack that
>> results in added complexity and leaky abstraction now that the feature
>> has been stretched even further into an async framework. I don't see
>> much point in arguing about it though since it's highly unlikely to
>> change.
>
> Having gone through a recent 2to3 effort that left my conscience
> stained, I can only lament for the lost paradise which was Python 2.7.
> There *was* one real gain: MemoryBIO, but that's not enough to bring a
> smile to my face.
>

Spoken like a true eight-bit-stringer (kinda like a flat-earther only
a lot more wrong).

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guido van Rossum resigns as Python leader

2018-07-14 Thread Tim Daneliuk
On 07/14/2018 10:16 AM, Skip Montanaro wrote:
>> Is it irrational to wonder whether projects should be looking to migrate to
>> new languages? This kind of announcement makes me worry for the future.
> 
> Umm, yeah. The language is stable, widely used packages are stable.
> Guido actually has little involvement in the larger Python ecosystem.
> It's not like NumPy, Django, Pandas, Flask, PyPI, Conda, or other
> popular packages or subsystems built with/for Python are suddenly
> going to crumble because Guido is no longer BDFL.
> 
> But, by all means, if rewriting your applications in a different
> language floats your boat, go right ahead...
> 
> Skip
> 

+1
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Marko Rauhamaa
Chris Angelico :

> On Sun, Jul 15, 2018 at 4:44 AM, Marko Rauhamaa  wrote:
>> Having gone through a recent 2to3 effort that left my conscience
>> stained, I can only lament for the lost paradise which was Python
>> 2.7. There *was* one real gain: MemoryBIO, but that's not enough to
>> bring a smile to my face.
>
> Spoken like a true eight-bit-stringer

True enough. Modern-day protocols as well as Linux file formats and
commands intentionally blur the line between strings and bytes. The
software in question deals with all of the above. It is virtually
impossible to keep track of what is "really" text and what is "really"
binary. In the end, the Gordian Knot was sliced by using Python3's
strings for everything and restricting oneself to Latin-1 codepoints
(almost) everywhere.

> (kinda like a flat-earther only a lot more wrong).

Ah, that's called "shunning," isn't it?


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Terry Reedy

On 7/14/2018 2:44 PM, Marko Rauhamaa wrote:


Having gone through a recent 2to3 effort that left my conscience
stained, I can only lament for the lost paradise which was Python 2.7.


I am curious, which release of 2.7 do you apply that to?  The initial 
2.7.0?  Should we have stopped there?  The current 2.7.15?  Should we 
stop with this?  If you think paradise needed and needs improving, what 
help did you and will you contribute?


What do you mean by 'lost'?  All past releases since about 1.5 will 
remain available indefinitely.


For some people, in particular core developers, 2.7 was more like hell, 
a developmental dead end.  The different opinions may be responses to 
the same facts.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Guido van Rossum resigns as Python leader

2018-07-14 Thread Etienne Robillard



I'm really sad to hear that news! Python is the language which made me 
gain the most skills in modern software programming ever! I have not 
encountered a better programming language than Python for quickly 
becoming a mature developer!


I just hope the Python software foundation will continue to provide to 
his community all the same services than before and that the project 
will continue to evolve!


Thanks for everything Guido! :-)

Etienne



--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Chris Angelico
On Sun, Jul 15, 2018 at 5:54 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>
>> On Sun, Jul 15, 2018 at 4:44 AM, Marko Rauhamaa  wrote:
>>> Having gone through a recent 2to3 effort that left my conscience
>>> stained, I can only lament for the lost paradise which was Python
>>> 2.7. There *was* one real gain: MemoryBIO, but that's not enough to
>>> bring a smile to my face.
>>
>> Spoken like a true eight-bit-stringer
>
> True enough. Modern-day protocols as well as Linux file formats and
> commands intentionally blur the line between strings and bytes. The
> software in question deals with all of the above. It is virtually
> impossible to keep track of what is "really" text and what is "really"
> binary. In the end, the Gordian Knot was sliced by using Python3's
> strings for everything and restricting oneself to Latin-1 codepoints
> (almost) everywhere.
>
>> (kinda like a flat-earther only a lot more wrong).
>
> Ah, that's called "shunning," isn't it?
>

No, it isn't. Shunning would be killfiling you, which is apparently
"more polite" than telling you how utterly and completely wrong you
are.

What I would like to do is ban you for endemic racism, honestly. By
recommending and preferring eight-bit text strings, you're saying
"Chinese text doesn't matter". And by stipulating Latin-1, you're also
saying "Russian text doesn't matter" and "Thai text doesn't matter"
and "Hebrew text doesn't matter" and more. You are declaring that YOUR
culture is the only one that matters. When I see behaviour like that
in a Twitch stream that I moderate, I smack it with a banhammer,
because that is utterly unacceptable. Why should we tolerate it in
programming?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Etienne Robillard



Le 2018-07-14 à 16:02, Chris Angelico a écrit :


No, it isn't. Shunning would be killfiling you, which is apparently
"more polite" than telling you how utterly and completely wrong you
are.

What I would like to do is ban you for endemic racism, honestly. By
recommending and preferring eight-bit text strings, you're saying
"Chinese text doesn't matter". And by stipulating Latin-1, you're also
saying "Russian text doesn't matter" and "Thai text doesn't matter"
and "Hebrew text doesn't matter" and more. You are declaring that YOUR
culture is the only one that matters. When I see behaviour like that
in a Twitch stream that I moderate, I smack it with a banhammer,
because that is utterly unacceptable. Why should we tolerate it in
programming?


lol

+1



ChrisA



--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Marko Rauhamaa
Chris Angelico :

> On Sun, Jul 15, 2018 at 5:54 AM, Marko Rauhamaa  wrote:
>> True enough. Modern-day protocols as well as Linux file formats and
>> commands intentionally blur the line between strings and bytes. The
>> software in question deals with all of the above. It is virtually
>> impossible to keep track of what is "really" text and what is "really"
>> binary. In the end, the Gordian Knot was sliced by using Python3's
>> strings for everything and restricting oneself to Latin-1 codepoints
>> (almost) everywhere.
>
> [...] By recommending and preferring eight-bit text strings, you're
> saying "Chinese text doesn't matter". And by stipulating Latin-1,
> you're also saying "Russian text doesn't matter" and "Thai text
> doesn't matter" and "Hebrew text doesn't matter" and more. You are
> declaring that YOUR culture is the only one that matters. When I see
> behaviour like that in a Twitch stream that I moderate, I smack it
> with a banhammer, because that is utterly unacceptable. Why should we
> tolerate it in programming?

I'm not saying that at all. What I'm saying is that I'm using Python3
strings as holders for bytes. Since every byte is a valid Unicode code
point, a Python3 string can hold any sequence of bytes.

Couldn't you use bytes objects everywhere for the same purpose?

Yes and no.

Yes, but it would be ugly as hell and would involve changing a large
percentage of the source code.

No, as a large number of Python3 facilities require str objects as
arguments. Consider urllib.request.urlopen(), for example, which
requires a URL to be an str object.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Chris Angelico
On Sun, Jul 15, 2018 at 8:15 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>
>> On Sun, Jul 15, 2018 at 5:54 AM, Marko Rauhamaa  wrote:
>>> True enough. Modern-day protocols as well as Linux file formats and
>>> commands intentionally blur the line between strings and bytes. The
>>> software in question deals with all of the above. It is virtually
>>> impossible to keep track of what is "really" text and what is "really"
>>> binary. In the end, the Gordian Knot was sliced by using Python3's
>>> strings for everything and restricting oneself to Latin-1 codepoints
>>> (almost) everywhere.
>>
>> [...] By recommending and preferring eight-bit text strings, you're
>> saying "Chinese text doesn't matter". And by stipulating Latin-1,
>> you're also saying "Russian text doesn't matter" and "Thai text
>> doesn't matter" and "Hebrew text doesn't matter" and more. You are
>> declaring that YOUR culture is the only one that matters. When I see
>> behaviour like that in a Twitch stream that I moderate, I smack it
>> with a banhammer, because that is utterly unacceptable. Why should we
>> tolerate it in programming?
>
> I'm not saying that at all. What I'm saying is that I'm using Python3
> strings as holders for bytes. Since every byte is a valid Unicode code
> point, a Python3 string can hold any sequence of bytes.

Since every byte is also a valid IEEE 754 64-bit binary floating point
value, a sequence of floats can hold any sequence of bytes, too. Is it
a good idea to use floats to represent bytes?

Text strings and sequences of bytes *are different*. If you're going
to try to blur the line, you do NOT want Latin-1. You *might* be able
to do this with ASCII, but you cannot use an eight-bit character set.

> Couldn't you use bytes objects everywhere for the same purpose?
>
> Yes and no.
>
> Yes, but it would be ugly as hell and would involve changing a large
> percentage of the source code.
>
> No, as a large number of Python3 facilities require str objects as
> arguments. Consider urllib.request.urlopen(), for example, which
> requires a URL to be an str object.

Well, duh. It also doesn't accept a list of floats, just because you
COULD represent a text string that way.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Tim Daneliuk
On 07/14/2018 04:09 AM, Christian Gollwitzer wrote:
> I agree with this observation and it feels quite strange to me. I regularly 
> use three languages (C++, Python and Tcl), all three are under active 
> development, and IMHO all of them have flaws, there are is always something 
> which is elegantly solved in one system but needs more work in another.


Dusting off some of my musings written years ago but at least tangentially
related to all this:

   https://www.tundraware.com/TechnicalNotes/How-To-Pick-A-Programming-Language/
   https://www.tundraware.com/TechnicalNotes/Bullet/

I am not particularly enamored of the feeping creaturism that that infested
Python 3, but then again, I'm not required by law to use said feeping 
creatures...

I wish GvR well.  He's served this community magnificently and deserves far
better than he got, especially lately. := pedantry aside (and I am NOT a fan),
great things come from individual minds, not committees and I think it is
simply inarguable that GvR built a Very Great Thing.  So ... thanks ... and
go enjoy your life, sir, you've more than earned it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Chris Angelico
On Sun, Jul 15, 2018 at 5:19 AM, Tim Daneliuk  wrote:
> On 07/14/2018 04:09 AM, Christian Gollwitzer wrote:
>> I agree with this observation and it feels quite strange to me. I regularly 
>> use three languages (C++, Python and Tcl), all three are under active 
>> development, and IMHO all of them have flaws, there are is always something 
>> which is elegantly solved in one system but needs more work in another.
>
>
> Dusting off some of my musings written years ago but at least tangentially
> related to all this:
>
>
> https://www.tundraware.com/TechnicalNotes/How-To-Pick-A-Programming-Language/
>https://www.tundraware.com/TechnicalNotes/Bullet/

No idea what this has to do with the features of different languages.
You basically say "blah blah blah nothing matters", which is not
entirely false, but far from true. (For example, you're right that
it's important to understand algorithms independently of a language,
but wrong that that means cross-platform code is irrelevant.)

> I am not particularly enamored of the feeping creaturism that that infested
> Python 3, but then again, I'm not required by law to use said feeping 
> creatures...

You'd better avoid most of JavaScript, C++, and most other languages,
then. Every language feeps a little, and Python is definitely not as
bad as some.

> I wish GvR well.  He's served this community magnificently and deserves far
> better than he got, especially lately. := pedantry aside (and I am NOT a fan),
> great things come from individual minds, not committees and I think it is
> simply inarguable that GvR built a Very Great Thing.  So ... thanks ... and
> go enjoy your life, sir, you've more than earned it.

And here's the big thing. People are STILL complaining about the :=
operator, while paying lip service to "Guido's design sensibilities
are good". At some point, people have to simply accept or reject.
Either you trust Guido to decide what's best for the language, or you
think he's making mistakes. Either you believe that his idea of what's
good for the language is worth following, or you don't. Either you
continue to use Python, or you go and rewrite your code in another
language. Quit beefing about how Guido's a smart person but you still
hate what he's decided here. At very least, just cool off on it for a
year. No wonder he's wanting to retire.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Steven D'Aprano
On Sun, 15 Jul 2018 09:07:17 +1000, Chris Angelico wrote:

> On Sun, Jul 15, 2018 at 8:15 AM, Marko Rauhamaa 
> wrote:
>> Chris Angelico :
>>
>>> On Sun, Jul 15, 2018 at 5:54 AM, Marko Rauhamaa 
>>> wrote:
 True enough. Modern-day protocols as well as Linux file formats and
 commands intentionally blur the line between strings and bytes. The
 software in question deals with all of the above. It is virtually
 impossible to keep track of what is "really" text and what is
 "really" binary.

Of course we have no idea what Marko's software is, or what it is doing, 
but frankly that seems pretty implausible to me. On the face of it, it 
seems as ridiculous as the claim that he can't tell which variables are 
quote-unquote "really" lists of weights and which are lists of distances.

On the face of things, this really sounds more like an admission that 
Marko is working with a shitty code base, not a fundamental problem with 
Python. But dealing with shitty code bases is the reality.


 In the end, the Gordian Knot was sliced by using
 Python3's strings for everything and restricting oneself to Latin-1
 codepoints (almost) everywhere.
[...]

I wonder whether Marko's Python 2.7 code base was ever actually tested 
with non-Latin1 text. I suspect that if Marko had (let's say) Japanese 
users expecting to use CJK characters in the application, his affection 
for the 2.7 version would be a lot less.


[Marko]
>> What I'm saying is that I'm using Python3
>> strings as holders for bytes. Since every byte is a valid Unicode code
>> point, a Python3 string can hold any sequence of bytes.

[Chris] 
> Since every byte is also a valid IEEE 754 64-bit binary floating point
> value, a sequence of floats can hold any sequence of bytes, too. Is it a
> good idea to use floats to represent bytes?


3.6e-322 1.6e-322 4.8e-322 5.1e-322 5.63e-322 5e-322 5e-322 1.63e-322



> Text strings and sequences of bytes *are different*.

At an implementation level, everything is bytes. People do so insist on 
conflating implementation with interface, even when they don't need to...

(Sometimes I think people should be required to implement algorithms on 
analogue computing devices before they're allowed to write code for 
digital computers, just to drive home the point that neither bytes nor 
bits are fundamental to computing, but are mere implementation details.)

At a semantic level, byte strings and text strings represent 
fundamentally different things, as distinct as weights and lengths.

Unfortunately, due to the long influence of ASCII in computing, a lot of 
people have internalised that "byte 0x41 *really is* the letter A" when 
that's just a mere encoding convention. You wouldn't add 5kg to 5cm and 
expect to get a meaningful result, but people expect to combine bytes and 
text and "just make it work".

One might as well say that bytes b'@=<\xed\x91hr\xb0' really is the 
number 29.238 and expect to multiple your name by 12.5 and get your 
height in seconds.


[Marko]
>> Couldn't you use bytes objects everywhere for the same purpose?
>>
>> Yes and no.
>>
>> Yes, but it would be ugly as hell and would involve changing a large
>> percentage of the source code.

It would also require re-inventing the entire Unicode infrastructure 
already provided -- unless you intended to just say No to 99% of human 
languages in the world, including English, in favour of restricting 
everyone, including English speakers, to an artificial subset of the 
characters they use in real life.

(Even Latin1 doesn't cover all the English punctuation marks I expect to 
be able to use in text.)

It's not 1970 any more. Under what circumstances is that acceptable?


>> No, as a large number of Python3 facilities require str objects as
>> arguments. Consider urllib.request.urlopen(), for example, which
>> requires a URL to be an str object.

That's because URLs are fundamentally text strings.

Quick quiz: which of the following are real URLs?

(a)  http://правительство.рф

(b)  http://παράδειγμα.δοκιμή

(c)  http://실례.테스트

(d)  All of the above.

https://uxmag.com/articles/a-url-in-any-language



> Well, duh. It also doesn't accept a list of floats, just because you
> COULD represent a text string that way.



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

-- 
https://mail.python.org/mailman/listinfo/python-list


Guido's leaving

2018-07-14 Thread Jack Gilbert
To Guido, I wish you much success in all your future endeavors.


Jack G
Python Newby
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Chris Angelico
On Sun, Jul 15, 2018 at 12:55 PM, Steven D'Aprano
 wrote:
> On Sun, 15 Jul 2018 09:07:17 +1000, Chris Angelico wrote:
>
>> On Sun, Jul 15, 2018 at 8:15 AM, Marko Rauhamaa 
>> wrote:
>>> Chris Angelico :
>>>
 On Sun, Jul 15, 2018 at 5:54 AM, Marko Rauhamaa 
 wrote:
> True enough. Modern-day protocols as well as Linux file formats and
> commands intentionally blur the line between strings and bytes. The
> software in question deals with all of the above. It is virtually
> impossible to keep track of what is "really" text and what is
> "really" binary.
>
> Of course we have no idea what Marko's software is, or what it is doing,
> but frankly that seems pretty implausible to me. On the face of it, it
> seems as ridiculous as the claim that he can't tell which variables are
> quote-unquote "really" lists of weights and which are lists of distances.
>
> On the face of things, this really sounds more like an admission that
> Marko is working with a shitty code base, not a fundamental problem with
> Python. But dealing with shitty code bases is the reality.

Fair point - but doesn't justify hating on Python 3 for making it
easier to work with good code than with bad code. I've had to work
with ridiculous data formats before (forty-ish lines of block comment
concluding with "Cthulhu's got nothing on a determined bank"), but
when that happens, I *know* that my code is being warped to fit the
requirements. It's not something to replicate elsewhere.

> In the end, the Gordian Knot was sliced by using
> Python3's strings for everything and restricting oneself to Latin-1
> codepoints (almost) everywhere.
> [...]
>
> I wonder whether Marko's Python 2.7 code base was ever actually tested
> with non-Latin1 text. I suspect that if Marko had (let's say) Japanese
> users expecting to use CJK characters in the application, his affection
> for the 2.7 version would be a lot less.

I very much doubt it has. He *restricted* to Latin-1, which means that
he threw away all the support Python offers, restricting to one
seventy-thousandth of the available characters, or a thousandth of the
allocated ones.

>> Text strings and sequences of bytes *are different*.
>
> At an implementation level, everything is bytes. People do so insist on
> conflating implementation with interface, even when they don't need to...

And at a different implementation level, everything is electrical signals.

> (Sometimes I think people should be required to implement algorithms on
> analogue computing devices before they're allowed to write code for
> digital computers, just to drive home the point that neither bytes nor
> bits are fundamental to computing, but are mere implementation details.)

Every week, I live-stream a workshop on data structures and
algorithms. (You're all most welcome to come by; it's Friday lunchtime
in the US, or Saturday early morning in Australia.) I use JavaScript
(because a lot of people know it), Python (because it's a really
expressive language), or a deck of cards. Have you ever seen
merge-sort implemented on a deck of cards? It's beautifully simple and
elegant. Interestingly, quick-sort looks very different from
merge-sort when implemented in C, but they're fairly similar when
implemented in cards.

Bytes? Bits? Arrays? If you want them, you have to first implement them.

> At a semantic level, byte strings and text strings represent
> fundamentally different things, as distinct as weights and lengths.

Or, as I keep running into when I try to mod Team Fortress 2, entities
and clients and users. They're all represented by the "int" data type,
and I have to spend an insane amount of effort trying to keep them
straight - does this function take a user or a client? Oh wait, this
isn't the user at all, it's the entity ID of that user's gun. But it's
still just an int... *sigh* SourcePawn (the language in question)
lacks a type system strong enough to handle this.

Having different data types for fundamentally different types of data
is not a weakness. It is a strength.

> One might as well say that bytes b'@=<\xed\x91hr\xb0' really is the
> number 29.238 and expect to multiple your name by 12.5 and get your
> height in seconds.

QOTD.

>>> No, as a large number of Python3 facilities require str objects as
>>> arguments. Consider urllib.request.urlopen(), for example, which
>>> requires a URL to be an str object.
>
> That's because URLs are fundamentally text strings.
>
> Quick quiz: which of the following are real URLs?
>
> (a)  http://правительство.рф
>
> (b)  http://παράδειγμα.δοκιμή
>
> (c)  http://실례.테스트
>
> (d)  All of the above.
>
> https://uxmag.com/articles/a-url-in-any-language

I had to actually check two of those to be sure they really truly were
*real* URLs, not merely *correctly formatted* URLs. But yes, URLs are
fundamentally text. For hysterical raisins, DNS has some oddities to
it, so when you dive into how these are actually represented, the
Korean example is actually http

Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Steven D'Aprano
On Sat, 14 Jul 2018 22:54:52 +0300, Marko Rauhamaa wrote:

> Ah, that's called "shunning," isn't it?

No, shunning is when people simply stop responding to those they don't 
approve of, turn their back on them in the street, and refuse to 
acknowledge their existence in any way.


-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Gregory Ewing

Paul Rubin wrote:

If you see the historical absence
of an assignment operator in Python as a mistake, then the introduction
of := is a fix for the mistake that only happened because people kept
complaining.


That's not quite the same thing. There was no a PEP saying
that there would never be assignment expressions in Python, so
there was room for useful debate. Now that the := PEP is
accepted, further argument about it is not productive. As
far as I know, no PEP has ever been revoked after acceptance,
and that's a good thing for the stability of the language.

It's like the rule sports usually have that the referee's
decision is final, even if it turns out to be wrong. At some
point you need to make a decision and move on.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Abdur-Rahmaan Janhangeer
@GregoryEwing

maybe another word for pep revocation is fork

Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 526 - var annotations and the spirit of python

2018-07-14 Thread Christian Gollwitzer

Am 05.07.18 um 12:04 schrieb Steven D'Aprano:

On Thu, 05 Jul 2018 09:17:20 +0200, Christian Gollwitzer wrote:


Am 04.07.18 um 17:31 schrieb Steven D'Aprano:

On Wed, 04 Jul 2018 13:48:26 +0100, Bart wrote:


Presumably one type hint applies for the whole scope of the variable,
not just the one assignment.


You know how in C you can write

  int x = 1;  # the type applies for just this one assignment x =
  2.5;# perfectly legal, right?



Not sure what point you are trying to make, but your example compiles in
C, if you replace the '#' comment sign with '//'.



Oops.


But... it compiles? Seriously?


Only it doesn't do
what you might think: the 2.5 is down-converted to an integer, therefore
x will be 2 in the end. There will be a compiler warning but no error.


Sometimes I wonder how C programmers manage to write a bug-free "Hello
World" program. No wonder it is described as a type-unsafe language or a
weakly-typed language.


Even this compiles:

#include 
int main() {
int x=1;
x="This is serious";
printf("%d\n", x);
return 0;
}
Apfelkiste:Tests chris$ gcc intx.c && ./a.out
intx.c:4:3: warning: incompatible pointer to integer conversion assigning to
  'int' from 'char [16]' [-Wint-conversion]
x="This is serious";
 ^~
1 warning generated.
15294370


Assignment in C to an integer will only fail when the source is a 
struct. Everything else can be "converted" to an integer by the compiler.



I understand upcasting ints to floats, that's cool (even if a few
languages take a hard line on that too, I don't). I understand Python's
dynamic typing approach. I don't understand C requiring type
declarations, then down-casting floats to integers.


Without prototypes, it would be worse; the compiler would put the 
bit-pattern of a float onto the stack and reinterpret that as an 
integer. With prototypes there is a "sensible" result, namely the 
integer part of the float. At least it doesn't crash ("2.5" in C is a 
double constant, which is usually 64 bit, whereas int is usually 32 bit 
only).


At least it shows a warning. But hell, who pays attention to C compiler
warnings? There's *so many of them*.


In programs that are maintained, the warnings are typically taken 
seriously. Some warnings can be annoying, e.g. warnings from generated 
code about unused variables and such, but if you see a flood of warnings 
in regular code, that is a sign that the code has bad quality or wasn't 
ever tested on the platform you try it to compile.




(And I bet that by default the warning is disabled, amirite?)


Some people develop with -Werror (treat warnings as error and abort).

Christian
--
https://mail.python.org/mailman/listinfo/python-list