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

2018-07-05 Thread 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

Re: Congrats to Chris for breaking his PEP curse

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 17:59:05 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Not everything in Python uses a strict left-to-right reading order. >> Just like English really. > > Well, English is read left to right, but it doesn't always mean thi

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

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 13:54:28 +0200, Antoon Pardon wrote: > On 05-07-18 11:59, Steven D'Aprano wrote: >> On Thu, 05 Jul 2018 17:34:55 +1200, Gregory Ewing wrote: >> >> >>>> Indeed, that's often the best way, except for the redundant type >>>&g

RANT why the *%#&%^ does installing pip not install setuptools???

2018-07-05 Thread Steven D'Aprano
dency of pip, just because it happens to be a dependency of pip? That would be too sensible. sudo apt install python3-setuptools fixed the issue. But now I want to go out and kick puppies. /rant -- Steven D'Aprano "Ever since I learned about confirmation bias, I'

Dealing with dicts in doctest

2018-07-05 Thread Steven D'Aprano
tty printer to the end od the line, instead of the beginning, to reduce the emphasis on it". And then I thought, yes I can!" and re-wrote the pretty printer to use the __ror__ method instead: >>> func(1) | _ppr {'a': 1, 'b': 2, 'c': 3} I

Re: about main()

2018-07-05 Thread Steven D'Aprano
ency (without necessarily achieving it) than for any other single reason — including blind stupidity. -- W.A. Wulf The Rules of Optimization are simple. Rule 1: Don’t do it. Rule 2 (for experts only): Don’t do it yet. -- Michael A. Jackson, "Principles of Program Design"

Re: about main()

2018-07-05 Thread Steven D'Aprano
s. And its true, I'm entirely clueless how to identify poisonous mushrooms from edible ones. However will I survive? Nor do I know how to smelt copper, or tan leather using nothing but dung, or perform brain surgery. I guess civilization is about to collapse. -- Steven D'Aprano &

Re: RANT why the *%#&%^ does installing pip not install setuptools???

2018-07-05 Thread Steven D'Aprano
/stable/ Bugs: https://bugs.launchpad.net/ubuntu/+filebug Origin: Ubuntu -- 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: Dealing with dicts in doctest

2018-07-05 Thread Steven D'Aprano
On Fri, 06 Jul 2018 09:31:50 +1000, Cameron Simpson wrote: > On 05Jul2018 17:57, Steven D'Aprano > wrote: >>I have a function which returns a dict, and I want to use doctest to >>ensure the documentation is correct. So I write a bunch of doctests: >> >>def

Re: Dealing with dicts in doctest

2018-07-05 Thread Steven D'Aprano
;"" Hmmm it still has the disadvantage of putting the emphasis on the sorted() function instead of the function being doctested, and obscuring the fact that it returns a dict. But I actually like that. -- 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: RANT why the *%#&%^ does installing pip not install setuptools???

2018-07-05 Thread Steven D'Aprano
On Fri, 06 Jul 2018 11:58:08 +1000, Chris Angelico wrote: > On Fri, Jul 6, 2018 at 11:35 AM, Steven D'Aprano > wrote: >> On Fri, 06 Jul 2018 03:47:55 +1000, Chris Angelico wrote: >> >>> What's the output of: >>> >>> $ apt-cache show pytho

Re: about main()

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 18:40:11 -0700, Jim Lee wrote: > On 07/05/18 18:25, Steven D'Aprano wrote: >> On Thu, 05 Jul 2018 11:27:09 -0700, Jim Lee wrote: >> >>> Take a village of people.  They live mostly on wild berries. >> Because of course a community of people li

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

2018-07-05 Thread Steven D'Aprano
nfer, deduct, derive] 2: draw from specific cases for more general cases [syn: generalize, generalise, extrapolate, infer] 3: conclude by reasoning; in logic [syn: deduce, infer] > Unless you mean "A probable guess" by interfere. No. -- 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

Looking for a recent quote about dynamic typing, possibly on this list

2018-07-06 Thread Steven D'Aprano
ne remember this? My google-fu is failing me. -- 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: Looking for a recent quote about dynamic typing, possibly on this list

