can't convert tuple object to str

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

can't convert tuple object to str

Post by devnull » Sun Jun 17, 2018 12:23 am

Not sure if this is a bug or ??

Code: Select all

ext = ('.pdf', '.doc', '.xls')
'test.doc'.endswith(ext)
In python 3:

Code: Select all

True
In Micropython

Code: Select all

TypeError: can't convert 'tuple' object to str implicitly

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: can't convert tuple object to str

Post by Damien » Sun Jun 17, 2018 1:24 am

MicroPython doesn't support passing a tuple of strings to endswith. You need to pass one at a time.

Post Reply