Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

How to solve imports? #6

Open
SaadBazaz opened this issue Mar 24, 2022 · 0 comments
Open

How to solve imports? #6

SaadBazaz opened this issue Mar 24, 2022 · 0 comments
Labels
discussion enhancement New feature or request

Comments

@SaadBazaz
Copy link
Owner

Preface

Python imports are interesting.

They can happen in many forms. For example:

import os
os.open()

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?
@SaadBazaz SaadBazaz added enhancement New feature or request discussion labels Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant