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

Saran Ahluwalia ahlusar.ahluwalia at gmail.com
Thu Apr 2 21:19:55 CEST 2015


Danny,

You were spot on with that issue. I debugged this. Here are my two commits
for my homework: Starting with pyinotify
<https://github.com/ahlusar1989/WGProjects/blob/master/pyinotifyWGrun.py>
 and OS agnostic?
<https://github.com/ahlusar1989/WGProjects/commit/b8a2de25d45b1dc02b1dc189d2cfb71683fbdd9a?diff=unified#diff-0700a6bf321f99757963c11d7866aea4>
I
am still working on the latter - in regards to adding more customization
that fits the homework specifications.

Feel free to shoot me any critical feedback - when you can.

Cheers:

Saran

On Thu, Apr 2, 2015 at 1:45 PM, Danny Yoo <danny.yoo at gmail.com> wrote:

>
> On Apr 2, 2015 9:45 AM, "Saran Ahluwalia" <ahlusar.ahluwalia at gmail.com>
> wrote:
> >
> > Good Morning:
> >
> > 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? I
> > use Python 2.7.
> >
> > "Traceback (most recent call last):
> > before = dict([(f, None) for f in os.listdir(dirlist)])
> > TypeError: coercing to Unicode: need string or buffer, list found"
>
> I actually do not understand the error.  :p
>
> In particular, I do not understand the subexpression:
>
>     os.listdir(dirlist)
>
> Can you explain what you are trying to do there?  The listdir function
> only consumes single strings, so this looks like a mistake unless dirlist
> is a string.
>


More information about the Tutor mailing list