Mike Driscoll Profile picture
Mar 17 β€’ 6 tweets β€’ 2 min read
Starting in Python 3.7, the `breakpoint()` built-in function was added

It is defined in PEP 553 and simplifies adding a breakpoint to your code

#python_builtins_by_driscollis

πŸ§΅πŸπŸ‘‡
You can read about the `breakpoint()` function for Python here:

python.org/dev/peps/pep-0…
Here is some sample code showing how to use the `breakpoint()` function in your Python code
Here is a GIF that shows how to run the code. When a breakpoint is reached, the Python debugger (pdb) will launch automatically
If you'd like to learn more about debugging your #Python code with `breakpoint()` and the `pdb` module, you should check out my tutorial @mousevspython

blog.pythonlibrary.org/2020/07/07/pyt…
I hope you enjoyed learning about Python's `breakpoint()` function. It's super handy!

Follow me to learn more about the Python programming language!

β€’ β€’ β€’

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

Mar 16
#Python has a TON of different ways to create executables!

Here are some of the packages you can use:

🐍 PyInstaller
🐍 Py2Exe
🐍 cx_freeze
🐍 Briefcase
🐍 Nuitka
🐍 py2app

πŸ§΅πŸπŸ‘‡
If you want to create a Mac executable, you can use any of these:

🐍 PyInstaller
🐍 Briefcase
🐍 py2app
🐍 Nuitka
When creating a Windows executable with PyInstaller or py2exe, avoid using the single-file option.

If you use the single-file option, Windows Defender may think you are creating malware and delete it or flag it.

You can sign your executables to prevent this
Read 7 tweets
Mar 11
Did you know #Python has a regular expressions module in its standard library? It is called `re`

Let's talk a little about it today!

πŸ§΅πŸπŸ‘‡
Regular expressions or RegEx is a tiny language that is used primarily for matching strings or substrings.

Here is an example in #Python where you use RegEx to search for a string that starts with "a" and ends in "f". The middle letters must be "b-f"
For this next example, you use a list of words that you want to search for in a string.

You print out when you find the string and what position it was found at
Read 9 tweets
Mar 10
Today we are going to talk about environment variables with #Python!

This will be a thread, so prepare yourself!

πŸ§΅πŸπŸ‘‡
Environment variables are variables that are available to all your programs and saved in memory by your operating system.

You can get a listing of your environment variables using #Python's `os.environ` attribute:

🐍πŸ”₯ Image
The `os.environ` call returns a #Python dictionary.

This allows you to get environment variable values using dictionary access, like this: Image
Read 6 tweets
Feb 8
Logging in #Python is a popular topic and it's a really useful one to understand.

Today we are going to learn more about that!

πŸ§΅πŸπŸ‘‡
Python includes the `logging` module as a part of its standard library.

You can get started using it quite easily:
Python's `logging` module supports multiple logging levels:

🐍 notset
🐍 debug
🐍 info
🐍 warning
🐍 error
🐍 critical
Read 17 tweets
Feb 6
If you are a Windows user, #Python has a few special libraries just for you.

Once such module is `winsound`

Let's learn more in this mini-thread!

πŸ§΅πŸπŸ‘‡
#Python's `winsound` module is a sound-playing interface for Windows.

Here's a link to the documentation:

docs.python.org/3/library/wins…
If you'd like to give `winsound` a try on your Windows machine, I would recommend trying to `Beep()` the speaker.

`Beep()` takes in the frequency and the duration of the sound in milliseconds.

The code below beeps your system speaker at 3 different frequencies Image
Read 5 tweets
Feb 6
You can sort #Python lists in a couple of different ways. Find out how in this thread!

πŸ§΅πŸ‘‡
#Python lists come with a `sort()` method that makes sorting easy! Image
#Python pro-tip: Don't assign the result of calling a list's `sort()` method to a variable.

`sort()` does NOT return a sorted list. It returns NONE!

`sort()` will sort the list in-place instead Image
Read 5 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!

:(