Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ANN: dedent 0.5 released

37 views
Skip to first unread message

Christian Tismer

unread,
Sep 29, 2016, 10:38:26 AM9/29/16
to
Dedent 0.5
==========

What is it?
-----------

Dedent is a very simple tool for those people who like to
indent their inline code nicely.

For those who got already what it is, stop reading. :-)
All the others:

What is it, really?
-------------------

Ok, think of some inline Python code, something like

$ python -c """some code"""

For very simple scripts, there is nothing wrong with it.
But for inline code over several lines, things become ugly:

$ python -c """
"The problem is that you have to start your"
"script very much on the left, although you"
"would probably like to indent it somehow."

One very ugly solution are constructs like """if True:
"now I may indent the code"
"""

This becomes even more ugly if you have to use the __future__
statement, which always must come first!

Now, here is what dedent does for you, simply that, not less
and not more:

$ python -m dedent """
from __future__ import print_function

"now I can really indent my code, because"
"the dedent module takes care of the indent,"
"and that was my intent. :-)"
"""

Installation
------------

$ pip install dedent


That's all, folks! Have fun.


p.s.: Why is that not build in by default?

--
Christian Tismer :^) tis...@stackless.com
Software Consulting : http://www.stackless.com/
Karl-Liebknecht-Str. 121 : https://github.com/PySide
14482 Potsdam : GPG key -> 0xFB7BEE0E
phone +49 173 24 18 776 fax +49 (30) 700143-0023

Lele Gaifax

unread,
Sep 29, 2016, 4:15:24 PM9/29/16
to
Christian Tismer <tis...@stackless.com> writes:

> Dedent 0.5
> ==========
>
> What is it?
> -----------
>
> Dedent is a very simple tool for those people who like to
> indent their inline code nicely.
>
> p.s.: Why is that not build in by default?

Isn't it roughly the same as
https://docs.python.org/3.6/library/textwrap.html#textwrap.dedent ?

ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
le...@metapensiero.it | -- Fortunato Depero, 1929.

Christian Tismer

unread,
Sep 29, 2016, 5:22:03 PM9/29/16
to
On 29/09/16 22:14, Lele Gaifax wrote:
> Christian Tismer <tis...@stackless.com> writes:
>
>> Dedent 0.5
>> ==========
>>
>> What is it?
>> -----------
>>
>> Dedent is a very simple tool for those people who like to
>> indent their inline code nicely.
>>
>> p.s.: Why is that not build in by default?
>
> Isn't it roughly the same as
> https://docs.python.org/3.6/library/textwrap.html#textwrap.dedent ?

Yes, it actually uses the dedent function.
They just failed to expose it.

Cheers - Chris

Vito De Tullio

unread,
Sep 30, 2016, 1:53:45 AM9/30/16
to
Christian Tismer wrote:

> $ python -c """some code"""

totally offtopic but... since when bash support python-style triple quote??
Is it another shell??

--
By ZeD

Jussi Piitulainen

unread,
Sep 30, 2016, 1:57:45 AM9/30/16
to
Bash allows any odd number of quotes on each side.
0 new messages