Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80926

Re:How modules work in Python

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'package,': 0.03; 'syntax': 0.04; 'importing': 0.05; 'retrieved': 0.05; 'subject:Python': 0.06; 'interpreter.': 0.07; 'here?': 0.09; 'part,': 0.09; 'pil': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:modules': 0.09; 'subject:How': 0.10; '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; 'open()': 0.16; 'pil.': 0.16; 'received:80.91.229.3': 0.16; 'received:97': 0.16; 'received:plane.gmane.org': 0.16; 'said.': 0.16; 'syntax,': 0.16; 'library': 0.18; 'module': 0.19; 'appears': 0.22; 'example': 0.22; 'import': 0.22; 'print': 0.22; 'module,': 0.24; 'versions': 0.24; 'question': 0.24; 'class.': 0.26; 'equivalent': 0.26; 'asking': 0.27; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'thus': 0.29; "doesn't": 0.30; 'especially': 0.30; "i'm": 0.30; 'that.': 0.31; 'about.': 0.31; 'img': 0.31; 'ordinary': 0.31; 'another': 0.32; 'open': 0.33; 'linux': 0.33; 'guess': 0.33; 'could': 0.34; 'but': 0.35; 'version': 0.36; 'module.': 0.36; 'ubuntu': 0.36; 'method': 0.36; "i'll": 0.36; 'should': 0.36; 'question,': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'read': 0.60; 'tell': 0.60; 'new': 0.61; "you're": 0.61; 'name': 0.63; 'such': 0.63; 'yes': 0.68; 'containing': 0.69; 'capital': 0.73; 'wanted,': 0.84; 'subject::': 0.85
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re:How modules work in Python
Date Sun, 16 Nov 2014 17:39:32 -0500 (EST)
Organization news.gmane.org
References <CAA+hu4WstWquKEJ3C4AnWqbcNb5Y55G+xmywzF1hhEei9NQi=A@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 97.73.240.77
X-Newsreader PiaoHong.Usenet.Client.VIP:1.65
X-Archive encrypt
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15918.1416177570.18130.python-list@python.org> (permalink)
Lines 61
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416177570 news.xs4all.nl 2945 [2001:888:2000:d::a6]:39968
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80926

Show key headers only | View raw


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
 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)

<type 'module'>

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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re:How modules work in Python Dave Angel <davea@davea.name> - 2014-11-16 17:39 -0500

csiph-web