2018-07-06 Thread Steven D'Aprano
On Fri, 06 Jul 2018 14:02:28 +0100, Bart wrote: > On 06/07/2018 13:43, Steven D'Aprano wrote: >> I think it might have been on this list, or possibly one of >> Python-Ideas or Python-Dev. >> >> Somebody gave a quote about dynamic typing, along the lines of >&g

Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-06 Thread Steven D'Aprano
Check to Time Of Use bug where some other thread could conceivably insert 'c' into the dict between the check and the insertion. How do I do a thread-safe insertion if, and only if, the key isn't already there? Thanks in advance, -- Steven D'Aprano "Ever since I

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-06 Thread Steven D'Aprano
On Sat, 07 Jul 2018 02:51:41 +0900, INADA Naoki wrote: > D.setdefault('c', None) Oh that's clever! Thanks! -- 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: about main()

2018-07-06 Thread Steven D'Aprano
rk for you: https://www.vettimes.co.uk/app/uploads/wp-post-to-pdf-enhanced-cache/1/a-dirty-job-but-not-to-be-sniffed-at.pdf -- 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: PEP 526 - var annotations and the spirit of python

2018-07-06 Thread Steven D'Aprano
On Fri, 06 Jul 2018 09:42:09 +0200, Antoon Pardon wrote: > On 06-07-18 08:17, Steven D'Aprano wrote: >> On Thu, 05 Jul 2018 16:09:52 +0200, Antoon Pardon wrote: >> >>>> This is not an innovation of Mypy. It's how type inference is >>>> supposed

Re: Looking for a recent quote about dynamic typing, possibly on this list

2018-07-06 Thread Steven D'Aprano
On Sat, 07 Jul 2018 11:38:37 +1000, Ben Finney wrote: > Steven D'Aprano writes: > >> Somebody gave a quote about dynamic typing, along the lines of >> >> "Just because a language allows a lot of dynamic features, doesn't mean >> people's code

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Steven D'Aprano
= 1 # thread 2 assert i == 3 Executing statements out of order is impossible, even in threaded code. Redefining the meaning of the integer literal 1 is impossible (ignoring unsupported shenanigans with ctypes). Monkey-patching the int __iadd__ method is impossible. So there is no coherent way to

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Steven D'Aprano
2 and have a result of 3, rather than 2 or 4. Some people, when confronted with a problem, say, "I know, I'll use threads". Nothhtwo probw ey ave lems. > But you're absolutely right that there are only a small handful of > plausible results, even with threading

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Steven D'Aprano
hough. Any mutable object shared between two threads is potentially a risk. Globals are just the most obvious example. -- 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: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-08 Thread Steven D'Aprano
. That's irrelevant. A legal Python does not inherit the quirks of the underlying implementation -- it must still follow the rules of the language, or it isn't Python. Java is statically typed, with machine ints, Python is dynamically typed, with no machine ints. Relevant: http://

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-08 Thread Steven D'Aprano
On Sun, 08 Jul 2018 14:11:58 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : >> Changing implementations from one which is thread safe to one which is >> not can break people's code, and shouldn't be done on a whim. >> Especially since such breakage could be

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-08 Thread Steven D'Aprano
On Sun, 08 Jul 2018 19:35:55 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : >> On Sun, 08 Jul 2018 14:11:58 +0300, Marko Rauhamaa wrote: >>> PS My example with "impossible" being the result of a racy integer >>> operation is of course unlikely but coul

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-08 Thread Steven D'Aprano
On Sun, 08 Jul 2018 16:37:11 +0100, MRAB wrote: > On 2018-07-08 14:38, Steven D'Aprano wrote: >> On Sun, 08 Jul 2018 14:11:58 +0300, Marko Rauhamaa wrote: >> > [snip] >>> More importantly, this loop may never finish: >>> >>> # Init

Re: Invalid error in python program

2018-07-08 Thread Steven D'Aprano
atical errors. Like writing "make your homeworks" for "do your homework"... *wink* > Anyways, I don't think anyone here may want to make your homeworks for > you... Prafull is not asking for us to do his or her homework, but for help with basic syntax. That&#x

Re: Invalid error in python program

2018-07-08 Thread Steven D'Aprano
te it directly in your message. Thank you. -- 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: 转发: No pip for my Python 3.6.5!

2018-07-09 Thread Steven D'Aprano
ing the actual errors you are getting, I'm just guessing what the problem is. -- 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

Generator Comprehensions

2018-07-09 Thread Steven D'Aprano
nsion (expr for x in values) a.k.a. generator expression -- 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: variable scope in try ... EXCEPT block.

