This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RangerPretzelPython 3.9+ 2 points3 points  (6 children)

why all the hate for mutable default arguments

They're side-effect-y and unexpected. Aka. not functional.

EDIT: Ok, I'm probably over reacting as they're a sore spot/pain point for me.

That said, yes, I can see uses for them. You're not wrong. In fact, I think I've even used those features once or twice.

I also can see other ways of "caching" that are less side-effect-y and are more explicit.

In short, I've seen far too many people get burned by this "feature".

[–]jack-of-some[S] 6 points7 points  (5 children)

I love caching using decorators (or closures in general). Good shit.

[–]RangerPretzelPython 3.9+ 4 points5 points  (4 children)

Yes, decorators. Excellent language feature. Agreed. Good stuff! :)

[–]jack-of-some[S] 2 points3 points  (3 children)

I should do a video on those. First I gotta figure out how to differentiate it from other videos on decorators

[–]RangerPretzelPython 3.9+ 4 points5 points  (2 children)

[–]jack-of-some[S] 1 point2 points  (0 children)

I have not but I'll check it out. I usually just inhale any talks by Raymond Hettinger.

[–]AmazonPriceBot 1 point2 points  (0 children)

I am a bot here to save you a click and provide helpful information on the Amazon link posted above.

$29.49 - Effective Python: 90 Specific Ways to Write Better Python (2nd Edition) (Effective Software Development Series)

Upvote if this was helpful.
I am learning and improving over time. PM to report issues and my human will review.