Why Python 3.6.1 throws AttributeError: module ‘enum’ has no attribute ‘IntFlag’?

It’s because your enum is not the standard library enum module. You probably have the package enum34 installed. One way check if this is the case is to inspect the property enum.__file__ import enum print(enum.__file__) # standard library location should be something like # /usr/local/lib/python3.6/enum.py Since python 3.6 the enum34 library is no longer compatible … Read more

Multiline f-string in Python

From Style Guide for Python Code: The preferred way of wrapping long lines is by using Python’s implied line continuation inside parentheses, brackets and braces. Given this, the following would solve your problem in a PEP-8 compliant way. return ( f'{self.date} – {self.time}\n’ f’Tags: {self.tags}\n’ f’Text: {self.text}’ ) Python strings will automatically concatenate when not … Read more

How to use newline ‘\n’ in f-string to format output in Python 3.6?

You can’t. Backslashes cannot appear inside the curly braces {}; doing so results in a SyntaxError: >>> f'{\}’ SyntaxError: f-string expression part cannot include a backslash This is specified in the PEP for f-strings: Backslashes may not appear inside the expression portions of f-strings, […] One option is assinging ‘\n’ to a name and then … Read more

Are dictionaries ordered in Python 3.6+?

Are dictionaries ordered in Python 3.6+? They are insertion ordered[1]. As of Python 3.6, for the CPython implementation of Python, dictionaries remember the order of items inserted. This is considered an implementation detail in Python 3.6; you need to use OrderedDict if you want insertion ordering that’s guaranteed across other implementations of Python (and other … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)