2018-07-12 Thread Steven D'Aprano
END_FINALLY >> 44 LOAD_CONST 0 (None) 47 RETURN_VALUE -- 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

Hey Ranting Rick, this is your moment to shine!

2018-07-12 Thread Steven D'Aprano
Hey Rick, if you're reading this, now that Guido has resigned, this is your opportunity to declare yourself as the true Heir and take over as BDFL. *runs and hides* Sorry-sometimes-I-can't-help-myself-I-would-have-deleted-this-post-but-I- already-hit-send-ly y'rs, --

Re: Google weirdness

2018-07-13 Thread Steven D'Aprano
k door through Google's firewalls and security, and now have total control over their entire network of tens of thousands of computers around the world; or 2) it's an Easter egg and coding challenge. My money is on number 1. -- Steven D'Aprano "Ever since I learned

Re: Guido van Rossum resigns as Python leader

2018-07-13 Thread Steven D'Aprano
om his comments) the levels of abuse he (probably) received privately and on social media after his announcement was made. The downside of being the visible face of a popular language while having a publicly visible email address. -- Steven D'Aprano "Ever since I learned abou

Enabling and disabling custom wanings

2018-07-13 Thread Steven D'Aprano
ing, module=__name__) Am I doing it right? -- 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-13 Thread Steven D'Aprano
d major disasters. I've been using it since 1973. Doesn't Python have the same?" -- 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: Kindness

2018-07-13 Thread Steven D'Aprano
with the community here, or the fact that he's been kill-filed by probably half the regulars here. But nevertheless you felt qualified to state an opinion. -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson --

Cult-like behaviour [was Re: Kindness]

2018-07-13 Thread Steven D'Aprano
f emails, posts, tweets and other messages telling Guido off for getting it idiotically wrong *really* sounds like cultists taking the words of their leader as divine truth. /s -- 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: Kindness

2018-07-13 Thread Steven D'Aprano
tal relationships, shunning is one of the cruelest and most toxic ways to deal with conflict short of physical abuse, but we've made it the norm on the internet. If somebody says something you don't like, block them, ignore them silently, don't respond to their messages, even he

Re: Kindness

2018-07-13 Thread Steven D'Aprano
f being trolls with no provocation. (I think Mark is mistaken, in this case, but I understand his sentiments.) -- 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-13 Thread Steven D'Aprano
On Fri, 13 Jul 2018 17:48:15 -0700, dbd wrote: > On Friday, July 13, 2018 at 4:59:06 PM UTC-7, Steven D'Aprano wrote: ... >> I think that Marko sometimes likes to stir the ants nest by looking >> down at the rest of us and painting himself as the Lone Voice Of Sanity >&g

Re: Kindness

2018-07-13 Thread Steven D'Aprano
coming in return than if they come in, flop out their dick and start pissing all over your favourite things. "Why are you so unwelcoming? I'm just making a technical criticism." -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it e

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

2018-07-14 Thread Steven D'Aprano
e 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&#x

Re: Kindness

2018-07-14 Thread Steven D'Aprano
27;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

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

2018-07-14 Thread Steven D'Aprano
equires 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

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 existe

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

2018-07-15 Thread Steven D'Aprano
and get pi) then I guess Go got it right. > That's the ten-billion-dollar question, isn't it?! No. The real ten billion dollar question is how people in 2018 can stick their head in the sand and take seriously the position that Latin-1 (let alone ASCII) is enough for text str

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

2018-07-15 Thread Steven D'Aprano
On Sun, 15 Jul 2018 11:39:40 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Of course we have no idea what Marko's software is, or what it is >> doing, > > Correct, you don't, but the link Paul Rubin posted gives you an idea: > >Pyt

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

2018-07-15 Thread Steven D'Aprano
On Sun, 15 Jul 2018 14:17:51 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Sun, 15 Jul 2018 11:43:14 +0300, Marko Rauhamaa wrote: >>> Paul Rubin : >>>> I don't think Go is the answer either, but it probably got strings >>>> r

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

2018-07-15 Thread Steven D'Aprano
On Sun, 15 Jul 2018 11:22:11 -0700, James Lee wrote: > On 7/15/2018 3:43 AM, Steven D'Aprano wrote: >> >> No. The real ten billion dollar question is how people in 2018 can >> stick their head in the sand and take seriously the position that >> Latin-1 (let alone A

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

