Skip to content
Advertisement

Tag: python-3.x

error installing nltk supporting packages : nltk.download()

I have installed the nltk package. Following that I am trying to download the supporting packages using nltk.download() and am getting error: [Errno 11001] getaddrinfo My machine / software details are: OS: Windows 8.1 Python: 3.3.4 NLTK Package: 3.0 Below are the commands run in python: It looks like it is going to http://nltk.github.com/nltk_data/ whereas it should Ideally try to

Python: reduce (list of strings) -> string

I expected something like ‘a.b.c.d’ or ‘abcd’. Somehow, can’t explain the results. There are similar questions here, but not quite like this one. Answer The result of executing the function passed as the first parameter, will be the first parameter to that function in the next iteration. So, your code works like this When x, y are ‘alfa’ and ‘bravo’

How to make a variable inside a try/except block public?

How can I make a variable inside the try/except block public? This code returns an error How can I make the variable text available outside of the try/except block? Answer try statements do not create a new scope, but text won’t be set if the call to url lib.request.urlopen raises the exception. You probably want the print(text) line in an

Python “raise from” usage

What’s the difference between raise and raise from in Python? which yields and which yields Answer The difference is that when you use from, the __cause__ attribute is set and the message states that the exception was directly caused by. If you omit the from then no __cause__ is set, but the __context__ attribute may be set as well, and

Tracking how many elements processed in generator

I have a problem in which I process documents from files using python generators. The number of files I need to process are not known in advance. Each file contain records which consumes considerable amount of memory. Due to that, generators are used to process records. Here is the summary of the code I am working on: My process_records function

Advertisement