Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > returning results from function

Reply
Thread Tools

returning results from function

 
 
Neil Berg
Guest
Posts: n/a
 
      11-11-2010
Hi Python community,

In a main script, I pass the year (yr), month (mo), day (dy) and hour(hr) into the utc_to_local function (pasted below) which converts that date and time into local standard time. I am passing several dates and times into this function and would like to work with the "returned" loc_y/m/d/h values, but no output is visibly seen when I run the main script. I want the "return" command to just return the values to me in the main script so I can work with them! Any help is appreciated.

Thanks in advance,
Neil

_________
Mac OS X 10.6.4
Python 2.6
_________

from datetime import datetime
from pytz import timezone
import pytz

def utc_to_local(yr,mo,dy,hr):
fmt = '%Y-%m-%d %H %Z'
utc = pytz.utc
local = pytz.timezone("US/Pacific")
utc_dt = datetime(yr,mo,dy,hr, tzinfo=utc)
loc_dt = utc_dt.astimezone(local) # local date YY-MM-DD HR TZ
#print utc_dt.strftime(fmt), " = ", loc_dt.strftime(fmt)

loc_y = loc_dt.year # local year
loc_m = loc_dt.month # local month
loc_d = loc_dt.day # local day
loc_h = loc_dt.hour # local hour

return loc_y, loc_m, loc_d, loc_h

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
returning none when it should be returning a list? randomtalk@gmail.com Python 11 05-02-2006 10:26 AM
Request received well, returning it results in loss of data! Edwin Knoppert ASP .Net 5 01-06-2006 01:10 PM
Returning results through the function parameter list? Daniel Rudy C Programming 15 05-16-2005 04:35 AM
User Defined function returning table give inconsistent results Marc Walgren ASP General 3 08-23-2004 04:02 PM
returning results with embedding Roberto Python 0 02-04-2004 05:48 PM



Advertisments