2018-07-15 Thread Steven D'Aprano
ming tasks.  For a > great deal more, it's absolutely necessary.  That why I said a "smart" > language would make it easy to turn on and off. You actually said that I18N features should be able to be turned on and off. Unicode and I18N are unrelated. -- Steven D&

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

2018-07-15 Thread Steven D'Aprano
ate my point with Python code since Python won't let me deal with > strings without also dealing with Unicode. Nonsense. b"Look ma, a Python 2 style ASCII string." -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere.&q

Unicode [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
On Sun, 15 Jul 2018 17:39:55 -0700, Jim Lee wrote: > On 07/15/18 17:18, Steven D'Aprano wrote: >> On Sun, 15 Jul 2018 16:08:15 -0700, Jim Lee wrote: >> >>> Python3 is intrinsically tied to Unicode for string handling. >>> Therefore, the Python programmer

Unicode [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
et to the crux of the matter. It isn't really the technical issues of Unicode that annoy you. It is the loss of privilege that you, as an ASCII user, no longer get to dismiss 90% of the world as beneath your notice. Nice. -- 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: Getting process details on an operating system process/question answer by vouce

2018-07-16 Thread Steven D'Aprano
xplain: > > Ask: how was your day > record answer in voice translate it via google ask new question Sorry, I don't understand this. -- 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: Unicode [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
On Mon, 16 Jul 2018 14:17:35 +, Dan Sommers wrote: > On Mon, 16 Jul 2018 10:39:49 +0000, Steven D'Aprano wrote: > >> ... people who think that if ISO-8859-7 was good enough for Jesus ... > > It may have been good enough for his disciples, but Jesus spoke Aramaic. The

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

2018-07-16 Thread Steven D'Aprano
label your output in Khmer, Hiragana and Gujarati if you don't want to. -- 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

I18N and Unicode [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
roups of users who share a single character set, even ASCII. My application might display "Rubbish Bin" in the UK and Australia and "Trash Can" in the USA. If you think that Unicode is about internationalization, you are labouring under serious misapprehensions about

Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
ebody who insists that because Python's float data type doesn't support full CAS (computer algebra system) and theorem prover, its useless and a step backwards and we should abandon IEEE-754 float semantics and let users implement their own floating point maths using nothing but fixed

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

2018-07-16 Thread Steven D'Aprano
tter "V", although that's non-standard. -- 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: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
On Mon, 16 Jul 2018 13:11:23 -0400, Richard Damon wrote: >> On Jul 16, 2018, at 12:51 PM, Steven D'Aprano >> wrote: >> >>> On Mon, 16 Jul 2018 00:28:39 +0300, Marko Rauhamaa wrote: >>> >>> if your new system used Python3's UTF-32 stri

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

2018-07-16 Thread Steven D'Aprano
and in for any string handling on ASCII over print("Hello World!") which works just as well if you control the data you are working with and know that it is pure ASCII. -- 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: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
so is just special pleading. And the thing about special pleading is that we're not obliged to accept it. Plead as much as you like, the answer is still no. -- 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: Users banned

2018-07-16 Thread Steven D'Aprano
ave words for that. There's no statute of limitation for murder, but surely "being obnoxious on the internet" ought to come with a fairly short period of forgiveness. -- 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

Python 4000 was Re: [SUSPICIOUS MESSAGE] Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
thon 3000'. Call it 'a mythical > Python 4000', if you must use such a term. I prefer to say Python 5000, to make it even more clear that should such a thing happen again, it will be a *REALLY* long time from now. -- Steven D'Aprano "Ever since I learned about confirm

Unicode is not UTF-32 [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
nsidered to be a single unit of language, which some people might choose to call a character. (But not a single letter, naturally.) If you don't like that example, "qu" is probably a better one: aside from acronyms and loan words, no modern English word can fail to follo

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
On Tue, 17 Jul 2018 06:15:25 +1000, Chris Angelico wrote: > On Tue, Jul 17, 2018 at 4:55 AM, Steven D'Aprano > wrote: >> There is nothing special about diacritics such that we ought to treat >> some combinations like "Ch" (two code points = one character) as &quo

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

2018-07-16 Thread Steven D'Aprano
ily dealt with by a helper function. That *is* a nice example of where byte strings in Python 3 aren't as nice as in Python 2. -- 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: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
veryone just used ASCII. -- 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: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
nits, and from 1 to 4 code units per code point; UTF-16 uses 2-byte code units (a 16-bit word), and 1 or 2 words per code point; UTF-32 uses 4-byte code units (a 32-bit word), and only ever a single code unit for every code point. -- Steven D'Aprano "Ever since I learned about

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-16 Thread Steven D'Aprano
even wrong. Of course a *single* byte cannot, but a single byte is not "UTF-8 bytes". -- 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: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-17 Thread Steven D'Aprano
On Mon, 16 Jul 2018 21:48:42 -0400, Richard Damon wrote: >> On Jul 16, 2018, at 9:21 PM, Steven D'Aprano >> wrote: >> >>> On Mon, 16 Jul 2018 19:02:36 -0400, Richard Damon wrote: >>> >>> You are defining a variable/fixed width codepoint set

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-17 Thread Steven D'Aprano
On Mon, 16 Jul 2018 21:25:20 -0500, Tim Chase wrote: > On 2018-07-17 01:08, Steven D'Aprano wrote: >> In English, I think most people would prefer to use a different term >> for whatever "sh" and "ch" represent than "character". > >

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-17 Thread Steven D'Aprano
On Tue, 17 Jul 2018 08:26:45 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : >> On Mon, 16 Jul 2018 22:51:32 +0300, Marko Rauhamaa wrote: >>> UTF-8 bytes can only represent the first 128 code points of Unicode. >> >> This is DailyWTF material. Perhaps y

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-17 Thread Steven D'Aprano
vert 'int' object to str implicitly Python strings are sequences of abstract characters. -- 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: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-17 Thread Steven D'Aprano
ion in the string object, as they do now. It might even be more compact, although a naive implementation would lose the ability to do constant time indexing into strings. That might be a tradeoff worth keeping, if indexing remained sufficiently fast. -- Steven D'Aprano "Ever

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-17 Thread Steven D'Aprano
-adding % support for byte strings) they will consider them, but going back to the Python 2 misdesign is off the table. -- 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: test for absence of infinite loop

2018-07-17 Thread Steven D'Aprano
times deal with that sort of thing is to re-write selected potentially-infinite loops: while condition: # condition may never become False do something to something like this: for counter in range(1000): if not condition: break do something else: raise TooManyIterationsErr

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-19 Thread Steven D'Aprano
> speaker) In English, that would be "shop assistant". "Assist shop" would be grammatically incorrect: it should be written as "assist the shop", meaning "help the shop". Relevant: https://www.theatlantic.com/technology/archive/2018/01/the-shallowness-of-google-translate/551570/ -- 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: [OT] Bit twiddling homework

2018-07-19 Thread Steven D'Aprano
On Fri, 20 Jul 2018 08:25:04 +0200, Brian Oney via Python-list wrote: > PS: Can I twiddle bits in Python? Yes. These operators work on ints: bitwise AND: & bitwise OR: | bitwise XOR: ^ -- Steven D'Aprano "Ever since I learned about confirmation bias, I&

Re: try except inside a with open

2018-07-20 Thread Steven D'Aprano
try and expect in a 'with open' function as shown in > the below example code . Yes. > (2) If I hit any other exceptions say Value-error can I catch them as > show below If you hit ValueError, that is almost always a bug in your code. That's exactly the sort of thing you *shouldn't* be covering up with an except clause unless you really know what you are doing. -- 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: Better way / regex to extract values form a dictionary

2018-07-21 Thread Steven D'Aprano
= os.path.basename(path) print filename # prints 'test04_Failures.log' testcase, remaining_junk = filename.split('_', 1) print testcase # prints 'test04' -- 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: Non-GUI, single processort inter process massaging - how?

2018-07-21 Thread Steven D'Aprano
nt the process ID. Let's say it prints 12345, over in another terminal, you can run: kill -USR1 12345 kill -USR2 12345 to send the appropriate signals. To do this programmatically from another Python script, use the os.kill() function. https://docs.python.org/3/library/signal.html

Re: coding style - where to declare variables

2018-07-22 Thread Steven D'Aprano
.k.a. "assignment") comes from lambda calculus; - which has no assignment (a.k.a. "binding"). Which leads us to the conclusion that lambda calculus both has and doesn't have binding a.k.a. assignment at the same time. Perhaps it is a quantum phenomenon. Are you happy with th

Re: coding style - where to declare variables

2018-07-22 Thread Steven D'Aprano
e. the "variables are a named box at a fixed memory location" model) include Algol, Pascal, Modula-3, C, C++, C#, Objective C, D, Swift, COBOL, Forth, Ada, PL/I, Rust and many others. -- 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: coding style - where to declare variables

