not able to download PyAudio

2021-04-02 Thread ᗷᑌᑎᑎY
   Hello  everyone
   I am not able to download PyAudio. I tried by typing pip install in
   PyAudio in cmd but it show's no compatible version availbale. What should
   I do? .



   Y




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


how to separate the strings in a string

2021-04-02 Thread Egon Frerich
I have a string like

'"ab,c" , def'

and need to separate it into

"ab,c" and "def".

split separates at the first ',':

>>> bl
'"a,bc", def'
>>> bl.split(',')
['"a', 'bc"', ' def']


Egon





signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Aw: not able to download PyAudio

2021-04-02 Thread Karsten Hilbert
The same as with speech recognition.

Research.

Karsten

> Gesendet: Freitag, 02. April 2021 um 10:40 Uhr
> Von: "ᗷᑌᑎᑎY" 
> An: "Igor Korot" 
> Cc: "python-list@python.org" 
> Betreff: not able to download PyAudio
>
>Hello  everyone
>I am not able to download PyAudio. I tried by typing pip install in
>PyAudio in cmd but it show's no compatible version availbale. What should
>I do? .
> 
> 
> 
>Y
> 
> 
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: not able to download PyAudio

2021-04-02 Thread Benjamin Schollnick

> On Apr 2, 2021, at 4:40 AM, ᗷᑌᑎᑎY  wrote:
> 
>   Hello  everyone
>   I am not able to download PyAudio. I tried by typing pip install in
>   PyAudio in cmd but it show's no compatible version availbale. What should
>   I do? .

There seems to be some confusion, which I can understand…  

“No compatible version”, simply means that Pip was unable to find a version of 
 for your version of python.

Please note, that does not mean that a version *EXISTS*, just that it could not 
find a version for your platform.

So go to https://pypi.org  and do a search.  

- Benjamin


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


Re: how to separate the strings in a string

2021-04-02 Thread Peter Otten

On 02/04/2021 11:16, Egon Frerich wrote:

I have a string like

'"ab,c" , def'

and need to separate it into

"ab,c" and "def".

split separates at the first ',':


bl

'"a,bc", def'

bl.split(',')

['"a', 'bc"', ' def']



The initial string looks like it's close enough to the CSV format.
Unfortunately Python's csv module operates on files, not strings -- to
use it you have to wrap the string into a stream:

>>> import csv
>>> import io
>>> next(csv.reader(io.StringIO('"ab,c" , def')))
['ab,c ', ' def']


Apply str.strip() on every part to remove leading and trailing whitespace:


>>> def mysplit(s):
return [part.strip() for part in next(csv.reader(io.StringIO(s)))]

>>> mysplit('"ab,c" , def')
['ab,c', 'def']

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


Re: how to separate the strings in a string

2021-04-02 Thread Peter Otten

On 02/04/2021 12:38, Peter Otten wrote:

On 02/04/2021 11:16, Egon Frerich wrote:

I have a string like

'"ab,c" , def'

and need to separate it into

"ab,c" and "def".

split separates at the first ',':


bl

'"a,bc", def'

bl.split(',')

['"a', 'bc"', ' def']



The initial string looks like it's close enough to the CSV format.
Unfortunately Python's csv module operates on files, not strings -- to
use it you have to wrap the string into a stream:


import csv
import io
next(csv.reader(io.StringIO('"ab,c" , def')))

['ab,c ', ' def']


Apply str.strip() on every part to remove leading and trailing whitespace:



def mysplit(s):

 return [part.strip() for part in next(csv.reader(io.StringIO(s)))]


mysplit('"ab,c" , def')

['ab,c', 'def']



I forgot that the reader() accepts arbitrary iterables. Instead of
io.StringIO(s) you can just write [s].

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


Re: memory consumption

2021-04-02 Thread Alexey
> I had the (mis)pleasure of dealing with a multi-terabyte postgresql 
> instance many years ago and figuring out why random scripts were eating 
> up system memory became quite common. 
> 
> All of our "ETL" scripts were either written in Perl, Java, or Python 
> but the results were always the same, if a process grew to using 1gb of 
> memory (as your case), then it never "released" it back to the OS. What 
> this basically means is that your script at one time did in fact 
> use/need 1GB of memory. That becomes the "high watermark" and in most 
> cases usage will stay at that level. And if you think about it, it makes 
> sense. Your python program went through the trouble of requesting memory 
> space from the OS, it makes no sense for it to give it back to the OS as 
> if it needed 1GB in the past, it will probably need 1GB in the future so 
> you will just waste time with syscalls. Even the glibc docs state 
> calling free() does not necessarily mean that the OS will allocate the 
> "freed" memory back to the global memory space. 
> 
> There are basically two things you can try. First, try working in 
> smaller batch sizes. 10,000 is a lot, try 100. Second, as you hinted, 
> try moving the work to a separate process. The simple way to do this 
> would be to move away from modules that use threads and instead use 
> something that creates child processes with fork(). 

