Why can’t I ‘yield from’ inside an async function?

According to PEP 525, which introduces asyncronous generators in Python 3.6: Asynchronous yield from While it is theoretically possible to implement yield from support for asynchronous generators, it would require a serious redesign of the generators implementation. yield from is also less critical for asynchronous generators, since there is no need provide a mechanism of … Read more

NoReturn vs. None in “void” functions – type annotations in Python 3.6

NoReturn means the function never returns a value. The function either does not terminate or always throws an exception: “The typing module provides a special type NoReturn to annotate functions that never return normally. For example, a function that unconditionally raises an exception..”. from typing import NoReturn def stop() -> NoReturn: raise RuntimeError(‘no way’) That … Read more

In Python format (f-string) strings, what does !r mean? [duplicate]

It just calls the repr of the value supplied. It’s usage is generally not really needed with f-strings since with them you can just do repr(self.radius) which is arguably more clear in its intent. !r (repr), !s (str) and !a (ascii) were kept around just to ease compatibility with the str.format alternative, you don’t need … Read more

How can I use newline ‘\n’ in an f-string to format output?

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

pip3 installs inside virtual environment with python3.6 failing due to ssl module not available

I followed the below steps for python3.6 installation in ubuntu 14.04 and virtualenv pip installs works fine. Python 3.6 Installation: sudo apt-get install python3-dev libffi-dev libssl-dev wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz tar xvf Python-3.6.0.tgz cd Python-3.6.0 ./configure –enable-optimizations make -j8 sudo make altinstall python3.6 If seeing the following error — zipimport.ZipImportError: can’t decompress data; zlib not available make: … Read more

Microsoft Windows Python-3.6 PyCrypto installation error

The file include\pyport.h in Python installation directory does not have #include < stdint.h > anymore. This leaves intmax_t undefined. A workaround for Microsoft VC compiler is to force include stdint.h via OS environment variable CL: Open command prompt Setup VC environment by runing vcvars*.bat (choose file name depending on VC version and architecture) set CL=-FI”Full-Path\stdint.h” … Read more

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