Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance expressiveness of Path #17

Closed
wants to merge 2 commits into from
Closed

Enhance expressiveness of Path #17

wants to merge 2 commits into from

Conversation

geovanisouza92
Copy link

Hello guys!

Thank you for this useful lib.

Inspired by Python's 3.4 new pathlib, I made this change that allow us to write:

BASE_DIR = Path(os.path.dirname(os.path.dirname(__file__)))

TEMPLATE_DIRS = (
    BASE_DIR.parent.child("templates"),
)

As

TEMPLATE_DIRS = (
    BASE_DIR / ".." / "templates",
)

@mikeorr
Copy link
Owner

mikeorr commented Jan 5, 2015

This works on Python 2 but on Python 3 it raises "TypeError: unsupported operand type(s) for /: 'PosixPath' and 'str'". I looked at the pathlib source; it uses 'truediv' and 'rtruediv' and calls some complex methods. But 'truediv' raises the same TypeError on Python 2.

I'm thinking of making a pathlib/pathlib2 extension with some Unipath features, after I fix the outstanding Unipath bugs. I think that might be a better approach than trying to get this to work in Unipath.

@mikeorr mikeorr closed this Jan 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants