20161209
Using Perl for a net 3 days since I started writing Python
Except for the here-document alternative, '''
exists only for pydoc
, and all other comments should be written in #
[^ 1].
[^ 1]: The source of pydoc
itself is written that way ... At the very least, I wish I could specify = begin, = end, = cut
of perl
...
--Confirmed in 2.6, 2.7, 3.4 ――In a tactical sense, we do not consider whether function nesting or class in if block is possible.
foo.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
about NAME
DESCRIPTION
'''
__author__ = 'bunzaemon'
__version__ = '1.0'
__date__ = '2016/12/09'
x = 42
print (x)
'IGNORED comment'
def foo ():
# of course ignored
'DEF: foo'
'IGNORED comment'
def bar ():
'DEF: bar <= IGNORED'
class Clas:
'CLASS: Clas'
def __init__ (self):
'CLASS DEF: __init__'
if 1:
'IGNORED comment'
y = 42
print (y)
def buz ():
'DEF: buz'
def bux ():
'IGNORED comment'
class Clas2:
'CLASS: Clas2'
if 0:
z = 42
print (z)
class Clas3:
'IGNORED comment'
--ʻU'...'` is useless => 2.6 series is moss. [^ 2] --It seems confusing to write a comment by relying on the IGNORED comment. [^ 3]
[^ 2]: 2.6 series If you don't have to think about it, you should add it. [^ 3]: My future self
$ python --version
Python 2.6.6
$ python ./foo.py
42
42
$ pydoc ./foo.py
Help on module foo:
NAME
foo - about NAME
FILE
/PATH/TO/foo.py
DESCRIPTION
DESCRIPTION
CLASSES
Clas
Clas2
class Clas
| CLASS: Clas
|
| Methods defined here:
|
| __init__(self)
| CLASS DEF: __init__
class Clas2
| CLASS: Clas2
FUNCTIONS
buz()
DEF: buz
foo()
DEF: foo
DATA
__author__ = 'bunzaemon'
__date__ = '2016/12/09'
__version__ = '1.0'
x = 42
y = 42
VERSION
1.0
DATE
2016/12/09
AUTHOR
bunzaemon
Recommended Posts