mod_php).1 <?php
2 items = array('spam', 'eggs', 'beans');
3 foreach ($items as $item) {
4 echo $item . "\n";
5 }
6 ?>
1 items = ['spam', 'eggs', 'beans']
2 for item in items:
3 print item
CamelCaselowercase_with_underscoressomething_Else_Weird($MY_VAR);PEP8: Style Guide for Python Code
http://www.python.org/dev/peps/pep-0008/
No arguments.
...what namespaces?
Everything is global. The only way to namespace code is to use a class.
Namespaces are optional. No namespace declaration? No namespace.
Namespaces are one honking great idea -- let's do more of those!
A file containing Python code (a module) gets its own namespace.
firstfile.py
1 some_variable = "Hello Brighton"
secondfile.py
1 from firstfile import some_variable
2 print some_variable
1 my_string = 'hello'
2 print my_string
3 print my_string.upper()
4 print 'hello'.upper()
1 def say_hello(name):
2 print 'hello ' + name
3
4 def say_goodbye(name):
5 print 'goodbye ' + name
6
7 greetings = [hello, goodbye]
8 for greeting in greetings:
9 print greeting('brighton')
... but let's not go there.