Thank you!

Decided to use separate process, because despite some improvements
and positive effects when it runs within Celery in production environment
there are still some significant overheads.

Another problem occurred with "Using Connection Pools with 
Multiprocessing or os.fork()" but I figured it out with 'Engine.dispose()' and
and 'pool_pre_ping'. Solutions can be found in official documentation for
SQLAlchemy.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Horrible abuse of __init_subclass__, or elegant hack?

2021-04-02 Thread Chris Angelico
On Fri, Apr 2, 2021 at 10:43 AM dn via Python-list
 wrote:
>
> On 02/04/2021 10.13, Chris Angelico wrote:
> > Well, it's a simple matter of chronology. First you have crude oil,
> > then time passes, and then you have plastic and residue. It makes
> > sense ONLY if you think of it with a specific ordering, which implies
> > Python 3.7 or later.
>
> My anxiety over 'ordering' comes to the fore: if there are multiple
> inputs and/or multiple outputs, how can one tell where the former series
> ends and the latter begins?
>
> "Explicit" cf "implicit"?

The exact same way. Before time passes, you have all of the inputs;
after time passes, you have all of the outputs. (The way the game
goes, all inputs are consumed simultaneously and all outputs produced
simultaneously, so there's no chronological distinctions between
them.)

> > Hot chocolate? Ahh, now, that's the other thing I drink a lot of. I
> > even have a dedicated mug with a Cadbury logo on it. Sadly, not easily
> > purchasable, but this one was a gift from a family member who knows
> > full well that I have my priorities straight.
>
> Cadbury do not make chocolate!
> Neither do Hershey, for that matter!
> There, now that I've upset most of the English-speaking world...
>
> PS they use the milk to 'water down' the chocolate! It's much like
> buying Easter Eggs: the density of chocolate is much lower for the price.

Chocolate comes in tiers.

1: Top tier chocolates - fine chocolates - are made by true artisans,
and are generally purchased in smaller quantities due to pricing.
(Although I did once buy something like 50kg of Lindor balls. That was
a gd day.)

2: Everyday chocolate. Mass-produced, so it's lower quality but far
lower in price. Sure, it's not as amazing as eating Guylian or Godiva,
but you can eat a block of Cadbury every day and still be within
budget.

3: Cooking chocolate. Comes cheaper than typical block chocolate, is
usually firmer, and takes more effort to make good use of, but you can
take a potato peeler to it and put chocolate shavings on your Pavlova,
which doesn't really work as well with a block of Dairy Milk.

