On 07/08/18 13:46, Rafael Knuth wrote: > Now I want to convert the code above into a function. > This is what I wrote: > > def FileReader(file_path): > with open(file_path) as file_object: > contents = file_object.read > return contents > > print(FilePrinter("C:\\Users\\...\\MyFile.txt")) # path shortened for
Note that you used a different name here than in your function definition! I'm guessing that's a typo, but its one reason to always cut 'n paste real code into your emails. Also as a matter of style its usual in Python to make function names start with a lower case letter: def myFunction(): or def my_function(): But that's just a community convention. But Chris has answered your original question, you need to add calling parens. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor