top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Output is not coming with defined color

0 votes
23 views

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 greenx1b[0m', 'x1b[34mThis is bluex1b[0m', 'x1b[31mThis is redx1b[0m'])
posted May 29, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes

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

answer May 29, 2013 by anonymous
Similar Questions
+3 votes

I just updated this morning my Python from a 3.3rc to 3.4 (Windows) and I noticed that the 'Green' color in tkinter GUI is not the same at all.

'Green' in 3.4 is very dark. I had to replace it with 'Lime' to get back a nice 'Green'.

+1 vote

I Tried the below code, the color is not reflected, Am i missing something?

#add description box beside test cases
    testCaseDescWindow = gtk.ScrolledWindow()
    testCaseDescWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    testCaseDescWindow.get_vscrollbar().modify_fg(gtk.STATE_NORMAL,gtk.gdk.color_parse('#40515F'))
    testCaseDescWindow.get_hscrollbar().modify_fg(gtk.STATE_NORMAL,gtk.gdk.color_parse('#40515F'))
+3 votes

I seem to have misunderstood something about the way Crypto.Cipher is supposed to work, because I'm getting unexpected results, here is my code..

import hashlib
from Crypto.Cipher import AES
from Crypto import Random

h = hashlib.new('sha256')
h.update('my key')
key = h.digest()

iv = Random.new().read(AES.block_size)
cipher = AES.new(key, AES.MODE_CFB, iv)
txt = 'hello world'

This is the part where I'm confused, because it seems like encrypt will output a different result every time, so how can I decrypt it?

msg = cipher.encrypt(txt)    
>>> '|sx08xf2x12xdex8cDxe7u*'

msg = cipher.encrypt(txt)
>>> 'xa1xed7xb8h
0 votes

I have the following script which does not return anything, no apparent mistake but my output file is empty.I am just trying to extract some decimal number from a file according to their names which are in another file. from collections import defaultdict import numpy as np

ercc_contigs= {}
for line in open ('Faq_ERCC_contigs_name.txt'):
 gene = line.strip().split()

ercc_rpkm = defaultdict(lambda: np.zeros(1, dtype=float))
output_file = open('out.txt','w')

rpkm_file = open('RSEM_Faq_Q1.genes.results.txt')
rpkm_file.readline()
for line in rpkm_file:
 line = line.strip()
 columns = line.strip().split()
 gene = columns[0].strip()
 rpkm_value = float(columns[6].strip())
 if gene in ercc_contigs:
 ercc_rpkm[gene] += rpkm_value

ercc_fh = open ('out.txt','w')
for gene, rpkm_value in ercc_rpkm.iteritems():
 ercc = '{0}t{1}n'.format(gene, rpkm_value)
 ercc_fh.write (ercc)

If someone could help me spot what's wrong it would be much appreciate cheers

+3 votes

Sometimes python shell throws error while declaring variables . Is there any single place where all the rules are defined ?


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...