Python Forum
How to shorten the size of program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to shorten the size of program
#6
Import just what you need for the program.
For example:

In [1]: import urllib

In [2]: page = urllib.request.urlopen('http://python-forum.io')

In [3]: html = page.read()
Here I import the whole urllib module. But I am using only urlopen method. I do not need all the rest.
So it becomes:

In [1]: from urllib.request import urlopen

In [2]: page = urlopen('http://python-forum.io')

In [3]: html = page.read()
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
How to shorten the size of program - by garikhgh0 - Feb-20-2018, 05:48 AM
RE: How to shorten the size of program - by Larz60+ - Feb-20-2018, 05:53 AM
RE: How to shorten the size of program - by Larz60+ - Feb-20-2018, 06:21 AM
RE: How to shorten the size of program - by wavic - Feb-20-2018, 07:09 AM
RE: How to shorten the size of program - by buran - Feb-20-2018, 07:20 AM
RE: How to shorten the size of program - by wavic - Feb-20-2018, 07:24 AM
RE: How to shorten the size of program - by abhin - Feb-21-2018, 03:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python multiple try except block in my code -- can we shorten code mg24 10 6,433 Nov-10-2022, 12:48 PM
Last Post: DeaD_EyE
  Want to shorten the python code shantanu97 3 1,334 Apr-25-2022, 01:12 PM
Last Post: snippsat
  size of set vs size of dict zweb 0 2,181 Oct-11-2019, 01:32 AM
Last Post: zweb
  CSV file created is huge in size. How to reduce the size? pramoddsrb 0 10,537 Apr-26-2018, 12:38 AM
Last Post: pramoddsrb
  how to add smilar size python interpreter to my program. harun2525 7 5,804 Feb-25-2017, 09:14 PM
Last Post: snippsat
  How do I shorten my input options? - text adventure ShiningKnight 3 4,725 Jan-01-2017, 03:21 AM
Last Post: ichabod801
  Shorten this List Comprehension ATXpython 7 7,106 Oct-10-2016, 07:50 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020