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


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

Re: argparse action on default values

Started byChris Angelico <rosuav@gmail.com>
First post2014-01-10 02:24 +1100
Last post2014-01-10 02:24 +1100
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: argparse action on default values Chris Angelico <rosuav@gmail.com> - 2014-01-10 02:24 +1100

#63606 — Re: argparse action on default values

FromChris Angelico <rosuav@gmail.com>
Date2014-01-10 02:24 +1100
SubjectRe: argparse action on default values
Message-ID<mailman.5263.1389281054.18130.python-list@python.org>
On Thu, Jan 9, 2014 at 5:20 AM, Florian Lindner <mailinglists@xgm.de> wrote:
> def norm_path(*parts):
>     """ Returns the normalized, absolute, expanded and joined path, assembled of all parts. """
>     parts = [ str(p) for p in parts ]
>     return os.path.abspath(os.path.expanduser(os.path.join(*parts)))

Apologies for responding to something that's not the point of your
post, but I see this as a job for map, rather than a list comp:

def norm_path(*parts):
    """ Returns the normalized, absolute, expanded and joined path,
assembled of all parts. """
    path = os.path.join(*map(str,parts))
    return os.path.abspath(os.path.expanduser(path))

(or completely onelinered, since you don't seem to mind longish lines).

ChrisA

[toc] | [standalone]


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


csiph-web