Mike Driscoll Profile picture
Sep 7 β€’ 4 tweets β€’ 2 min read
#Python includes more than 200 modules as a part of its standard library.

Today we will look at the `atexit` module

#PythonStdLib 🐍πŸ”₯

πŸ§΅πŸ‘‡
The `atexit` module in #Python defines functions to register and unregister cleanup functions.

Read more about `atexit` in the docs πŸ“š here:

docs.python.org/3/library/atex…
The Python docs have several interesting examples of using the `atexit` module.

Here is a module that can initialize a counter from a file when it is imported and save the counter’s updated value automatically when the program terminates
Thanks for reading my short thread on #Python's amazing `atexit` module!

You should give `atexit` a try. It looks like a really handy module.

Follow me to learn more about Python and its amazing modules

#PythonStdLib 🐍πŸ”₯

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Mike Driscoll

Mike Driscoll Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @driscollis

Sep 8
#Python has TONS of great packages and frameworks.

In this thread, I am going to highlight just a few of the THOUSANDS that are available to you on pypi.org

πŸπŸ§΅πŸ‘‡
Python has lots of great cross-platform GUI packages:

🐍 PySimpleGUI @PySimpleGUI
🐍 PyQt / PySide
🐍 wxPython
🐍 Tkinter
🐍 @DearPyGui
🐍 EasyGUI
@PySimpleGUI @DearPyGui #Python also has a couple of GUI frameworks for mobile development (i.e. iOS and Android):

πŸ”₯ Kivy @kivyframework
🐍 Toga from @PyBeeWare

I have heard PyQt also supports mobile, but haven't been able to verify it
Read 10 tweets
Sep 6
Today is a great day to talk about #Python's package installer, pip!

You can learn all about it in a mini-thread!

🐍πŸ”₯🧡
If you need to install a 3rd party #Python package, you will almost certainly need to use pip.

Examples of 3rd party packages include:

🐍 Django
🐍 SQLAlchemy
🐍 requests
🐍 Mypy

with thousands more available on the Python Packaging Index (PyPI) Image
You can install multiple #Python packages with pip as well. πŸπŸš€

One way to do that is by separating the package names with spaces when calling pip Image
Read 8 tweets
Aug 13
#Python also includes a special function named `__import__()`

This function is NOT used in everyday Python programming and is in fact, usually discouraged.

But we will talk about it briefly anyway!

#python_builtins_by_driscollis

πŸ§΅πŸπŸ‘‡
The `__import__()` function takes the following args:

🐍 name
🐍 globals=None
🐍 locals=None
🐍 fromlist=()
🐍 level=0
You can use `__import__()` to import modules. Here's an example of import Python's `sys` module using it:
Read 6 tweets
Aug 11
You hear a lot about typing when it comes to computer programming. I'm not talking about using your keyboard ⌨️

I'm talking about:

πŸ’ͺ Strong typing
πŸš€ Dynamic typing
🚨 Static typing

What kind of typing does #Python 🐍 have? Let's talk about that!
Let's start with strong πŸ’ͺ typing!

Strong typing means that variables have a type (int, str, dict, etc) and that that type matters when you perform an operation on the variable.

An example of an operation is addition or subtraction
Because of strong typing, variables need to be compatible when doing an operation on them. In #Python, you can add integers and floats together because they are compatible types.

But you can't add integers and strings together! 🐍🀯 Image
Read 11 tweets
Aug 11
Let's spend a little time learning how to say "Hello World" in different languages

And when I say different languages, I mean different programming languages!

πŸ§΅πŸ‘‡
My favorite programming language is #Python. 🐍

You can do a "Hello World" program in Python in one line: Image
When I first began learning about programming computers, C++ was one of the first languages that I learned in school.

"Hello World" is a bit more verbose in C++ land: Image
Read 12 tweets
Aug 4
Today is a great day to learn about exception handling in #Python!

Let's find out how they work!

πŸ§΅πŸπŸ‘‡
#Python handles exceptions using the `try/except` keywords.

You can optionally add `finally` and `else` to the mix too!

Here's an example that uses all of them:
#Python has the concept of the "bare except". What that means is that you catch ALL exceptions.

You can do this by catching Exception, which is the base class of ALL other exceptions.

Or you can just not specify an exception type all!
Read 15 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(