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

path.__enter__ could return self #22

Closed
sametmax opened this issue Apr 30, 2013 · 4 comments
Closed

path.__enter__ could return self #22

sametmax opened this issue Apr 30, 2013 · 4 comments

Comments

@sametmax
Copy link
Collaborator

Could be nice to be able to to:

with path('stuff') as p:
@jaraco
Copy link
Owner

jaraco commented Apr 30, 2013

I'm not sure I see the value in that over:

p = path('stuff')

Can you elaborate the use case?

@sametmax
Copy link
Collaborator Author

path.__enter__ does a chdir, so I can just chdir to somewhere and get
a reference to it with a onliner:

with path('..') as p:
    print('Processing {}'.format(p.abspath()))
    subprocess.Popen('stuff here')

It's clean, it's easy to understand and write, and it won't make the
lib much fatter (it's just return self after all). For scripting and
fiddling in the shell, it's really handy.

Le mar. 30 avril 2013 17:12:22 CEST, Jason R. Coombs a écrit :

I'm not sure I see the value in that over:

|p = path('stuff')
|

Can you elaborate the use case?


Reply to this email directly or view it on GitHub
#22 (comment).

@jaraco jaraco closed this as completed in 9bcce0c May 7, 2013
@jaraco
Copy link
Owner

jaraco commented May 7, 2013

Released as 3.2

@sametmax
Copy link
Collaborator Author

sametmax commented May 7, 2013

Wow you did add that based on my monster of a comment :-) Kudos

Sorry about the format, I didn't notice.

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

No branches or pull requests

2 participants