mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 14:35:00 +01:00
Fix documentation & coding style of User.name & User.full_name (#956)
- Use string `format` instead of dict comprehension. - Better documentation to signify the semantics difference between `name` and `full_name`. - Use string `format` instead of dict comprehension. - Better documentation to signify the semantics difference between `name` and `full_name`. * Removed the NOTE and mentinoed the "@" prefix.
This commit is contained in:
parent
0faa19726a
commit
a2c04313d3
1 changed files with 7 additions and 10 deletions
|
@ -72,26 +72,23 @@ class User(TelegramObject):
|
|||
@property
|
||||
def name(self):
|
||||
"""
|
||||
:obj:`str`: The users :attr:`username` if available, if not it returns the first name and
|
||||
if present :attr:`first_name` and :attr:`last_name`.
|
||||
:obj:`str`: Convenience property. If available, returns the user's :attr:`username`
|
||||
prefixed with "@". If :attr:`username` is not available, returns :attr:`full_name`.
|
||||
|
||||
"""
|
||||
|
||||
if self.username:
|
||||
return '@%s' % self.username
|
||||
if self.last_name:
|
||||
return '%s %s' % (self.first_name, self.last_name)
|
||||
return self.first_name
|
||||
return '@{}'.format(self.username)
|
||||
return self.full_name
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
"""
|
||||
:obj:`str`: The users :attr:`first_name` and if present :attr:`last_name`.
|
||||
:obj:`str`: Convenience property. The user's :attr:`first_name`, followed by (if available)
|
||||
:attr:`last_name`.
|
||||
|
||||
"""
|
||||
|
||||
if self.last_name:
|
||||
return '%s %s' % (self.first_name, self.last_name)
|
||||
return '{} {}'.format(self.first_name, self.last_name)
|
||||
return self.first_name
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in a new issue