473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Question about import

I'm a complete newbie to using Python. I have a small question about
importing modules.

Is there any difference between the two following statements, and what
(if any) are they?
from Module import *

and
import Module

Thanks.

kjm
Jul 18 '05 #1
1 1615
On 5 Aug 2003 09:28:54 -0700, kj******@yorku.ca (Kevin MacKenzie)
wrote:
I'm a complete newbie to using Python. I have a small question about
importing modules.

Is there any difference between the two following statements, and what
(if any) are they?
from Module import *

and
import Module
Yes. As I said to someone else hereabouts not all /that/ long ago
(!), import Module is the computing equivalent to getting your toolkit out of the
cupboard and putting it on your workbench.
from Module import * is the computing equivalent of getting your toolkit out of the
cupboard, tipping the contents onto the workbench, and putting the box
back into the cupboard.

If "Module" contains "foo()", import Module means that you can call Module.foo()
from Module import * means that you can use foo(). But if your code or any other module
contains something called "foo()" then you get a name clash. That can
be nasty, because you can get everything working fine, and somebody
using a library that's supposed to be compatable with the one you've
tested finds it doesn't work.

For all but the very simplest of code, use import Module


Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: djw | last post by:
I'm sturcturing my (relatively) large application into packages and am having trouble understanding one aspect of module/package paths. If I have a structure like: in /: appA.py __init__.py...
6
by: Jon | last post by:
Hi, The following four lines of code: import sys, os, re sentence = raw_input("Enter a sentence: ") capwords (sentence) print sentence gives me the following error: NameError: name...
16
by: dario | last post by:
Hi, Im new on phyton programming. On my GPRS modem with embedded Phyton 1.5.2+ version, I have to receive a string from serial port and after send this one enclosed in an e-mail. All OK if the...
1
by: Dan | last post by:
Could someone please help me with auto importing a series of data files into an Access table. I tried to follow code given below in a previous messagebut i'm getting error messages. Here's my...
1
by: deko | last post by:
Is there an Import Wizard for MSDE? In Access, when you select File >> Get External Data >> Import, you get a Wizard that lets you browse for a file to import by file type (txt, Excel, etc.). ...
3
by: David Hirschfield | last post by:
An xmlrpc client/server app I'm writing used to be super-simple, but now threading has gotten into the mix. On the server side, threads are used to process requests from a queue as they come in....
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
5
by: Steven W. Orr | last post by:
I'm trying again, since no response indicates that I'm not providing enough info. I have module M1 which has the following line in it: StartTime = safe_dict_get ( dic, 'starttime',...
5
by: sstidham | last post by:
I cannot understand for the life of me why this isn't working, but maybe someone can help me out. It should be a simple Sum. I have a table that is imported data from Excel. I need to total up...
17
by: Suresh Pillai | last post by:
I am performing simulations on networks (graphs). I have a question on speed of execution (assuming very ample memory for now). I simplify the details of my simulation below, as the question I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.