0

I'm trying to simply draw a picture using stddraw with this code:

def main():
    if len(sys.argv) <= 1:
        stdio.writeln("ERROR: Too few Arguments")
    else:
        pic = sys.argv[1]

        stddraw.picture(pic)

        stddraw.show()

if __name__ == "__main__": main()

but each time I run it with input like "picture.jpg" I get this error:

AttributeError: 'str' object has no attribute 'width'

Why is it processing it as a string and what do I need to do to make it work?

Pignotto
  • 555
  • 3
  • 11

1 Answers1

2
from introcs import Picture, stddraw

def main():
    if len(sys.argv) <= 1:
        stdio.writeln("ERROR: Too few Arguments")
    else:
        pic_file = sys.argv[1]
        pic = Picture(pic_file)  # Create a Picture object

        stddraw.picture(pic)

        stddraw.show()

if __name__ == "__main__":
    main()
Pignotto
  • 555
  • 3
  • 11