python-3.5

cannot use pycorenlp for python3.5 through terminal

大城市里の小女人 提交于 2019-11-29 15:57:12
My default python is 2.7, but have to do this project in python3.5 I installed pycorenlp through this command line: pip3 install pycorenlp . And it is showing I have already installed it: Requirement already satisfied (use --upgrade to upgrade): pycorenlp in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages Requirement already satisfied (use --upgrade to upgrade): requests in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from pycorenlp) However, when I type python3.5 through terminal to enter into python environment, then type from

Changing Active Directory user password in Python 3.x

依然范特西╮ 提交于 2019-11-29 15:31:13
I am trying to make a Python script that will open an LDAP connection to a server running AD, take a search entry (in this case a name), search for that entry and change that users password to a randomly generated password (as well as set the option to change password on logon) and then send them an automated secure email containing the new temporary password. So far I have been able to connect to the server, and search for a single DN which returns. The temporary password is being generated, and an email is being sent (although the password is not hashed, and the email is not secure yet).

ImportError: cannot import name 'HTMLAwareEntitySubstitution'

流过昼夜 提交于 2019-11-29 13:45:39
I just setup beautifulsoup4-4.1.0 and upgrade pip to version 9.0.1. When I write this : from bs4 import BeautifulSoup error occurs: Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> from bs4 import BeautifulSoup File "D:\Program Files (x86)\Python35-32\lib\site-packages\bs4\__init__.py", line 35, in <module> from .builder import builder_registry, ParserRejectedMarkup File "D:\Program Files (x86)\Python35-32\lib\site-packages\bs4\builder\__init__.py", line 7, in <module> from bs4.element import ( ImportError: cannot import name 'HTMLAwareEntitySubstitution' what should

Installing pip locally without root privileges

♀尐吖头ヾ 提交于 2019-11-29 12:30:25
I am working on a compute server which runs a linux. The machine is used by several users so I don't have and won't get root privileges. I need to install Keras which you would normally do by using pip Now, pip is not installed and the root won't install it for me either unless I beg him for probably a month or so. I tried to locally install pip with the python installation scrip Python352/bin/python3.5 get-pip.py --user This unfortunately throws me an no permission error /etc . This is not exactly what I expected from installing the tool locally. Is it somehow possible to make an installation

Python 3.5 typed NamedTuple syntax produces SyntaxError

喜夏-厌秋 提交于 2019-11-29 09:53:38
I get a SyntaxError: invalid syntax error when I try the new typed namedtuple syntax: class Employee(NamedTuple): name: str id: int in Python 3.5.2 even though according to the documentation it should be valid from 3.5+ onwards. Am I missing something? I've imported NamedTuple from typing in the code. The syntax to declare the types for the name and id fields you are using requires Python 3.6 or up . Python 3.5 does not support the variable-level type hints required. From the typing.NamedTuple documentation : Changed in version 3.6: Added support for PEP 526 variable annotation syntax. Use the

Is it possible to make python throw errors if the type of the argument passed to the annotated function doesn't match the one specified?

偶尔善良 提交于 2019-11-29 09:45:24
One of the new features in python3.5 is type hinting. For example the code below is valid now: def greeting(name: str) -> str: return 'Hello ' + name But, as I understand, it doesn't check anything by itself and also is interpreted absolutely the same way as this: def greeting(name): return 'Hello ' + name and was implemented mostly to help static analyzers (and to make code that is easier to understand). But is there (or is planned to be implemented in the future) any way (maybe by using some third-party libraries) to make python throw errors when an argument of an invalid type is passed to a

Test if function or method is normal or asynchronous

随声附和 提交于 2019-11-29 09:04:50
How can I find out if a function or method is a normal function or an async function? I would like my code to automatically support normal or async callbacks and need a way to test what type of function is passed. async def exampleAsyncCb(): pass def exampleNomralCb(): pass def isAsync(someFunc): #do cool dynamic python stuff on the function return True/False async def callCallback(cb, arg): if isAsync(cb): await cb(arg) else: cb(arg) And depending on what type of function gets passed it should either run it normally or with await. I tried various things but have no idea how to implement

Registering a Python list property to QML in pyside2

删除回忆录丶 提交于 2019-11-29 08:59:59
I'm trying to load a spreadsheet and pass a list of the worksheets back to my QML interface. But I'm unable to find a way to provide a list(and later a dictionary) back to the QML script. Here's my QML: FileDialog { id: openDialog title: "Open spreadsheet" nameFilters: [ "Excel files (*.xls *.xlsx)", "All files (*)" ] selectedNameFilter: "Excel files (*.xls *.xlsx)" onAccepted: { file.load(fileUrl) console.log(file.name) console.log(file.sheetnames) } onRejected: { console.log("Rejected") } } Here's the my python class: class File(QtCore.QObject): def __init__(self, *args, **kwargs): super

how to define dynamic nested loop python function

不打扰是莪最后的温柔 提交于 2019-11-29 06:45:55
a = [1] b = [2,3] c = [4,5,6] d = [a,b,c] for x0 in d[0]: for x1 in d[1]: for x2 in d[2]: print(x0,x1,x2) Result: 1 2 4 1 2 5 1 2 6 1 3 4 1 3 5 1 3 6 Perfect, now my question is how to define this to function, considering ofcourse there could be more lists with values. The idea is to get function, which would dynamicaly produce same result. Is there a way to explain to python: "do 8 nested loops for example"? You can use itertools to calculate the products for you and can use the * operator to convert your list into arguments for the itertools.product() function. import itertools a = [1] b =

python 3.5 type hints: can i check if function arguments match type hints?

好久不见. 提交于 2019-11-29 04:22:31
does python 3.5 provide functions that allow to test whether a given argument would fit the type hints given in the function declaration? if i have e.g. this function: def f(name: List[str]): pass is there a python method that can check whether name = ['a', 'b'] name = [0, 1] name = [] name = None ... fit the type hints? i know that 'no type checking happens at runtime' but can i still check the validity of these arguments by hand in python? or if python does not provide that functionality itself: what is the tool i'd need to use? Ilya Peterov Python itself doesn't provide such functions, you