> Many Python users rarely create classes. Creating classes isn’t an essential part of Python, though many types of programming require it. Huh. Okay.
It's really true. You can do a lot with data objects (dicts, lists) and stateless functions.
Python built-ins worth learning
11–20 of 69 posts
Re: Python built-ins worth learning
#12> Many Python users rarely create classes. Creating classes isn’t an essential part of Python, though many types of programming require it. Huh. Okay.
Re: Python built-ins worth learning
#13If you are reading this, the orange bar at the bottom 5% of my screen is hugely distracting. Please allow us to close it.
Re: Python built-ins worth learning
#14Amazing post Trey, as usual. This is a very comprehensive list. I can't think of any other important function missing. My students will love this :)
Re: Python built-ins worth learning
#15I disagree with only one thing in this article. Frozenset is super useful. You should prefer frozenset over set by default imo. Immutable objects are safer to work with, often easier to work with (frozenset is hashable, you can key a dict with it), and sets come up all the time in a lot of work. You can get by with a sorted list, but sets are nicer and faster.
Re: Python built-ins worth learning
#16If you are reading this, the orange bar at the bottom 5% of my screen is hugely distracting. Please allow us to close it.
Re: Python built-ins worth learning
#17I disagree with only one thing in this article. Frozenset is super useful. You should prefer frozenset over set by default imo. Immutable objects are safer to work with, often easier to work with (frozenset is hashable, you can key a dict with it), and sets come up all the time in a lot of work. You can get by with a sorted list, but sets are nicer and faster.
I've never very rarely seen these used in production code though. I'm also not as strongly biased toward them because set objects in my own code are often pretty short-lived so their mutability rarely matters.
Re: Python built-ins worth learning
#18> Many Python users rarely create classes. Creating classes isn’t an essential part of Python, though many types of programming require it. Huh. Okay.
This was quite useful for those of us who were bewildered by OOP.
When I learned Python, I was comfortable enough with using objects, that I had no problem creating classes.
So I think it's fair to say that creating classes is something that beginning Python programmers can put off.
Since I introduced Python to my workplace, I get to watch some fairly neophyte programmers develop their skills. These are typically engineers doing scientific programming, not commercial software developers. There's a point where I get to say: "You could put that stuff in a class." And later on, "You're creating too many classes." ;-)
Re: Python built-ins worth learning
#19My one minor suggestion would be to cover getattr and related methods sooner. I stumbled across that one pretty early on as I was learning programming and it was a serious "Ah ha!" moment. Dynamic lookups with a sensible default value are useful in countless contexts.
Re: Python built-ins worth learning
#20> Many Python users rarely create classes. Creating classes isn’t an essential part of Python, though many types of programming require it. Huh. Okay.