Live data from Hacker News

Metaprogramming in Python

developer.ibm.com

1–10 of 61 posts

Re: Metaprogramming in Python

#3
post #2

Thanks for sharing! Instead of using meta classes for subclass registration though, please just use __subclass_init__ instead. It’ll often be simpler unless you have a complex use case. https://docs.python.org/3/reference/datamodel.html#object.__...

Yes, also for anything else than subclass registration, there are things like the descriptor protocol or class decorators that are likely to be easier to use, debug and understand.

And metaclasses can be any callable, not just class. It's usually better to use a simple function.

Re: Metaprogramming in Python

#7

It is shocking how much vodoo magic there is in a programming language marketed as "easy to learn and use". And with the recent addition of new syntax, I would hardly call Python easy.

Python is easy, not because it prevent people from doing complicated things, but because with only a few simple things, you are productive.

Most python programmer use 10% of the language, the same 10% that is described in most tutorial, because that's enough, and they don't even know the rest exist.

This makes for a very smooth, but long learning curve which allow you to enjoy python in the early years, yet keep getting a kick out of it after 15 years.

I hear a lot of people raising the same kind of concern you do in comments, but in the field, I never do with people actually using the language.

Re: Metaprogramming in Python

#9

It is shocking how much vodoo magic there is in a programming language marketed as "easy to learn and use". And with the recent addition of new syntax, I would hardly call Python easy.

> It is shocking how much vodoo magic there is in a programming language marketed as "easy to learn and use".

But that's exactly what that expression means?

A car with an automatic transmission is "easy to learn and use", but an automatic transmission is way more complicated to construct than a manual one.

Re: Metaprogramming in Python

#10

It is shocking how much vodoo magic there is in a programming language marketed as "easy to learn and use". And with the recent addition of new syntax, I would hardly call Python easy.

Python is easy, not because it prevent people from doing complicated things, but because with only a few simple things, you are productive. Most python programmer use 10% of the language, the same 10% that is described in most tutorial, because that's enough, and they don't even know the rest exist. This makes for a very smooth, but long learning curve which allow you to enjoy python in the early years, yet keep gett…

That "smooth learning curve" applies when you are learning the language, use it by yourself or work in the ML/Data science industry.

Once you get thrown in a big project that makes heavy use of type hinting (plus the whole environment of it, mypy et all), Object Oriented design and all those hidden things...you realize how much you really don't know.

And that 10% is way too small. To be productive in Python, you need to know at least 50%, or you will be reinventing a lot of existing things. Poorly.

Post reply on HN