python 3.12 was ALMOST javascript

preview_player
Показать описание
today we're talking about AttrDict, maintainability of cpython, and the burden of maintenance.

==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

As a wise man once said "when building a language, only add what you really need and set out to do, adding neat little conviences will lead to the most issues later". I dont remember who said it and thats paraphrased

This is where JavaScript probably fails the most.

oakley
Автор

I totally agree with all your points. Thank god for all the folks who are looking after consistency in Python.

GrahamAtDesk
Автор

I'm literally a data scientist and I think Pandas is bizzare and I avoid it as much as possible. Fortunately I don't need it much because I mostly work text not tabular data, though I have been using it every so often for almost a decade. But man the syntax is weird, unpythonic, not even internally consistent, impossible to predict/guess. I feel like any time I use it I have to look up everything. In my experience you can go to SO at any time of day, search python, and at least 30% of the page will be "how do I do X in pandas". There's no other library in existence where people have such difficulty figuring out the syntax. I think the only people who really like it are people who learnt pandas before really learning much Python, and people with R/matlab backgrounds. But then again, I have an R/matlab background. And I actually enjoyed both of those. I've never enjoyed pandas.

neildutoit
Автор

That "object_pairs_hook=lambda attrs... " made me laugh so hard lol

"yeah, it's *little* clunky" 😂

paxdriver
Автор

I like to go by a rule which is that if something is supposed to be complicated or expensive, it should look complicated or expensive; so that it's discouraged from being used or at least approached differently.

We are also currently starting to suffer from over-abstraction of concepts in Python (and web-dev), so it's nice to see that they didn't go through with this feature.

_Robin_
Автор

Lot's of comments here bashing pandas for the dot notation, but I actually like this feature a lot, even though I realize that there are downsides to it. Main reason being convenience - not having to type square brackets and quotation marks (which sucks on a keyboard with Scandinavian layout), and also that autocomplete works even in a terminal.

hakansvensson
Автор

My biggest complaint about pandas is when people do the attribute access from tables with dot notation. I find it really bad practice to do so especially since in tabular data you can have column names be strings with spaces, and it's like a weird patchy thing to do, especially since it may have the same name as something already attached to the dataframe. Whenever I find code from friends or other students using dot notation, I almost immediately tell them to use the key access instead. Great video! Also really neat to know that SimpleNamespaces can handle it anyways

Squeemos
Автор

Oh no, yeah pandas is not a prime example of good API (not entirely its fault tbh). It’s an awesome tool, very convenient but so inconsistent in its API it’s not even funny. Same deal with matplotlib (which inherited much of its API from matlab). It’s one of the best we have, but far from perfect.

Loved the video! Glad to see them popping back up.

TheAulto
Автор

It is kinda hilarious. The stdlib is so huge that people have tried to reimplement the same thing a bunch of times. I agree with you that this style is not broadly useful for design. Hehe, even though I use argparse all the time, I am not sure I ever thought of using Namespace/SimpleNamespace for this purpose. I've rolled my own solutions over the years for exploring APIs interactively (back when HATEOS and _links were in high vogue). But like you say, that's almost a toy. (And was meant to be)

BrianJorgensenAbides
Автор

This a good example for me to understand what consistency means for a big project like this because this can be helpful `obj.a.b.a` can be helpful for diff tools to find diff between deeply nested dicts but again as you explained this can be done using object_pair_hook

princeroshan
Автор

Great video good job explaining the issue. We can't just add features for the sake of adding features.

fedoraguy
Автор

As a heavy Pandas user I refuse to use the dot notation for columns and find it unnecessary.

danielcs
Автор

Totally agree, I wish Pandas did not do this. It's complex enough without that added ambiguity.

dixonstroi
Автор

Much like how you can't write a dynamic language these days without having some support for javascript syntax (because you need to support JSON), you also can't implement a compiled language in general without that language "speaking C", because although C does not have an ABI, C is so deeply rooted into the way that everything works that you cannot make anything work without making it binary-compatible with C programs. C and JavaScript are unique in this regard, as C is the language that everything in Unix is built on top of and JavaScript is the language that everything on the modern web is built on top of. These languages are so deeply embedded into everything that you're very likely to know (or at least be more than a little familiar with) them.

All this is to say that saying python was "almost" javascript because it did something weird in the name of JSON support is kind of like saying Rust is almost C because when you look under the hood of the compiler you see a BUNCH of stuff related to ABIs and libraries that interop with C and C programs, not because the developers of Rust chose to make it compatible, but because it literally won't work if they don't.

BradenBest
Автор

Did they forget that dataclasses are part of the std library?

gardnmi
Автор

This is super really easy to write yourself. I did this already in python2, where such an object came in handy for a specific parsing task. If I need this I just basicly write it down.

RogerValor
Автор

Just case across your channel, pretty cool stuff!

Q: What do you think of pythons module import system? For me, its the most limiting factor of python. In C# (just for examples sake), you can access a class from basically anywhere within a namespace without circular imports. This is specially useful when using classes as types (as one should) rather than as "aggregators of functions". In python you have to use something like var: "MyType" or use fence check your imports to see if you are on "IDE" mode or "RUN" mode (i forget what its called now) to avoid importing those types at runtime, where you will hit circular imports.
Do you think its a good idea for python to mature on this front?

tswdev
Автор

There is no reason to include something like this in the standard library. It is easy to implement and use as a separate library. This also provides the incentive - if necessary - for different implementations.

mydetlef
Автор

I have a similar class, that I use a lot, I call namespace. It's very similar to the built in types.SimpleNamespace, but I use a single dictionary to initialize the attributes, and not the keyword args.

EvanOfTheDarkness
Автор

I was waiting for you to finish to say exactly what you did about pandas. It's not even consistent within pandas. DataFrames still rock though.

cleverclover