It's quite straight forward, and I bet it's a noob question.
Why is it that the following can print the year BEFORE declaring it, as it is shown in the code
from datetime import datetime
now = datetime.now()
print now.year
current_year = now.year
current_month = now.month
current_day = now.day
This shows 2015, as it should, but how is it possible to pring out now.year, when I haven't even declared it at that point.
datetime.now()
returns a date object, which has a member named year. What you are doing here:is assigning local variables, not assigning the members of now.