Danny Lessio
Danny Lessio

Reputation: 627

Multiple aliases on one-line Python import

Can I import module in Python giving it two or more aliases in one line?

With two lines this works:

from time import process_time as tic
from time import process_time as toc

This doesn't work, but I would want to be able to write something like:

from time import process_time as tic,toc

Upvotes: 18

Views: 8975

Answers (2)

Ithilion
Ithilion

Reputation: 140

You could do

from time import process_time as tic

toc = tic

Upvotes: 7

Francesco
Francesco

Reputation: 4250

You can do that with

from time import process_time as tic, process_time as toc

Upvotes: 33

Related Questions