On 16/08/2010 17:47, fuglyducky wrote:
I am trying to call a function with a couple additional parameters.
Unfortunately, for whatever reason I am unable to get this to work. I
am assuming that line is not passing correctly but I don't understand
why???

I can't share all of the code because it has IP in it but below are
the pertinent snippets.

Thanks in advance!

##################################################################################

PY: 3.1.2


FUNCTION CALL:
text_file = open(file_name, "r")
for line in text_file:
     new_foo = pop_time(current_time, line)
# current_time = datetime.datetime.now()


FUNCTION:
def pop_time(line, cur_time):

Look at the two arguments to pop_time, when you make the actual call they are swapped.

     global new_string
     global current_time


     # Generate random time between 0 and 30 seconds
     # Changes the time delta every time function is run
     rand_time = random.randint(0, 30)
     delta_time = datetime.timedelta(seconds=rand_time)

     # Sets the time format for string output
     format_time = cur_time.strftime("%Y-%m-%d %H:%M:%S")


ERROR MSG:
     format_time = cur_time.strftime("%Y-%m-%d %H:%M:%S")
AttributeError: 'str' object has no attribute 'strftime'


NOTE: current_time prints within the function, line does not

HTH.

Mark Lawrence.


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to