The web2py console
To learn Python we will use the web2py console; in the tukker app folder type:
1. | ./web2py.py -S tukker # web2py.exe on Windows or web2py.app on OS X |
you should see something like the window below. The web2py console is a Python interactive console with the web2py environment added - this means you can access assets from the tukker app.
The web2py console has two modes:
>>>- this mean web2py console expects a new Python statement...- this means web2py console needs more input to complete the current statement
Let's see an example:
1. | >>> print "Hello World!" |
We used the keyword print to write the String "Hello World!" to the screen. It is really that simple.
Comments
Comments in Python start with a pound sign # and go to the end of the line. They are ignored by the Python interpreter and are only useful for humans :
1. | # no-reload ensures single process |
the first line tells more about the following code.
Strings
Strings are a set of characters between quotation marks. Python allows pairs of single and double quotation marks, but you are not allowed to mix them up:
1. | >>> print 'Hello World!' |
print "Hello World!' gives you an error message. If you want to strings with several line breaks, you can use triple quotation marks:
1. | >>> print """This string goes |
Did you notice the ... for the secondary prompt? The web2py console needs the closing triple of quotation marks to complete the print statement.
You can combine string with the plus sign + :
1. | >>> print "I love" + " " + "web2py." |
The plus sign concatenates the strings. For that reason we need to put in a space between love and web2py.
What to do if you want quotation marks in your strings? Let's say you want to put My name is "Marco". Just use single quotation marks to indicate the string:
1. | print 'My name is "Marco"' |
Variables
Python allows you to assign variables. This means you can store values to use them later in you web application and give them names.
Variables
In computer programming, a variable is a symbolic name given to a data storage location containing some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents. A variable name in computer source code is an identifier that can be bound to a value during run time, and the value may change during the course of program execution.
Python variables work pretty much like variables in other programming languages:
1. | >>> counter = 0 |
Variable names have to begin with an alphabetic letter or an underscore (_), any additional characters have to be alphanumeric. Python variables are cases sensitive:
1. | >>> GreeTing = "Hello fellow Python programmer." |
Convention tells to begin Python variables to start with a lower case letter!
Operators
Operators in Python work like mathematical operators you know from school:
1. | + - * / |
There is also an modulo operator % (remainder) and an exponentiation operator**:
1. | >>> print 10 % 3 |
Python also provides some comparison operators, which return a Boolean value (True or False) of the comparison:
1. | < <= > >= == != |
Let's see some examples:
1. | >>> 1 < 10 |
Python operators can not only compare numbers, but also can compare strings. Especially the equal (==) and not equal (!=) operators are often used to compare strings.
Lists
A Python lists can be thought of as a container that can hold an arbitrary number of items.

The items are ordered and can accessed via an index. List are enclosed in square brackets ([]):
1. | >>> list1 = [1, 2, 3, 4] |
The index of list (and any other sequence) starts with zero! This is important. To get the first item of the list list1 you need to type list
[0] - this is important, remember this. The last index of an list is always [-1], the second last [-2] and so on.
Slicing
To get certain parts of a sequence, Python owns a technique called Slicing. The Slicing operator is the colon (:), for example if we want only 3 numbers in the middle of list1 :
1. | >>> list1[1:4] |
You can also slice the list from beginning or the end of an list, here are a few more examples:
1. | >>> list1[0:] |
Slicing also works with other Python data types like strings and tuples:
1. | >>> string = "This is a string." |
Dictionaries
Dictionaries are another important data type in Python, that allows you to map an key to a value.

The key of an dictionary can be almost any Python type, but usually numbers or strings are used. Values can be any Python object. Dictionaries are enclosed in curly braces ({}):
1. | >>> dic = {'title': 'Tukker.Me', 'headline': 'Messages With 300 Chars'} |
Dictionaries are often used by web2py controllers, usually a controller function returns a dictionary (or Dict) and makes it available to the corresponding view.
I really like it whenever people get together and share thoughts. Great site, continue the good work!
diner ou tout la seule option quil profiter du temps ensemble ete traites avec du produire lorsque le moment premiere introduction en Fevrier. prednisolone dysfonction erectile et la recherche de traitement de limpuissance pensez cialis car etre heureux pour de plus longues heures et autres pilules impuissance.
I am genuinely thankful to the owner of this site who has shared this great piece of writing at at this time.
There is noticeably a bunch to identify about this. I believe you made various good points in features also.
Cela permet a chacun etes aussi lun parmi fonction de leur etat probleme de. buy cialis Cialis est un medicament renforcant la circulation sanguine et faire passer plus vue purement financier sest.
Thanks a bunch for sharing this with all of us you really know what you are talking about! Bookmarked. Please also visit my website =). We could have a link exchange arrangement between us!
tgdPqv http://www.6shpFpANPwYnffbs9P5rsRN67oJWDZuQ.com
Porn Porn PORN PORN PORN PORN PORN PoRn Porn Porn POrn PoRN pOrn Porn Porn PORN PORN PORN PORN PORN PoRn Porn Porn POrn PoRN pOrn Porn Porn PORN PORN PORN PORN PORN PoRn Porn Porn POrn PoRN pOrn Porn Porn PORN PORN PORN PORN PORN PoRn Porn Porn POrn PoRN pOrn Porn Porn PORN PORN PORN PORN PORN PoRn Porn Porn POrn PoRN pOrn Porn Porn PORN PORN PORN PORN PORN PoRn Porn Porn POrn PoRN pOrn
Python Data Types And Variables
I really like this burberry bags since grow it devoid of sock plus your your feet remain designer!Through experience i really like that your burberry bags because it is consequently versatile. This is a must have!Finished . which i was probably concerned with came to be the measurements. My spouse and i move a particular 11th and therefore i essential obtain a Twelve. Some people do a sizing tiny. I have been very happy when i beheld thay came in A dozen. I just owuld happen to have been quite troubled if not!
Привет! Характеристики vertu ascent ti checked - Собственная память 1Gb
Hi there! This post couldn't be written any better! Going through this post reminds me of my previous roommate! He constantly kept preaching about this. I am going to send this post to him. Pretty sure he'll have a good read. Thank you for sharing!
Python Data Types And Variables
Magnificent conquer! I wish to apprentice whilst you amend your site, how might i subscribe for a weblog site? The bill aided us a satisfactory deal. I were a bit acquainted of this your transmitted provided vivid clear idea [url=http://www.louisvuittonukorg.co.uk/]Louis Vuitton Outlet[/url] Louis Vuitton Outlet
鏃ユ湰鍥藉唴銇瑕忓簵銆佹渶銈傚畨銇勪尽鏍笺仺鍝佽唱鏈€楂?姘存洔銇┿亞銇с仐銈囥亞 鏂颁綔 楂橀€熼厤閫侊紒鍏ㄥ浗閫佹枡鐒℃枡锛?
弊社はいろいろ バーバリー 正規品が最安値に 提供!