1
How do I create a library without having to matter like that: from x import *
or from x import y
? Only by importing import x
.
Who will answer me, please use the script below as a library example.
def imprimir():
print('Olá!')
Note: I want to give import nome_da_biblioteca
and not have to use from nome_da_biblioteca import imprimir
or from nome_da_biblioteca import *
.
How so library?
– ThiagoO
A library in Python that I would create, only with the function
imprimir()
.– Henrique
You want to add the print function to the namespace but you don’t want to have to import it?
– ThiagoO
And why you need this?
– Maniero
I don’t want to write
from biblio import *
, want to write onlyimport biblio
– Henrique
You can as long as the file is in the same directory.
– ThiagoO
You say I can do
import biblio
only if it is in the same folder, otherwise:from biblio import imprimir
, this?– Henrique
@Henrique Exatamente.
– ThiagoO
Thanks, and why it appears that this post is unanswered?
– Henrique
I will add an answer.
– ThiagoO
Ah, all right. = D
– Henrique
Don’t forget to set the answer as correct if it has cleared your doubts.
– ThiagoO