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


Groups > comp.lang.python > #83155

Re: pathlib type error

References <CAHRCC4=TE7Ep7GPVAw-3pFnzSzopHjkJPLgK-NbmmFkSMqg-eQ@mail.gmail.com>
Date 2015-01-03 23:06 +1100
Subject Re: pathlib type error
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.17348.1420286783.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sat, Jan 3, 2015 at 10:55 PM, Georg Grafendorfer
<georg.grafendorfer@gmail.com> wrote:
> I'm using Debian 8 Jessie on an AMD64 machine.
> Getting this error:
>
> ~$ python3
> Python 3.4.2 (default, Oct  8 2014, 10:45:20)
> [GCC 4.9.1] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from pathlib import Path
>>>> p = Path("/etc")
>>>> q = p / "init.d"
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: unsupported operand type(s) for /: 'PosixPath' and 'str'
>>>>

Unable to reproduce:

rosuav@dewey:~$ python3
Python 3.4.2 (default, Oct  8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> p = Path("/etc")
>>> q = p / "init.d"
>>> q
PosixPath('/etc/init.d')
>>> pathlib.__file__
'/usr/lib/python3.4/pathlib.py'

Is it possible you have another pathlib installed? It's available on
PyPI, maybe you got it with pip - check 'pip freeze|grep pathlib' on
the off-chance. Is your pathlib.__file__ the same as mine?

ChrisA

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


Thread

Re: pathlib type error Chris Angelico <rosuav@gmail.com> - 2015-01-03 23:06 +1100

csiph-web