Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed0.kamp.net!newsfeed.kamp.net!87.79.20.101.MISMATCH!newsreader4.netcologne.de!news.netcologne.de!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; '16,': 0.03; 'package,': 0.03; 'syntax': 0.04; 'importing': 0.05; 'retrieved': 0.05; 'subject:Python': 0.06; 'conventions': 0.07; 'interpreter.': 0.07; 'here?': 0.09; 'part,': 0.09; 'pil': 0.09; 'subject:modules': 0.09; 'subject:How': 0.10; 'cc:addr:python- list': 0.11; 'python': 0.11; 'assume': 0.14; 'wrote': 0.14; 'question.': 0.14; 'thread': 0.14; '"from': 0.16; "didn't,": 0.16; 'namespace.': 0.16; 'naming': 0.16; 'open()': 0.16; 'pil.': 0.16; 'said.': 0.16; 'syntax,': 0.16; 'wrote:': 0.18; 'library': 0.18; 'module': 0.19; 'thanks.': 0.20; 'appears': 0.22; 'example': 0.22; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; "aren't": 0.24; 'module,': 0.24; 'questions:': 0.24; 'versions': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'class.': 0.26; 'equivalent': 0.26; 'asking': 0.27; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'thus': 0.29; "doesn't": 0.30; 'especially': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'that.': 0.31; 'about.': 0.31; 'img': 0.31; 'ordinary': 0.31; 'another': 0.32; 'open': 0.33; 'linux': 0.33; 'url:python': 0.33; 'guess': 0.33; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'module.': 0.36; 'ubuntu': 0.36; 'words,': 0.36; 'url:listinfo': 0.36; 'method': 0.36; 'thanks': 0.36; "i'll": 0.36; 'url:org': 0.36; 'should': 0.36; 'skip:& 10': 0.38; 'nov': 0.38; 'question,': 0.38; 'pm,': 0.38; 'skip:& 20': 0.39; 'either': 0.39; 'url:mail': 0.40; 'read': 0.60; 'dave': 0.60; 'skip:\xc2 10': 0.60; 'tell': 0.60; 'new': 0.61; "you're": 0.61; 'name': 0.63; 'such': 0.63; 'yes': 0.68; '8bit%:31': 0.68; 'containing': 0.69; 'capital': 0.73; 'wanted,': 0.84; 'angel': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=T7CijIqnR1UkF8ccpYMtrVPbMykGrFU2AYBCvphC7R0=; b=NIYFHKt2QVRNehm33rF5u2sq1WzJJ7aM+iuJFLd+yx0PVR7rCBMl9+WO/mYHArS5wx 2c1muhSrXByq8cpKg27O4vYCphoIFolM6G52G62ktIb6FIZbgtlupPCH7v7qL0M4OcdS JIKeKJbb1/3D2VLjtPwt4TFs9xAGUj6VUxR3R+EbogXDd7nrVkj1Dgm6rEpQqLnzNRc1 l/iei/CNe165C3XDcV34VEUy54ctwxygDmLThrceGqdKDh6fduDalJo44w0oscfQ0bdW yjCYsXzWZTzs8JYCYXvbqApME50hjewfYGGZCTraWke/m57DmUJD4XKcArk0zSeHtn8O jtZA== MIME-Version: 1.0 X-Received: by 10.202.229.74 with SMTP id c71mr102774oih.69.1416184911630; Sun, 16 Nov 2014 16:41:51 -0800 (PST) In-Reply-To: References: Date: Mon, 17 Nov 2014 01:41:51 +0100 Subject: Re: How modules work in Python From: Abdul Abdul To: Dave Angel Content-Type: multipart/alternative; boundary=001a114090349818410508033eeb Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 178 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416184915 news.xs4all.nl 2859 [2001:888:2000:d::a6]:43651 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80936 --001a114090349818410508033eeb Content-Type: text/plain; charset=UTF-8 Dave, Thanks for your nice explanation. For your answer on one of my questions: * Modules don't have methods. open is an ordinary function in the module.* Isn't "method" and "function" used interchangeably? In other words, aren't they the same thing? Or, Python has some naming conventions here? Thanks. On Sun, Nov 16, 2014 at 11:39 PM, Dave Angel wrote: > Abdul Abdul Wrote in message: > > Hello, > > > > I'm new to Python, and just have a small question, and thought you might > have an idea on it. > > You should start any new thread with a specification of the > versions of software you're asking about. Since you didn't, > I'll assume python version 2.7, PIL version 1.7, and Linux Ubuntu > version 14.04. > > > > > I came across the following example that uses the Python Imaging Library > (PIL): > > > > > from PIL import Image > > img = Image.open('xyz.jpg') > > > > I know that PIL is a module. And, I think that Image is also a module, > especially we are importing it. > > PIL is a package, whuch means it's a module containing other > modules., and contains modules such as Image. But that syntax > "from PIL import Image" doesn't tell you that. Any type of name > defined in module PIL can be retrieved by the from > syntax. > > The way I can tell is either read the docs, or ask in the interpreter. > from PIL import Image > print type (Image) > > > > That from syntax is roughly equivalent to > import PIL > Image = PIL.Image > > And the leading capital I would have made me guess it was a class. > Thus I checked, using type () > > > > > I also understood the Image,open() part, as it appears we are using the > method open() from the Image module. > > Modules don't have methods. open is an ordinary function in the module. > > > > > My question is, where did PIL go here? > > I don't understand the question. By using the from syntax, you > avoided having PIL in your namespace. If you wanted, you could > have said. import PIL. And used PIL.Image.open() > > Can a module have another module inside it? > > > Yes > > > > > > > > -- > DaveA > > -- > https://mail.python.org/mailman/listinfo/python-list > --001a114090349818410508033eeb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Dave,

