A blog post on choosing more specific types rather than general ones like list and dict.

You are viewing a single thread.
View all comments
3 points

The important difference is that you don’t need to import anything in order to quickly use list type. This wins in the majority of the cases, unless I’m building something that will be imported by multiple other modules and it really pays to be that explicit.

permalink
report
reply
2 points

That was definitely a nice feature (I forget exactly when list over List was added). That said I’ve never really been bothered about having imports. Especially when I know the import is side effect free like the typing module. But I definitely use import free list for script files without many lines of code.

permalink
report
parent
reply

Python

!python@programming.dev

Create post

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events
Past

November 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
  • Pythörhead: a Python library for interacting with Lemmy
  • Plemmy: a Python package for accessing the Lemmy API
  • pylemmy pylemmy enables simple access to Lemmy’s API with Python
  • mastodon.py, a Python wrapper for the Mastodon API
Feeds

Community stats

  • 431

    Monthly active users

  • 455

    Posts

  • 2.2K

    Comments