Passing callable objects instead of strings

Reviewing documentation, I noticed a very nice suggestion and change now supported in the django web framework, written in python. Callable objects used to resolve URL requests are now supported:

from mysite import views

urlpatterns = patterns(”,
(r’^archive/$’, views.archive),
(r’^about/$’, views.about),

In addition to the older style syntax:

urlpatterns = patterns(”,
(r’^archive/$’, ‘mysite.views.archive’),
(r’^about/$’, ‘mysite.views.about’),
(r’^contact/$’, ‘’),


One response to “Passing callable objects instead of strings

  1. I hadn’t noticed…cool!

    (Oh, and BTW…I haven’t forgotten our thread on my site, just been busy. It takes some thinking to do reply! Thanks for sticking with me on that; it’s kind of weird stuff.)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s