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


Groups > comp.lang.python > #81635 > unrolled thread

Re: Where is path.py?

Started byDave Angel <davea@davea.name>
First post2014-11-27 10:34 -0500
Last post2014-11-27 10:34 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Where is path.py? Dave Angel <davea@davea.name> - 2014-11-27 10:34 -0500

#81635 — Re: Where is path.py?

FromDave Angel <davea@davea.name>
Date2014-11-27 10:34 -0500
SubjectRe: Where is path.py?
Message-ID<mailman.16369.1417102506.18130.python-list@python.org>
On 11/27/2014 09:10 AM, David Aldrich wrote:
> Hi
>
> I am running Python 2.7 on Windows 8.1. Today I installed path.py using easy_install:
>
> 	easy_install path.py
>
> The example code that I've seen imports path.py as follows:
>
> 	from path import path
>
> I am fairly new to Python and have a few questions about this:
>
> 1) Why is 'from path' required here?
>

The module called "path" evidently has a global symbol "path" in it. 
That's unfortunate and very confusing, but it's pretty common.  (See the 
time function in the time module, standard library.)  I don't know 
anything about the module, but I'll make a wild guess that path is a 
function.  It doesn't matter, but it'll let me make explicit examples.

So the obvious approach to dealing with a module is to import it.

import path

At that point, to call the above mentioned function, you would need to use:

result =  path.path(arguments)

That gets confusing, so you might want a shortcut:

pathfunc = path.path

and now you can use

result =  pathfunc(arguments)

The "from" logic facilitates that, by combining the import with the 
assignment:  The line:

from path import path
is equivalent to
import path;  path = path.path


I don't know where path.py is, and it might be called something else, 
such as path.pyc, or path.pyd, or ...  But you can probably search for 
it, if you like, with something like

     dir /s  c:\path.p*

I am assuming you're running on Windows, because you mention a Microsoft 
IDE.  If you were on Linux or Unix or Mac, you'd presumably use the find 
program.

 >
 > 2) I am using Microsoft's PTVS IDE to develop my code. It is not 
displaying code completion for path.py (it works for the standard 
libraries). How would I tell PTVS about path.py?


No clue about Microsoft's PTVS IDE;  I hadn't heard of it before.  But 
if somebody else doesn't jump in, you should be able to use the Python
   dir() and help() built-in functions.  Then only work if the path 
module is well written, of course.

-- 
DaveA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web