On Sun, 2017-06-11 at 13:21 +0000, Ryan Frame via Digitalmars-d-learn
wrote:
> On Sunday, 4 June 2017 at 18:15:36 UTC, Russel Winder wrote:
> > On Sun, 2017-06-04 at 17:56 +0200, Jacob Carlborg via 
> > Digitalmars-d- learn wrote:
> > > On 2017-06-04 07:44, Jesse Phillips wrote:
> > > 
> > > > What is your expected behavior? Throw an exception? You can't
> > > > really
> > > > append an absolute path to another.
> > > 
> > > Of course you can. I expect buildPath("/foo", "/bar") to 
> > > result in "/foo/bar". That's how Ruby behaves.
> > 
> > And Python, Groovy, Java, Kotlin, Ceylon, C++, …
> 
> Python 3.5.1 on my machine:
> 
>      >>> os.path.join("/asdf", "/bcd")
>      '/bcd'
>      >>> os.path.join("asdf", "/bcd")
>      '/bcd'

####### #### you are absolutely right, and it is clearly stated in the
documentation that this is the expected behaviour. Clearly, I have
never tried doing that in 20 years of playing with Python. And it has
never come up in 12 years of running Python workshops!

This behaviour is reinforced by pathlib which is the modern way of
doing paths in Python, replacing os.path:

    import pathlib

    p = pathlib.Path()
    p = p.joinpath('/', 'usr', '/local', '/bin')
    print(p)

result /bin.

So given Python is one of the targets for D, consistency of behaviour
implies D is currently doing the right thing.
 
-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[email protected]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [email protected]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to