Click here to load reader
Upload
dinesh-manajipet
View
1.043
Download
1
Embed Size (px)
DESCRIPTION
These were the slides used in my talk at conf.kde.in 2011.
Citation preview
Python.__init__(Qt)
Dinesh
Why ANOTHER Language?
● Whats there in a language?- a few keywords and a little bit of grammar
● Then why NOT C/C++ ?�- developing in Python is way faster!- lot less hassle ?- you wouldn't want to use a canon to kill a mosquito ;)
● Even then, why Python!?- Easy , Extensible, Everywhere!
So what IS Python?
● Interpreted Language :) (no more autotools, awk , cmake , qmake madness!)- But its an INTERPRETED Language!! :S
● Dynamically typed language. (no more int, char, float, etc.. ?!)
● Its Mixable. (You dont really have to build a class to print hello world)
● Indentation (and HENCE, the Beauty of your code!) Counts!
● Try using " help() " whenever needed...
Python's keywords
and del �from not �while
as elif �global or with
assert �else �if �pass yield
break except �import �print �class
�exec �in �raise �continue �finally
�is �return �def for �lambda
�try
Python's Core DatatypesObject type Example
Numbers 1234, 4, 999L , 3+ 4j , ..
Strings " Hello" , 'There' , ''' :) '''
Lists [1 , [2 , "Three"], 4]
Dictionaries {"Food" : 1 , :"Tastes" : "Good":}
Tuples (1 , "Is" , 'one' )
Files myfile = open ("door", 'r' )
Other types Sets , Types, None , Booleans
OperatorsUnary + - ~
**
* / %
+ -
>> <<
&
^
|
< <= == >= > != <> is
not
and
or
Arithmetic , Boolean , Relational and Bitwise operators are all left to right associated
On the other hand, the assignment operator is right associated
9 / 3 * 3 = 9
*when confused, simply use parenthesis :)
Hello Qt
from PySide.QtGui import *import sys
#Create a new application for me to work onmyApplication = QApplication ( sys.argv )
#A new push button with a Label!hello = QPushButton ( " Hi There " )
#Show the button!!hello.show()
#run my applicationmyApplicatioin.exec_()