[Tutor] New to Programming: TypeError: coercing to Unicode: need string or buffer, list found

Danny Yoo danny.yoo at gmail.com
Thu Apr 2 21:31:11 CEST 2015


On Thu, Apr 2, 2015 at 12:19 PM, Saran Ahluwalia
<ahlusar.ahluwalia at gmail.com> wrote:
> Danny,
>
> You were spot on with that issue. I debugged this. Here are my two commits
> for my homework: Starting with pyinotify and OS agnostic? I am still working
> on the latter - in regards to adding more customization that fits the
> homework specifications.

As a high-level thing: when you see an error message, do not
automatically assume the error message knows the proper remediation.


Revisit the error message and your initial instincts:

#####################################################################
TypeError: coercing to Unicode: need string or buffer, list found"

> I understand this error message when I run this code. However, I am curious
> to know what the most pythonic way is to convert  the list to a string?
#####################################################################

And in retrospect, hopefully you'll see that the correct thing to do
was something other than what you thought at first.  In programming,
when things go wrong, they can go wrong for several different reasons.


There is research that suggests that beginners often misinterpret a
course of actions when reading error messages.
http://gmarceau.qc.ca/papers/Marceau-2010-Measuring-Effectiveness.pdf
So try to avoid the temptation to only do something that makes the
computer happy.  Revisit assumptions.


Good luck!


More information about the Tutor mailing list