A bit fun with Python

Anand B Pillai abpillai at lycos.com
Tue Mar 25 01:48:41 EST 2003


My python interpreter does not seem to
understand this riddle.

I got this output from it.

Traceback (most recent call last):
  File "<stdin>", line 4, in ?
AttributeError: 'module' object has no attribute 'fork'

Btw, the second line is also wrong because sys has
no attribute 'compile'.

The only sensible thing I could make out of this was

import re
import os

re.compile("this works")
print os.fork()

which will again work only on unix because os has fork() attribute
only on unices.

Thanks

Anand Pillai



"Steve Holden" <sholden at holdenweb.com> wrote in message news:<_QPfa.4316$jN6.2933 at news2.central.cox.net>...
> "Ulrich Petri" <ulope at gmx.de> wrote in message
> news:b5nvo6$2aio1s$1 at ID-67890.news.dfncis.de...
> > a little riddle:
> >
> > how does this script:
> > ------------------
> > re.fork("this works")
> > print sys.compile
> > ------------------
> > produce that output:
> >
> > ------------------
> > this works
> > posix
> > ------------------
> >
> > ;)
> >
> 
> The same way that
> ----------------
> print "Somebody's name"
> ----------------
> produces
> ----------------
> Steve Holden
> ----------------
> 
> just-playing-myself-ly y'rs -  steve




More information about the Python-list mailing list