4: Cheap chocolate. Easter eggs, bulk stuff, the sorts of things you
throw at children to keep them happy. Sometimes has nostalgia value,
but it's low-grade stuff. Some of it isn't too bad, but you end up
paying MORE for it than you would for tier two chocolate, since it's
usually packaged up far too much. Also, some of it is downright
disgusting. I won't name names, but one time I had access to a bulk
load of white chocolate (and yes, you could say that white chocolate
isn't chocolate to start with, but some of it is actually good), and
it tasted like milk powder. Why people pay so much for low-grade
chocolate wrapped up in fiddly foil covers, I don't know.

> View
> https://www.whittakers.co.nz/en_NZ/products/72-dark-ghana/block-250g
> before questioning my curmugeonly credentials!

Oh yes, that's definitely one of the good brands. By "credentials", do
you mean that you have some connection with the company? If not,
that's fine, but it would certainly be notable if you do!

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


all versions of python fail to indent after conditional statement

2021-04-02 Thread mikedianeterry



   The following snap shot of system prompt illustrates my problem. I have
   tried 3.8, 3.92 and 3.10 with the same result. When I run in the window
   interface it doesn't even display one row of ... but does print if I hit
   return twice. I'm new to Python and was excited about learning it but am
   becoming very frustrated over a bug in such a simple conditional statement
   - please help as I would really like to master Python.

   Regards,

   Michael Terry



   Microsoft Windows [Version 10.0.19041.867]

   (c) 2020 Microsoft Corporation. All rights reserved.

   C:\WINDOWS\system32>py



   Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64
   bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for
   more information.



   >>> dog_has_fleas=True

   >>> if dog_has_fleas:

   ... print('too bad')

 File "", line 2

   print('too bad')

   ^

   IndentationError: expected an indented block

   >>> Microsoft Windows [Version 10.0.19041.867]





   Sent from [1]Mail for Windows 10



References

   Visible links
   1. https://go.microsoft.com/fwlink/?LinkId=550986
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Horrible abuse of __init_subclass__, or elegant hack?

2021-04-02 Thread Alan Gauld via Python-list
On 02/04/2021 00:42, dn via Python-list wrote:

> Contrarily "tuck" in (old) English slang represented "sweets" (or

Not that old. We still use it occasionally today. And we
certainly had a "tuck shop" at school. It was where you
bought lunch if not eating in the refectory. ie. sandwiches,
crisps, pop etc. But its main sales were sweets including
chocolate bars  (bringing us back to Cadbury :-)

Unusually, our tuck shop was run by the student body. The
school prefects were the operating committee and
responsible for finding volunteers to staff it and
order supplies and bank the proceeds 9with the school
secretary)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: not able to download PyAudio

2021-04-02 Thread Terry Reedy

On 4/2/2021 6:09 AM, Benjamin Schollnick wrote:



On Apr 2, 2021, at 4:40 AM, ᗷᑌᑎᑎY  wrote:

   Hello  everyone
   I am not able to download PyAudio. I tried by typing pip install in
   PyAudio in cmd but it show's no compatible version availbale. What should
   I do? .


There seems to be some confusion, which I can understand…

“No compatible version”, simply means that Pip was unable to find a version of 
 for your version of python.

Please note, that does not mean that a version *EXISTS*, just that it could not 
find a version for your platform.

So go to https://pypi.org  and do a search.


https://pypi.org/project/PyAudio/#files shows that the latest version on 
pypi is for 3.6, uploaded 4 years ago.


https://www.lfd.uci.edu/~gohlke/pythonlibs/ has binaries for 3.7-9, but 
you have to download manually to your machine using the instructions at 
the top of the page.


--
Terry Jan Reedy


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


Re: all versions of python fail to indent after conditional statement

2021-04-02 Thread MRAB

On 2021-04-02 01:40, mikedianete...@gmail.com wrote:



The following snap shot of system prompt illustrates my problem. I have
tried 3.8, 3.92 and 3.10 with the same result. When I run in the window
interface it doesn't even display one row of ... but does print if I hit
return twice. I'm new to Python and was excited about learning it but am
becoming very frustrated over a bug in such a simple conditional statement
- please help as I would really like to master Python.

Regards,

Michael Terry



Microsoft Windows [Version 10.0.19041.867]

(c) 2020 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>py



Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64
bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for
more information.



>>> dog_has_fleas=True

>>> if dog_has_fleas:

... print('too bad')

  File "", line 2

print('too bad')

^

IndentationError: expected an indented block


It said that it expected an indented block. You didn't indent the block.

Python uses indentation, but the Python prompt doesn't indent 
automatically, you have to do that yourself.

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


Re: all versions of python fail to indent after conditional statement

2021-04-02 Thread Joe Pfeiffer
It's not a bug, it's a design choice you are disagreeing with:  managing
indentation is your job, not the interpreter's.  For anything other than
an absolutely trivial three-line script, I write in an editor that does
a good job helping me manage indentation (in my case, emacs in Python
mode).

 writes:

>The following snap shot of system prompt illustrates my problem. I have
>tried 3.8, 3.92 and 3.10 with the same result. When I run in the window
>interface it doesn't even display one row of ... but does print if I hit
>return twice. I'm new to Python and was excited about learning it but am
>becoming very frustrated over a bug in such a simple conditional statement
>- please help as I would really like to master Python.
>
>Regards,
>
>Michael Terry
>
>
>
>Microsoft Windows [Version 10.0.19041.867]
>
>(c) 2020 Microsoft Corporation. All rights reserved.
>
>C:\WINDOWS\system32>py
>
>
>
>Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64
>bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for
>more information.
>
>
>
>>>> dog_has_fleas=True
>
>>>> if dog_has_fleas:
>
>... print('too bad')
>
>  File "", line 2
>
>print('too bad')
>
>^
>
>IndentationError: expected an indented block
>
>>>> Microsoft Windows [Version 10.0.19041.867]
>
>
>
>
>
>Sent from [1]Mail for Windows 10
>
>
>
> References
>
>Visible links
>1. https://go.microsoft.com/fwlink/?LinkId=550986
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: all versions of python fail to indent after conditional statement

2021-04-02 Thread Mats Wichmann

On 4/2/21 9:42 AM, Joe Pfeiffer wrote:

It's not a bug, it's a design choice you are disagreeing with:  managing
indentation is your job, not the interpreter's.  For anything other than
an absolutely trivial three-line script, I write in an editor that does
a good job helping me manage indentation (in my case, emacs in Python
mode).


The Python interactive interpreter is very useful for doing quick 
experiments in, but for any kind of serious work, you definitiely want 
an editor with an understanding of Python syntax to help you out.  Even 
the included IDLE development environment will auto-indent for you.  So 
will vim, emacs, Visual Studio Code, PyCharm, Eric, Atom, Wing IDE and a 
host of others.  No need to get frustrated!!!




 writes:


The following snap shot of system prompt illustrates my problem. I have
tried 3.8, 3.92 and 3.10 with the same result. When I run in the window
interface it doesn't even display one row of ... but does print if I hit
return twice. I'm new to Python and was excited about learning it but am
becoming very frustrated over a bug in such a simple conditional statement
- please help as I would really like to master Python.



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


RE: Horrible abuse of __init_subclass__, or elegant hack?

2021-04-02 Thread Avi Gross via Python-list
Chris,

Now that it is April 2, I have to ask which of the methods for dealing with
chocolate is more pythonic and is there a module for that?

Next April, can we switch beans and discuss different grades of coffee and
which ones are best to shave at home with a potato peeler? 

I think that would be equally relevant. 

I will agree that some kinds of pie-thon have chocolate as a middle
ingredient but what good is any kind of pie without coffee?

Oops, I should have sent this yesterday!

Avi

-Original Message-
From: Python-list  On
Behalf Of Chris Angelico
Sent: Thursday, April 1, 2021 8:00 PM
To: Python 
Subject: Re: Horrible abuse of __init_subclass__, or elegant hack?

On Fri, Apr 2, 2021 at 10:43 AM dn via Python-list 
wrote:
>
> On 02/04/2021 10.13, Chris Angelico wrote:
> > Well, it's a simple matter of chronology. First you have crude oil, 
> > then time passes, and then you have plastic and residue. It makes 
> > sense ONLY if you think of it with a specific ordering, which 
> > implies Python 3.7 or later.
>
> My anxiety over 'ordering' comes to the fore: if there are multiple 
> inputs and/or multiple outputs, how can one tell where the former 
> series ends and the latter begins?
>
> "Explicit" cf "implicit"?

The exact same way. Before time passes, you have all of the inputs; after
time passes, you have all of the outputs. (The way the game goes, all inputs
are consumed simultaneously and all outputs produced simultaneously, so
there's no chronological distinctions between
them.)

> > Hot chocolate? Ahh, now, that's the other thing I drink a lot of. I 
> > even have a dedicated mug with a Cadbury logo on it. Sadly, not 
> > easily purchasable, but this one was a gift from a family member who 
> > knows full well that I have my priorities straight.
>
> Cadbury do not make chocolate!
> Neither do Hershey, for that matter!
> There, now that I've upset most of the English-speaking world...
>
> PS they use the milk to 'water down' the chocolate! It's much like 
> buying Easter Eggs: the density of chocolate is much lower for the price.

Chocolate comes in tiers.

1: Top tier chocolates - fine chocolates - are made by true artisans, and
are generally purchased in smaller quantities due to pricing.
(Although I did once buy something like 50kg of Lindor balls. That was a
gd day.)

2: Everyday chocolate. Mass-produced, so it's lower quality but far lower in
price. Sure, it's not as amazing as eating Guylian or Godiva, but you can
eat a block of Cadbury every day and still be within budget.

3: Cooking chocolate. Comes cheaper than typical block chocolate, is usually
firmer, and takes more effort to make good use of, but you can take a potato
peeler to it and put chocolate shavings on your Pavlova, which doesn't
really work as well with a block of Dairy Milk.

4: Cheap chocolate. Easter eggs, bulk stuff, the sorts of things you throw
at children to keep them happy. Sometimes has nostalgia value, but it's
low-grade stuff. Some of it isn't too bad, but you end up paying MORE for it
than you would for tier two chocolate, since it's usually packaged up far
too much. Also, some of it is downright disgusting. I won't name names, but
one time I had access to a bulk load of white chocolate (and yes, you could
say that white chocolate isn't chocolate to start with, but some of it is
actually good), and it tasted like milk powder. Why people pay so much for
low-grade chocolate wrapped up in fiddly foil covers, I don't know.

> View
> https://www.whittakers.co.nz/en_NZ/products/72-dark-ghana/block-250g
> before questioning my curmugeonly credentials!

Oh yes, that's definitely one of the good brands. By "credentials", do you
mean that you have some connection with the company? If not, that's fine,
but it would certainly be notable if you do!

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

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


Re: Horrible abuse of __init_subclass__, or elegant hack?

2021-04-02 Thread Chris Angelico
On Sat, Apr 3, 2021 at 3:51 AM Avi Gross via Python-list
 wrote:
>
> Chris,
>
> Now that it is April 2, I have to ask which of the methods for dealing with
> chocolate is more pythonic and is there a module for that?

I have a JavaScript front end package called "Chocolate Factory",
which works well for making a web app with a Python back end.

> Next April, can we switch beans and discuss different grades of coffee and
> which ones are best to shave at home with a potato peeler?

Sure! I don't have any experience with shaving coffee, though, so I'll
leave that thread for you.

> I think that would be equally relevant.
>
> I will agree that some kinds of pie-thon have chocolate as a middle
> ingredient but what good is any kind of pie without coffee?

Ohh, you've perhaps never tasted a good Aussie meat pie. With or
without coffee, those are awesome.

> Oops, I should have sent this yesterday!

Blame timezones :)

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


