wish: multiline comments

Paul M paul.m at yale.edu
Wed Dec 1 12:17:39 EST 1999


Yes, but try:


Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> f = open('foo.py', 'w')
>>> f.write('"""')
>>> for i in range(100000):
...     f.write('a comment\nmore commenatry\n')
...
>>> f.write('"""')
>>> f.write('\nprint 'Finished!')

Now try it.  On NT4, with Python 1.5.2 I get....

C:\>python foo2.py
Finished!

Now try importing it:

>>> import foo2
Finished!
>>>

Tres Seaver wrote in message ...
>
>In article <009901bf3c15$6d5c5290$4500a8c0 at thomasnotebook>,
>Thomas Heller <thomas.heller at ion-tof.com> wrote:
>>> well, the compiler throws away strings that does
>>> not appear in valid docstring positions.  if you put
>>> this in a module:
>>>
>>> class B:
>>>     "this is class B"
>>>     """"
>>> okay. this is a 42 million line comment string.
>>> etc etc etc
>>> """
>>>
>>> and import it, the PYC file is smaller than you
>>> may think.
>>
>>AFAIK, python chokes on source files with more than
>>32767 lines (or was it 65536)?
>>But I never tried it.
>>
>
>[/home/tres] $ uname -a
>Linux silver 2.0.36 #1 Tue Oct 13 22:17:11 EDT 1998 i586 unknown
>[/home/tres] $ python
>Python 1.5.1 (#1, Jan 31 1999, 17:30:49)  [GCC 2.7.2.3] on linux2
>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>>> f = open( 'foo.py', 'w' )
>>>> for i in range( 100000 ):
>...    f.write( 'x = 1\n' )
>...
>>>> f.close()
>>>> ^D
>[/home/tres] $ python foo.py
>Memory fault (core dumped)
>[/home/tres] $ gdb python core
>GNU gdb 4.17.0.4 with Linux/x86 hardware watchpoint and FPU support
>Copyright 1998 Free Software Foundation, Inc.
>GDB is free software, covered by the GNU General Public License, and
you are
>welcome to change it and/or distribute copies of it under certain
conditions.
>Type "show copying" to see the conditions.
>There is absolutely no warranty for GDB.  Type "show warranty" for
details.
>This GDB was configured as "i386-redhat-linux"...
>Core was generated by `python foo.py'.
>Program terminated with signal 11, Segmentation fault.
>Reading symbols from /lib/libdl.so.2...done.
>Reading symbols from /lib/libpthread.so.0...done.
>Reading symbols from /lib/libm.so.6...done.
>Reading symbols from /lib/libc.so.6...done.
>Reading symbols from /lib/ld-linux.so.2...done.
>#0  0x805f813 in PyNode_AddChild (n1=0x4005eff8, type=265, str=0x0,
>    lineno=32768) at node.c:73
>73              n = &n1->n_child[n1->n_nchildren++];
>(gdb) where
>#0  0x805f813 in PyNode_AddChild (n1=0x4005eff8, type=265, str=0x0,
>    lineno=32768) at node.c:73
>#1  0x805fa46 in push (s=0x80b9340, type=265, d=0x808fb30,
newstate=1,
>    lineno=32768) at parser.c:178
>#2  0x805fbaf in PyParser_AddToken (ps=0x80b9340, type=1,
str=0x9d3a588 "x",
>    lineno=32768) at parser.c:263
>#3  0x804f4eb in parsetok (tok=0x80ae1d8, g=0x8090390, start=257,
>    err_ret=0xbffffc24) at parsetok.c:163
>#4  0x804f3f1 in PyParser_ParseFile (fp=0x8094908,
>    filename=0xbffffeb2 "foo.py", g=0x8090390, start=257, ps1=0x0,
ps2=0x0,
>    err_ret=0xbffffc24) at parsetok.c:113
>#5  0x805bf5c in PyParser_SimpleParseFile (fp=0x8094908,
>    filename=0xbffffeb2 "foo.py", start=257) at pythonrun.c:946
>#6  0x805bdcd in PyRun_File (fp=0x8094908, filename=0xbffffeb2
"foo.py",
>    start=257, globals=0x8095d68, locals=0x8095d68) at
pythonrun.c:855
>#7  0x805b5a6 in PyRun_SimpleFile (fp=0x8094908, filename=0xbffffeb2
"foo.py")
>    at pythonrun.c:565
>#8  0x805b235 in PyRun_AnyFile (fp=0x8094908, filename=0xbffffeb2
"foo.py")
>    at pythonrun.c:444
>#9  0x804f281 in Py_Main (argc=2, argv=0xbffffdf8) at main.c:286
>#10 0x804ed22 in main (argc=2, argv=0xbffffdf8) at python.c:10
>(gdb)
>
>It GPFs on NT4 with 1.5.2, as well.
>
>Tres.
>--
>---------------------------------------------------------------
>Tres Seaver           tseaver at palladion.com       713-523-6582
>Palladion Software    http://www.palladion.com





More information about the Python-list mailing list