Beginner question

David LeBlanc whisper at oz.net
Thu May 16 03:35:19 EDT 2002


you can also do:

from math import *

cos(10)

This form of importing is NOT generally recommended though. It makes every
name in math common to your program - while it ok for a math package where
the names are pretty unambiguous, what if you had two fft packages and where
comparing them (just a lame, off the cuff example). You'd want to do
first.fft() and second.fft(), so you'd "import first" and "import second" so
that the routines with the same name stay in different namespaces.

David LeBlanc
Seattle, WA USA

> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Erik Max Francis
> Sent: Thursday, May 16, 2002 0:14
> To: python-list at python.org
> Subject: Re: Beginner question
>
>
> Mats Holmberg wrote:
>
> > ?? what to do? I need the trigonometric functions, but how do I get to
> > use
> > them?
>
> The way you get any objects inside modules.  Reference them explicitly:
>
> 	import math
> 	print math.cos(10)
>
> or import it individually:
>
> 	from math import cos
> 	print cos(10)
>
> --
>  Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
>  __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
> /  \ Who'd ever think it / Such a squalid little ending
> \__/ The American and Florence, _Chess_
>     Church / http://www.alcyone.com/pyos/church/
>  A lambda calculus explorer in Python.
> --
> http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list