-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
  • 5,193
  • 4
  • 30
  • 59

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
  • 7,049
  • 9
  • 37
  • 61
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
  • 1,216
  • 2
  • 13