I wrote little wrapper for urllib (python3). Is it proper and safe to import module in if?

if self.response_encoding == 'gzip':
    import gzip

I didn't find any PEP about this code. However, it bothers me.

Edit
Report