How to postpone/defer the evaluation of f-strings?

Here’s a complete “Ideal 2”. It’s not an f-string—it doesn’t even use f-strings—but it does as requested. Syntax exactly as specified. No security headaches since we are not using eval(). It uses a little class and implements __str__ which is automatically called by print. To escape the limited scope of the class we use the … Read more

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

Pip error: Microsoft Visual C++ 14.0 is required

You need to install Microsoft Visual C++ 14.0 to install pycrypto: error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”: http://landinghub.visualstudio.com/visual-cpp-build-tools In the comments you ask which link to use. Use the link to Visual C++ 2015 Build Tools. That will install Visual C++ 14.0 without installing Visual Studio. … 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