2018-07-22 Thread Steven D'Aprano
and Python are the ones that are not "common". Indeed. Its not just older languages from the 60s and 70s with value-type variables. Newer languages intended as systems languages, like Rust and Go, do the same. -- Steven D'Aprano "Ever since I learned about confirmation bias

Re: coding style - where to declare variables

2018-07-23 Thread Steven D'Aprano
On Mon, 23 Jul 2018 20:24:30 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> So let me see if I understand your argument... >> >> - we should stop using the term "binding", because it means >> nothing different from assignment; >> -

Re: coding style - where to declare variables

2018-07-23 Thread Steven D'Aprano
different. [1] What, all of them? Even those with a comp sci PhD and 40 years programming experience in two dozen different languages? -- 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: coding style - where to declare variables

2018-07-23 Thread Steven D'Aprano
s on a long paper tape, and an analog computer emulating Python would use I-have-no-idea. Clockwork? Hydraulics? https://en.wikipedia.org/wiki/MONIAC https://makezine.com/2012/01/24/early-russian-hydraulic-computer/ [2] Except by dropping into ctypes or some other interface to the implementati

Re: coding style - where to declare variables

2018-07-23 Thread Steven D'Aprano
On Mon, 23 Jul 2018 14:39:56 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Lambda calculus has the concept of a binding operator, which is >> effectively an assignment operator: it takes a variable and a value and >> binds the value to the variable, changi

