I am programming a game in Python where all I / O operations are performed by an IO object (in the hope that it will be easy to swap this object for another that implements a different user interface). Almost all other objects in the game should at some point gain access to the I / O system (for example, print a message, update the position of the player, show a special effect caused by the action in the game), so my question is:
Does it make sense to reference an IO object that is accessible globally?
An alternative is to pass a reference to an I / O __init__()object in each object that should use it. I understand that this is good from a testing point of view, but is it worth the “function signature pollution”?
Thanks.
James
source
share