-1

In python you can import multiple libraries at once and also you can import a specific function from a library like below:

import sys, os, csv
from shutil import copyfile

Is there a way to combine this?

For example, like this:

import sys, os, csv, from shutil import copyfile

Note, i'm aware that we can use shutil.copyfile, but I would like to use copyFile without shutil

Gangula
  • 3,484
  • 2
  • 19
  • 41

3 Answers3

2

If you NEED it in one line, you could use a semicolon

Such as:

import sys, os, csv; from shutil import copyfile

1

You can use ;to add multiple statements in single lines in Python

import sys, os, csv; from shutil import copyfile
Harsha Biyani
  • 6,633
  • 9
  • 33
  • 55
1

If you really want to combine the imports in one line, you can do this :

import sys, os, csv; from shutil import copyfile

Just change de "," anfter csv to ";"

However, it is not recommended to do this.

HMH1013
  • 104
  • 3