> -----Original Message-----
> From: 
> [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]
> rg] On Behalf Of Kay Schluehr
> Sent: 30 September 2006 18:02
> To: python-list@python.org
> Subject: Re: Escapeism
> 
> Sybren Stuvel wrote:
> > Kay Schluehr enlightened us with:
> > > Usually I struggle a short while with \ and either 
> succeed or give up.
> > > Today I'm in a different mood and don't give up. So here is my
> > > question:
> > >
> > > You have an unknown character string c such as '\n' , 
> '\a' , '\7' etc.
> > >
> > > How do you echo them using print?
> > >
> > > print_str( c ) prints representation '\a' to stdout for c = '\a'
> > > print_str( c ) prints representation '\n' for c = '\n'
> > > ...
> > >
> > > It is required that not a beep or a linebreak shall be printed.
> >
> > try "print repr(c)".
> 
> This yields the hexadecimal representation of the ASCII character and
> does not simply echo the keystrokes '\' and 'a' for '\a' ignoring the
> escape semantics. One way to achieve this naturally is by prefixing
> '\a' with r where r'\a' indicates a "raw" string. But unfortunately
> "rawrification" applies only to string literals and not to string
> objects ( such as c ). I consider creating a table consisting of pairs
> {'\0': r'\0','\1': r'\1',...}  i.e. a handcrafted mapping but maybe
> I've overlooked some simple function or trick that does the same for
> me.
> 
> Kay
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
>  
> 


This email is confidential and may be privileged. If you are not the intended 
recipient please notify the sender immediately and delete the email from your 
computer. 

You should not copy the email, use it for any purpose or disclose its contents 
to any other person.
Please note that any views or opinions presented in this email may be personal 
to the author and do not necessarily represent the views or opinions of Digica.
It is the responsibility of the recipient to check this email for the presence 
of viruses. Digica accepts no liability for any damage caused by any virus 
transmitted by this email.

UK: Phoenix House, Colliers Way, Nottingham, NG8 6AT UK
Reception Tel: + 44 (0) 115 977 1177
Support Centre: 0845 607 7070
Fax: + 44 (0) 115 977 7000
http://www.digica.com

SOUTH AFRICA: Building 3, Parc du Cap, Mispel Road, Bellville, 7535, South 
Africa
Tel: + 27 (0) 21 957 4900
Fax: + 27 (0) 21 948 3135
http://www.digica.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to