From: moshez at math.huji.ac.il (Moshe Zadka)
Date: Thu, 27 May 1999 08:51:27 +0300 (IDT)
Subject: problem with variable scoping
In-Reply-To: <000301bea7fd$59bee600$a49e2299@tim>
Message-ID: <Pine.SUN.3.95-heb-2.07.990527084857.22361A-100000@sunset.ma.huji.ac.il>
X-UID: 1890                                                 

On Thu, 27 May 1999, Tim Peters wrote:

> > def process(line):
> >         ...
> >         if last_line_empty:
> >                 pass
> >         else:
> >                 print "<P>"
> >         last_line_empty = 1
> 
> C:
> 
> int last_line_empty = 0;
> 
> void process(const char* line)
> {
>   int last_line_empty;
>   if (last_line_empty)
>       ;
>   else
>       printf("<P>\n");
>   last_line_empty = 1;
> }

Ummmm.....Tim, I beg to differ: it is more like the C++

void process(const char *line)
{
  if (last_line_empty)
      ;
  else
      printf("<P>\n");
  int last_line_empty;

  last_line_empty = 1;
}

The  Python code shadows last_line_empty only *after* the "decleration"

would-be-interesting-if-python-had-set!-and-not-just-define-ly y'rs, Z.

--
Moshe Zadka <mzadka at geocities.com>. 
QOTD: My own exit is more likely to be horizontal then perpendicular.






