Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Build a Social Network with Flask Takin' Names Flask-WTF Forms

Within validators for each form field, why don't we need to use parenthesis after the methods that we write?

Such as email_exists and name_exists, there are no parenthesis when calling the method name. How is python going to know that is a method? Thanks.

3 Answers

Hello Pete.

I had your same doubt and asked in the forums, I will link it here:

https://teamtreehouse.com/forum/1-question-and-1-code-problem-with-my-formspy-file

Basically it is syntax rules as per documentation and python will take care of it.

Vittorio

"How is python going to know that is a method?" Your answer lies in .../wtfforms/fields/core.py—line 110—where the parenthesis are assumed by the gettattr() function's specified default. From there, it launches into a setattr() function, via a for loop, which 'constructs' our method's attributes—via instantiations of the Flags class, on line 352 of core.py.

That's cool, if you ask me...

Thanks Vittorio. That helps.

Kenneth highlighted that the time stamp can also be called without parenthesis. The interesting thing is that it has a different function with or without the parenthesis. Like you said, its syntax, seems like I just gotta memorize some things...cheers and good luck with your coding..