user11487075
user11487075

Reputation:

Question on importing library's into python3

I'm learning Python and the imports that have accumulated whilst developing my app seem like I'm repeating imports. Please can someone advise me on development practices.

from pathlib import Path
from urllib.request import urlopen
from gi.repository import Gtk, Gio
from gi.repository import GLib as glib
from gtk_assistant import AssistantApp

import urllib.request
import urllib.error
import xml.etree.ElementTree as ET
import json
import gi
import sys
import os
import hashlib

Upvotes: 0

Views: 51

Answers (1)

Kurtis Streutker
Kurtis Streutker

Reputation: 1317

You can group imports like this if you want:

from urllib import request, error
from xml.etree import ElementTree as ET
import json, gi, sys, os, hashlib

However, the pep8 style guide says you should have them on seperate lines so the way you did it is fine

Upvotes: 1

Related Questions