Python code with error at line 11
1 #!/usr/bin/python
2
3 import os
4 import time
5
6 prcfile="/home/sjing/prod/man/python/batch_cf/tmpfile"
7 while True:
8 fsize=int(os.path.getsize(prcfile))
9 print "file %s size is : %d" % (prcfile,fsize)
10 time.sleep(10)
11 if fsize == int(os.path.getsize(prcfile))
12 print "transaction is done. Exit\n"
13 break
-bash-3.2$ python -m py_compile test.py
File "test.py", line 11
if fsize == int(os.path.getsize(prcfile))
^
SyntaxError: invalid syntax
python -v will disply module initialization message:
-bash-3.2$ python -v -m py_compile test.py
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /appl/mtg/dev/vendor/python/lib/python2.4/site-packages/site.pyc matches /appl/mtg/dev/vendor/python/lib/python2.4/site-packages/site.py
import site # precompiled from /appl/mtg/dev/vendor/python/lib/python2.4/site-packages/site.pyc
import imp # builtin
# /usr/lib64/python2.4/os.pyc matches /usr/lib64/python2.4/os.py
import os # precompiled from /usr/lib64/python2.4/os.pyc
import posix # builtin
# /usr/lib64/python2.4/posixpath.pyc matches /usr/lib64/python2.4/posixpath.py
import posixpath # precompiled from /usr/lib64/python2.4/posixpath.pyc
# /usr/lib64/python2.4/stat.pyc matches /usr/lib64/python2.4/stat.py
import stat # precompiled from /usr/lib64/python2.4/stat.pyc
import errno # builtin
# /usr/lib64/python2.4/UserDict.pyc matches /usr/lib64/python2.4/UserDict.py
import UserDict # precompiled from /usr/lib64/python2.4/UserDict.pyc
# /usr/lib64/python2.4/copy_reg.pyc matches /usr/lib64/python2.4/copy_reg.py
import copy_reg # precompiled from /usr/lib64/python2.4/copy_reg.pyc
# /usr/lib64/python2.4/types.pyc matches /usr/lib64/python2.4/types.py
import types # precompiled from /usr/lib64/python2.4/types.pyc
# /usr/lib64/python2.4/site.pyc matches /usr/lib64/python2.4/site.py
import site # precompiled from /usr/lib64/python2.4/site.pyc
import japanese # directory /usr/lib64/python2.4/site-packages/japanese
# /usr/lib64/python2.4/site-packages/japanese/__init__.pyc matches /usr/lib64/python2.4/site-packages/japanese/__init__.py
import japanese # precompiled from /usr/lib64/python2.4/site-packages/japanese/__init__.pyc
import japanese.aliases # directory /usr/lib64/python2.4/site-packages/japanese/aliases
# /usr/lib64/python2.4/site-packages/japanese/aliases/__init__.pyc matches /usr/lib64/python2.4/site-packages/japanese/aliases/__init__.py
import japanese.aliases # precompiled from /usr/lib64/python2.4/site-packages/japanese/aliases/__init__.pyc
import encodings # directory /usr/lib64/python2.4/encodings
# /usr/lib64/python2.4/encodings/__init__.pyc matches /usr/lib64/python2.4/encodings/__init__.py
import encodings # precompiled from /usr/lib64/python2.4/encodings/__init__.pyc
# /usr/lib64/python2.4/codecs.pyc matches /usr/lib64/python2.4/codecs.py
import codecs # precompiled from /usr/lib64/python2.4/codecs.pyc
import _codecs # builtin
# /usr/lib64/python2.4/encodings/aliases.pyc matches /usr/lib64/python2.4/encodings/aliases.py
import encodings.aliases # precompiled from /usr/lib64/python2.4/encodings/aliases.pyc
# zipimport: found 10 names in /appl/mtg/dev/vendor/python/lib64/python2.4/site-packages/python_sybase-0.39-py2.4-linux-x86_64.egg
# zipimport: found 50 names in /appl/mtg/dev/vendor/python/lib64/python2.4/site-packages/simplejson-2.0.9-py2.4-linux-x86_64.egg
# zipimport: found 77 names in /appl/mtg/dev/vendor/html5lib/lib/python/html5lib-0.90-py2.4.egg
# /usr/lib64/python2.4/new.pyc matches /usr/lib64/python2.4/new.py
import new # precompiled from /usr/lib64/python2.4/new.pyc
# /usr/lib64/python2.4/warnings.pyc matches /usr/lib64/python2.4/warnings.py
import warnings # precompiled from /usr/lib64/python2.4/warnings.pyc
# /usr/lib64/python2.4/linecache.pyc matches /usr/lib64/python2.4/linecache.py
import linecache # precompiled from /usr/lib64/python2.4/linecache.pyc
# /usr/lib64/python2.4/encodings/ascii.pyc matches /usr/lib64/python2.4/encodings/ascii.py
import encodings.ascii # precompiled from /usr/lib64/python2.4/encodings/ascii.pyc
Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import marshal # builtin
# /usr/lib64/python2.4/traceback.pyc matches /usr/lib64/python2.4/traceback.py
import traceback # precompiled from /usr/lib64/python2.4/traceback.pyc
File "test.py", line 11
if fsize == int(os.path.getsize(prcfile))
^
SyntaxError: invalid syntax
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] japanese
# cleanup[1] errno
# cleanup[1] imp
# cleanup[1] _codecs
# cleanup[1] new
# cleanup[1] zipimport
# cleanup[1] warnings
# cleanup[1] site
# cleanup[1] signal
# cleanup[1] traceback
# cleanup[1] linecache
# cleanup[1] posix
# cleanup[1] marshal
# cleanup[1] japanese.aliases
# cleanup[1] encodings
# cleanup[1] encodings.ascii
# cleanup[1] codecs
# cleanup[1] types
# cleanup[1] encodings.aliases
# cleanup[1] exceptions
# cleanup[2] copy_reg
# cleanup[2] posixpath
# cleanup[2] os.path
# cleanup[2] stat
# cleanup[2] UserDict
# cleanup[2] os
# cleanup sys
# cleanup __builtin__
# cleanup ints: 810 unfreed ints in 21 out of 26 blocks
# cleanup floats
Correct the code's error and check again
1 #!/usr/bin/python
2
3 import os
4 import time
5
6 prcfile="/home/sjing/prod/man/python/batch_cf/tmpfile"
7 while True:
8 fsize=int(os.path.getsize(prcfile))
9 print "file %s size is : %d" % (prcfile,fsize)
10 time.sleep(10)
11 if fsize == int(os.path.getsize(prcfile)):
12 print "transaction is done. Exit\n"
13 break
-bash-3.2$ python -m py_compile test.py
-bash-3.2$
No error found.