Re: Dumb newbie back in shell

2007-12-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (top-post corrected, once again... duh.) > Bruno Desthuilliers wrote: >>[EMAIL PROTECTED] a écrit : >> >>Martin, would you _please_ learn to quote properly ? top-posting and >>keeping the whole text of the previous posts are two really annoying >>practices. TIA >>(snip

Re: Dumb newbie back in shell

2007-12-11 Thread MartinRinehart
re top posting Thanks for explaining. google groups hides the quoted text, so I didn't see it. Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a �crit : > > Martin, would you _please_ learn to quote properly ? top-posting and > keeping the whole text of the previous posts are two really annoying

Re: Dumb newbie back in shell

2007-12-11 Thread Bruno Desthuilliers
Chris Mellon a écrit : > On Dec 11, 2007 8:51 AM, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: >> Chris Mellon a écrit : >> (snip) >>> What's probably happening is that line_ptr < last_line is not true >> Indeed. >> >>> and the body of the function isn't executed at all. The unbound local >>>

Re: Dumb newbie back in shell

2007-12-11 Thread Chris Mellon
On Dec 11, 2007 8:51 AM, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Chris Mellon a écrit : > (snip) > > What's probably happening is that line_ptr < last_line is not true > > Indeed. > > > and the body of the function isn't executed at all. The unbound local > > exception is a runtime error

Re: Dumb newbie back in shell

2007-12-11 Thread Bruno Desthuilliers
Chris Mellon a écrit : (snip) > What's probably happening is that line_ptr < last_line is not true Indeed. > and the body of the function isn't executed at all. The unbound local > exception is a runtime error that occurs when the local is accessed, > not when the function is compiled. Now sin

Re: Dumb newbie back in shell

2007-12-11 Thread J. Clifford Dyer
On Tue, Dec 11, 2007 at 08:36:54AM -0600, Chris Mellon wrote regarding Re: Dumb newbie back in shell: > Delivered-To: [EMAIL PROTECTED] > Date: Tue, 11 Dec 2007 08:36:54 -0600 > From: "Chris Mellon" <[EMAIL PROTECTED]> > To: "python-list@python.org" > Su

Re: Dumb newbie back in shell

2007-12-11 Thread Bruno Desthuilliers
J. Clifford Dyer a écrit : > The code you just posted doesn't compile successfully. > > However, in your code, you probably have char_ptr defined at the > module level, and you're confused because you didn't declare it as > global. Am I right? My crystal ball has a smudge on it, but I think > I

Re: Dumb newbie back in shell

2007-12-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Martin, would you _please_ learn to quote properly ? top-posting and keeping the whole text of the previous posts are two really annoying practices. TIA > I'm less confused. If someone can explain the wisdom of this design, > I'd be grateful. Since there's no disti

Re: Dumb newbie back in shell

2007-12-11 Thread Chris Mellon
On Dec 11, 2007 8:23 AM, J. Clifford Dyer <[EMAIL PROTECTED]> wrote: > The code you just posted doesn't compile successfully. > It *compiles* fine, but it'll raise an error when run. > However, in your code, you probably have char_ptr defined at the module > level, and you're confused because yo

Re: Dumb newbie back in shell

2007-12-11 Thread J. Clifford Dyer
able, but the second time through, it references a local variable, because it has now been defined. Cheers, Cliff On Tue, Dec 11, 2007 at 05:18:00AM -0800, [EMAIL PROTECTED] wrote regarding Re: Dumb newbie back in shell: > > I'm less confused. If someone can explain the wisdom of thi

Re: Dumb newbie back in shell

2007-12-11 Thread MartinRinehart
I'm less confused. If someone can explain the wisdom of this design, I'd be grateful. If someone can explain why the following compiles successfully, I'd be even more grateful: def get_toks( text ): global line_ptr, last_line while line_ptr < last_line: while char_ptr < len(text[l

Re: Dumb newbie back in shell

2007-12-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (Martin, please, don't top post - fixed) > > Peter Otten wrote: >> MartinRinehart wrote: >> >>> However, here's the little tester I wrote: >>> >>> # t.py - testing >>> >>> global g >>> g = 'global var, here' >>> >>> def f(): >>> print g >>> >>> f() >>> >>> It prints

Re: Dumb newbie back in shell

2007-12-10 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Not trying to write C, I meant "trying to use Python like it was C" - but I guess it doesn't matter that much !-) > I'm trying to write Decaf, a language I've > designed (see www.MartinRinehart.com for more) but which doesn't > exist. Got to code the first bit in s

Re: Dumb newbie back in shell

2007-12-10 Thread MartinRinehart
Peter, question is, why did the first one work? In my real code I've got module-level vars and an error msg trying to use them in a function. In my test example I've got them accessed from within a function w/o error message. I am confused. Martin Peter Otten wrote: > MartinRinehart wrote: > >

Re: Dumb newbie back in shell

2007-12-10 Thread MartinRinehart
Not trying to write C, I'm trying to write Decaf, a language I've designed (see www.MartinRinehart.com for more) but which doesn't exist. Got to code the first bit in something. Later I can write Decaf in Decaf. Chose Python as it looked like a faster write (learning curve included) than C or C++.

Re: Dumb newbie back in shell

2007-12-10 Thread Peter Otten
MartinRinehart wrote: > However, here's the little tester I wrote: > > # t.py - testing > > global g > g = 'global var, here' > > def f(): > print g > > f() > > It prints 'global var, here,' not an error message. Wassup? Try it again with a modified f(): def f(): print g g = 42

Re: Dumb newbie back in shell

2007-12-10 Thread MartinRinehart
Thanks, Marc. However, here's the little tester I wrote: # t.py - testing global g g = 'global var, here' def f(): print g f() It prints 'global var, here,' not an error message. Wassup? Marc 'BlackJack' Rintsch wrote: > On Mon, 10 Dec 2007 08:31:01 -0800, MartinRinehart wrote: > > > But

Re: Dumb newbie back in shell

2007-12-10 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > OK, it's a scripting language. For which definition of "scripting language" ?-) def g(): > ...os.remove('tokeneizer.pyc') > ...reload( tokeneizer ) > ...tokeneizer.tokenize('sample_decaf.d') > ... > > But that gets me to: > > ... line 110, in get_t

Re: Dumb newbie back in shell

2007-12-10 Thread Marc 'BlackJack' Rintsch
On Mon, 10 Dec 2007 08:31:01 -0800, MartinRinehart wrote: > But that gets me to: > > ... line 110, in get_toks > UnboundLocalError: local variable 'line_ptr' referenced before > assignment > > Here's a bit of the code, with line #s > > ... > 68 global line_ptr > 69 global char_ptr > ... > 75 li