On Jan 12, 2012, at 7:11 AM, David wrote:
> I think it would be a worthwhile feature to be able to get information from a
> URL helper object.
>
> For example,
>
> If we create a tuple of URL objects, and we want to loop through them, we may
> want to be able to extract things like vars and args that were set when the
> object was created.
>
> ie:
>
> urls =
> (URL('default','action',args=['arg1','arg2']),URL('default','action',args=['arg1','arg2']))
>
> now I want to do something like
>
> for url in urls:
> print url.function
>
>
> This obviuosly does not work.
It's an interesting idea, but URL just returns a string, and aside from being a
fairly big rewrite, it's likely that it would break existing code that relies
on it being a string.
You could create your own object that takes the same arguments as URL and
stores them as attributes, and whose __str__ and __repr__ functions are the
actual call to URL().