- Naming
- Allowed characters in a name: a-z A-Z 0-9 underscore, and must begin with a letter or underscore.
- Names and identifiers are case sensitive.
- Identifiers can be of unlimited length.Special names, customizing, etc. -- Usually begin and end in double underscores.
- Special name classes -- Single and double underscores.
- Leading double underscores -- Name mangling for method names.
- Leading single underscore -- Suggests a "private" method name in a class. Not imported by "from module import *".
- Trailing single underscore -- Sometimes used to avoid a conflict with a keyword, for example, class_.
- Naming conventions -- Not rigid, but here is one set of recommendations:
- Modules and packages -- all lower case.
- Globals and constants -- Upper case.
- Class names -- Bumpy caps with initial upper.
- Method and function names -- All lower case with words separated by underscores.
- Local variables -- Lower case (possibly with underscore between words) or bumpy caps with initial lower or your choice.
- No declaration or data type definition is needed/used.
- Block
- Python represents block structure and nested block structure with indentation, not with begin and end brackets
- The statements which go together must have the same indentation. Each such set of statements is called a block.
- The empty block -- Use the pass no-op statement.
- DocStrings : A doc string is a quoted string at the beginning of a module, function, class, or method.We can use triple-quoting to create doc strings that span multiple lines.
- Doc strings can be viewed with several tools, e.g. help(),obj.__doc__, and, in IPython, a question mark (?) after a name will produce help.
- Statement
- while running:
guess = int(raw_input('Enter an integer : '))
if guess == number:
print 'Congratulations, you guessed it.'
running = False # this causes the while loop to stop
elif guess < number:
print 'No, it is a little higher than that.'
continue
else:
print 'No, it is a little lower than that.'
break
else:
print 'The while loop is over.'
# Do anything else you want to do here
print 'Done' - for i in range(1, 5):
print i
else:
print 'The for loop is over'
2012年4月30日 星期一
Python - a study note
Reference : http://www.rexx.com/~dkuhlman/python_book_01.html
Python Development with Eclipse
- extract Eclipse : eclipse-java-indigo-win32_32bit.zip
- Install PyDev plugin for Eclipse
- Help/Install New Software
- Add Repository : PyDev - http://pydev.org/updates
- select [PyDev] => [Next]/[Next]/Accept license/[Finish] => select trust certificate/[OK]
- Restart Eclipse
- Configuration PyDev
- Window/Preferences
- Select PyDev/Interpreter - Python => press [Auto Config] (ps. precondition : python installed) => [OK]
- Install UML modeling for phthon Feature (Using TextUML Toolkit + Acceleo)
- Install TextUML Toolkit
- Help/Install New Software
- Add Repository : TextUML Toolkit - http://abstratt.com/update/
- select All => [Next]/[Next]/Accept license/[Finish]
- Install Acceleo code generator – http://acceleo.org/update/
- Help/Install New Software
- Add Repository : Acceleo code generator – http://acceleo.org/update/
- select Acceleo => [Next]/[Next]/Accept license/[Finish]
- Install Acceleo code generation modules
- Help/Install New Software
- Add Repository : Acceleo code generation modules - http://acceleo.org/modules/update
- select Acceleo Modules Experimental/Ecore to Python code generator => [Next]/[Next]/Accept license/[Finish]
- Use PyDev to develop python
- Window/Open Perspective/Other => select PyDev/[OK]
- File/New/PyDev Project
- Project name : scm_build, Grammer version : 2.6 => [Finish]
- Create Python UML
- New/Other => Acceleo/Module Luncher [Next] Encore to Python => [Next]
- Encore Model : /scm_build/module/scm_build.ecore
Output folder : /scm_build/out
Error Log file : /scm_build/error.log
[Solved]Can't connect BoxNet Dav network drive in Windows XP
1. Start up WebClient service in Windows Service
2. connect net drive by file://www.box.net/dav
2. connect net drive by file://www.box.net/dav
訂閱:
意見 (Atom)