[RELEASE] Python 3.9.3 and 3.8.9 are now available

2021-04-02 Thread Łukasz Langa
Those are expedited security releases, recommended to all users. Get them here:

https://www.python.org/downloads/release/python-393/ 


https://www.python.org/downloads/release/python-389/ 

Security Content

bpo-43631 : high-severity CVE-2021-3449 and 
CVE-2021-3450 were published for OpenSSL, it’s been upgraded to 1.1.1k in CI, 
and macOS and Windows installers.
bpo-42988 : CVE-2021-3426: Remove the 
getfile feature of the pydoc module which could be abused to read arbitrary 
files on the disk (directory traversal vulnerability). Moreover, even source 
code of Python modules can contain sensitive data like passwords. Vulnerability 
reported by David Schwörer.
bpo-43285 : ftplib no longer trusts the IP 
address value returned from the server in response to the PASV command by 
default. This prevents a malicious FTP server from using the response to probe 
IPv4 address and port combinations on the client network. Code that requires 
the former vulnerable behavior may set a trust_server_pasv_ipv4_address 
attribute on their ftplib.FTP instances to True to re-enable it.
bpo-43439 : Add audit hooks for 
gc.get_objects(), gc.get_referrers() and gc.get_referents(). Patch by Pablo 
Galindo.
 
