Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46366 > unrolled thread
| Started by | Avnesh Shakya <avnesh.nitk@gmail.com> |
|---|---|
| First post | 2013-05-29 04:14 -0700 |
| Last post | 2013-05-29 07:09 -0700 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
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
| From | Avnesh Shakya <avnesh.nitk@gmail.com> |
|---|---|
| Date | 2013-05-29 04:14 -0700 |
| Subject | Output is not coming with defined color |
| Message-ID | <0965b949-8bf4-4105-aa8a-17cfd0d22aa4@googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | Fábio Santos <fabiosantosart@gmail.com> |
|---|---|
| Date | 2013-05-29 13:11 +0100 |
| Message-ID | <mailman.2349.1369829480.3114.python-list@python.org> |
| In reply to | #46366 |
[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
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-05-29 07:09 -0700 |
| Message-ID | <ea907a83-e2a6-4654-858d-7e96b6733bf7@be10g2000pbd.googlegroups.com> |
| In reply to | #46369 |
On May 29, 5:11 pm, Fábio Santos <fabiosantos...@gmail.com> wrote:
> On 29 May 2013 12:25, "Avnesh Shakya" <avnesh.n...@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
Or
for x in d: print x
should work
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web