Remix.run Logo
commandersaki 7 hours ago

Plus Swift goes directly against the Zen of Python

The Zen of Python is how we got crap like argparse where arguments are placed in the namespace instead of a dict.

coldtea 4 hours ago | parent [-]

I wouldn't change that in any way. I'd might make it an Arguments class, but I wound't make what parser returns merely a dict.

commandersaki 4 hours ago | parent [-]

Yeah, so what happens when you have an option with a '-' in it that isn't valid as a variable name (I know what happens). It's just stupid.

coldtea 2 hours ago | parent [-]

The same thing you'd do yoursef if you wanted to assign it to a namesake local variable even if it was in a dict to begin with: you'd make the dash an underscore.

commandersaki 2 hours ago | parent [-]

It would be extremely unlikely that you would replicate the name as a local variable if it was in a dict, but regardless a dict doesn't have that limitation. The namespace thing is atrocious and bad design -- no straightforward way to iterate over them, merging/updating them is awful, collides with keyword methods (keys, items, etc.), and so on; thankfully more modern argument parsing libraries didn't repeat this mistake. It's just a shame this ended up in the standard library, but then Python standard library has never really been any good, e.g. logging and urllib1234567.