Copy
View this email in your browser
Subscribed by mistake? Unsubscribe
DUTC WEEKLY
Issue no. 84
May 11th,  2022

Issue Preview


1. Front Page: Pop Goes the Seminar- NEW Standalone Session 
2. News Article: Fun and Games Series Is Almost Here
3. Cameron's Corner
4. Community Calendar

Pop Goes the Seminar:
NEW Standalone Session!

 
Our newest pop-up seminar,

“Make It Pretty in Matplotlib,”

is coming at you on

May 12th at 9:30 a.m. EDT!

What can you expect from this event? We're going to show you how to...
  • make high-quality plots using interfaces attached to tools like pandas, xarray, and seaborn
  • effectively communicate a message via data
  • make your graphs, charts, and plots pretty
There's still time to sign up! Get your ticket now!
THU, MAY 12, 2022 - Make it Pretty in Matplotlib - Standalone Seminar
THU, MAY 12, 2022 - Make it Pretty in Matplotlib - Standalone Seminar
$0.00 - $89.00
Tickets

Fun and Games Series Is Almost Here


Are you ready? Starting this Friday, May 13th, our instructors will walk you through essential Python concepts within the framework of your favorite games: Connect 4, Scrabble, Battleship, Wordle, and more! 

Best yet, if you sign up for the ALL Sessions pass, you get tickets to all four seminars, PLUS an invitation to an exclusive, VIP-only session!

What are you waiting for? Sign up now!
FRI, MAY 13, 2022 - Coding at the Speed of Thought ① Tic·Tac·Toe & Connect 4
FRI, MAY 13, 2022 - Coding at the Speed of Thought ① Tic·Tac·Toe & Connect 4
$0.00 - $399.00
Tickets
THU, MAY 19, 2022 - Coding at the Speed of Thought ② Jumble, Crossword, Scrabble
THU, MAY 19, 2022 - Coding at the Speed of Thought ② Jumble, Crossword, Scrabble
$0.00 - $399.00
Tickets
FRI, MAY 20, 2022 - Coding at the Speed of Thought ③ Battleship
FRI, MAY 20, 2022 - Coding at the Speed of Thought ③ Battleship
$0.00 - $399.00
Tickets
THU, MAY 26, 2022 - Coding at the Speed of Thought Ⓑ Bonus Session! (Wordle!)
THU, MAY 26, 2022 - Coding at the Speed of Thought Ⓑ Bonus Session! (Wordle!)
$0.00 - $399.00
Tickets



Cameron’s Corner
collections.namedtuple

In one of our recent intro courses, the topic of structured data came up. As we know, the tuple is typically used to model single conceptual entities. In our discussion with course attendees, we compared the
built-in
tuple and the collections.namedtuple to assess whether use of the latter could improve our code.
 

Definition


If we want to represent a grouping of fields corresponding to a single conceptual entity, the tuple type is the most appropriate built-in type for us to use.

For example, the below represents a device in a network that we manage:
devices = [
    ('abc.example.net', '5.17.5-arch1-1', 16, True),
    ('def.example.net', '5.17.1-arch1-1', 32, False),
]

for host, kernel_version, cores, requires_jumphost in devices:
    if requires_jumphost:
        ...
The below represents a collection of devices that we may iterate over as
part of our management of the network:
devices = [
    ('abc.example.net', '5.17.5-arch1-1', 16, True),
    ('def.example.net', '5.17.1-arch1-1', 32, False),
]

for host, kernel_version, cores, requires_jumphost in devices:
    if requires_jumphost:
        ...
It's likely that we would use unpacking syntax in order to interact with this data. It would be very hard for someone to read this code if we instead wrote if device[3] or if device[-1].

