Printing the result of datetime directly?


Why is it necessary to store in a variable before printing it, ie



There is no variable there...


It does return a value that gets stored in a variable, so it seems like you should be able to print the value directly. Other languages will allow this, so I'm curious why python doesn't.


I'm still not seeing this 'variable' you're talking about.

You are calling which is a method/function call.

Aren't you printing it directly?


In the lesson code, we have

now =
print now

now is the variable I meant, I should have been clearer. So it seems like you should be able to omit the assignment statement and just write


and get the same output.

The examples on this page suggest that you can directly print the value that a function returns, but it also says

 "Print is for people. Remember that slogan. Printing has no effect on the ongoing
 execution of a program. It doesn’t assign a value to a variable. It doesn’t return a
 value from a function call."

So I'm still confused.


You can print it as you've shown, but you print it this way in the exercise:

now =
print now

Because you are later going to access datetime's internal methods in the next exercise.