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


Groups > comp.lang.python > #46369

Re: Output is not coming with defined color

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <fabiosantosart@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:not': 0.03; 'output': 0.05; 'blue': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'green,': 0.16; 'possible?': 0.16; 'red,': 0.16; 'repr': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; "skip:' 10": 0.31; 'subject:with': 0.35; 'display': 0.35; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'set.': 0.36; 'thanks': 0.36; 'hi,': 0.36; 'received:209': 0.37; 'ends': 0.38; 'how': 0.40; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'colour': 0.84; 'subject:color': 0.84; 'contents.': 0.91; '2013': 0.98
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:to :cc:content-type; bh=EQPN0CEKCdoLECTK2RCwZ3Bp8Y7OXWOgWJc7NFofnk8=; b=zSxdl7eEt6dpuMCgEW+vMI188YaARm4iGFyA1fmbWF32WDqF6oR2vNQQYMftLMIxt/ 9pJJECq/peRxWGjOtVbSadd0HBofAKthv8Wf8J3dfO3VmWkK48pETWZsYWZsk6V2cB71 2Ul07G+psO8NpJ5rPTBZ3XSXx/1DR9qG+DL6gXC5brlopWzFtE3nuxwAzGzwpxvyKHLu nZOaXVKBR8JWYRjs85+W/q0nJ45u6t9+QKsFEm1m9SV4Zsz1E7UA7QP8Us5N0Az3cUCj CSIeKsM4RgFRBDxhMqKXzxyd1P8ZcbShND6KOL9Q3ZRK2fRgi3/6G0oZEhMZEwjc/8cu iQYg==
MIME-Version 1.0
X-Received by 10.224.163.129 with SMTP id a1mr2782248qay.1.1369829477481; Wed, 29 May 2013 05:11:17 -0700 (PDT)
In-Reply-To <0965b949-8bf4-4105-aa8a-17cfd0d22aa4@googlegroups.com>
References <0965b949-8bf4-4105-aa8a-17cfd0d22aa4@googlegroups.com>
Date Wed, 29 May 2013 13:11:17 +0100
Subject Re: Output is not coming with defined color
From Fábio Santos <fabiosantosart@gmail.com>
To Avnesh Shakya <avnesh.nitk@gmail.com>
Content-Type multipart/alternative; boundary=089e01538c7e689c5f04ddda4743
Cc python-list@python.org
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2349.1369829480.3114.python-list@python.org> (permalink)
Lines 67
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369829480 news.xs4all.nl 15881 [2001:888:2000:d::a6]:35250
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:46369

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 29 May 2013 12:25, "Avnesh Shakya" <avnesh.nitk@gmail.com> wrote:
>
> hi,
>    I am trying to display my output with different colour on terminal,
but it's
> coming with that colour code.
> Please help me how is it possible?
>
> my code is -
> from fabric.colors import green, red, blue
> def colorr():
>     a = red('This is red')
>     b = green('This is green')
>     c = blue('This is blue')
>     d = {a, b, c}
>     print d
> colorr()
>
> output -
> set(['\x1b[32mThis is green\x1b[0m', '\x1b[34mThis is blue\x1b[0m',
'\x1b[31mThis is red\x1b[0m'])
>
> Thanks

You are printing the {a, b, c} set. That ends up printing the repr of all
of its contents. The repr breaks the desired output. Try to just

print a, b, c

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


Thread

Output is not coming with defined color Avnesh Shakya <avnesh.nitk@gmail.com> - 2013-05-29 04:14 -0700
  Re: Output is not coming with defined color Fábio Santos <fabiosantosart@gmail.com> - 2013-05-29 13:11 +0100
    Re: Output is not coming with defined color rusi <rustompmody@gmail.com> - 2013-05-29 07:09 -0700

csiph-web