silmathoron,
@silmathoron@floss.social avatar

Hey fellow programmers,
I think I remember someone posting a link to a website listing some mistakes that even rather advanced programmers still make. Probably related to some ill-known quirks of the language (shared reference related, etc, not your "10 most common mistakes" basic list).
However I cannot find it anymore.

Does it ring a bell, or do you have a favorite of weird Python quirks to share?

LucidDan,

@silmathoron is it https://www.toptal.com/python/top-10-mistakes-that-python-programmers-make by any chance? The title doesn’t mention it but it’s targeted the way you describe.

LucidDan,

@silmathoron after 15+ years, no. 4 and 7 are my worst ones (scoping and circular imports). Still trip me up from time to time.

meejah,
@meejah@mastodon.social avatar

@silmathoron One that still bites me sometimes is "mutable default args", like:

def foo(bar=[]):
...

...but that empty list is only constructed at load-time, not each time you run "foo".

cs,

@meejah @silmathoron yeah, I sometimes write this with a tuple instead of a list

silmathoron,
@silmathoron@floss.social avatar

@cs @meejah I just use None and do bar = bar or [] nowadays

meejah,
@meejah@mastodon.social avatar

@silmathoron @cs Yeah, IMO that's best (for basically any option). Luckily "typing" got that one correct with Optional

  • All
  • Subscribed
  • Moderated
  • Favorites
  • python
  • DreamBathrooms
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • GTA5RPClips
  • JUstTest
  • tacticalgear
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • ethstaker
  • Leos
  • anitta
  • cisconetworking
  • megavids
  • provamag3
  • lostlight
  • All magazines