Python Forum
Pygame Particle Generator
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pygame Particle Generator
#5
I should clarify that.

My intention was to encapsulate the cache. You can do the trick inside the function definition. I think the most people don't know, that mutable objects are created at function definition time. This is odd.

The easiest way is, to define the cache-dictionary outside of the function and call it explicit with the function.

# instead of
def foo(cache={}):
    # code

# explicit
def foo(cache):
    # code
Alternatives can be a class or a closure. But for a class the function is too minimal.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
Pygame Particle Generator - by nilamo - Aug-25-2017, 05:12 AM
RE: Pygame Particle Generator - by Larz60+ - Aug-25-2017, 08:50 AM
RE: Pygame Particle Generator - by DeaD_EyE - Aug-25-2017, 11:14 AM
RE: Pygame Particle Generator - by nilamo - Aug-25-2017, 12:52 PM
RE: Pygame Particle Generator - by DeaD_EyE - Aug-27-2017, 09:21 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020