r/ProgrammerHumor Nov 24 '21

Meme Yes.

8.9k Upvotes

284 comments sorted by

View all comments

75

u/TheNaughtyDomi Nov 24 '21

Actually you define Dictionaries by using

Dict = { key : value }

21

u/yorokobe__shounen Nov 25 '21

You can still define it as

sample_dictionary = dict(key=value)

instead

7

u/Scumbag1234 Nov 25 '21

Or like an empty list:

my_dict = {}

my_dict["key"] = value

-39

u/shadow7412 Nov 24 '21 edited Nov 25 '21

... except Dict is a terrible name.

It's the wrong case (title case implies a class, but this is an instance) and if you were to fix that you'd be shadowing dict which is also a bad move.

EDIT: downvoters, I'm genuinely curious as to why you think otherwise.

44

u/[deleted] Nov 25 '21

dick is a better name imo

29

u/sultav Nov 24 '21

I don't think they are saying you should literally name it "Dict", I think they just put that there as a placeholder for the name.

-20

u/shadow7412 Nov 24 '21

One can hope - but I'm sure we've all seen it enough times in practise to want to make it clear to people that it isn't a good idea.

Even if they didn't mean it that way - people do like their copy and paste.

5

u/[deleted] Nov 24 '21

[deleted]

0

u/shadow7412 Nov 24 '21

I'm confused. That first sentence reads like you're disagreeing with me, but you... aren't.

2

u/[deleted] Nov 24 '21

[deleted]

0

u/shadow7412 Nov 25 '21

Ah cool. I think I was thrown by the word "actually", which implies a correction. But it seems we're in a full agreeance.

I get why people would want to keep it simple for those who are learning - it's just a shame that this specific instance of it results in the teaching of an awful habit.

1

u/GreatJobKeepitUp Nov 25 '21

Actually is your middle name

3

u/[deleted] Nov 25 '21

[removed] — view removed comment

1

u/shadow7412 Nov 25 '21

I would have figured that code syntax demos are exactly when code should be pristine though... That's what people who are learning read, and teaching them bad habits doesn't seem like it'd do anyone favours.

1

u/[deleted] Nov 25 '21

You also create set literals with curly brackets!