String.digits help!!!

Simon Forman rogue_pedro at yahoo.com
Tue Aug 8 15:02:37 EDT 2006


Anoop wrote:
> Hi All
>
> Hope u all might have come across the string deprecation thought of in
> Python 3.0.
>
> For example : string.lower(str) needs to be some thing like
> str.lower().
>
> Can some one help me out whether such a change in the common python
> would require
> "string.digits" to be changed. If yes wat would be ur suggestions
>
> Thanks for ur inputs
>
> Anoop

Some of the functions in module string are being deprecated in favor of
new methods on the str type itself.  The digits variable of the string
module is just a string of the '0123456789' digits.  It's unlikely to
be deprecated since it doesn't make much sense to make it an attribute
of the str type.

Also, to answer another question of yours, observe:

|>> import string
|>> for ch in string.digits:
...     print ch
...
0
1
2
3
4
5
6
7
8
9


the form "for var in string:" simply assigns each character (string of
length one, technically) in the string to the var variable at each
iteration.

HTH,
~Simon

(BTW, "ur" is "your" and "u" is "you".  I'm sorry to nitpick, but it's
a personal idiosyncrasy of mine to be bothered by such.)




More information about the Python-list mailing list