how to do draw pattern with python?

Chris Angelico rosuav at gmail.com
Fri Sep 21 13:31:54 EDT 2012


On Sat, Sep 22, 2012 at 2:50 AM, Ismael Farfán <sulfurfff at gmail.com> wrote:
> 2012/9/21 Peter Otten <__peter__ at web.de>:
>> echo.hping at gmail.com wrote:
>>
>>     print "\x1b[2J\x1b[0;0H" # optional
>
> Nice code : )
>
> Could you dissect that weird string for us?
>
> It isn't returning the cursor to (0,0), it's just like executing
> clear(1), and looks like those line coloring scape sequences for bash.

It's an ANSI escape sequence, or rather two of them. The first one
clears the screen, the second returns you to 0,0. (Isn't that implicit
in the 2J code? Maybe I'm misremembering.) But it depends on the
terminal responding to them, and not all terminals do. For instance,
most MUD clients parse only a very small subset of ANSI codes, eg
color codes only.

ChrisA



More information about the Python-list mailing list