Re: yield from () Was: Re: weirdness with list()

2021-03-12 Thread Thomas Jollans

On 03/03/2021 01:01, Cameron Simpson wrote:

On 02Mar2021 15:06, Larry Martell  wrote:

I discovered something new (to me) yesterday. Was writing a unit test
for generator function and I found that none of the function got
executed at all until I iterated on the return value.

Aye. Generators are lazy - they don't run at all until you ask for a
value.

By contrast, this is unlike Go's goroutines, which are busy - they
commence operation as soon as invoked and run until the first yield
(channel put, I forget how it is spelled now). This can cause excessive
CPU utilisation, but it handle for _fast_ production of results. Which
is a primary goal in Go's design.

Cheers,
Cameron Simpson 




I've been learning a bit more JavaScript recently (I know, I know, 
that's no fun) and I think that's the main practical difference between 
JavaScript's async functions, which are scheduled even if nobody awaits 
on them, and Python async functions which are just funky generators and 
therefore scheduled only when somebody awaits their result.




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


Re: Why assert is not a function?

2021-03-12 Thread Richard Damon
On 3/12/21 12:31 AM, Chris Angelico wrote:
> On Fri, Mar 12, 2021 at 3:53 PM Cameron Simpson  wrote:
>> For me, try/except is for when something might reasonably "go wrong" in
>> normal use, even niche normal use. Whereas assert is for things which
>> should _never_ occur. Roughly, again for me, try/except if for catching
>> misuse and assert is for catching misdesign/misimplementation.
> Something like that, yeah. An assertion failure represents a bug *in
> this code*, something that shouldn't ever happen. If it's possible to
> trigger the failure with some other piece of code (calling something
> with bad arguments, or whatever), then assert is the wrong tool for
> the job. Similarly, if you find yourself catching AssertionError
> anywhere outside of unit testing, something is horribly wrong
> somewhere :)
>
> ChrisA

Chris, I would disagree with that statement. An assert says that there
is something wrong with THE code, not THIS code. It is perfectly
reasonable, and good defensive programming, to assert on the
per-conditions to the procedure at its beginning.

Now, it may be true that a 'friendlier' procedure may be defined to
check some of these and return an error, but that then locks that
behavior into the API, so the cost of the check becomes an absolute
requirement.

In langauges like C, the assert for this may be more important because
the language provides more opportunity for 'undefined behavior'.

It is reasonable to skip the input assert if it becomes too expensive
for benefit it provides, or if something else will catch the error. This
likely actually applies to a lot of Python code, so it may seem that it
doesn't apply.

-- 
Richard Damon

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


<< robot control >>

2021-03-12 Thread Alex Kaye
I am looking for a package or module that

would use my Rasberry Pi 3 wirelessly to control a

land vehicle or someone to consult with to

discuss some of my options. Maybe with joystick commands.


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


Re: Why assert is not a function?

2021-03-12 Thread Chris Angelico
On Sat, Mar 13, 2021 at 12:11 AM Richard Damon  wrote:
>
> On 3/12/21 12:31 AM, Chris Angelico wrote:
> > On Fri, Mar 12, 2021 at 3:53 PM Cameron Simpson  wrote:
> >> For me, try/except is for when something might reasonably "go wrong" in
> >> normal use, even niche normal use. Whereas assert is for things which
> >> should _never_ occur. Roughly, again for me, try/except if for catching
> >> misuse and assert is for catching misdesign/misimplementation.
> > Something like that, yeah. An assertion failure represents a bug *in
> > this code*, something that shouldn't ever happen. If it's possible to
> > trigger the failure with some other piece of code (calling something
> > with bad arguments, or whatever), then assert is the wrong tool for
> > the job. Similarly, if you find yourself catching AssertionError
> > anywhere outside of unit testing, something is horribly wrong
> > somewhere :)
> >
> > ChrisA
>
> Chris, I would disagree with that statement. An assert says that there
> is something wrong with THE code, not THIS code. It is perfectly
> reasonable, and good defensive programming, to assert on the
> per-conditions to the procedure at its beginning.
>
> Now, it may be true that a 'friendlier' procedure may be defined to
> check some of these and return an error, but that then locks that
> behavior into the API, so the cost of the check becomes an absolute
> requirement.
>

