[Tutor] ASCII Conversion

Russel Winder russel at russel.org.uk
Tue Jan 31 10:06:09 CET 2012


On Tue, 2012-01-31 at 07:33 +0200, Christian Witts wrote:
> [...]o with 
> `type(y) == int`, and to get the ASCII value of a character you can use 
> `ord` like `ord('a') == 97`. And how to avoid your ValueError with a bad 
> conversion, do your type checking before hand.

isinstance ( y , int ) 

preferred?

Violates EAFP obviously but...

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at russel.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/tutor/attachments/20120131/e3256acb/attachment-0001.pgp>


More information about the Tutor mailing list