Release
 Calendar

Due to the security fixes, those releases are made a month sooner than planned. 
I decided to keep the release calendar intact, meaning that the last full 
regular maintenance release of Python 3.8 is still planned for May 3rd 2021, 
after which it will shift to source releases only for security bug fixes only. 
Maintenance releases for the 3.9 series will continue at regular bi-monthly 
intervals, with 3.9.3 planned for May 3rd 2021 as well.

 
What’s
 new?

The Python 3.9 series contains many new features and optimizations over 3.8. 
See the “What’s New in Python 3.9  
” document for more information 
about features included in the 3.9 series. We also have a detailed change log 
for 3.9.3  
specifically.

Detailed information about all changes made in version 3.8.9 can be found in 
its respective changelog 
.

 
We
 hope you enjoy those new releases!

Thanks to all of the many volunteers who help make Python Development and these 
releases possible! Please consider supporting our efforts by volunteering 
yourself or through organization contributions to the Python Software 
Foundation.

Your friendly release team,
Ned Deily @nad 
Steve Dower @steve.dower 
Łukasz Langa @ambv 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Horrible abuse of __init_subclass__, or elegant hack?

2021-04-02 Thread dn via Python-list
On 02/04/2021 21.32, Alan Gauld via Python-list wrote:
> On 02/04/2021 00:42, dn via Python-list wrote:
> 
>> Contrarily "tuck" in (old) English slang represented "sweets" (or
> 
> Not that old. We still use it occasionally today. And we
> certainly had a "tuck shop" at school. It was where you
> bought lunch if not eating in the refectory. ie. sandwiches,
> crisps, pop etc. But its main sales were sweets including
> chocolate bars  (bringing us back to Cadbury :-)
> 
> Unusually, our tuck shop was run by the student body. The
> school prefects were the operating committee and
> responsible for finding volunteers to staff it and
> order supplies and bank the proceeds 9with the school
> secretary)


Old? I suspect we need a veritable line of people holding up their hands
so that we can count on their fingers the number of years since we were
at our respective schools!

We did not have any choice of meals: one ate what was given - or did
not. (yes, that is in-itself a choice) Thus "tuck" was a cupboard/closet
from which we could purchase confectionery for pleasurable-eating.

Given that today we refer to such as 'junk foods', I have no need to
comment further on the (perceived) quality of our meals... although I
suspect one could/can only 'graduate' from such institutions after
putting-in considerable practise at varied complaints about the food -
or is that merely a tradition?

Once I had 'debugged' chocolate (and tested the range assiduously and
exhaustively), Bournville was the only Cadbury chocolate I would
consider. Today, even that seems to lack, er, chocolate, and has an
unsatisfactory after-taste.

Over here, Cadbury attempted to replace ingredients with Palm Oil. It
caused a minor-revolution. The result tasted ghastly and left a slick
and messy taste in one's mouth. Needless to say, whilst many were dumped
(in the harbor?) the company hurriedly reversed that decision.


However, (and ensuring Python remains within the subject of
conversation) it is worth noting that the Cadbury brothers had some
ideas about caring for workers/contributors in similar manner to PSF's
interests in egalitarianism and diversity - certainly a quality-of-life
beyond those of the often quoted 'advances' credited to Henry Ford.
https://www.cadbury.co.uk/about-bournville (maybe they are recognised in
British cf US management texts?)
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Horrible abuse of __init_subclass__, or elegant hack?

