Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101345
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: What meaning is 'from . import' |
| Date | 2016-01-08 04:00 +1100 |
| Message-ID | <mailman.51.1452186009.2305.python-list@python.org> (permalink) |
| References | <5cc5c4f2-ecc9-4ae4-b2d4-92a234012ae7@googlegroups.com> |
On Fri, Jan 8, 2016 at 3:50 AM, Robert <rxjwg98@gmail.com> wrote: > Hi, > > I see the following code. After searching around, I still don't know the > meaning of '.'. Could you tell me that ? Thanks, > > > > > > from . import _hmmc > from .utils import normalize That's called a package-relative import. https://www.python.org/dev/peps/pep-0328/ If you create a package called (let's be really creative here) "package", an external script could do this: from package import _hmmc from package.utils import normalize Within the package, you can say "from myself import stuff". It's exactly the same thing, only it doesn't repeat the package name. If you think of a package as a directory (which it often will be anyway), the dot is similar to the common notation for "current directory". ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
What meaning is 'from . import' Robert <rxjwg98@gmail.com> - 2016-01-07 08:50 -0800 Re: What meaning is 'from . import' Chris Angelico <rosuav@gmail.com> - 2016-01-08 04:00 +1100
csiph-web