python-3.6

Why are single type constraints disallowed in Python?

守給你的承諾、 提交于 2020-01-12 11:52:49
问题 Suppose you want to constrain a type variable to implement a certain interface. You might write something like so: from typing import TypeVar, Callable T = TypeVar('T', Callable) class Foo(Generic[T]): ... >> TypeError: A single constraint is not allowed Why is Python unhappy about this use of type constraints? PEP 484 and the Python source code are unhelpful in this regard. Note: in my particular case I am interested in constraining a type variable to implement an abstract base class, but

Django migration with python3.6 ERROR:root:code for hash sha3_224 was not found

倾然丶 夕夏残阳落幕 提交于 2020-01-11 04:58:28
问题 Hello I read Django tutorials and I have an error related to specific sha3_224 hash function during the migration process. How to solve this problem? Thank you. (venv) linuxoid@linuxoid-ThinkPad-L540:~/myprojects/myproject$ python manage.py makemigrations ERROR:root:code for hash sha3_224 was not found. Traceback (most recent call last): File "/home/linuxoid/myprojects/venv/lib/python3.6/hashlib.py", line 121, in __get_openssl_constructor f = getattr(_hashlib, 'openssl_' + name)

How to install specific awscli version in conda env (running 3.6) when not found in current channels

和自甴很熟 提交于 2020-01-06 05:30:18
问题 I am trying to install a specific version of awscli within my conda environment (running python 3.6). I have tried adding conda-forge to my current channels, as suggested in another post. When I run the command conda install -p /Users/myname/anaconda3/envs/py36 awscli==1.11.156 -y It errors with this message: Solving environment: failed PackagesNotFoundError: The following packages are not available from current channels: - awscli==1.11.156 Current channels: - https://repo.continuum.io/pkgs

How to manipulate data in arrays using pandas (and resetting evaluations)

此生再无相见时 提交于 2020-01-06 05:23:06
问题 I've revised the question for clarity and removed artifacts and inconsistencies - please reopen for consideration by the community. One contributor already thinks a solution might be possible with groupby in combination with cummax. I have a dataframe in which the max between prior value of col3 and current value of col2 is evaluated through a cummax function recently offered by Scott Boston (thanks!) as follows: df['col3'] = df['col2'].shift(-1).cummax().shift(). The resulting dataframe is

cx_Freeze ModuleNotFoundError: No module named 'codecs'

二次信任 提交于 2020-01-05 12:58:14
问题 Trying to convert a .py file into a .exe when trying to run the .exe file in the exe.win32-3.6 folder I get the following error: C:\Users\Aktan\Desktop\build\exe.win32-3.6>StatisticsCalculator.exe Fatal Python error: Py_Initialize: unable to load the file system codec Traceback (most recent call last): File "C:\Users\Aktan\AppData\Local\Programs\Python\Python36-32\lib\encodings\__init__.py", line 31, in <module> ModuleNotFoundError: No module named 'codecs' here is my setup.py code: import cx

cx_Freeze ModuleNotFoundError: No module named 'codecs'

六月ゝ 毕业季﹏ 提交于 2020-01-05 12:58:06
问题 Trying to convert a .py file into a .exe when trying to run the .exe file in the exe.win32-3.6 folder I get the following error: C:\Users\Aktan\Desktop\build\exe.win32-3.6>StatisticsCalculator.exe Fatal Python error: Py_Initialize: unable to load the file system codec Traceback (most recent call last): File "C:\Users\Aktan\AppData\Local\Programs\Python\Python36-32\lib\encodings\__init__.py", line 31, in <module> ModuleNotFoundError: No module named 'codecs' here is my setup.py code: import cx

Local maximum identification within a set % (trigger True on the downside)

回眸只為那壹抹淺笑 提交于 2020-01-05 07:11:25
问题 Looking to identify (flag True) when current values in col1 drop below the most recent local maximum in col1 achieved by a set percent such that there will be multiple such signals as maxima are achieved and current values drop by the set percent (i.e. resets automatically without a set threshold other than the percent). Note that flag True should occur only on downside, not upside. percent = 0.7 df = pd.DataFrame({'col0':[1,2,3,4,5,6,7,8,9] ,'col1':[5,4.9,5.5,3.5,3.1,4.5,5.5,1.2,5.8] ,'col2'

how avoid Anaconda to hijack pip

谁说胖子不能爱 提交于 2020-01-05 04:30:06
问题 I have 2 versions of Python installed on my PC (Windows 7, 64Bit). Python 2.7 Version installed with Anaconda Python 3.6 Version installed directly from python.org (the "regular IDLE") Now, i would like to install the necessary packages on the 3.6 using pip, but anaconda keeps on hijacking the command. For example, on typing in the cmd window: pip install numpy and i get: Requirement already satisfied: numpy in c:\users\georges\anaconda2\lib\site_packages Which is the case for python2.7, but

elegant way to have an almost-copy-constructor that allows to update some members

点点圈 提交于 2020-01-05 04:04:50
问题 i have an instance of a container class that serves as basis for several other instances. it is called data0 in the example. i would like to be able to make copies of that and then update some of the members of the copies. yes, that could be done using the copy module, creating a copy and assigning the new values for the members. but what if the container class is immutable? i was hoping to be able to implement what is needed to turn the class into a mapping ( keys and __getitem__ ) and make

Partial stub in PyCharm

社会主义新天地 提交于 2020-01-04 14:21:17
问题 I would like to introduce partial type annotation to my project. For example for overloading. I found that pep561 introduce partial stub file support. I develop my project with PyCharm and I add corresponding *.pyi file. And got expected information, but PyCharm reports that cannot find reference in pyi file. It is possible to force PyCharm to look to orginal py file when there is no entry in pyi file? Or maybe it is also doable with partial entry for class? I create sample project to show