Avatar ·

How to create a static class property in Python?

📁 python, ошибка

I'm trying this:

class ChatCodes:   _chat = 'cht'   @property   def chat(self):      retu self._chat

if I use it like this:

print(ChatCodes.chat + 'any_str')

I get an error:

unsupported operand type(s) for +: 'property' and 'str'

how to correctly create a static property?

Avatar ·

Google has an official library, you can use it:

Example Python code can be seen here:

>>> from google.cloud import translate>>> client = translate.Client()>>> client.translate(['Me llamo Jeff', 'My name is Jeff'],...                  target_language='de')[    {        'translatedText': 'Mein Name ist Jeff',        'detectedSourceLanguage': 'es',        'input': 
                            

Log in to leave an answer

Blogs