MTG: Introductions to PyQt and DataClasses
The Auckland Branch of NZPUG meets this Wednesday, 20 March at 1830 NZDT (0530 UTC, midnight-ish Tue/Wed in American time-zones), for a virtual meeting. Part 1: Learn the basics of PyQt with code examples. Hannan Khan is currently consulting as a Data Scientist for the (US) National Oceanic and Atmospheric Administration. He holds a Bachelor's degree in Neuroscience as well as a Masters in Computer Science. As a keen member of the PySprings Users' Group (Colorado), his contribution is part of a collaboration between our two PUGs. Part 2: Why use Dataclasses? - will be the question asked, and answered, by yours truly. After surveying a number of groups, it seems most of us know that Dataclasses are available, but we don't use them - mostly because we haven't ascertained their place in our tool-box. By the end of this session you will, and will have good reason to use (or not) Dataclasses! Everyone is welcome from every location and any time-zone. The NZPUG Code of Conduct applies. JetBrains have kindly donated a door-prize. Our BigBlueButton web-conferencing instance is best accessed using Chromium, Brave, Vivaldi, Safari, etc, (rather than Firefox - for now). A head-set will facilitate asking questions but text-chat will be available. Please RSVP at https://www.meetup.com/nzpug-auckland/events/299764049/ See you there! =dn, Branch Leader -- https://mail.python.org/mailman/listinfo/python-list
Re: Configuring an object via a dictionary
On 17/03/24 12:06, Peter J. Holzer via Python-list wrote: On 2024-03-16 08:15:19 +, Barry via Python-list wrote: On 15 Mar 2024, at 19:51, Thomas Passin via Python-list wrote: I've always like writing using the "or" form and have never gotten bit I, on the other hand, had to fix a production problem that using “or” introducted. I avoid this idiom because it fails on falsy values. Perl has a // operator (pronounced "err"), which works like || (or), except that it tests whether the left side is defined (not None in Python terms) instead of truthy. This still isn't bulletproof but I've found it very handy. So, if starting from: def method( self, name=None, ): rather than: self.name = name if name else default_value ie self.name = name if name is True else default_value the more precise: self.name = name if name is not None or default_value or: self.name = default_value if name is None or name because "is" checks for identity, whereas "==" and True-thy encompass a range of possible alternate values? -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Configuring an object via a dictionary
On 2024-03-16 08:15:19 +, Barry via Python-list wrote: > > On 15 Mar 2024, at 19:51, Thomas Passin via Python-list > > wrote: > > I've always like writing using the "or" form and have never gotten bit > > I, on the other hand, had to fix a production problem that using “or” > introducted. > I avoid this idiom because it fails on falsy values. Perl has a // operator (pronounced "err"), which works like || (or), except that it tests whether the left side is defined (not None in Python terms) instead of truthy. This still isn't bulletproof but I've found it very handy. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Configuring an object via a dictionary
On 16/03/24 21:15, Barry via Python-list wrote: On 15 Mar 2024, at 19:51, Thomas Passin via Python-list wrote: I've always like writing using the "or" form and have never gotten bit I, on the other hand, had to fix a production problem that using “or” introducted. I avoid this idiom because it fails on falsy values. As with any other facility, one has to understand ALL implications! It must be one of those intensely-frustrating errors to track-down, which is then oh-so-simple to fix! Are you able to list (real, if suitably anonymised) examples of where the truthy/falsy was inappropriate, please? -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Configuring an object via a dictionary
On 3/16/2024 8:12 AM, Roel Schroeven via Python-list wrote: Barry via Python-list schreef op 16/03/2024 om 9:15: > On 15 Mar 2024, at 19:51, Thomas Passin via Python-list wrote: > > I've always like writing using the "or" form and have never gotten bit I, on the other hand, had to fix a production problem that using “or” introducted. I avoid this idiom because it fails on falsy values. Me too. It's just too fragile. When writing code you're going to need an alternative for cases where "config.get('source_name') or default_value" doesn't work correctly; much better to use that alternative for all cases. Trying to remember when I've used it, that was probably on personal code where I had a good idea what the values could be. Otherwise, I'm in agreement. -- https://mail.python.org/mailman/listinfo/python-list
Re: Configuring an object via a dictionary
Barry via Python-list schreef op 16/03/2024 om 9:15: > On 15 Mar 2024, at 19:51, Thomas Passin via Python-list wrote: > > I've always like writing using the "or" form and have never gotten bit I, on the other hand, had to fix a production problem that using “or” introducted. I avoid this idiom because it fails on falsy values. Me too. It's just too fragile. When writing code you're going to need an alternative for cases where "config.get('source_name') or default_value" doesn't work correctly; much better to use that alternative for all cases. -- "This planet has - or rather had - a problem, which was this: most of the people living on it were unhappy for pretty much of the time. Many solutions were suggested for this problem, but most of these were largely concerned with the movement of small green pieces of paper, which was odd because on the whole it wasn't the small green pieces of paper that were unhappy." -- Douglas Adams -- https://mail.python.org/mailman/listinfo/python-list
Re: Configuring an object via a dictionary
> On 15 Mar 2024, at 19:51, Thomas Passin via Python-list > wrote: > > I've always like writing using the "or" form and have never gotten bit I, on the other hand, had to fix a production problem that using “or” introducted. I avoid this idiom because it fails on falsy values. Barry -- https://mail.python.org/mailman/listinfo/python-list