@driscollis@mastodon.social avatar

driscollis

@driscollis@mastodon.social

I write, blog, podcast and more about everything #Python

Writing about Python at https://blog.pythonlibrary.org/ and https://pythonpapers.com/

Teaching at https://teachmepython.com/

Podcasting at https://pythonshow.com/

Author of multiple books, including Python 101

This profile is from a federated server and may be incomplete. Browse more on the original instance.

driscollis, to python
@driscollis@mastodon.social avatar

A common task of a programmer or engineer is to split an absolute path into the directory name and the last part of the path, which could be a file or folder.

You have two options in :

🐍 os.path.split
🐍pathlib

Here are the two approaches:

image/png

driscollis, to python
@driscollis@mastodon.social avatar

The latest episode of The Python Show Podcast is out!

This week I chatted with Antonio Cuni @antocuni who works on @pypyproject, HPy, and other packages!

@ThePythonShow

driscollis, to python
@driscollis@mastodon.social avatar

Pop Quiz 🐍❓

What will be the output when you run this code?

A) Syntax Error
B) 'hi'
C) hissssssss
D) hiss
E) None of the above

driscollis, to python
@driscollis@mastodon.social avatar

Don't miss out. My latest book is up on Kickstarter now

This is your chance to get a signed paperback or other fun swag.

I also am offering a huge deal on a lifetime subscription to @TeachMePython which gets you all my books and courses!

driscollis, to python
@driscollis@mastodon.social avatar

The latest edition of The Python Papers Newsletter is out 🐍🚀

Learn even more about drawing shapes on images with and in this final installment of a three-part series!

driscollis, to python
@driscollis@mastodon.social avatar

Want to print directly to a printer with ? 🐍🖨

Try this out. I discovered this method a couple of years ago:

driscollis, to django
@driscollis@mastodon.social avatar

About two years ago, I started learning about the web framework, one of the most popular web frameworks around.

I created a short cheatsheet while I was reading books and learning on the job that I am sharing below.

driscollis, to python
@driscollis@mastodon.social avatar

The latest episode of The Python Show Podcast is out now with special guest Trey Hunner!

We chat about technical training, , learning strategies, and more!

https://open.substack.com/pub/thepythonshow/p/38-technical-training-in-python-with @treyhunner @ThePythonShow

driscollis, to python
@driscollis@mastodon.social avatar

Pop Quiz 🐍❓

What does the following code print out, if anything?

A) An exception
B) 1
C) 2
D) 3
E) None of the above

driscollis, to python
@driscollis@mastodon.social avatar

Did you know you can watermark images with and ?

Here's the code and its output 🐍🔥

image/png

driscollis, to python
@driscollis@mastodon.social avatar

Did you know you can calculate the Fibonacci sequence in using the following

🐍 list()
🐍map()
🐍 range()
🐍 lambda

It's weird code, but it's still neat!

driscollis, to python
@driscollis@mastodon.social avatar

Did you know that has a generator expression? 🤯🐍

Generator expressions look like list comprehensions but return a generator instead of a list.

Here's an example:

driscollis, to python
@driscollis@mastodon.social avatar

Pop Quiz 🐍❓

Here you have a dataclass where you want a default list. But it doesn't work! Can you fix the code, so it works?

driscollis, to python
@driscollis@mastodon.social avatar

Did you know you adjust an image's contrast using and ?

It's true and you only need around SIX lines of code to do it too!

driscollis, to python
@driscollis@mastodon.social avatar

Which REPL have you tried?

🐍 IPython
🐍 bpython
🐍 ptpython

Something else?

driscollis, to python
@driscollis@mastodon.social avatar

's turtle module lets you do all kinds of neat things.

🐢 It's a teaching tool
🐢You can draw neat shapes
🐢You can make games
🐢Do animations

image/png

driscollis, to python
@driscollis@mastodon.social avatar

What did you do with last week?

driscollis, to python
@driscollis@mastodon.social avatar

Do you ever need to create a unique user ID? comes with a handy uuid module that you can use for that.

You only need two lines to create a UUID: 🐍🚀

driscollis, to python
@driscollis@mastodon.social avatar

Did you know you can use and to create plots in your terminal? 🐍🔥

It's super fun! Here's an example:

image/png

driscollis, to python
@driscollis@mastodon.social avatar

Did you know you can use and to adjust the contrast of your images? 🐍🔥

Here's a code example:

driscollis, to random
@driscollis@mastodon.social avatar

What language was your first “Hello World” written in?

driscollis, to python
@driscollis@mastodon.social avatar

Did you know you can use an equals sign in your f-strings to include the variable name and its variable?

Yup! It's been there since version 3.8 and it's super handy!

Try it today! 🐍🚀

driscollis, to random
@driscollis@mastodon.social avatar

Will McGugan ( @willmcgugan) released Toolong yesterday

Toolong is a terminal application to view, tail, merge, and search log files made with Textual

Check it out:

https://pypi.org/project/toolong/

driscollis, to python
@driscollis@mastodon.social avatar

I came across this neat little collection of packages recently and thought I would share

The creator of this graphic is Dan Nanni on Instagram

driscollis, to python
@driscollis@mastodon.social avatar

supports function overloading using the functools module. 🐍🔥

It isn't as full-featured as other languages, but it's a handy tool.

Here's an example:

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • GTA5RPClips
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • everett
  • Youngstown
  • mdbf
  • Durango
  • slotface
  • rosin
  • thenastyranch
  • kavyap
  • modclub
  • anitta
  • cubers
  • tester
  • osvaldo12
  • tacticalgear
  • ethstaker
  • ngwrru68w68
  • khanakhh
  • Leos
  • normalnudes
  • cisconetworking
  • provamag3
  • megavids
  • lostlight
  • All magazines