Welcome to weblogs.com.pk Sign in | Join | Help

Adnan Siddiqi

Lets get technical

News



  • View Adnan Siddiqi's profile on LinkedIn
Concatenation of strings and Integers in Python

Ok,finally i have decided to play with Python,i made few warmup scripts.Python is yet very neat and clean language for me and easy to learn.Like Java or C#, "+" is used for concatenation purpose,but if you try to  something like this:

"adnan" + 007

you will get something like:

 

TypeError: cannot concatenate 'str' and 'int' objects

 

weird,isn't it?

"Adnan"+"007" #ok

the easy way to do runtime type conversion is to use str() function,so now

a=005

print "adnan"+str(a)  will work perfectly fine.

Posted: Tuesday, February 14, 2006 5:23 PM by kadnan
Filed under:

Comments

khurram said:

Where do you think Python fits well?
What made you learn it?
# February 17, 2006 4:48 PM

kadnan said:

Khurram

I would reply your 2nd question first and i wouldnt give a diplomatic answer.The main reason was "Google" and if you know,python is like "darling" for googlers,each google product has used Python interface(except orkut but it also uses google authentication for sign in).

When i explored why did they choose python over scripting languages like perl or php,i found that python is easy to learn,nice and strong OOP support.

Python is used for both desktop and webbased application,it has some nice frameworks for web applications,you can make c/c++ modules for custom features,there is a python port for QT toolkit as "PyQt" and now its being supported by Nokia too,new Nokia sets now have support for python so one can maek apps in C++.java and python.Python future seems bright.
Try it ,you would like it a lot and its not C-like language so no more use of { } etc.Nice change for me =)

P.S: read this(http://wingware.com/python/evaluating),nice info
# February 18, 2006 10:18 PM

TrackBack said:

# February 23, 2006 4:22 PM
Anonymous comments are disabled