Type error str object not callable


#1

line 20 type error ‘str’ object not callable

"""dsfads
sdfas
asdf
asdfasd"""
from time import sleep, strftime
raw_input = "m"
user_name = raw_input
calendar = {}
def welcome():
  print "Welcome, " + user_name
  sleep(1)
  strftime("%A, %B, %d, %Y")
  strftime("%H:%M:%S:")
  sleep(1)
  print "What would you like to do?"
def start_calendar():
  welcome()
  start = True
  while True :
    user_choice = raw_input("A to Add, U to Update, V to View D to Delete, X to Exit: ")
    user_choice = user_choice.upper()
    if user_choise == "V":
      if len(calendar.keys()) < 1:
        print "Calendar empty."
      else:
        print calendar
    elif user_choise == "U":
          date = raw_input("What date? ")
          update = raw_input("Enter the update: ")
          calendar[date] = update
          print "mmmmm"
          print calendar
    elif user_choise == "A":
      event = raw_input("Enter event: ")
      date = raw_input("Enter date (MM/DD/YYYY): ")
      if len(date) > 10 or int(date[6:]) < int(strftime("%Y")):
        print "invalid date was entered"
        try_again = raw_input("Try Again? Y for Yes, N for No: ")
        try_again = try_again.upper()
        if user_choise == "Y":
          continue
        else:
          start = False
      else:
        calendar[date] = event
        print "successfully added"
        print calendar
    elif user_choise == "D":
      if len(calendor.key()) > 1:
        print "calendar is empty"
      else:
        event = raw_input("mmmmmm")
        for date in calendor.keys():
            if event == calander[date]:
              del calandor[date]
              print "mmmm"
              print calendor
    elif user_choise == "x":
      start = False
    else :
      print "mmmm"
      start = False
    
start_calendar()

#2

That line overwrites the function in the namespace. Not a good idea.

By not invoking the function, you end up assigning a stub to the variable. Also not a good idea.

user_name = raw_input("Enter your name: ")

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.