[problem]-python3 can't run official website demo

18 views
Skip to first unread message

呂曜吉

unread,
Dec 18, 2018, 7:56:05 PM12/18/18
to PyPNG Users
[problem]-python3 can't run official website demo
--------------------------------------------------------------------
and 
i try the example : "a little message" at python3 in command line on mac os
there is a error about TypeError: 'map' object is not subscriptable
so i guess  there is some wrong on this example



在此輸入代碼...
import png
s = ['110010010011',
     
'101011010100',
     
'110010110101',
     
'100010010011']
s = map(lambda x: map(int, x), s)

f = open('png.png', 'wb')
w = png.Writer(len(s[0]), len(s), greyscale=True, bitdepth=1)
w.write(f, s)
f.close()

David Jones

unread,
Dec 19, 2018, 3:49:11 AM12/19/18
to pypng...@googlegroups.com
On Wed, 19 Dec 2018 at 00:56, 呂曜吉 <ab123...@gmail.com> wrote:
>
> [problem]-python3 can't run official website demo
> --------------------------------------------------------------------
> i go to the site https://pythonhosted.org/pypng/ex.html#reading
> and
> i try the example : "a little message" at python3 in command line on mac os
> there is a error about TypeError: 'map' object is not subscriptable
> so i guess there is some wrong on this example

You are correct. The code was written years ago in Python 2 time.

Change the problematic line that contains map to

s = [[int(c) for c in row] for row in s]

I'll raise an issue and fix it.

David Jones

呂曜吉

unread,
Dec 20, 2018, 7:01:09 AM12/20/18
to pypng...@googlegroups.com
thanks

by the way, i am finding some project to code
and, i think your project is fun.
so, how can i join the project?
> --
> You received this message because you are subscribed to the Google Groups "PyPNG Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pypng-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

David Jones

unread,
Dec 20, 2018, 8:33:16 AM12/20/18
to pypng...@googlegroups.com
On Thu, 20 Dec 2018 at 12:01, 呂曜吉 <ab123...@gmail.com> wrote:
>
> thanks
>
> by the way, i am finding some project to code
> and, i think your project is fun.
> so, how can i join the project?

Well, you found the pypng-users mailing list, that's a good start.

You can carry on by using PyPNG, reporting problems, and writing about
what you like or didn't like, what you found helpful and what you
found confusing.

Would be interesting to know some more about what you're doing with PyPNG.

Cheers,
drj
Reply all
Reply to author
Forward
0 new messages