In <[EMAIL PROTECTED]>, Stef Mientki wrote:

> I want to return a "simple" variable from a function, not using the
> function result.

Why?

> The code below is from O'Reilly, "Learning Python", and there seems no
> way to return a simple var like "z" in the example below. Is that true ?

To return objects the ``return`` statement is used.

> def some_function (z, y):
>    z = 2
>    y[2] = 'global ?'

Add:
    return z

The string content seems to be a question.  No `y` is not global here but
you modify the content of the object that's bound to the local name `y`. 
Modifying an object is different from binding a name to a new object.
``y = ['uno', 'dos', 'tres']`` would not be visible outside the function.

> x = 5
> y = [1,2,3,4]
> print x,y
> some_function(x,y)

Change to:

x = some_function(x, y)

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to