Python‎ > ‎operator‎ > ‎

operator.concat()

http://www.adilwaseem.com/

Definition
concat(a, b) -- Same as a + b, for a and b sequences.

Syntax
Operator.concat(a,b)->a+b
operator.__concat(a,b)->a+b

Parameters
string

Import module
Importing module is required in the Shell window and the Editor window.

Example
Here the method join two strings.
>>>import operator 
>>> operator.concat("Python", "Lake")
'PythonLake

operator.__concat__(a,b)
The method return the same value as Operator.concat(a,b).
 >>> operator.__concat__("Python", "Lake")
'PythonLake'
>>>

Method (a+b)
a+b return the same value as operator.concat().
Here in this example, it joins two variable and placing into the strings format as requested in double or single quotes.
 >>> a="pyhton"
>>> b="lake"
>>> a+b
'pyhtonlake'
>>> 
>>> a+"lake"
'python lake'
>>> 
>>> "Python "+"Lake"
'Python Lake'
>>>

The method concatenate the strings.
 >>> x="python"
>>> y=" Lake Learning Center "
>>> x+y
'python Lake Learning Center'
>>> 

Limitation
  • don't join number unless number are placed inside the quotes.
Comments