Skip to content
Advertisement

Tag: alias

Alias for long list name and modification

I have a nested data structure (e.g. mydict[names[num]]) which is difficult to read in code. Hence I would like to create a proxy (alias) and use it to modify this structure. Given the AssertionError on id(a) = id(b), do I understand correctly python separates short and long_name during comprehension and allocates separate memory? In practice, my structure contains millions of

How do I create an alias for a variable in Python?

Normal way: Aliased approach: How does one accomplish aliasing in Python? The reason I want to do this is to reduce cluttering due to long variable names. It’s a multi threaded environment, so simply copying to a local variable will not work. Answer The solution to this is to use getter and setter methods – fortunately Python has the property()

Advertisement