Some basic questions

Brian Christopher Robinson a at b.c
Wed Mar 26 21:07:52 CET 2003

I just began writing Python today and have a few basic questions:

How can I read a single character from the standard input without consuming 
any more input?

Is there any way to write a boolean function?  I wanted to write a simple 
is_alpha function (which may be in the standard library but I'm leanring), 
and this is what I came up with:

def is_alpha(c) :
    letters = re.compile("[a-zA-Z]")
    return letters.match(c)

Instead of checking for true or false I check to see if None is returned, 
but that seems a little kludgy.

How can I print to standard out without printing a newline?  It seems that 
the print statement always adds a newline and I haven't found any other 
outputting functions yet.

More information about the Python-list mailing list