Re: [pylons-discuss] Question about creating routes

2024-03-14 Thread Laurent Daverio
Thank you so much Theron, this is spot-on! So, it was lambda after all (although not Pyramid). You've solved my problem, I can move on to the next  Thanks again, Laurent. Le jeu. 14 mars 2024 à 06:57, Theron Luhn a écrit : > That’s a result of the lack of block scoping in Python. `op` is

Re: [pylons-discuss] Question about creating routes

2024-03-13 Thread Theron Luhn
That’s a result of the lack of block scoping in Python. `op` is going to resolve when the lambda first executes, which is always after the loop has finished, and scoped to the containing function so `op` will always be the final loop value. Easiest workaround is to just wrap the loop contents

Re: [pylons-discuss] Question about creating routes

2024-03-13 Thread Laurent Daverio
Thank you everybody, I'll try to set up a working example tomorrow. Actually you're right, my question was formulated incorrectly, it may not be a question of lambdas. Basically, I was trying to create a series of routes in a reasonably concise way, something like this : 2 types of objects

Re: [pylons-discuss] Question about creating routes

2024-03-13 Thread Michael Merickel
Laurent, what error do you get? I'm not immediately aware of limitations around using lambdas in Pyramid. This example below works fine with a lambda as a view: from pyramid.config import Configurator from waitress import serve config = Configurator() config.add_route('foo', '/')

Re: [pylons-discuss] Question about creating routes

2024-03-13 Thread Mike Orr
I'm not an expert in this, but I think the maybe-resolve functions only do lookups when the spec is a string, and pass non-strings through unchanged. As far as I know lambdas are regular functions, so I'd expect it to pass them through like view callable functions. Maybe another exception is

[pylons-discuss] Question about creating routes

2024-03-13 Thread Laurent Daverio
Hello list, it seems that Google is allowing me to post on here again. A couple of weeks ago, I was banned, both from emailing the list, AND from posting on the web group  I am trying to create a series of routes based on lambda functions, something like: ```