Unpacking syntax has been present in Python from at least as early as Python 0.9.1! (Stay tuned for a future blog post where I'll show you how I know…) In the years since, it has been extended:

An aside: you may wonder what PEP-3113 was all about. In Python 2, you can actually perform destructuring in function parameters. The below used to be possible:
def f((a, b)):
    pass

x = ..., ...
f(x) # NOTE: no `*`!
This was very useful when using a key= argument with {}.items:
sorted({}.items(), key=lambda (k,v): v) # Python 2
sorted({}.items(), key=lambda kv: kv[-1]) # Python 3
PEP-557 introduced the dataclasses.dataclass in Python 3.7, but prior to that, we are very likely to have used a collections.namedtuple as a way to add some additional conveniences to the modeling of our devices.

The
collections.namedtuple allows us to access the fields by name, which...
  • makes our code more readable
  • allows us to add more fields or re-arrange fields later (assuming we eliminate any use of unpacking syntax or any direct indexing)
from collections import namedtuple

Device = namedtuple('Device', 'host kernel_version cores requires_jumphost')
devices = [
    Device('abc.example.net', '5.17.5-arch1-1', 16, True),
    Device('def.example.net', '5.17.1-arch1-1', 32, False),
]

for dev in devices:
    if dev.requires_jumphost:
        ...
In Python 2, the collections.namedtuple had a verbose=True flag which would allow you to see all of the code that it would auto-generate. 
sorted(devices, lambda d: d.kernel_version)
sorted(devices, lambda d: d[1])
# Choice 1
# Choice 2
# Choice 3
@dataclass(frozen=True, order=True)
class T:
    a : int = field(default_factory=...)
    
class T(namedtuple(...)):
    def __new__(cls, ...):
        pass
Whew. Well, I think that's enough namedtuple for today! Hopefully, you've enjoyed this post, and make sure you stay tuned for when I take a slightly deeper dive comparing the namedtuple and dataclass

Community Calendar

DUTC: Make It Pretty in Matplotlib
May 12, 2022

Matplotlib is a popular tool for publication-quality (static) data visualization. The defaults have improved over time, but not all of its functionality is readily apparent to the casual user. In this seminar, we'll cover common tips & tricks for better communicating a message using data by showing you how to make your charts - and your message - stand out. Can we make Matplotlib pretty?
DUTC: Coding at the Speed of Thought ① Tic·Tac·Toe & Connect 4s
May 13, 2022

Tic·Tac·Toe and Connect 4 seem like easy enough games to model and play. But under extreme time constraints, how do we ensure that the code we write will be sufficiently clean and sufficiently flexible as a working prototype?
DUTC: Coding at the Speed of Thought - Jumble, Crossword, Scrabble
May 19, 2022

Turning our attention to the Sunday newspaper, let’s play some word games—Scrabble, the Crossword, and the Jumble. Under strict time constraints, can we model these problems, solve them, and develop generalized library code for them?
DUTC: Coding at the Speed of Thought - Battleship
May 20, 2022

You sunk my Battleship! Let’s play a complex board game with multiple rules, moving parts, and entities. Under strict time constraints, let’s see how we can rapidly develop small proofs-of-concept and connect them together into a fully functional working prototype. Can we do it? Can we sink the battleship?
Django Girls 2022
May 21, 2022

If you are a woman, know English and have a laptop, you can apply for this event to learn how to build a website! You don't need to know any technical stuff – this workshop is for people who are new to programming.
DUTC: Coding at the Speed of Thought - Wordle
May 26, 2022

Wordle has been the craze of early 2022. Let’s explore how we can model Wordle in our own terminal from its core mechanics to its minute details. We'll also examine how well we've prototyped this game as we tweak the engine to create some of Wordle's most popular (and fun) spin-offs!
PyCon LT 2022
May 26–27, 2022



DUTC's James Powell will be attending as a keynote speaker!

PyCon LT is a community event that brings together new and experienced Python users. Their goals are to grow and support a community of Python users, encourage learning and knowledge sharing, and popularize Python tools/libraries and open source in general. You can find more information on their website or Facebook page.
PyCon IT 2022
June 2–5, 2022

PyCon Italia is the Italian conference on Python. Organised by Python Italia, it has now become one of the most important Python conferences in Europe. With over 700 attendees, the next edition will be the 12th.
PyData London 2022
June 17–19, 2022



DUTC's James Powell will be attending, giving a talk, and hosting the PubQuiz!

PyData London 2022 is a 3-day event for the international community of users and developers of data analysis tools to share ideas and learn from each other. The global PyData network promotes discussion of best practices, new approaches, and emerging technologies for data management, processing, analytics, and visualization.
GeoPython 2022
June 20–22, 2022

The conference is focused on Python and Geo, its toolkits and applications. GeoPython 2022 will be the continuation of the yearly conference series. The conference started in 2016 and this is now the 7th edition. Key subjects for the conference series are the combination of the Python programming language and Geo.
EuroPython 2022
July 11–17, 2022

   

DUTC's James Powell and Cameron Riddell will be participating in the EuroPython mentorship program!

Welcome to the 21st EuroPython. We're the oldest and longest-running, volunteer-led Python programming conference on the planet! Join us in July in the beautiful and vibrant city of Dublin. We'll be together, face to face and online, to celebrate our shared passion for Python and its community!
Kiwi PyCon 2022
August 19–21, 2022

The first-ever Kiwi PyCon was held in Ōtautahi Christchurch, in 2009, the same year that New Zealand Python User Group was founded. The Garden City holds a very special place in the history of Python in New Zealand and Kiwi PyCon XI should have been held there in September 2020.  Along came the pandemic...

Somewhat later, they are back!

For more information, check out their official Twitter account.
PyCon APAC 2022
September 3–4, 2022

PyCon Taiwan is an annual convention in Taiwan for the discussion and promotion of the Python programming language. It is held by enthusiasts and focuses on Python technology and its versatile applications.
PyCon UK 2022
September 16–18, 2022

PyCon UK will be returning to Cardiff City Hall from Friday 16th to Sunday 18th September 2022.
More details coming soon!
DjangoCon Europe 2022
September 21–25, 2022

This is the 14th edition of the Conference and it is organized by a team made up of Django practitioners from all levels. We welcome people from all over the world.

Our conference seeks to educate and develop new skills, best practices, and ideas for the benefit of attendees, developers, speakers, and everyone in our global Django Community, not least those watching the talks online.
For more community events, check out python.org's event page.

Have any community events you'd like to see in the Community Calendar? Submit your suggestions to newsletter@dutc.io!
Twitter
Website
Copyright © 2022 Don't Use This Code, All rights reserved.