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


Groups > comp.lang.python > #63606

Re: argparse action on default values

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '"""': 0.07; 'responding': 0.07; 'skip:o 50': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'jan': 0.12; 'absolute,': 0.16; 'assembled': 0.16; 'comp:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'parts.': 0.16; 'subject:argparse': 0.16; 'subject:default': 0.16; 'subject:values': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'expanded': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'joined': 0.36; 'list': 0.37; 'skip:o 20': 0.38; 'rather': 0.38; 'skip:n 10': 0.64; 'florian': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=5lBfV2ELGglJrp61te5DbDKfYUydFSjScXqBYBhUGO8=; b=JQm3Vyx0W5uMnpjQDl37wb5KLj1h9YlYwFWFT+2cmrkTzsF8VcHBVbYsT0iMb87Xph xdIZh65hTXVzbpcB4SrZgF6A+hfNMHJKJmoZVfKNDQcQX3iA2kQmiW7e9wgQqkHp41ou QhzKCwlaQNE5aDASoPN1TX7kAMNWgx9Ugu+IaWzMqG1B7/Hx6/LJDx+xe6sSvNDOBI6b 3XiBvnyHoK7MVqgULpPjfUf09YaNDqlA2hzSEDPCC+ndrswKMr60buHM01ydU69LScQQ CrAil0v/tv1gX4sX7IXrJkxxeH6DidYWIefB/tsCDA6ZomXiLw2rn8YGlxvlTeGrFJx4 RQcw==
MIME-Version 1.0
X-Received by 10.66.102.39 with SMTP id fl7mr4268799pab.43.1389281051147; Thu, 09 Jan 2014 07:24:11 -0800 (PST)
In-Reply-To <7353849.WXZ0zEZ0QV@horus>
References <7353849.WXZ0zEZ0QV@horus>
Date Fri, 10 Jan 2014 02:24:11 +1100
Subject Re: argparse action on default values
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5263.1389281054.18130.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389281055 news.xs4all.nl 2944 [2001:888:2000:d::a6]:40737
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63606

Show key headers only | 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