[Edu-sig] Re: Least used builtins?

Kirby Urner urnerk@qwest.net
Mon, 07 Jul 2003 01:30:15 -0700


At 06:10 AM 7/6/2003 -0500, you wrote:
>I wrote -
> >> Kirby writes -
> > >The strikes me as unimaginative, plodding.
> >
> > pitooey.,
>
>To elaborate. I agree that going down the list of built-ins as a teaching
>technique is unnecessary.  My point is much different than that.  As always,
>I am more than willing to have my point rejected - but prefer it happen
>*after* it is understood.

OK, so what IS your much different point?  'pitooey' fails to communicate
much.

>I go on when I feel that it is only a trivialized version of my point that
>is being put on the dung heap.

I was mainly responding to the passage attributed to Lulu (as follows):

 > Yet a fourth matter is that I think it would be slightly easier to teach
 > Python to beginners if __builtins__ did not include a number of
 > functions that were extremely difficult to explain to novices... and
 > that are really only of use to fairly expert Pythoneers.  I find that
 > callable, classmethod, id, intern, and a number of others fall in this
 > category.  My thinking is that anything meant for experts should need to
 > get imported by specific request.

I was countering the above, saying:

(a) the content of __builtins__ is not about what's easy or introductory,
it's about what's necessary to have the nucleus of a complete language,
along with keywords and other syntax

and

(b) there's no need to feel obligated to plod through all the builtins
when teaching Python to beginners

I was not responding to your sense of 'betrayal' re the absence of
'copy' as one of the builtins.  I responded to that a long time ago and
have nothing new to add.

>Deja-vu, again.
>
>Art

Appended is a list of built-ins that are callable as functions, not including
error and warning objects.  You need not import first, to use any of the
below.  And then we also have the keywords in keyword.kwlist.  A lot of
these *are* important to know about early, but surely not all of them.

Quiz question:  what makes something a "keyword" versus a "builtin"
other than that some appear on one list, some on the other?

I notice that builtins aren't protected from being used as variable
names (not a good idea to do this, but possible), whereas true keywords
generate a syntax error if you try to rebind them.  Also, builtins may
be used alone and return their type as built-in functions or objects.
Keywords used alone generate more syntax errors.  Keywords are too
primitive to use alone.  They only make sense as syntax elements in more
complicated expressions and statements.

But beyond the keywords, we have other syntax, such as the operators
and stuff like [] () {}.

Built-in functions (callable):

__import__
abs
apply
basestring
bool
buffer
callable
chr
classmethod
cmp
coerce
compile
complex
copyright
credits
delattr
dict
dir
divmod
enumerate
eval
execfile
file
filter
float
getattr
globals
hasattr
hash
help
hex
id
input
int
intern
isinstance
issubclass
iter
len
license
list
locals
long
map
max
min
object
oct
open
ord
pow
property
range
raw_input
reduce
reload
repr
round
setattr
slice
staticmethod
str
sum
super
tuple
type
unichr
unicode
vars
xrange
zip