It's perfectly reasonable to put "if condition: raise Blah", but is it
really reasonable to use the assert statement, which (a) might not be
run, and (b) raises a very generic exception? Make assertions about
your own code, not other people's.

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


Re: Why assert is not a function?

2021-03-12 Thread Marco Sulla
On Thu, 11 Mar 2021 at 23:11, Ethan Furman  wrote:
> Basically, you are looking at two different philosophies:
>
> - Always double check, get good error message when something fails
>
> vs
>
> - check during testing and QA, turn off double-checks for production for best 
> performance possible.

In a perfect world, I said the second option is the best. But for the
majority of projects I contributed, speed was not a critical issue. On
the contrary, it's very hard to get meaningful informations about
problems in production, so I'm in favour of the first school :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Scientific Software Developer | Job position at CMCC Foundation, Italy

2021-03-12 Thread info cmcc
*Please, feel free to circulate *
*to anyone you think may be interested.**---*

*Scientific Software Developer (code 12305)*


*Deadline: April 4th, 2021*

The CMCC is taking into consideration the possibility to hire a talented,
motivated and proactive Scientific Software Developer.
This job announcement is a public invitation to express interest for the
above mentioned CMCC Position.

The location is CMCC Headquarters in Lecce, Italy. Remote working is
considered as an option.

The main responsibility for this position is the design and development of
Python-based scientific tools and applications for climate data management
and analysis. Other duties will be related to the deployment using
container technologies (Docker, Kubernetes) and the engagement and
contribution to open source software communities.

The minimum qualifications are:

   - M.Sc. degree in Computer Science or Computer Engineering or equivalent
   fields;
   - 2+ years experience in scientific software development;
   - Excellent knowledge of Python programming languages;
   - Good knowledge of Python scientific libraries (numpy, scipy,pandas);
   - Excellent knowledge of Git;
   - Good knowledge of container technologies (Docker, Kubernetes);
   - Good working experience with Linux/Mac OS environments;
   - Good knowledge of both written and spoken English language.

Additional preferred experience:

   - Good knowledge of NETCDF/GRIB data formats and corresponding tools
   (NCO, CDO), and Python libraries (xarray, iris);
   - Experience with Jupyter notebooks;
   - Knowledge of Go programming languages;
   - Knowledge of databases – PostgreSQL, TimescaleDB.

Belonging to legally protected categories (ex L. 68/99) will constitute a
preferential condition.

The initial appointment is for n° 12 months starting from May 2021 at an
annual salary ranging from 22K to 34K Euros, comprehensive of benefits,
depending on qualification and experience.

*APPLY
NOW: 
https://cmccfoundation.applytojob.com/apply/L0Zntdu4Je/12305-Scientific-Software-Developer
*

-- 

Fondazione CMCCCentro Euro-Mediterraneo sui Cambiamenti Climatici
Via Augusto Imperatore, 16 - 73100 Lecce
[email protected] - www.cmcc.it
-- 
https://mail.python.org/mailman/listinfo/python-list


Uninstall error

2021-03-12 Thread Premmy
Hi. I am trying to uninstall python on my computer because i found a better
one but its not getting deleted from control panel. can you please help me

-- 
Regards,
N.V.S. Prem Kumar
Mobile: 07502069339
-- 
https://mail.python.org/mailman/listinfo/python-list


pygame "font not intialized"

2021-03-12 Thread Quentin Bock
my code is almost identical to this so I hope it's okay that I don't
include all of my code
error message:
font = pygame.font.Font('freesansbold.ttf', 32)
pygame.error: font not initialized

Tutorial Link: https://www.youtube.com/watch?v=FfWpgLFMI7w
Timestamp to this part of the video:  1:55:08
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pygame "font not intialized"

2021-03-12 Thread 2QdxY4RzWzUUiLuE
On 2021-03-12 at 17:27:36 -0500,
Quentin Bock  wrote:

> my code is almost identical to this so I hope it's okay that I don't
> include all of my code
> error message:
> font = pygame.font.Font('freesansbold.ttf', 32)
> pygame.error: font not initialized
> 
> Tutorial Link: https://www.youtube.com/watch?v=FfWpgLFMI7w
> Timestamp to this part of the video:  1:55:08

https://duckduckgo.com/?q=pygame.error%3A+font+not+initialized

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