What's the correct way to use 'import requests as' in Python? or Why do some scripts use 'import requ

18 Replies, 1733 Views

The only time I’d *import requests as* is if I’m nesting it in a function or class where the name might clash. Otherwise, *requests* is short enough.

If you’re curious, try disassembling both imports with *dis*—you’ll see they’re identical under the hood.

Aliasing is a tool, not a rule. Use it when it helps, ignore it when it doesn’t.

Messages In This Thread



Users browsing this thread: 1 Guest(s)