2021-04-02 Thread dn via Python-list
On 02/04/2021 13.00, Chris Angelico wrote:
> On Fri, Apr 2, 2021 at 10:43 AM dn via Python-list
>  wrote:
>>
>> On 02/04/2021 10.13, Chris Angelico wrote:
>>> Well, it's a simple matter of chronology. First you have crude oil,
>>> then time passes, and then you have plastic and residue. It makes
>>> sense ONLY if you think of it with a specific ordering, which implies
>>> Python 3.7 or later.
>>
>> My anxiety over 'ordering' comes to the fore: if there are multiple
>> inputs and/or multiple outputs, how can one tell where the former series
>> ends and the latter begins?
>>
>> "Explicit" cf "implicit"?
> 
> The exact same way. Before time passes, you have all of the inputs;
> after time passes, you have all of the outputs. (The way the game
> goes, all inputs are consumed simultaneously and all outputs produced
> simultaneously, so there's no chronological distinctions between
> them.)

Ah, I hadn't suspended enough of (my) reality to realise that we are
talking about a game.

Morphology in the arms of Morpheus?

English Idiom/quotation:
https://en.wiktionary.org/wiki/in_the_arms_of_Morpheus


> Chocolate comes in tiers.
> 
> 1: Top tier chocolates - fine chocolates - are made by true artisans,

It is well to remember artisans (people who work with artesian water?),
but I'm more interested in being an aficionado - thus any
addition/alteration to the chocolate is at best diminution, and at
worst, 'pollution'!

Stop being distracted, AND save money!


> 2: Everyday chocolate. ...can eat a block of Cadbury every day

I realised that the days of my six-pack were over when I met chocolate.
These days rather than an eight-pack, I'm settling for an ate-pack!

"Six pack" abs:
https://www.menshealth.com/uk/building-muscle/a747790/four-week-six-pack-plan/

"Ate-pack": I saw it. I ate it!


> 3: Cooking chocolate. 

Eating this sounds much like drinking from a plain, brown, bag...


> 4: Cheap chocolate. 

This is like trying to write Python code as if it were Java - they even
taste much the same!


>> View
>> https://www.whittakers.co.nz/en_NZ/products/72-dark-ghana/block-250g
>> before questioning my curmugeonly credentials!
> 
> Oh yes, that's definitely one of the good brands. By "credentials", do
> you mean that you have some connection with the company? If not,
> that's fine, but it would certainly be notable if you do!

