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.
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.
Bruno, right now I've got
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()
So how
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
the
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
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
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.
I
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() # looks at
[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 (yields) a
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 the first
thing I
[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 appear as an LHS in bar(),
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 towards
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 :
Hi, Bruno. Merry Christmas!
aol /
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
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 outside foo().
Right?
Back outside foo.
x = [some string]
x is a
[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 these to
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 outside foo().
Right?
... 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
[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
confused by that viewpoint. It depend on exactly what one means
by 'reference'.
| foo(x)
|
| Reference is passed to function.
The first parameter name of foo gets bound to the object referred to by
'x'.
Calling that 'passing by reference' sometimes misleads people as to how
Python behaves
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/
Typing is
I understand the parameters to Python functions are passed by
reference:
def foo(a):
a = a + 1
Will change the value of a in the calling function. How do I implement
the equivalent in C when extending Python?
I know how to write a function that can be called from Python and I
know how to use
On Thu, 29 Nov 2007 14:39:52 -0800 (PST), [EMAIL PROTECTED] wrote:
I understand the parameters to Python functions are passed by
reference:
def foo(a):
a = a + 1
Will change the value of a in the calling function. How do I implement
the equivalent in C when extending Python?
You misunderstand
On 2007-11-29, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
I understand the parameters to Python functions are passed by
reference:
def foo(a):
a = a + 1
Will change the value of a in the calling function. How do I
implement the equivalent in C when extending Python?
You've got the
[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
|I understand the parameters to Python functions are passed by reference:
Nope. Python's name-object model is so far different from the named memory
block model of Fortran/C/etc that terms invented for the latter are
misleading when
Thanks for the replies - I see that I completely misunderstood
passing by reference when discussing Python. It looks like wrapping
the object up in a list will be the path I go down as it remains
closer to the C API I am wrapping.
Thanks again!
Andy
--
http://mail.python.org/mailman/listinfo
On Sat, 2007-06-23 at 18:25 +, [EMAIL PROTECTED] wrote:
I'm writing my own python extension module with the C API. In python
all functions pass arguments by reference,
Pass by reference, while correct from a certain standpoint, is to be
taken with a large grain of salt. It is correct in so
[EMAIL PROTECTED] schrieb:
I'm writing my own python extension module with the C API. In python
all functions pass arguments by reference
Can you please show an example what you mean by that? There is no
pass-by-reference in Python: a function can not normally modify
the variable in the caller.
I'm writing my own python extension module with the C API. In python
all functions pass arguments by reference, but how can I make use of
this in C? Right now, I am using:
PyArg_ParseTuple(args, (ii)(ii), faceId1, vertId1, faceId2,
vertId2)
I want the to change the faceId's in my function. From
Thanks for that clarification Martin. When I googled it before, the
first page I read said Python passes all arguments using 'pass by
reference'. However, after seeing your reply and further searching I
see that this is not true.
I have a python function insertEdge which takes to 2-tuples of
30 matches
Mail list logo