[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] String interpolations

From: Jeff Forcier
Subject: Re: [Fab-user] String interpolations
Date: Wed, 13 May 2009 09:39:17 -0400

2009/5/13 Niklas Lindström <address@hidden>:

> But I *really* dislike the arcane syntax, especially the trailing "s".
> And at least my fabric scripts uses interpolation quite often, which
> makes it very noisy IMHO.

I totally agree about how current Python string interpolation is a
little on the verbose side and could be easier to use (and that the
newer format string stuff in 2.6+ looks pretty nice); but I don't
think it's *bad enough* to merit adding a decent amount of extra
complexity to Fabric. That was basically my thinking when I decided
not to reimplement it in the 0.9 rewrite, and I still maintain it's
the way to go.

> Another option might be e.g. adding a `fmt` method on env (placing it
> in env to avoid the _getframe "hack"), and use `string.Template` in
> that (available since Python 2.4). It could be used like:
>    run(env.fmt("cd $some_dir && cmd $a_dir"))

I might be OK with this approach, however: adding a convenience
function to do this special interpolation, which users may opt into
using, and which is not sitting around cluttering up the rest of the
code, would be more palatable than something with its fingers in the
majority of all string-handling functions.

Still think there needs to be a stronger argument for this existing --
i.e. for a new user reading the docs, and coming across this, what
will the docs say to justify the existence of such a function outside
of "someone didn't really like the default string interpolation

But, if this were to be implemented in some fashion I would definitely
at least consider putting it in, especially if other users would find
it useful.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]