You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
makes os available in the global namespace, so you can call the function it contains as os.open(). In this case, you cannot call open() directly.
Another way is:
from os import open
open()
This now makes open available in the global namespace, hence you can call it directly.
Also, imports in Python can happen anywhere in the code, so when they do happen again, they override the previous ones.
e.g.
from os import open
.
.
# some code...
.
.
from numpy import open # just an example
The second import's open will now become the global open.
How to solve this in UrduPython?
There are some methods which I'm contemplating.
Ideas for module imports
Do nothing
Pros:
Works out-of-the-box
No extra work needed
Always compatible
Cons:
Hurts user experience (mix of English and Urdu)
Use global translations
e.g. numpy.open and os.open -> Open == کھولو in both scenarios, using a global dictionary
Pros:
One word fits all
Minimizes effort
Cons:
Compatibility issues (Example?? Idk)
Meaning may vary across libraries, e.g. open might mean open a file (کھولو) or something which is already opened (کھلا). Depends on what the function does. So meanings might become jumbled.
Use package-specific translations
e.g. numpy would have it's own list of translations, nested translations, etc
Pros:
Separate meaning for each package
Cons:
Needs runtime checking, so compilation step might not work
What if an import happens later?
The text was updated successfully, but these errors were encountered:
Preface
Python imports are interesting.
They can happen in many forms. For example:
makes
os
available in the global namespace, so you can call the function it contains asos.open()
. In this case, you cannot callopen()
directly.Another way is:
This now makes
open
available in the global namespace, hence you can call it directly.Also, imports in Python can happen anywhere in the code, so when they do happen again, they override the previous ones.
e.g.
The second import's
open
will now become the global open.How to solve this in UrduPython?
There are some methods which I'm contemplating.
Ideas for module imports
Do nothing
Pros:
Cons:
Use global translations
e.g. numpy.open and os.open -> Open == کھولو in both scenarios, using a global dictionary
Pros:
Cons:
Use package-specific translations
e.g. numpy would have it's own list of translations, nested translations, etc
Pros:
Cons:
The text was updated successfully, but these errors were encountered: