“Asyncio Event Loop is Closed” when getting loop
On Windows seems to be a problem with EventLoopPolicy, use this snippet to work around it: asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) asyncio.run(main())
On Windows seems to be a problem with EventLoopPolicy, use this snippet to work around it: asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) asyncio.run(main())
Confusingly, np.array is a function useful for creating numpy arrays. It isn’t the actual type of the arrays created. The type is np.ndarray. So, replace np.array with np.ndarray. That should fix the problem.
PEP 0484 – Type Hints – The problem of forward declarations addresses the issue: The problem with type hints is that annotations (per PEP 3107 , and similar to default values) are evaluated at the time a function is defined, and thus any names used in an annotation must be already defined when the function … Read more
It’s not exactly an answer to your question but I’d consider using ChainMap to be an idiomatic and elegant way to do what you propose (merging dictionaries in-line): >>> from collections import ChainMap >>> d1 = {1: ‘one’, 2: ‘two’} >>> d2 = {3: ‘three’} >>> ds = [d1, d2] >>> dict(ChainMap(*ds)) {1: ‘one’, 2: … Read more
You could just iterate over the indices of the range of the len of your list: dataList = [{‘a’: 1}, {‘b’: 3}, {‘c’: 5}] for index in range(len(dataList)): for key in dataList[index]: print(dataList[index][key]) or you could use a while loop with an index counter: dataList = [{‘a’: 1}, {‘b’: 3}, {‘c’: 5}] index = 0 … Read more
According to https://github.com/pypa/pip/issues/4022, this is a bug resulting from Ubuntu providing incorrect metadata to pip. So, no there does not seem to be a good reason for this behaviour. I filed a follow-up bug with Ubuntu. https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1635463
There is no problem in mypy (at least, not in 0.501). But there is a problem with Python 3.6.0. Consider the following: from collections import OrderedDict from typing import Dict def foo() -> Dict[str, int]: result: OrderedDict[str, int] = OrderedDict() result[‘two’] = 2 return result This code will both satisfy mypy (0.501) and Python (3.6.0). … Read more
Yes, there are functional differences between native coroutines using async def syntax and generator-based coroutines using the asyncio.coroutine decorator. According to PEP 492, which introduces the async def syntax: Native coroutine objects do not implement __iter__ and __next__ methods. Therefore, they cannot be iterated over or passed to iter(), list(), tuple() and other built-ins. They … Read more
I met the same issue with python 3.5.2 and pip3 (9.0.1). And I fixed it by following this workaround: https://github.com/pypa/setuptools/issues/885#issuecomment-307696027 More specifically, I edited line #2121~2122 of this file: “sudo vim /usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py” #orig_path.sort(key=position_in_sys_path) #module.__path__[:] = [_normalize_cached(p) for p in orig_path] orig_path_t = list(orig_path) orig_path_t.sort(key=position_in_sys_path) module.__path__[:] = [_normalize_cached(p) for p in orig_path_t]
If this sudo ln -fs /usr/bin/python3.5 /usr/bin/python doesn’t work (it should) you could just add an alias into your /home/.bashrcwith this command: alias python=”/usr/bin/python3.5″ and if this does not work either you should just use virtual env. Read this page to get started.