python-3.6

iter() not working with datetime.now()

对着背影说爱祢 提交于 2019-12-03 11:27:16
问题 A simple snippet in Python 3.6.1: import datetime j = iter(datetime.datetime.now, None) next(j) returns: Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration instead of printing out the classic now() behavior with each next() . I've seen similar code working in Python 3.3, am I missing something or has something changed in version 3.6.1? 回答1: This is definitely a bug introduced in Python 3.6.0b1. The iter() implementation recently switched to using _PyObject

How do I annotate types in a for-loop

半世苍凉 提交于 2019-12-03 09:18:02
I want to annotate a type of a variable in a for -loop. I tried this: for i: int in range(5): pass But it didn't work, obviously. What I expect is working autocomplete in PyCharm 2016.3.2. Pre-annotation like this: i: int for i in range(5): pass doesn't help. P.S. Pre-annotation works for PyCharm >= 2017.1 According to PEP 526 , this is not allowed: In addition, one cannot annotate variables used in a for or with statement ; they can be annotated ahead of time, in a similar manner to tuple unpacking Annotate it before the loop: i: int for i in range(5): pass PyCharm 2018.1 and up now

How to use virtualenv with python3.6 on ubuntu 16.04?

北慕城南 提交于 2019-12-03 05:40:11
问题 I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through alias python3=python3.6 . Then, I've installed virtualenv using sudo -H pip3 install virtualenv . When I checked, the virtualenv got installed in "/usr/local/lib/python3.5/dist-packages" location, so when I'm trying to create virtualenv using python3 -m venv ./venv1 it's throwing me errors: Error Command: ['/home/wgetdj/WorkPlace/Programming/Python

iter() not working with datetime.now()

痞子三分冷 提交于 2019-12-03 00:56:08
A simple snippet in Python 3.6.1: import datetime j = iter(datetime.datetime.now, None) next(j) returns: Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration instead of printing out the classic now() behavior with each next() . I've seen similar code working in Python 3.3, am I missing something or has something changed in version 3.6.1? This is definitely a bug introduced in Python 3.6.0b1. The iter() implementation recently switched to using _PyObject_FastCall() (an optimisation, see issue 27128 ), and it must be this call that is breaking this. The same issue

Kivy application does not work on Android

人盡茶涼 提交于 2019-12-02 21:44:09
问题 I want write simple application in Python for Android using kivy. Sadly when I start example code I see only splash screen and few second later application finish work. There is a huge problem with debugging because adb on Linux Mint does not detect my device. Can someone look at my code and tell my why? To build application I use buildozer. You can also see create_env script to check all dependencies are there. Best regards. Draqun EDIT: I started debugging my application. Conclusion:

How to use virtualenv with python3.6 on ubuntu 16.04?

早过忘川 提交于 2019-12-02 21:17:32
I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through alias python3=python3.6 . Then, I've installed virtualenv using sudo -H pip3 install virtualenv . When I checked, the virtualenv got installed in "/usr/local/lib/python3.5/dist-packages" location, so when I'm trying to create virtualenv using python3 -m venv ./venv1 it's throwing me errors: Error Command: ['/home/wgetdj/WorkPlace/Programming/Python/myvenv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip'] What should I do? We usually use $

PyTorch Tutorial Error Training a Classifier

只愿长相守 提交于 2019-12-02 20:29:44
问题 I just started the PyTorch-Tutorial Deep Learning with PyTorch: A 60 Minute Blitz and I should add, that I haven't programmed any python (but other languages like Java) before. Right now, my Code looks like import torch import torchvision import torchvision.transforms as transforms import matplotlib.pyplot as plt import numpy as np print("\n-------------------Backpropagation-------------------\n") transform = transforms.Compose( [transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (0

Installing Python3.6 alongside Python3.7 on Mac

六眼飞鱼酱① 提交于 2019-12-02 15:42:49
I'm trying to install tensorflow onto a Mac with Python3.7. However, I'm getting the error: $ pip3 -v install tensorflow ... Skipping link https://files.pythonhosted.org/packages/56/7a/c6bca0fe52a94ca508731d8b139e7dbd5a36cddc64c19f422f97e5a853e8/tensorflow-1.10.0rc1-cp36-cp36m-win_amd64.whl#sha256=3ab24374888d6a13d55ce2e3cf4ba0c9cd6f824723313db5322512087525cb78 (from https://pypi.org/simple/tensorflow/); it is not compatible with this Python Could not find a version that satisfies the requirement tensorflow (from versions: ) Cleaning up... Removed build tracker '/private/var/folders/4n

Second argument of three mandatory

偶尔善良 提交于 2019-12-02 11:52:51
I have a function that mimics range(). I am stuck at one point. I need to be able to make the first (x) and third (step) arguments optional, but the middle argument (y) mandatory. In the code below, everything works except the two commented out lines. If I am only passing in one argument, how do I construct the function to accept the single passed in argument as the mandatory (y) argument? I cannot do this: def float_range(x=0, y, step=1.0): Non-default parameter cannot follow a default parameter. def float_range(x, y, step=1.0): if x < y: while x < y: yield x x += step else: while x > y:

PyTorch Tutorial Error Training a Classifier

末鹿安然 提交于 2019-12-02 09:45:01
I just started the PyTorch-Tutorial Deep Learning with PyTorch: A 60 Minute Blitz and I should add, that I haven't programmed any python (but other languages like Java) before. Right now, my Code looks like import torch import torchvision import torchvision.transforms as transforms import matplotlib.pyplot as plt import numpy as np print("\n-------------------Backpropagation-------------------\n") transform = transforms.Compose( [transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))]) trainset = torchvision.datasets.CIFAR10(root='./data', train=True,download=True,