Python Tips and Hints #1 - Dunder functions __main__ and __name__

7 months ago
9

In this first Python hints video we will talk about the difference between building a program using def main() and one using code like:

if __name__=="__main__"

We will go through a couple of code examples and show you to reference material for further reading. The links are below.

Lexical analysis
https://docs.python.org/3/reference/lexical_analysis.html?highlight=dunder

Special considerations for __main__
https://docs.python.org/3/reference/import.html?highlight=__main__

Dunder in classes
https://docs.python.org/3/library/dataclasses.html?highlight=dunder

Top level code discussion and use: __name__ and __main__
https://docs.python.org/3/library/__main__.html?highlight=__main__

And since the channel is mostly about networking ... books and other products for networkers

Packet Guide to Core Network Protocols: https://www.oreilly.com/library/view/packet-guide-to/9781449308094/

Packet Guide to Routing and Switching: https://www.oreilly.com/library/view/packet-guide-to/9781449311315/

Packet Guide to Voice over IP: https://www.oreilly.com/library/view/packet-guide-to/9781449339661/

Network Engineering Fundamentals: https://www.oreilly.com/videos/network-engineering-fundamentals/9781491932643/

Advanced Network Engineering: https://www.oreilly.com/videos/advanced-network-engineering/9781491952559/

Virtualization, Networking, and Storage: https://www.oreilly.com/videos/virtualization-networking-and/9781491970478/

Loading comments...