Search code examples
pythonpylint

Possible To Format A List Without * Magic?


I wrote some Python code which works but Pylint doesn't like the star. It keeps telling me:

Used * or ** magic (star-args)

Is it possible to write my code without the star? Some info: I'm using lxml; self.xml is an objectified XML file.

@property
def version_string(self):
    '''Return the version as a string.'''
    try:
        version_format = self.xml.version.get("format")
    except AttributeError:
        return None
    version_values = (v.text for v in self.xml.version.v)
    return version_format.format(*version_values)

Solution

  • There's nothing wrong with the splat operator. Without knowing what the version_format function does, it's not possible to say if you could pass an iterable, or iterate the function directly, but frankly there's no reason to.