21

For example:

class FooBar:
    def __init__(self):
        self.a: int = None
        self.foo: str = None

Is this bad practice/go against PEP guidelines or is it fine?

you are viewing a single comment's thread
view the rest of the comments
[-] solrize@lemmy.ml 2 points 21 hours ago

foo[0] is also unsafe unless foo is known to be nonempty, ofc.

[-] jtrek@startrek.website 1 points 21 hours ago

Technically correct , the best kind of correct.

foo.lower() would have been a better example.

this post was submitted on 16 Mar 2026
21 points (100.0% liked)

Python

7812 readers
13 users here now

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

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS