On Sun, 23 Dec 2007 03:10:48 -0800, MartinRinehart wrote:
> Bruno, right now I've got this:
>
> def __init__ ( self, t ):
> """ Constructor, called with array of strings. """
>
> self.text = t
> ...
>
> Some other program will say:
> tok = Toker( text_array )
> tokens = tok.tokenize
Bruno Desthuilliers wrote:
> [EMAIL PROTECTED] a �crit :
> >
> > Bruno Desthuilliers wrote:
> >
> >>... that's definitively not
> >>something I'd store in global.
> >
> >
> > So where would you put it?
>
> You don't have to "put" functions arguments anywhere - they're already
> local vars.
Brun
Dennis Lee Bieber wrote:
> Great if one is using a teletype as editor
The original Dartmouth computer room was a basement that featured 8
teletypes.
The original BASIC, Dennis, was implemented on a time-shared
"mainframe" with a gigantic 8k words (20-bit words, if I remember) of
core memory. D
[EMAIL PROTECTED] a écrit :
>
> Bruno Desthuilliers wrote:
>
>>... that's definitively not
>>something I'd store in global.
>
>
> So where would you put it?
You don't have to "put" functions arguments anywhere - they're already
local vars.
def tokenize(text):
do some work
returns or (
Steven D'Aprano wrote:
> Context is all gone, so I'm not sure that I remember what "it" is. I
> think it is the text that you're parsing.
Yes. I'm tokenizing today. Parsing comes after Christmas.
> TEXT = "placeholder"
>
> def parse():
> while True:
> token = get_next_token() # look
On Sat, 22 Dec 2007 04:13:31 -0800, MartinRinehart wrote:
> Bruno Desthuilliers wrote:
>> ... that's definitively not
>> something I'd store in global.
>
> So where would you put it?
Context is all gone, so I'm not sure that I remember what "it" is. I
think it is the text that you're parsing.
Bruno Desthuilliers wrote:
> ... that's definitively not
> something I'd store in global.
So where would you put it?
--
http://mail.python.org/mailman/listinfo/python-list
Hendrik van Rooyen wrote:
> I wonder if you have some COBOL data divisions under your belt?
Hendrik, I go way back but somehow I missed COBOL.
Martin
--
http://mail.python.org/mailman/listinfo/python-list
MartinRinehart Wrote:
> More seriously, I can and do use lots of globals. In the tokenizer I'm
> writing, for example, all the token types(COMMENT_EOL = 0,
> CONSTANT_INTEGER = 1, ...) are global constants. The text to be
> tokenized is a global variable. (Actually, the text is unchanging once
>
[EMAIL PROTECTED] a écrit :
> Hi, Bruno. Merry Christmas!
> By "constant" I meant that it did not change during the lifetime of
> the Toker.
That's still a variable to me. It's even the essence of the variable,
since it's the main input of your program. And that's definitively not
something I
Hi, Bruno. Merry Christmas!
By "constant" I meant that it did not change during the lifetime of
the Toker.
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] a écrit :
>
> Sion Arrowsmith wrote:
>> Michael Sparks <[EMAIL PROTECTED]> wrote:
>>> def bar():
>>>global x
>>>x[0] += " another"
>>>print id(x[0])
>> ... and for bonus marks, explain why the "global x" in this function
>> is not required.
>
> Because x does not ap
Sion Arrowsmith wrote:
> Michael Sparks <[EMAIL PROTECTED]> wrote:
> >def bar():
> >global x
> >x[0] += " another"
> >print id(x[0])
>
> ... and for bonus marks, explain why the "global x" in this function
> is not required.
Because x does not appear as an LHS in bar(), just about t
Michael Sparks <[EMAIL PROTECTED]> wrote:
>def bar():
>global x
>x[0] += " another"
>print id(x[0])
... and for bonus marks, explain why the "global x" in this function
is not required.
--
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
"Frankly I have no feelings towar
In article <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]> wrote:
>
>Is the following correct?
Sort-of, but I would say that it's misleadingly correct. Try this:
http://starship.python.net/crew/mwh/hacks/objectthink.html
--
Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/
"T
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| Is the following correct?
|
| x = "some string"
|
| x is a reference to "some string"
x is a name bound to a string object with value 'some string'.
Some people find is useful to call that a 'reference', as you seem to have.
Others ge
[EMAIL PROTECTED] wrote:
> ... the first element of the list to which x refers is a reference to
> the new string and back outside foo, the first element of the list to
> which x refers will be a reference to the new string.
I'd rephrase that as:
* Both the global context and the inside of foo
... the first element of the list to which x refers is a reference to
the new string and back outside foo, the first element of the list to
which x refers will be a reference to the new string.
Right?
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 21, 5:57 am, [EMAIL PROTECTED] wrote:
> Is the following correct?
>
> x = "some string"
>
> x is a reference to "some string"
>
> foo(x)
>
> Reference is passed to function.
>
> In foo:
> x += " change"
>
> Strings are immutable, so x in foo() now points to a different string
> than x ou
[EMAIL PROTECTED] writes:
> Is the following correct?
>
> [lots of references to "references"]
All good so far.
> x[0] += " other"
>
> Another string is created, the first element of x is modified to point
> to the new string and back outside foo(), x[0] will point to the new
> string.
Change
20 matches
Mail list logo