Jump to content
  • Advertisement
Sign in to follow this  
Storyyeller

python importing woes

This topic is 2555 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to use a Python library which accepts PIL images as input. However, I kept getting strange errors.

Eventually, I discovered that the problem is that I imported PIL using import Image whereas the library imported it with import PIL
and Image and PIL.Image appear to behave differently.

Anyway, I am a beginner to Python so I haven't seen this before. What is the reason for the incompatibility? What can I do to prevent this?


>>> im = Image.open("twilight.png")
>>> im2 = PIL.Image.open("twilight.png")
>>> isinstance(im, Image.Image)
True
>>> isinstance(im, PIL.Image.Image)
False
>>> isinstance(im2, Image.Image)
False
>>> isinstance(im2, PIL.Image.Image)
True
>>>


Edit: On further insepction, it looks like the library isn't even consistent with its type checking. In some places it uses isinstance(im, PIL.Image.Image) and in other places, isinstance(im, Image.Image).
Maybe I should just try to extract the useful bits of the library and strip out all the type checking.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!