alternative for passing references around in python
NickName:Rolf Schorpion Ask DateTime:2013-10-17T18:51:53

alternative for passing references around in python

I'm relatively new to python and oop, and i have a question around the design of my code for a hobby project.

I created a lot of variables in my main program. These variables are lists of objects (not configuration parameters and not constants). The objects in the lists are sprites.

I'm passing these variables around between objects, by calling methods and passing the variables around as arguments for a specific method. (pass-by-reference)

For example:

spritelist = [Sprite(...), Sprite(..)]

mycollisiondetector = CollisionDetector()

mycollisiondetector.check_collision(spritelist)

Then, in class CollisionDetector, spritelist is passed to "private" methods of the class. These private methods call other methods, and keep passing spritelist ... .

So, my question is just this: is there an alternative for endlessly passing variables around from one method to another ?

Copyright Notice:Content Author:「Rolf Schorpion」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19424706/alternative-for-passing-references-around-in-python

More about “alternative for passing references around in python” related questions

alternative for passing references around in python

I'm relatively new to python and oop, and i have a question around the design of my code for a hobby project. I created a lot of variables in my main program. These variables are lists of objects ...

Show Detail

Passing self into a constructor in python

I recently was working on a little python project and came to a situation where I wanted to pass self into the constructor of another object. I'm not sure why, but I had to look up whether this was...

Show Detail

Why is passing references to the Mutex class not a good design?

From here: Logic error in my defined Mutex class and the way I use it in producer consumer program - pthreads the way you pass around references(!) to your mutex class is plainly asking for trou...

Show Detail

Alternative to Initializer List of References

I really needed and Initializer List of References but it seems that is not possible. The problem of being a copy is that I wanted to disable copy construction and because these copies call the des...

Show Detail

Problem with passing around Object references in Java

i'm writing some stuff in java and i ran into some problems lately. cut short, i need to compare an object i created to another instance of this very class i instantiazed before with different data.

Show Detail

Python - passing object references?

I learning Python (coming from a dotnet background) and developing an app which interacts with a webservice. The web service is flat, in that it has numerous calls some of which are related to se...

Show Detail

Passing object references needlessly through a middleman

I often find myself needing reference to an object that is several objects away, or so it seems. The options I see are passing a reference through a middle-man or just making something available

Show Detail

Alternative to passing IOC container around

I had the following base class with several dependencies: public abstract class ViewModel { private readonly ILoggingService loggingService; public ViewModel( ILoggingService

Show Detail

Alternative to using stubs to get rid of cross references

Over 15 years I have created my own "framework" which consists of some classes and some modules. For example: Strings (contains wrappers for string functions) Conversions (contains wrappers for

Show Detail

How should common references be passed around in an assembly?

I am trying to get rid off static classes, static helper methods and singleton classes in my code base. Currently, they are pretty much spread over the whole code, especially so for the utility cla...

Show Detail