472,989 Members | 3,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 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 1595
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.