home.social

#pythongotcha — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #pythongotcha, aggregated by home.social.

fetched live
  1. Important PSA For @jack !!!

    `os.truncate(path, length)` truncates THE FILE, not the path string 😳 (with no warning)

    Thank goodness you were in a venv!

    😅

    #Python #PythonGotcha #PythonGotchas #Oops #OhNo

  2. #PythonGotcha 🧵

    It is often useful to make a #copy of a given list before performing operations that would mutate the elements.

    When you make a shallow copy of an existing list, you create a new pointer to a new list object that points to the same old elements. (It saves memory.)

    On the other hand, if you make a deep copy, then you create a completely new copy of the original list.

    In other words: realpython.com/python-mutable-

    #learning #objects #python #dev #CS #DataScience #memory #dataDev