Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Reminders - Delete Calendar (List)
-
I am desperately trying to delete a calendar (task list) by name, using the reminder class and delete_calendar. Also checked the documentation and web with no result. Would you mind providing me a simple code example? Thanks!
-
This post is deleted! -
import reminders print('=' * 25) c = reminders.Calendar() c.title = "Delete Me!!!" c.save() print(c) while True: calendars = reminders.get_all_calendars() for i, calendar in enumerate(calendars): print(i, calendar) i = int(input('Enter number of the calendar to delete ("q" to quit): ').strip()) reminders.delete_calendar(calendars[i])
-
Hello,
many thanks for your incredible fast reply! I copy-pasted and executed the code and received the following error message:
(...)
line 15, in <module>
reminders.delete_calendar(calendars[i])
TypeError: 'str' object is not callable
(...)maybe it's a device setting then... kind regards,
Simon
-
Did you enter a number (3) or a string ("Delete Me!!!")?
Please paste the full text of your run.
-
Are you on Python 2??
import reminders try: # https://docs.python.org/3/whatsnew/3.0.html#builtins raw_input # Python 2 except NameError: raw_input = input # Python 3 print('=' * 25) c = reminders.Calendar() c.title = "Delete Me!!!" c.save() print(c) while True: calendars = reminders.get_all_calendars() for i, calendar in enumerate(calendars): print(i, calendar) i = int(raw_input('Enter number of the calendar to delete ("q" to quit): ').strip()) reminders.delete_calendar(calendars[i])
-
Hi, python 3.5 is indicated on the top. With both codes, I get the same error message (see below).
=========================
<Calendar "Delete Me!!!">
0 <Calendar "Delete Me!!!">
1 <Calendar "Delete Me!!!">
2 <Calendar "Delete Me!!!">
3 <Calendar "Delete Me!!!">
Enter number of reminder to delete ("q" to quit): 1
Traceback (most recent call last):
File „(…)“, line 15, in <module>
reminders.delete_calendar(calendars[i])
TypeError: 'str' object is not callableThanks again!
-
Works fine for me. Your exception suggests that in your enviroment the function
delete_calendar()
in the namespacereminders
has been overwritten with a string of the same name. You should investigate that with the inspector when your exception is raised.Or more likely ... you have missed a parenthesis while copying the snippet which often completely confuses the interpreter.
-
@simon You could insert these three lines just before the line that is failing.
print('({}): {}'.format(type(i), i)) print('({}): {}'.format(type(calendars[i]), calendars[i])) print(reminders.delete_calendar) # you should see results like: # (<class 'int'>): 4 # (<class 'reminders.Calendar'>): <Calendar "Delete Me!!!"> # <built-in function delete_calendar>
-
Good Morning Both,
Many thanks for your quick help!!!
I have closed / killed the APP an restarted Pythonista. Now the proposed solution works.
The issue is eventually, as I tried to delete the calendar with a name string instead of a calendar object in the beginning and the wrong solution was cached...