I recently started using UtilSnips, a Vim plugin allowing for a certain level of automation while coding by using template-like code snippets for common code fragments (class and function definitions, for example).
When using a popular snippet pack with Python, I noticed that snippets used when writing a class use a pattern I've never seen before in __init__ when using more arguments than just self:
class MyClass(object):
"""Docstring for MyClass. """
def __init__(self, user, password):
"""TODO: to be defined.
:user: TODO
:password: TODO
"""
self._user = user # this is the pattern I'm unfamiliar with
self._password = password
Is it common (or good) practice to use underscore when assigning instance variables in a constructor for a class in Python, or is this likely just the snippet pack author's preference? I haven't seen this type of naming convention in any other Python code I've interacted with.