Is there something like this:
a,b,c = a,b,c.method()
?
It's just an example, I want to know the shortest way to do this
Not short. But here's an alternative using operator.methodcaller.
a, b, c = map(operator.methodcaller('method'), (a,b,c))
Example:
>>> import operator
>>> a, b, c = [1,2,3], [4,5,6], [7,8,9]
>>> a, b, c = map(operator.methodcaller('pop'), (a,b,c))
>>> a
3
>>> b
6
>>> c
9
>>> m = operator.methodcaller('pop') # If you call `method` multiple times,
# keep a reference to the methodcaller
>>> a, b, c = [1,2,3], [4,5,6], [7,8,9]
>>> a, b, c = map(m, (a,b,c))
>>> a
3
>>> b
6
>>> c
9
If all objects are same type, you can use unbound method. For example a, b, c here all list instances. So you can use list.pop instead of operator.methodcaller('pop').
For example:
>>> a, b, c = [1,2,3], [4,5,6], [7,8,9] # a, b, c are all `list` objects.
>>> a, b, c = map(list.pop, (a,b,c))
>>> a
3
>>> b
6
>>> c
9
Using a generator would be the simplest way. For example, if a, b, and c were strings:
a, b, c = 'asdf', 'quer', 'zxcv'
And you wanted to capitalize the beginning of each string, you can do:
a, b, c = (x.capitalize() for x in (a, b, c))
a,b,c = (x.method() for x in (a,b,c))good enough?method()on each object back into the objects themselves?l2 = [x.method() for x in l1]might be a good way to do what you need.