top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to string module in Python?

+1 vote
47 views

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?

posted Jun 2, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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

answer Jun 2, 2015 by Kaushik
Similar Questions
0 votes

I am trying to make an HTTPS connection and read that HTTPS support is only available if the socket module was compiled with SSL support.

http://www.jython.org/docs/library/httplib.html

Can someone elaborate on this? Where can I get the socket module for HTTPS, or how do I build one if I have to?

0 votes

The type() builtin according to python docs, returns a "type object".
http://docs.python.org/2/library/types.html

And in this module is bunch of what I assume are "type objects". Is this correct?
http://docs.python.org/2/library/functions.html#type

And type(), aside from being used in as an alternative to a class statement to create a new type, really just returns the object class, doesn't it?

>>> import types
>>> a = type(1)
>>> b = (1).__class__
>>> c = int
>>> d = types.IntType
>>> a is b is c is d
True
>>> 

If type() didn't exist would it be much more of a matter than the following?:

def type(x): 
 return x.__class__

What is the purpose of type()?
What exactly is a "type object"? Is it a "class"?
What is the purpose of the types module?

I understand the purpose of isinstance and why it's recommended over something like (type(1) is int). Because isinstance will also return True if the object is an instance of a subclass.

>>> class xint(int):
 def __init__(self):
 pass

>>> x = xint()
>>> type(x) is int
False
>>> isinstance(x, int)
True
>>> 
+1 vote

Recently, I have been studying OpenCV to detect and recognize faces using C++. In order to execute source code demonstration from the OpenCV website I need to run Python to crop image first. Unfortunately, the message error is ImportError: No module named Image when I run the Python script ( this script is provided by OpenCV website). I installed python-2.7.amd64 and downloaded PIL-1.1.7.win32-py2.7 to install Image library. However, the message error is Python version 2.7 required, which was not found in the registry. And then, I downloaded the script written by Joakim Löw for Secret Labs AB / PythonWare to register registry in my computer. But the message error is "Unable to register. You probably have the another Python installation".

Please help

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...