Thanks for your nice exp= lanation. For your answer on one of my questions:

Modules don't have methods. open is an ordinary function in the = module.

Isn't "method" and "function&qu= ot; used interchangeably? In other words, aren't they the same thing? O= r, Python has some naming conventions here?

Thanks.
<= div class=3D"gmail_extra">
On Sun, Nov 16, 20= 14 at 11:39 PM, Dave Angel <davea@davea.name> wrote:
Abdul Abdul <abdul.sw84@gmail.com> Wrote in message:
> Hello,
>
> I'm new to Python, and just have a small question, and thought you= might have an idea on it.

You should start any new thread with a specification of the
=C2=A0versions of software you're asking about.=C2=A0 Since you didn= 9;t,
=C2=A0I'll assume python version 2.7, PIL version 1.7, and Linux Ubuntu=
=C2=A0 version 14.04.

>
> I came across the following example that uses the Python Imaging Libra= ry (PIL):

>
> from PIL import Image
> img =3D Image.open('xyz.jpg')
>
> I know that PIL is a module. And, I think that Image is also a module,= especially we are importing it.

PIL is a package, whuch means it's a module containing other
=C2=A0modules.,=C2=A0 and contains modules such as Image. But that syntax =C2=A0"from PIL import Image" doesn't tell you that. Any type= of name
=C2=A0defined in module PIL can be retrieved by the from
=C2=A0syntax.

The way I can tell is either read the docs, or ask in the interpreter.
from PIL import Image
print type (Image)

<type 'module'>

That from syntax is roughly equivalent to
import PIL
Image =3D PIL.Image

And the leading capital I would have made me guess it was a class.
=C2=A0Thus I checked, using type ()

>
> I also understood the Image,open() part, as it appears we are using th= e method open() from the Image module.

Modules don't have methods. open is an ordinary function in the = module.

>
> My question is, where did PIL go here?

I don't understand the question.=C2=A0 By using the from syntax,= you
=C2=A0avoided having PIL in your namespace. If you wanted, you could
=C2=A0have said. import PIL.=C2=A0 And used PIL.Image.open()

=C2=A0Can a module have another module inside it?
>
Yes

>
>


--
DaveA

--
https://mail.python.org/mailman/listinfo/python-list

--001a114090349818410508033eeb--