python-3.6

Python3.6 AttributeError: module 'asyncio' has no attribute 'run'

﹥>﹥吖頭↗ 提交于 2019-11-30 11:39:58
I tried to read https://hackernoon.com/asynchronous-python-45df84b82434 . It's about asynchronous python and I tried the code from this, but I'm getting a weird Error. The code is: ` import asyncio import aiohttp urls = ['http://www.google.com', 'http://www.yandex.ru', 'http://www.python.org'] async def call_url(url): print('Starting {}'.format(url)) response = await aiohttp.ClientSession().get(url) data = await response.text() print('{}: {} bytes: {}'.format(url, len(data), data)) return data futures = [call_url(url) for url in urls] asyncio.run(asyncio.wait(futures)) When I try to run it

Python 3.6 No module named pip

微笑、不失礼 提交于 2019-11-30 10:53:08
I have just installed Python 3.6 on Fedora 25 (64 bits) by running dnf install python36 and I can't use any modules Python 3.5 can otherwise use just fine, for example, PyCharm complains about setup tools not being installed, also I can run python3 and issue: import aiohttp However, if run python36 and then: import aiohttp I instead get: Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'aiohttp' Pip is also not present on python36, as python36 -m pip throws: /usr/bin/python36: No module named pip I have to note that I've got python 3.4, 3.5 and 3.6

Tkinter: Updating progressbar when a function is called

本小妞迷上赌 提交于 2019-11-30 09:59:37
问题 Imagine the following simple example: def doNothing(): sleep(0.5) barVar.set(10) sleep(0.5) barVar.set(20) sleep(0.5) barVar.set(30) mainWindow = Tk() barVar = DoubleVar() barVar.set(0) bar = Progressbar(mainWindow, length=200, style='black.Horizontal.TProgressbar', variable=barVar, mode='determinate') bar.grid(row=1, column=0) button= Button(mainWindow, text='Click', command=doNothing) button.grid(row=0, column=0) mainWindow.mainloop() What I get when I run this, the progressbar is already

Type hint for NumPy ndarray dtype?

泪湿孤枕 提交于 2019-11-30 05:58:36
问题 I would like a function to include a type hint for NumPy ndarray 's alongside with its dtype . With lists, for example, one could do the following... def foo(bar: List[int]): ... ...in order to give a type hint that bar has to be list consisting of int 's. Unfortunately, this syntax throws exceptions for NumPy ndarray : def foo(bar: np.ndarray[np.bool]): ... > np.ndarray[np.bool]) (...) TypeError: 'type' object is not subscriptable Is it possible to give dtype -specific type hints for np

How to use Asynchronous Comprehensions?

↘锁芯ラ 提交于 2019-11-30 05:21:43
问题 I'm trying to use Python 3.6's async comprehensions in a MacOS Sierra (10.12.2), but I'm receiving a SyntaxError . Here is the code I've tried: print( [ i async for i in range(10) ] ) print( [ i async for i in range(10) if i < 4 ] ) [i async for i in range(10) if i % 2] I am receiving a syntax error for async loops: result = [] async for i in aiter(): if i % 2: result.append(i) All code is copy/paste from the PEP. Terminal Output: >>> print([i for i in range(10)]) [0, 1, 2, 3, 4, 5, 6, 7, 8,

Python 3.5 vs. 3.6 what made “map” slower compared to comprehensions

雨燕双飞 提交于 2019-11-30 05:11:10
I sometimes used map if there was a function/method that was written in C to get a bit extra performance. However I recently revisited some of my benchmarks and noticed that the relative performance (compared to a similar list comprehension) drastically changed between Python 3.5 and 3.6. That's not the actual code but just a minimal sample that illustrates the difference: import random lst = [random.randint(0, 10) for _ in range(100000)] assert list(map((5).__lt__, lst)) == [5 < i for i in lst] %timeit list(map((5).__lt__, lst)) %timeit [5 < i for i in lst] I realize that it's not a good idea

Python Win 3.6.0 x64 issue, missing qt designer exe after pip3 install pyqt5

╄→尐↘猪︶ㄣ 提交于 2019-11-30 04:50:30
问题 I'm a Python newbie and trying to start my first application and am struggling to workout how to use Qt Designer with pyQT5. I've been using the next command which installs pyqt5.7.1: pip3 install pyqt5 After the install, I have a C:\Python36\Lib\site-packages\PyQt5\Qt\bin\Qt5Designer.dll file but no Qt Designer exe as far as i can tell. id really appreciate the help if anyone has any idea what i'm missing? Do I have to install the full Qt5 framework to be able to use Qt Designer and pyQT5?

Recommended way to install pip(3) on centos7

夙愿已清 提交于 2019-11-30 04:41:54
I am interrested in knowing the recommended way to install pip3 for python3.6 (as of today, may 2018) on current version of centos7 (7.5.1804) and the accepted answer of How to install pip in CentOS 7? seems to be outdated because: yum search -v pip outputs (among other things): python2-pip.noarch : A tool for installing and managing Python 2 packages Repo : epel python34-pip.noarch : A tool for installing and managing Python3 packages Repo : epel and python34-pip seems to be a (newer?) simpler way than the accepted answer of How to install pip in CentOS 7? : sudo yum install python34

Tensorflow 1.10 TFRecordDataset - recovering TFRecords

♀尐吖头ヾ 提交于 2019-11-30 03:26:28
问题 Notes: this question extends upon a previous question of mine. In that question I ask about the best way to store some dummy data as Example and SequenceExample seeking to know which is better for data similar to dummy data provided. I provide both explicit formulations of the Example and SequenceExample construction as well as, in the answers, a programatic way to do so. Because this is still a lot of code, I am providing a Colab (interactive jupyter notebook hosted by google) file where you

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

三世轮回 提交于 2019-11-30 03:06:29
I would like to know how to format this case in a Pythonic way with f-strings: names = ['Adam', 'Bob', 'Cyril'] text = f"Winners are:\n{'\n'.join(names)}" print(text) The problem is that '\' cannot be used inside the {...} expression portions of an f-string. Expected output: Winners are: Adam Bob Cyril 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, [.