Skip to content
This repository was archived by the owner on Apr 24, 2018. It is now read-only.

Conversation

Amper
Copy link

@Amper Amper commented Nov 27, 2012

class ArgsList(object):
    def __init__(self, args=None): 
        self._args = args or []
    @property
    def all(self): 
        return self._args
    @property
    def copy(self): 
        return ArgsList(self.all)

my_args = ArgsList([1,2,3,4,5])
tmp_args = my_args.copy
tmp_args.all[0] = 999

print(my_args.all)  # [999, 2, 3, 4, 5] - OOPS!

class ArgsList(object):
	def __init__(self, args=None): 
		self._args = args or []
	@Property
	def all(self): 
		return self._args
	@Property
	def copy(self): 
		return ArgsList(self.all)

my_args = ArgsList([1,2,3,4,5])
tmp_args = my_args.copy
tmp_args.all[0] = 999

print(my_args.all)  # [999, 2, 3, 4, 5] - OOPS!
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant