Could somebody please explain what is happening ....

Duncan Booth duncan at NOSPAMrcp.co.uk
Mon Sep 15 06:07:17 EDT 2003


"John Dean" <john at rygannon.com> wrote in
news:3f657f95$0$10968$fa0fcedb at lovejoy.zen.co.uk: 

> I have been reading quite a lot of Python source code recently and I
> have come across a particular construct which I don't understand. I
> would be grateful if somebody could explain the reason for including
> the following lines of code. I have seen it only at the beginning of a
> module:- 
> 
> global sys
> import sys
> 
> global os
> import os
> 
> ....
> ....
> 
> I know what global means and I know what import means but what is the
> reason for making an imported module global?

None whatsoever. This isn't a construct used by anyone who knows what the 
global statement does: outside a function global has precisely no effect.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?




More information about the Python-list mailing list