Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101969
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: importing: what does "from" do? |
| Date | Thu, 21 Jan 2016 07:52:17 -0700 |
| Lines | 51 |
| Message-ID | <mailman.151.1453387942.15297.python-list@python.org> (permalink) |
| References | <n7qpel$a3j$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de iqoyUShCmlL9jMbSBsQioA7fVFGQvdyzQ0Q9KXaqcovQ== |
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'importerror:': 0.05; '21,': 0.07; '(module)': 0.09; 'before.': 0.09; 'defined.': 0.09; 'func': 0.09; 'globals': 0.09; 'imported': 0.09; 'nameerror:': 0.09; 'jan': 0.11; '"from"': 0.16; '"module"': 0.16; '2016': 0.16; 'bind': 0.16; 'module?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'smith"': 0.16; 'sys.modules': 0.16; 'wrote:': 0.16; 'circular': 0.18; "shouldn't": 0.18; '>': 0.18; 'email addr:gmail.com>': 0.18; 'am,': 0.23; 'defined': 0.23; 'bit': 0.23; 'this:': 0.23; "haven't": 0.24; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; "doesn't": 0.26; 'equivalent': 0.27; 'right.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'idea': 0.28; 'subject:what': 0.29; 'symbols': 0.29; 'that.': 0.30; 'programmers': 0.30; "i'd": 0.31; 'probably': 0.31; 'problem': 0.33; 'except': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'loaded': 0.36; 'modules': 0.36; 'subject:" ': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'skip:& 10': 0.37; 'thought': 0.37; 'received:209': 0.38; 'mean': 0.38; 'why': 0.39; 'does': 0.39; 'subject:from': 0.39; "didn't": 0.39; 'enough': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'skip:u 10': 0.61; 'caused': 0.61; 'real': 0.62; 'information': 0.63; 'p.s.': 0.65; 'dict.': 0.84; 'to:name:python': 0.84; '***': 0.95 |
| 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 :content-type; bh=N2Ha643UTtBnhhDo6I7U6soBLuAr2VoDQdEZUt8YCoY=; b=cOUE64o7K5dN+31icY61Gnzp+Lt/fosZ+EOnB1W7BU+6hNmXzi+PCHbN2tZedQplkK 4SYt5IMVZ6WUth5DTPxCdcFFcLUc8dPPJecO9x58Tk2xTR+caTPyrf9O3dOVscsUo+1X eFw2ZFzAT4JZPM9AXE/AWcTd/QI4cyAIEQvw6wjEhqOW7AZ/QbsQFjygB6xFPgyep9ir jmMrrWQ2o/4iP5knLqJtIJzsb3bYcgTzazsQmLRAJyj499wqlcZj+GaBJjzJDCddWe7/ 40e4ctFIdvhiSjtNZgtk3sB/JJR1r5mufoHVtRWI6tA+PbQyCLpeI18TM+/IAyPZTldH gqhg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=N2Ha643UTtBnhhDo6I7U6soBLuAr2VoDQdEZUt8YCoY=; b=lTbj3F87wI7zu8/PWgBRUieE8m4fNQV9B071AxYgf7l097la+biMXZl2HPAnu0Frl6 /EcQzWh+X4JvVlLD1UzzLBmR9fSN7vlCgcdGoFgue/OCW6t9zWyIIOs1ZG1+Het2pcBe 0TMIQtf17X5fkzZPVbhRGkdXvmWcG9fuLGD4EYqt2Jsc/dsO4Rp//usvRMEADs5UC6I+ CQUu0D147E29FNjY0TxtzD+GsN/SjQRMyqUh/12mmmq+wTvTJmgEpnnVoFDaqjJnl9rH 12fsDZjOI+0dnyq6YxNUDdFWAyNVMzs91Oe4e+2i9RvidNYi+nzbrAf2WJuD5qc4H3uu gZqg== |
| X-Gm-Message-State | ALoCoQnDbpIrIGr6MrnRTPTusQIVpHw7N4MTmV7ezpAHGFkUg7oooMqw4jmePTUQQOcS3LQdLVUvI6nU48gWppwqxSWC4bV+aQ== |
| X-Received | by 10.107.185.6 with SMTP id j6mr38462398iof.111.1453387938044; Thu, 21 Jan 2016 06:52:18 -0800 (PST) |
| In-Reply-To | <n7qpel$a3j$1@dont-email.me> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.20+ |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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> |
| Xref | csiph.com comp.lang.python:101969 |
Show key headers only | View raw
On Jan 21, 2016 7:31 AM, "Charles T. Smith" <cts.private.yahoo@gmail.com> wrote: > > What does "from (module) import (func)" do? Approximately equivalent to: import module func = module.func Except that it doesn't bind "module" to anything. > Please don't tell me that I shouldn't ask because real programmers > know not to have circular dependencies ... > > I have no idea what was imported before. I just want to import hexdump(). > Unfortunately, this does not work: > > from utilities import hexdump > > ImportError: cannot import name hexdump What is utilities? Is it a module on your sys.path? > Now, I shouldn't have a problem because the programmers before me didn't > understand either, and so just duplicated it everywhere, but I'd really > like to do it right. > > I would have thought that "from" would allow me to import just one > symbol. Now, for all the people just chomping at the bit to tell > me about circular dependencies What makes you think this is caused by circular dependencies? It could be, but you really haven't given us enough information about what utilities is to diagnose that. > would you explain to me why I get this: > > (PDB)hexdump(msg) > *** NameError: name 'hexdump' is not defined Probably because the name 'hexdump' is not defined. > P.S. can I get a list of all the loaded symbols and/or modules? What do you mean by "loaded"? Bound to a name in the main module? In the globals of the current scope? In any module? Try the "dir" or "vars" built-in. You can get a view of all the *cached* modules by looking in the sys.modules dict.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
importing: what does "from" do? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-21 14:20 +0000
Re: importing: what does "from" do? Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-21 07:52 -0700
Re: importing: what does "from" do? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-21 15:12 +0000
Re: importing: what does "from" do? Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-21 08:59 -0700
Re: importing: what does "from" do? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-21 16:30 +0000
Re: importing: what does "from" do? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-21 16:41 +0000
Re: importing: what does "from" do? Steven D'Aprano <steve@pearwood.info> - 2016-01-22 03:22 +1100
Re: importing: what does "from" do? John Gordon <gordon@panix.com> - 2016-01-21 15:31 +0000
Re: importing: what does "from" do? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-21 15:37 +0000
Re: importing: what does "from" do? John Gordon <gordon@panix.com> - 2016-01-21 15:44 +0000
Re: importing: what does "from" do? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-21 15:46 +0000
Re: importing: what does "from" do? John Gordon <gordon@panix.com> - 2016-01-21 15:59 +0000
Re: importing: what does "from" do? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-21 15:53 +0000
Re: importing: what does "from" do? Steven D'Aprano <steve@pearwood.info> - 2016-01-22 03:28 +1100
Re: importing: what does "from" do? Rustom Mody <rustompmody@gmail.com> - 2016-01-21 23:03 -0800
Refactoring in a large code base (was: importing: what does "from" do?) Ben Finney <ben+python@benfinney.id.au> - 2016-01-22 18:54 +1100
Re: Refactoring in a large code base Marko Rauhamaa <marko@pacujo.net> - 2016-01-22 10:29 +0200
Re: Refactoring in a large code base Rustom Mody <rustompmody@gmail.com> - 2016-01-22 01:21 -0800
Re: Refactoring in a large code base Marko Rauhamaa <marko@pacujo.net> - 2016-01-22 12:19 +0200
Re: Refactoring in a large code base Chris Angelico <rosuav@gmail.com> - 2016-01-22 22:19 +1100
Re: Refactoring in a large code base Marko Rauhamaa <marko@pacujo.net> - 2016-01-22 13:54 +0200
Re: Refactoring in a large code base Chris Angelico <rosuav@gmail.com> - 2016-01-22 23:28 +1100
Re: Refactoring in a large code base Marko Rauhamaa <marko@pacujo.net> - 2016-01-22 15:00 +0200
Re: Refactoring in a large code base Chris Angelico <rosuav@gmail.com> - 2016-01-23 00:26 +1100
Re: Refactoring in a large code base Marko Rauhamaa <marko@pacujo.net> - 2016-01-22 15:48 +0200
Re: Refactoring in a large code base Chris Angelico <rosuav@gmail.com> - 2016-01-23 01:09 +1100
Re: Refactoring in a large code base Rustom Mody <rustompmody@gmail.com> - 2016-01-22 04:04 -0800
Re: Refactoring in a large code base Marko Rauhamaa <marko@pacujo.net> - 2016-01-22 14:21 +0200
Re: Refactoring in a large code base Thomas Mellman <tmellman@web.de> - 2016-01-22 12:27 +0000
Re: Refactoring in a large code base Chris Angelico <rosuav@gmail.com> - 2016-01-22 23:34 +1100
Re: Refactoring in a large code base Rustom Mody <rustompmody@gmail.com> - 2016-01-22 05:30 -0800
Re: Refactoring in a large code base Marko Rauhamaa <marko@pacujo.net> - 2016-01-22 15:43 +0200
Re: Refactoring in a large code base Rustom Mody <rustompmody@gmail.com> - 2016-01-22 05:58 -0800
Re: Refactoring in a large code base Chris Angelico <rosuav@gmail.com> - 2016-01-23 01:08 +1100
Re: Refactoring in a large code base "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-22 11:45 +0000
csiph-web