Import data to a function

python
datetime

#1

Hi there,
Another question please...
I have this code :

import datetime
timestamp = 1339521878
value = datetime.datetime.fromtimestamp(timestamp)
print(value.strftime('%Y'))

def Final(f):
if (f == 2015):
return (0.145 * 1)
elif (f ==2012):
return (0.145 * 2)
aa =Final(2015)
print aa

The first section take some "timestamp" that i entered and give me back the "year" of that time stamp..
The second section is just a simple function with "elif" and "if "...
the outputs now are :
2012
0.145
I need that the data from the "timestamp" request will go directly to my function,
It will go to : aa =Final(f) (it should be something like : aa =Final(value.strftime('%Y'))
How can i do that?
Tnx!


#2

Preamble

I'm working with the initial data,

from datetime import date
timestamp = 1339521878
value = date.fromtimestamp(timestamp)

Testing in the command line,

 > type(value)
=> <type 'datetime.date'>
 > value
=> datetime.date(2012, 6, 12)
 > value.strftime('%Y')
=> ''

I'm at a loss for an explanation, at this point. Fortunately we have an alternate approach:

    print value.year

That gives us this,

    aa = final(value.year)

Not sure I understand the meaning of 0.145. Please explain.