Re: Python 2.7.14 and Python 3.6.0 netcdf4

2018-07-23 Thread Steven D'Aprano
use you have the Python 2.7 version of the netCDF4 module installed in the Python 2.7 environment, doesn't mean it will magically work for Python 3.6. You have to install the module for 3.6 as well. How did you install it for Python 2.7? -- Steven D'Aprano "Ever since I

Re: Checking whether type is None

2018-07-24 Thread Steven D'Aprano
hese days, that is rarely what we need now. The usual way to check a type is: isinstance(something, dict) but even that should be rare. If you find yourself doing lots of type checking, using isinstance() or type(), then you're probably writing slow, inconvenient Python code.

Re: Checking whether type is None

2018-07-25 Thread Steven D'Aprano
s. It is wrong (in other words, it doesn't work) because it allows non-None objects to masquerade as None and pretend to be what they are not. If that's your intent, then of course you may do so. But without a comment explaining your intent, don't be surprised if more experienced P

Re: Checking whether type is None

2018-07-28 Thread Steven D'Aprano
_thing = None > >>> type(some_thing).__str__(some_thing) > 'None' > > Equally weird, I'd say, but what the heck... class Foo: def __str__(self): return 'None' -- 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: Are dicts supposed to raise comparison errors

2018-08-01 Thread Steven D'Aprano
actual problem; - or it is a false positive which (if unfixed) distracts attention and encourages a blasé attitude which could easily lead to problems in the future. Warnings are a code smell. Avoiding warnings is a way of "working clean": https://blog.codinghorror.com/programmer

Re: Are dicts supposed to raise comparison errors

2018-08-02 Thread Steven D'Aprano
. And my point was that ignoring warnings is not the right approach. Suppressing them on a case-by-case basis (if possible) is one thing, but a blanket suppression goes to far, for the reasons I gave earlier. -- Steven D'Aprano "Ever since I learned about confirmation bias, I've be

Re: Are dicts supposed to raise comparison errors

2018-08-02 Thread Steven D'Aprano
ample opportunity for code to accidentally compare bytes and text even in pure Python 3 code, e.g. comparing data read from files reading from files which are supposed to be opened in the same binary/text mode but aren't. -- Steven D'Aprano "Ever since I learned about confirmatio

Re: beware of linked in - mail used on this list

2018-08-02 Thread Steven D'Aprano
from people who I don't know from LinkedIn, and most of them don't even know they sent them. I got three from you yesterday. -- 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: machine learning forums

2018-08-05 Thread Steven D'Aprano
cated machine-learning site, "Cross Validated": https://meta.stackexchange.com/questions/130524/which-stack-exchange- website-for-machine-learning-and-computational-algorithms https://meta.stackexchange.com/questions/227757/where-to-ask-basic- questions-about-machine-learning -- Steven

<    26   27   28   29   30   31   32   33   34   35   >