• 0 Posts
  • 10 Comments
Joined 2 years ago
cake
Cake day: July 1st, 2023

help-circle

  • It won’t (using your example explicitly) but in general what you’ve discovered is that:

    1. Variables hold values
    2. Some of those values are references to shared mutable objects.

    Lists fall into the second category. There are ways to copy lists if you want distinct behaviour.

    list2 = list1[:]
    

    will perform a “shallow copy”. If you have a list of lists, however, the nested lists are still shared references. There is copy.deepcopy available to make a complete clone of something (including all its nested members).


  • Yeah, a more modern take on mutexes (as boxes for values) and support for structured concurrency would be fabulous. Those are somewhat orthogonal to the goal of being able to write straight-line code without function colouring. Long ago, eventlet provided something like this [although it had smoe subtle and deep bugs that took a long time to track down].

    Potentially, a major stumbling-block would be providing machinery so that interleaved FFI & python calls can cooperate (if that’s determined as being in-scope, which it ultimately should be).








  • How is that checker configured?

    It might be doing something like this:

    import student_module
    student_module.main()
    

    and because you’re already invoking main as the module is imported, it’s getting stuck the second time around. Maybe add some indicative print at the entrypoint to your main function.

    Another reply in here has supplied the standard idiom for making a module executable:

    if __name__ == "__main__":
      main()