Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Python display "bound method...." when returning results and how can I make it stop? [closed]

Tags:

python

methods

I keep getting the answer I am looking for plus bound method tramStop.returnUpcomingTimes of <__main__.tramStop instance at 0x141d030>.

I receive my time information as a long string of times, I set that = to a variable SabinesTimes, and then convert it from a string to a list (in order to be able to iterate through the times rather than characters).

Here is my code:

from datetime import datetime
from time import strftime
import shlex # <http://stackoverflow.com/questions/6868382/python-shlex-split-ignore-single-quotes> 
import types

# SabinesTimes is given to me as one long string, I need to iterate through each time and compare to current time.  So I convert it to a comma delineated list. 

SabinesTimes = "04:55 05:55 06:10 07:20 08:35 09:45 10:58 11:00 12:00 13:00 14:00 15:00 16:00 17:00 18:00 19:00 20:00 21:00 22:00 23:59"
SabinesTimes = ','.join(shlex.split(SabinesTimes))
SabinesTimes = SabinesTimes.split(",")


class ligne():
    def __init__ (self, stops):
        self.stops = stops
    def returnAllStopsOnLigne(self):
        return stops

# inherits from Ligne
class tramStop(ligne):
    def __init__ (self, times):
        self.times = times 
    def returnUpcomingTimes(self):
        now = strftime("%H:%M")
        Departing_Trams = [i for i in self.times if i>= now]
        return Departing_Trams


sabines = tramStop(SabinesTimes)

# the goal is to print all times greater than the current time at sabines.returnUpcomingTimes
print sabines.returnUpcomingTimes()
like image 907
wisnewski.robert Avatar asked Nov 28 '12 12:11

wisnewski.robert


1 Answers

Your code as in the question should work. The code you are actually running must be

print sabines.returnUpcomingTimes

rather than

print sabines.returnUpcomingTimes()
like image 52
YXD Avatar answered Oct 14 '22 10:10

YXD