Meaning that you'd only love me for my (access to) chocolate?
(I'd feel so used - if the chocolate 'high' allowed)

Sadly, my only connection to the company is purchaser:supplier. However,
I should volunteer to be a taster, or to use my ?expertise to train
their staff. Do you think they have an 'all you can eat' policy?

Is there such a thing as F/LOSS in the chocolate world? What does it
mean to fork a block of chocolate? Where is their repository?


My overwhelming qualifications and thus "credentials", and those which I
seem to be extending most often these days, involve ageing
(dis-)gracefully and becoming a curmudgeon.

Definition of 'grumpy old man': https://www.dictionary.com/browse/curmudgeon

Bah, the chocolate these days is nothing like what we had when I were a
lad...!
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Horrible abuse of __init_subclass__, or elegant hack?

2021-04-02 Thread Chris Angelico
On Sat, Apr 3, 2021 at 8:16 AM dn via Python-list
 wrote:
> Is there such a thing as F/LOSS in the chocolate world? What does it
> mean to fork a block of chocolate? Where is their repository?
>

It means exactly what you'd expect. The tricky part comes when you try
to knife the block of chocolate, and it makes for a hilarious party
game.

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


Friday Finking: initialising values and implied tuples

2021-04-02 Thread dn via Python-list
When there are several items to be defined and initialised, how do you
prefer to format the code, and why?


Apprentice: learn options
Journeyman: consider and discuss
Python Master: define, declare, and correct/advise/tutor


Some do not realise that using a tuple is a convenient way to convey
multiple values. Indeed if a function returns multiple values, that is
exactly what is happening, eg return x, y, z

Further, some think that the surrounding parentheses, ie ( surrounding
); 'define' the data-construct to be a tuple. This is not
completely-correct. In fact, it is the comma-separated list (in this
context) which identifies the data as a tuple - a 'tuple literal'.

https://docs.python.org/3/reference/expressions.html?highlight=literal%20tuple#parenthesized-forms

[yes, there'll be folk who decide that this *brief* intro should be the
discussion topic...]


The essence is to apply various values to a series of objects. Simple?
Using tuples can have its advantages, but as their length increases
humans have difficulties with the positional nature/relationship.

Here are a couple of ways that you may/not have seen, to express the
need (and perhaps you could contribute more?). Which one(s) make sense
to you; for visual reasons, 'speed', cognition, ... ?


(a) basic linear presentation:

resource = "Oil"
time = 1
crude = 2
residue = 3
my_list = "long"


(b) using explicit tuples:

( resource, time, crude, residue, my_list ) = ( "Oil", 1, 2, 3, "long" )


(c) linear and indented tuples:

(
resource,
time,
crude,
residue,
my_list
) = (
"Oil",
1,
2,
3,
"long"
)


(d) linear and differently-indented tuples:

(
resource,
time,
crude,
residue,
my_list
) = (
"Oil",
1,
2,
3,
"long"
)


(e) implicit tuples:

resource, time, crude, residue, my_list = "Oil", 1, 2, 3, "long"


NB a multiple-line expression is not possible using an 'implicit'
format! (unless one uses unattractive/distracting back-slashes)


(f) the space-saver:

resource = "Oil"; time = 1; crude = 2; residue = 3; my_list = "long"


Perhaps your editor/IDE prefers or frustrates one/other of the choices?
Perhaps your formatter/linter grinds you into submission?
Perhaps you have different approaches depending upon the number of
objects in the 'list' and the proximity of column-79, or by nature of
the application?
-- 
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Friday Finking: initialising values and implied tuples

2021-04-02 Thread Marco Ippolito
> (a) basic linear presentation:
> 
> resource = "Oil"
> time = 1
> crude = 2
> residue = 3
> my_list = "long"
> 
> (b) using explicit tuples:
> 
> ( resource, time, crude, residue, my_list ) = ( "Oil", 1, 2, 3, "long" )
> 
> (c) linear and indented tuples:
> 
> (
> resource,
> time,
> crude,
> residue,
> my_list
> ) = (
> "Oil",
> 1,
> 2,
> 3,
> "long"
> )

Choose: (a).

In (b) I have a problem matching identifiers to values horizontally at a
glance and in (c) I have the same problem vertically: i.e. "is 3 the value for
residue or crude above/to-the-left?"

Cognitive burden slows down and fatigues.

Alternatively, if the data "fits together", use a `namedtuple` with kwarg
initialisation or structured data types like `dataclasses`.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Friday Finking: initialising values and implied tuples

2021-04-02 Thread 2QdxY4RzWzUUiLuE
On 2021-04-02 at 19:25:07 -0300,
Marco Ippolito  wrote:

> > (a) basic linear presentation:
> > 
> > resource = "Oil"
> > time = 1
> > crude = 2
> > residue = 3
> > my_list = "long"
> > 
> > (b) using explicit tuples:
> > 
> > ( resource, time, crude, residue, my_list ) = ( "Oil", 1, 2, 3, "long" )
> > 
> > (c) linear and indented tuples:
> > 
> > (
> > resource,
> > time,
> > crude,
> > residue,
> > my_list
> > ) = (
> > "Oil",
> > 1,
> > 2,
> > 3,
> > "long"
> > )
> 
> Choose: (a).

I agree.

That said, I sometimes end up with something like this:

( resource, time, crude, residue, my_list ) = \
( "Oil", 1, 2, 3, "long" )

which mitigates matching up which value goes with which name.  But as
soon as either tuple overflows one physical line, it's back to (a).

I did go through a phase where I tried (c); note the past tense.

> In (b) I have a problem matching identifiers to values horizontally at
> a glance and in (c) I have the same problem vertically: i.e. "is 3 the
> value for residue or crude above/to-the-left?"
> 
> Cognitive burden slows down and fatigues.

Yep.

> Alternatively, if the data "fits together", use a `namedtuple` with
> kwarg initialisation or structured data types like `dataclasses`.

IMO, that's usually more troule than it's worth, although

thing = new_thing(
resource="Oil",
time=1,
crude=2,
residue=3,
my_list="long")

is often better than a collection of positional parameters.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Friday Finking: initialising values and implied tuples

2021-04-02 Thread Rob Cliffe via Python-list



On 02/04/2021 23:10, dn via Python-list wrote:

(f) the space-saver:

resource = "Oil"; time = 1; crude = 2; residue = 3; my_list = "long"

   
IMO This can be OK when the number of items is VERY small (like 2) and 
not expected to increase (or decrease).  Especially if there are 
multiple similar initialisations:

    x = 1; y = 2
        ...
    x = 2 ; y = 6
This saves vertical space and the similarity of the initialisations may 
be more apparent.  It also means only a single line need be 
cut/pasted/modified.

No doubt others will disagree.

This answer reflects my willingness to use multiple statements on a line 
OCCASIONALLY, WHEN I think it is appropriate (as I have said or implied 
in other posts), whereas many people seem to regard this as completely 
taboo.

Another example:
    x1 = 42; y1 =  3;  z1 = 10
    x2 = 41; y2 = 12; z2 = 9
    x3 =  8;  y3 =  8;  z3 = 10
(please imagine it's in a fixed font with everything neatly vertically 
aligned).
This has see-at-a-glance STRUCTURE: the letters are aligned vertically 
and the "subscripts" horizontally.  Write it as 9 lines and it becomes 
an amorphous mess in which mistakes are harder to spot.

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


Re: Horrible abuse of __init_subclass__, or elegant hack?

2021-04-02 Thread Alan Gauld via Python-list
On 02/04/2021 21:33, dn via Python-list wrote:

> Bournville was the only Cadbury chocolate I would
> consider. Today, even that seems to lack

Cadbury has always been a budget chocolate brand(*) here;
its a mass market option loaded with sugar and little
else. Certainly doesn't compare to Suchards, Lindt,
Nestle or Green & Black, or even Lidl's own brand:
Fin Carre (especially their "Rich Dark" milk choco!
).

(*)I'm guessing Hershey is the equivalent stateside?

> conversation) it is worth noting that the Cadbury brothers had some
> ideas about caring for workers/contributors in similar manner to PSF's
> interests in egalitarianism and diversity - certainly a quality-of-life
> beyond those of the often quoted 'advances' credited to Henry Ford.

