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


Groups > comp.lang.python > #63606

Re: argparse action on default values

References <7353849.WXZ0zEZ0QV@horus>
Date 2014-01-10 02:24 +1100
Subject Re: argparse action on default values
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5263.1389281054.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

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


Thread

Re: argparse action on default values Chris Angelico <rosuav@gmail.com> - 2014-01-10 02:24 +1100

csiph-web