gull

do severals, be severals. how it is

  • any

what's up, gull and such here, recent "wait there's more than one of us" realizers. whoops!

still giant robot fans, still pmd: explorers enthusiasts. imagine we are wearing a big button that says "ask us about Void Stranger". you should play all the games we like right now. the media backlog continues to grow ever further, and finally fucking continuing Initial D slips further and further out of reach.....


Discord
gullwingdoors (shoot me a friend request please)

lexyeevee
@lexyeevee

just saw someone link to https://www.w3schools.com/python/python_dictionaries.asp and insist someone else read it and i glanced over it for ten seconds and wanted to barf a little

there is so much weirdly, subtly wrong here. it's the kind of weird subtly wrong you get if you're mostly interested in doing SEO so you can show a lot of banner ads, and not so interested in teaching beginners anything

like look at this. what is going on here? this is your first introduction to dicts for someone who has never heard of the concept before. this is everything that appears above the fold on my 1440px monitor. and it contains:

  • the same dummy dict, twice
    • which is heterogeneous and not really a good use case for a dict
    • and which doesn't have a meaningful name anyway
  • waffling about whether dictionaries are "ordered", a detail that absolutely does not fucking matter 99% of the time you are using a dict
  • the terms "key" and "value" twice with no explanation of what the fuck that means
  • the phrase "do not allow duplicates", which i will return to later
  • printing a dict, which is nice to be able to do i guess but not actually, like, what they are for

here is what is conspicuously absent

  • what a dict is
  • what a key is
  • what dicts are for
  • looking up a key
  • assigning to a key (this doesn't appear anywhere on the page at all it's like three pages ahead)

it's just this mealy gray slop. it's sentences that are, mostly, sort of, more or less, correct facts, devoid of any real information or context. i'm getting madder the longer i look at it. why would anyone recommend this trash to anyone, let alone a beginner

and it gets better because here is how the page ends

Python Collections (Arrays)

There are four collection data types in the Python programming language:

  • List is a collection which is ordered and changeable. Allows duplicate members.
  • Tuple is a collection which is ordered and unchangeable. Allows duplicate members.
  • Set is a collection which is unordered, unchangeable*, and unindexed. No duplicate members.
  • Dictionary is a collection which is ordered** and changeable. No duplicate members.

* Set items are unchangeable, but you can remove and/or add items whenever you like.

** As of Python version 3.7, dictionaries are ordered. In Python 3.6 and earlier, dictionaries are unordered.

When choosing a collection type, it is useful to understand the properties of that type. Choosing the right type for a particular data set could mean retention of meaning, and, it could mean an increase in efficiency or security.

and just. chef kiss. what a glorious mishmash of not giving a fuck. check out how many ways this is wrong or misleading

  • what does "Python Collections (Arrays)" mean?? why is "Arrays" there?? these aren't arrays. dicts are nothing like arrays

  • there are way more than four collections in python. there's a whole fucking collections module. there are more than four built in collection types — they forgot frozenset

  • i do not know how you could justify saying sets are unchangeable, but then say haha well actually sets are changeable but the items aren't, which also isn't actually true

  • it says lists allow duplicate members, suggesting that "members" here refers to values. but then it also says dicts don't allow duplicate members, suggesting that "members" refers to keys?

  • How is it more secure to use a list over a dict or whatever

  • they are really obsessed with describing whether dicts are ordered or not when that is not what dicts are about

the page also stresses that dict values can be any type but only ever uses strings as keys; demonstrates calling type() on a dict for reasons i cannot even begin to fathom; invents slightly variant terminology like "key name"; etc.

i am looking at the following pages and becoming even more irate. it repeats a common misconception about del! why is it mentioning .popitem() at all, who even uses that!

i can only assume what happened here is that it's so milquetoast that it looks helpful to beginners despite having no rhyme or reason or order or context or really anything at all. it has microscopic examples not attached to anything else, so you can look at them and feel like they make sense. but i cannot imagine actually learning anything this way. there is no structure, no building towards anything larger. "user input" is the second to last fucking section

this is the ninth grade book report of websites. not only should you not read it, you should be skeptical of advice from anyone who suggests you read it, because they don't know enough to tell how fucking awful it is. it is the purest form of Content™.

just read the god damn python tutorial. it's probably dense in places. that's fine, welcome to programming, skip ahead if you like. fuck around. experiment. ask programmer friends about stuff. reading the equivalent of the standard library manual piped through chatgpt is going to turn your brain to mush


You must log in to comment.

in reply to @lexyeevee's post:

w3schools might have been useful once upon a time. i remember going through it in like... 2009? when i was learning html. it was fine back then, i guess. but there's so much better stuff now. it's aged so horrendously. like they just couldn't be fucked keeping it up to date, and just filled it with Slop to make it look somewhat relevant in present year at a first glance

every time i click on a w3schools link i click off in frustration, so i had no idea how truly terrible it is. it's especially frustrating because i've only seen it show up on searches for javascript and python stuff, both of which have actually good documentation (mdn and the official python docs for anyone who somehow doesn't know)

i don't know how you got "not how i would personally present it" out of this. they misuse terminology. they confuse concepts. they drop in a bunch of miscellaneous junk no one ever uses — isn't that too much information? why would you show upfront that you can call type() on a dict, rather than focus on the thing a dict is about: storing key/value pairs?

Btw I do use popitem for pretty specific uses (it’s great for having a set of pending single-use things wherein you want to guarantee that once a thing is used it’s no longer hanging around, e.g. access tokens) but yeah it’s not something that should be brought up as the first damn thing on a beginner’s tutorial.

I needed to know the basic usage patterns of python dicts a few days ago (as I don’t use python often) and ended up on this exact page and as an experienced professional programmer who knows what “keys” are and such I found it bafflingly useless

A comment on this that's even worse suited for the page, but: all that faff about ordering isn't even the right framing. dict behavior with regard to iteration was implementation-dependent until 3.7, which formalized the behavior that had been introduced first (I think) in PyPy, then ported to CPython 3.6. Prior to that, various different behaviors were tried in different versions of CPython, but it turns out that no iteration behavior is so "useless" that nobody will rely on it somehow, so they tried out a behavior that made various built-in features easier to work with, and then formalized it.

All of this is of purely historical and program design interest, of course, since Python 3.6 has been EOL since the end of 2021.

Now I'm trying to come up with contexts in which dict iteration order has been relevant to me...

  • Very careful **kwargs processing.
  • Very squirrelly metaclass __new__.
  • dict.popitem() is somehow useful.

(Huh. I thought I'd used popitem() in the past, but looking at the place that seemed likeliest, I'm only seeing pop().)

iirc what actually happened was that pypy's dict implementation was just faster overall, so cpython adopted it, and it happens to preserve insertion order (not sure if this is was a deliberate or emergent property), and then a later cpython wanted to use OrderedDict for kwargs or something (maybe for signature inspection?), which would require internals to refer to OrderedDict, which seemed silly when dict was already ordered by happenstance, so they asked gvr to declare dicts ordered and he did

but it's really only useful for a dict you create in one go, imo, since you can't change the order after the fact. in most cases you still want a list