module string.py

Gerhard Häring gerhard.haering at gmx.de
Thu Jun 20 08:15:06 EDT 2002


Hi "Nop",

* NOPollution <r_proietti at yahoo.com> [2002-06-20 11:38 +0000]:
> I have two trouble:
> 
> 1)  looking at the module "string.py" I have seen that are described
> some functions like "lower", "rjust", etc. Ther problem is that it
> seems not to describe exactly how this functions are made, but there
> is only a comment about their properties. So in which file are these
> functions described?

The behaviour of these functions is described in the documentation, for
example in http://www.python.org/doc/current/lib/module-string.html:

lower(s)
Return a copy of s, but with upper case letters converted to lower case. 

In this particular case, the docstring of the function has just as much
info:

>>> string.lower.__doc__
'lower(s) -> string\n\n    Return a copy of the string s converted to
lowercase.\n\n    '

If you're looking at additional info for _how_ exactactly these
functions are implemented, then the source code is the only info there
is. Btw. in current Python versions the string module just delegetages
to the string methods, which are the preferred option. So you could just
as well use.

> 2) I tried to cancel the file "string.py". After that, the Python
> Interpreter doesn't work anymore (it can't even start working). Why?

You're not supposed to delete modules from the standard library.  If you
don't want your Python to fail in obscure ways, you'd better get that
file back into place. Btw.  my Python 2.1.3 and 2.2.1 starts up fine
even without the string module.

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))





More information about the Python-list mailing list