Passing by reference

M

MartinRinehart

Bruno said:
(e-mail address removed) a �crit :

You don't have to "put" functions arguments anywhere - they're already
local vars.

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 does the constructor make the array of strings available to the
tokenize() method?
 
M

Marc 'BlackJack' Rintsch

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 does the constructor make the array of strings available to the
tokenize() method?

Assuming the `__init__()` above belongs to the `Toker` class then the
`tokenize()` method can access it via `self.text` of course.

Ciao,
Marc 'BlackJack' Rintsch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top