Skip to content

String Object helps to do several things like normal string manipultation like addition, subration, concartination, substing, lenght and more



To use the Sting object, we have to import String form our package

from tamilString import String


let we see how addition letter with the String would be easier

from tamilString import String

word = String("அம்ம்")

print(word + 'ஆ')

here it will automatically convert the letter to suitable unicode for process it to concartinate with the string letter

Output :

அம்மா


running in the terminal

(.venv) user@user:~/tamilstring$ python3
Python 3.12.3 (main, Jun 19 2026, 12:46:00) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from tamilstring import String
>>> word = String("அம்ம்")
>>> print(word + 'ஆ')
அம்மா
>>> 
from tamilString import String

word = String("அண்")

print(word + 'ணன்')

Output :

அண்ணன்





suppose if you want to remove a consonent or vowel letter form the last string we can able to do it

from tamilString import String

word = String("அம்மா")

print(word - 'ஆ')

Output :

அம்ம்

from tamilString import String

word = String("அம்மா")

print(word - 'ம்')

Output :

அம்ஆ




By defaut the addition and subtraction will return the string in any cause if you want the returning object want to same as the String you can use the object=true

from tamilString import String

word = String("அம்",object=true)

print(type(word + "மா"))

print(word.letters)

Output :

<class 'tamilstring.helper.String'>
['அ', 'ம்', 'மா']



from tamilString import String

word = String("செந்தமிழ்")
print(word.letters)

Output :

['செ', 'ந்', 'த', 'மி', 'ழ்']

word = String("ஶ்ரீனி")
print(word.letters)

Output :

['ஶ்ரீ', 'னி']



instead getting the letters individually form the String object if you like to get the whole string without individual letter list you can get it form the string


from tamilString import String

word = String("செந்தமிழ்")
print(word.string)

Output :

செந்தமிழ்

word = String("ஶ்ரீனி")
print(word.letters)

Output :

ஶ்ரீனி



we can able to get the string form the string object

incase if we need to change the string, string will act as both getter and setter

from tamilString import String

word = String("வணக்கம்")
print(word.string)

word.string = "நன்றி"
print(word.string)

Output :

வணக்கம்
நன்றி



will we soon

has_contain




By default, each declared String acts as a unique data structure instance in memory. By adding singleton=True, you register the sequence as a global resource.

from tamilString import String

# Regular separate instances
word1 = String("தமிழ்")
word2 = String("தமிழ்")
print(id(word1) == id(word2))
false

Singleton allocation patterns

singleton1 = String("வணக்கம்", singleton=True)
singleton2 = String("நன்றி", singleton=True)
print( id(singleton1) == id(singleton2))
print( singleton1.string)
true
நன்றி

Indexing in the string

just like the python we can do indexing

from tamilString import String

word = String("வணக்கம்")
print(word[0])

print(word[-1])

Output :


ம்

To learn about Letters

suppose while indexing if you want letter as Letter objects

we can achive that by indroducing the object=True at

String creation

from tamilString import String

word = String("வணக்கம்", object=True)
print(word[0])

print(word[0].vowel)

print(word[0].consonent)
வ்
print(type(word[-1]))

Output :



வ்
<class 'tamilstring.helper.Letter'>

from tamilString import String

Scenario A: Standard Primitive Outputs

raw_text = String("தமிழ்") print("Raw index type:", type(raw_text[0]))

Scenario B: Object Wrapper Enforcements

obj_text = String("தமிழ்", obj=True) print("Wrapped index type:", type(obj_text[0]))

print(compound + word)
print(compound + constant)

# subraction

print(compound - word)
print(compound - word)
Note that tamilString concardination always returns tamilString object

count tamil string

from tamilString import TamilChar

string = TamilChar("அம்மா")

print(string.coun)