⊗pyPmMdRe 83 of 128 menu

Renaming a Module in Python

If you need to rename an imported module, you should use the keyword as to the right of its original name. And then write down the new name:

import original name as new name

When naming a module, remember that it will be used as a variable. Therefore, a module cannot have the same name as a keyword. Also, the name cannot start with a number. Also, to avoid confusion, do not name your module the same as a standard Python module, such as math, re, etc.

Let's rename the lib module to the l module:

import lib as l

Now, when calling a function, a new module name is written to the left of the dot:

l.func()

Rename the file module you created and imported in the last lesson.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline