On Wed, 07 Dec 2011 16:56:20 -0800, H.T. Wei wrote:

> Hi,
> 
> I am a newbie to Pyramid and have a question about passing variable
> between callable like this one:
> 
>   def callable_a(request):
>      id = 1
>      ...
>      return dict( ... )
> 
>   def callable_b(request):
>      # get id from callable_a
> 
> Is there a best way for getting 'id' defined in "callable_a" in
> "callable_b"? Any example or document?

Just call it:

    def callable_b(request):
        id = callable_a(request)['id']
        ...

Or pull the functionality to calculate id out into another function, and 
call that function from callable_a and from callable_b:

    def callable_a(request):
        id = determine_id(request)
        ...
        return dict(...)

    def callable_b(request):
        id = determine_id(request)
        ...
        return dict(...)

    def determine_id(request):
        id = frobnicate(request)

Dan

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to