I've got following simple script, which gets text from some site:
from urllib.request import urlopen
def fetch_words():
contentdownload = urlopen('https://wolnelektury.pl/media/book/txt/treny-tren-viii.txt')
decluttered = []
for line in contentdownload:
decltr_line = line.decode('utf8').split(" ")
for word in decltr_line:
decluttered.append(word)
contentdownload.close()
return decluttered
When adding: print(fetch_words)
at the end, the program returns: <function fetch_words at 0x7fa440feb200>
, but on the other hand, when I replace it with: print(fetch_words())
it returns the content of the website, that a function downloads.
I have following question: why it works like this, what's the difference: function
with ()
or without...
All help appreciated!