Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91770 > unrolled thread

What use of string module?

Started byfl <rxjwg98@gmail.com>
First post2015-06-01 19:14 -0700
Last post2015-06-02 11:39 -0500
Articles 5 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  What use of string module? fl <rxjwg98@gmail.com> - 2015-06-01 19:14 -0700
    Re: What use of string module? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-02 04:37 +0100
    Re: What use of string module? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-02 17:21 +1000
    Re: What use of string module? Laura Creighton <lac@openend.se> - 2015-06-02 11:39 +0200
    Re: What use of string module? Tim Chase <python.list@tim.thechases.com> - 2015-06-02 11:39 -0500

#91770 — What use of string module?

Fromfl <rxjwg98@gmail.com>
Date2015-06-01 19:14 -0700
SubjectWhat use of string module?
Message-ID<d3bf3182-d70e-4160-b600-733cbda748e6@googlegroups.com>
Hi,

I read the online help about string. It lists string constants, string 
formatting, template strings and string functions. After reading these,
I am still puzzled about how to use the string module. 

Could you show me a few example about this module?

Thanks

[toc] | [next] | [standalone]


#91778

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-06-02 04:37 +0100
Message-ID<mailman.36.1433216310.13271.python-list@python.org>
In reply to#91770
On 02/06/2015 03:14, fl wrote:
> Hi,
>
> I read the online help about string. It lists string constants, string
> formatting, template strings and string functions. After reading these,
> I am still puzzled about how to use the string module.
>
> Could you show me a few example about this module?
>
> Thanks
>

I suggest you don't bother, it's effectively dead having been replaced 
by string methods.  See here 
https://docs.python.org/2/library/string.html#deprecated-string-functions and 
then compare to https://docs.python.org/3/library/string.html#module-string

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#91806

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2015-06-02 17:21 +1000
Message-ID<556d5986$0$11122$c3e8da3@news.astraweb.com>
In reply to#91770
On Tuesday 02 June 2015 12:14, fl wrote:

> Hi,
> 
> I read the online help about string. It lists string constants, string
> formatting, template strings and string functions. After reading these,
> I am still puzzled about how to use the string module.
> 
> Could you show me a few example about this module?


import string

c = "d"
if c in string.ascii_lowercase:
    print "character is an ASCII lower case letter"



-- 
Steve

[toc] | [prev] | [next] | [standalone]


#91814

FromLaura Creighton <lac@openend.se>
Date2015-06-02 11:39 +0200
Message-ID<mailman.49.1433237983.13271.python-list@python.org>
In reply to#91770
In a message of Mon, 01 Jun 2015 19:14:18 -0700, fl writes:
>Hi,
>
>I read the online help about string. It lists string constants, string 
>formatting, template strings and string functions. After reading these,
>I am still puzzled about how to use the string module. 
>
>Could you show me a few example about this module?
>
>Thanks

A long time ago, strings didn't have the methods they had now.
So the string module was created, so that people could all have
a common way to do some really common things that people like
to do with strings.  Now the strings have object methods to
do the same thing, so you don't really want to use it.

It's there for backwards compatibility.  You don't want all the
code that exists out there and uses it to all stop working one
day because we now have a better way to do it. :)

Laura

[toc] | [prev] | [next] | [standalone]


#91861

FromTim Chase <python.list@tim.thechases.com>
Date2015-06-02 11:39 -0500
Message-ID<mailman.72.1433263540.13271.python-list@python.org>
In reply to#91770
On 2015-06-02 04:37, Mark Lawrence wrote:
> > I read the online help about string. It lists string constants,
> > string formatting, template strings and string functions. After
> > reading these, I am still puzzled about how to use the string
> > module.
> 
> I suggest you don't bother, it's effectively dead having been
> replaced by string methods.

While most of the functions in the string module are obsoleted by the
methods on strings, I still find the constants useful to save myself
from my own inability to type, possibly omitting letters from the
alphabet or doubling them up.  I'd much rather just reference
string.printable than try to recreate it (or its kin) myself.

-tkc


[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web