python-3.6

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

南笙酒味 提交于 2019-11-26 12:38:47
问题 (py36venv) vagrant@pvagrant-dev-vm:/vagrant/venvs$ pip3 install pep8 pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Collecting pep8 Could not fetch URL https://pypi.python.org/simple/pep8/: There was a problem confirming the ssl certificate: Can\'t connect to HTTPS URL because the SSL module is not available. - skipping Could not find a version that satisfies the requirement pep8 (from versions: ) No matching distribution found for

f-strings in Python 3.6

会有一股神秘感。 提交于 2019-11-26 12:26:56
问题 I really like to delve into code style and it\'s interesting to know whether from now on in all cases it would be better to use the new style. I\'m using a lot the .format() in my Python 3.5 projects, and I\'m afraid that it will be deprecated during the next Python versions because of this new kind of string literals. >>> name = \"Test\" >>> f\"My app name is {name}.\" \'My app name is Test.\' Does the formatted string feature come to fully replace the old format() ? I understand that it

Microsoft Windows Python-3.6 PyCrypto installation error

Deadly 提交于 2019-11-26 10:25:24
问题 pip install pycrypto works fine with python3.5.2 but fails wiht python3.6 with the following error: inttypes.h(26): error C2061: syntax error: identifier \'intmax_t\' 回答1: 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

Are sets ordered like dicts in python3.6

让人想犯罪 __ 提交于 2019-11-26 09:41:26
问题 Due to changes in dict implementation in Python 3.6 it is now ordered by default. Do set s preserve order as well now? I could not find any information about it but as both of those data structures are very similar in the way they work under the hood I thought it might be the case. I know there is no promise for dict s to be ordered in all cases but they are most of the time. As stated in Python docs: The order-preserving aspect of this new implementation is considered an implementation

How to use type hints in python 3.6?

半城伤御伤魂 提交于 2019-11-26 09:36:13
问题 I noticed python 3.5 and python 3.6 added a lot of features about static type checking, so I tried with the following code(in python 3.6, stable version). from typing import List a: List[str] = [] a.append(\'a\') a.append(1) print(a) What surprised me was that, python didn\'t give me an error or warning, although 1 was appended to a list which should only contain strings. Pycharm detected the type error and gave me a warning about it, but it was not obvious and it was not shown in the output

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

ⅰ亾dé卋堺 提交于 2019-11-26 08:56:39
问题 I am using template strings to generate some files and I love the conciseness of the new f-strings for this purpose, for reducing my previous template code from something like this: template_a = \"The current name is {name}\" names = [\"foo\", \"bar\"] for name in names: print (template_a.format(**locals())) Now I can do this, directly replacing variables: names = [\"foo\", \"bar\"] for name in names: print (f\"The current name is {name}\") However, sometimes it makes sense to have the

String with &#39;f&#39; prefix in python-3.6

。_饼干妹妹 提交于 2019-11-26 04:45:35
问题 I\'m trying out Python 3.6. Going through new code, I stumbled upon this new syntax: f\"My formatting string!\" It seems we can do things like this: >>> name = \"George\" >>> print(f\"My cool string is called {name}.\") My cool string is called George. Can anyone shed some light on the inner workings of this? In particular what is the scope of the variables that an f-prefixed string can take? 回答1: See PEP 498 Literal String Interpolation: The expressions that are extracted from the string are

Issue installing Tensorflow — not a CUDA/CuDNN issue

☆樱花仙子☆ 提交于 2019-11-26 01:43:55
问题 I recently started getting into Tensorflow, but i\'m having issues with the install. Everytime I try to import it I get the following error >>> import tensorflow as tf Traceback (most recent call last): File \"C:\\Users\\[user]\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow_internal.py\", line 14, in swig_import_helper return importlib.import_module(mname) File \"C:\\Users\\[user]\\AppData\\Local\\Programs\\Python\\Python36\\lib\

What are variable annotations in Python 3.6?

会有一股神秘感。 提交于 2019-11-26 01:43:23
问题 Python 3.6 is about to be released. PEP 494 -- Python 3.6 Release Schedule mentions the end of December, so I went through What\'s New in Python 3.6 to see they mention the variable annotations : PEP 484 introduced standard for type annotations of function parameters, a.k.a. type hints. This PEP adds syntax to Python for annotating the types of variables including class variables and instance variables: primes: List[int] = [] captain: str # Note: no initial value! class Starship: stats: Dict

Are dictionaries ordered in Python 3.6+?

余生长醉 提交于 2019-11-25 22:53:59
问题 Dictionaries are ordered in Python 3.6 (under the CPython implementation at least) unlike in previous incarnations. This seems like a substantial change, but it\'s only a short paragraph in the documentation. It is described as a CPython implementation detail rather than a language feature, but also implies this may become standard in the future. How does the new dictionary implementation perform better than the older one while preserving element order? Here is the text from the documentation