python-3.6

Unable to Install Pylint in windows - python?

折月煮酒 提交于 2019-12-09 03:51:28
问题 I am new to python, I installed python on windows in the following directory C:\Program Files\Python36 , I am using vscode as IDE when I trying to run the following command in integrated terminal "C:\Program Files\Python36\python" -m pip install pylint Exception: Traceback (most recent call last): File "c:\program files\python36\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "c:\program files\python36\lib\site-packages\pip\commands\install.py",

python function annotation in class return type is the class raise undefined

允我心安 提交于 2019-12-09 03:15:08
问题 Python 3.6.1, there are several ways of type hinting, in the doc string or annotation. How can I achieve this using annotation? Say I have a class, which have a class method load to load data from somewhere, json or database for instance, and construct and return a instance of this class. class Foo: @classmethod def load(cls, bar) -> Foo: pass I think this is quite straightforward, but python interpreter raised an error that Foo is not defined. I know the reason, because when python loads Foo

Python 3.6.1 crashed after I installed readline module

时间秒杀一切 提交于 2019-12-08 22:24:28
问题 I've just installed Python 3.6.1 from source code, and then I run sudo pip3 install readline to install the readline module. But when I start the Python shell, it crashes no matter what I enter: Python 3.6.1 (default, Mar 25 2017, 13:40:56) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> print("Hello") *** Error in `python3': munmap_chunk(): invalid pointer: 0x00007fa3c64960a0 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc

cx_freeze ImportError: No module named 'idna'

孤人 提交于 2019-12-08 20:45:33
I'm using python 3.6 Trying to make and exe from my .py file. but when I run python setup.py build it give me an error raise ImportError("No module named %r" % name) ImportError: No module named 'idna' My setup file is like this setup file Save: # thanks to https://www.youtube.com/watch?v=GSoOwSqTSrs from cx_Freeze import setup, Executable setup( name='KutsalAklinNerde?', version='0.1', #Further information about its version description='Parse stuff', #It's description executables= [Executable("Example.py")]) as setup.py in the same directory of your Example.py (the .py you want to convert to

What is the correct format to write float value to file in Python

允我心安 提交于 2019-12-08 18:54:31
I have a bunch of float values, for example: x1 = 1.11111111 x2 = 2.22222222 I want to write these values to a file: f = open("a.dat", "w+") f.write("This is x1: ",x1) f.write("\n") #I want to separate the 2 lines f.write("This is x2: ",x2) At this point I got an error on the second line: write() takes exactly one argument (2 given) How do I write to file such that when I open it, I see this format: This is x1: 1,1111111 This is x2: 2,2222222 And yes, the file has to be ***.dat It's not .txt the way you are writing to the file looks like you are giving two arguments to write function. So you

Why does unpacking this map object print “must be an iterable, not map”?

依然范特西╮ 提交于 2019-12-08 14:58:11
问题 What is going on here? >>> list(map(lambda *x: x, *map(None, 'abc'))) Traceback (most recent call last): File "<pyshell#52>", line 1, in <module> list(map(lambda *x: x, *map(None, 'abc'))) TypeError: type object argument after * must be an iterable, not map Ignore the senselessness of the code. This is about the error message, "iterable, not map" . Maps are iterables, are they not? And if I only replace None with str , the whole thing works fine: >>> list(map(lambda *x: x, *map(str, 'abc')))

Why isn't it possible to use “await” in f-strings?

旧城冷巷雨未停 提交于 2019-12-08 14:54:20
问题 Why isn't it possible to use "await" in f-strings? Is there any way to coerce f-strings into evaluating the format expressions in the context of a coroutine function? $ python3 Python 3.6.0 (default, Mar 4 2017, 12:32:37) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> async def a(): return 1 ... >>> async def b(): return 'The return value of await a() is {}.'.format(await a()) ... >>> async def c(

Collisions aren't registering with Python Turtles

China☆狼群 提交于 2019-12-08 14:20:24
问题 I'm creating a simple 2D shooter following an online tutorial, and the enemy sprites (except 1, there are 5 total) are not abiding by my collision code. Everything works except the bullet object that the player controls simply passes right through the enemy sprites. Error messages I received: Traceback (most recent call last): File "C:\Python\Python36\pygame projects\space invaders.py", line 163, in <module> bullet.hideturtle() File "C:\Python\Python36\lib\turtle.py", line 2322, in hideturtle

Verify that an unknown module/object is obliged to a specific interface (python)

我是研究僧i 提交于 2019-12-08 14:06:47
问题 I'd like to check at runtime, for example, that a given object has methods foo() and bar() . My research system, built in python 3.6, is highly parameterized and can/should accept any kind of object as a replacement of its build in modules. This functionality is very useful because many different students who use this system can easily research different behavior without changing the source code of my system. The problem is that if they built the module wrong, they might discover this only

pymongo.errors.OperationFailure: unsupported type in filter

吃可爱长大的小学妹 提交于 2019-12-08 13:54:29
问题 I am working on Project Django with MongoDB (djongo) and I am using mongo atlas But when I am running this command python3 manage.py runserver python3 manage.py makemigrations this show this type error pymongo.errors.OperationFailure: unsupported type in filter But if I use my local mongod then it's works fine. Please help me My requirements.txt dataclasses==0.6 dj-database-url==0.5.0 Django==2.2 django-cors-headers==3.0.1 djangorestframework==3.9.4 djongo==1.2.32 dnspython==1.16.0 pymongo==3