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

20 Replies, 2022 Views

Title: Why do some scripts use *import requests as* instead of just *import requests*?

Hey folks!

I’ve been seeing a lot of scripts using *import requests as req* or something similar. Like, why not just *import requests* directly? Is there a legit reason or is it just a style thing?

I get that *import requests as req* can save a few keystrokes if you’re using it a ton, but does it actually make the code cleaner? Or is it just extra fluff?

Also, does it mess with readability? Like, if someone else reads your code, do they gotta mentally map "req" to "requests" every time?

Kinda curious if there’s a *right* way to do this or if it’s just preference.

Thanks!

Messages In This Thread
What's the correct way to use 'import requests as' in Python? or Why do some scripts use 'import requ - by - 11-11-2024, 02:10 AM



Users browsing this thread: 2 Guest(s)