Indeed, social engineering that to some extent still
exists today.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: Friday Finking: initialising values and implied tuples

2021-04-02 Thread Alan Gauld via Python-list
On 02/04/2021 23:10, dn via Python-list wrote:
> When there are several items to be defined and initialised, how do you
> prefer to format the code, and why?

> (a) basic linear presentation:
> 
> resource = "Oil"
> time = 1
> crude = 2
> residue = 3
> my_list = "long"

In production code I'd almost always go with this one.
It's the only option that both keeps the variable and value
together and allows me to add an explanatory comment if
necessary.

> (e) implicit tuples:
> 
> resource, time, crude, residue, my_list = "Oil", 1, 2, 3, "long"
Occasionally, and in personal code, I'll  use this.
Although this would be about as many items I'd ever
have in one list.

But in production code, if items are related, I'd use it.
eg.
x,y = 42,50   # starting coordinates
hour,min,sec = 0,0,0  # default start time

But in both those cases I'd more likely define a variable
to be a tuple:
eg.
start = (42,50)  # starting coordinates

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: Friday Finking: initialising values and implied tuples

2021-04-02 Thread 2QdxY4RzWzUUiLuE
On 2021-04-03 at 02:41:59 +0100,
Rob Cliffe via Python-list  wrote:

>     x1 = 42; y1 =  3;  z1 = 10
>     x2 = 41; y2 = 12; z2 = 9
>     x3 =  8;  y3 =  8;  z3 = 10
> (please imagine it's in a fixed font with everything neatly vertically
> aligned).
> This has see-at-a-glance STRUCTURE: the letters are aligned vertically
> and the "subscripts" horizontally.  Write it as 9 lines and it becomes
> an amorphous mess in which mistakes are harder to spot.

I agree that writing it as 9 lines is an accident waiting to happen, but
if you must see that structure, then go all in:

(x1, y1, z1) = (43,  3, 10)
(x2, y2, z2) = (41, 12,  9)
(x3, y3, z3) = ( 8,  8, 10)

Or even:

((x1, y1, z1)
 (x2, y2, z2)
 (x3, y3, z3)) = ((43,  3, 10)
  (41, 12,  9)
  ( 8,  8, 10))

Or not.  YMMV.  I guess this doesn't come up enough in my own code to
worry about it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Horrible abuse of __init_subclass__, or elegant hack?

2021-04-02 Thread Greg Ewing

On 3/04/21 10:36 am, Chris Angelico wrote:

It means exactly what you'd expect. The tricky part comes when you try
to knife the block of chocolate, and it makes for a hilarious party
game.


A guillotine could be useful in the case of Whittaker's.
IMO they don't make the grooves deep enough, making it
quite tricky to break off a row cleanly.

I'd upload a patch for that, but it doesn't seem to be
open source. At least I can't find it on chochub.

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


Python curses question: How to separate foreground and background colors from the value returned by inch()?

2021-04-02 Thread pjfarley3
The window.inch(([y, x])) function returns the character and attributes of
the character at the current or specified window position.  But how does one
separate the foreground and background colors from the resulting value?

colors = window.inch(0.0) & A_ATTRIBUTES

That should return the combined color + attributes value, but how to
separate the foreground and background color values from that result?
Should the following reliably work?

fg, bg = curses.pair_content (curses.pair_number(window.inch(0,0) &
A_ATTRIBUTES))

Peter


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


Re: Horrible abuse of __init_subclass__, or elegant hack?

2021-04-02 Thread dn via Python-list
On 03/04/2021 18.45, Greg Ewing wrote:
> On 3/04/21 10:36 am, Chris Angelico wrote:
>> It means exactly what you'd expect. The tricky part comes when you try
>> to knife the block of chocolate, and it makes for a hilarious party
>> game.
> 
> A guillotine could be useful in the case of Whittaker's.
> IMO they don't make the grooves deep enough, making it
> quite tricky to break off a row cleanly.

You're so right! It has become a filial duty, to be performed every time
I go to see my 90-year old mother. Also, noted the uneven division. Some
of the 'squares' are significantly larger/smaller than others!


> I'd upload a patch for that, but it doesn't seem to be
> open source. At least I can't find it on chochub.

Recommend you use our local facility:
https://git.nzoss.org.nz/users/sign_in
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list