Why not use @classmethod decorator consitently in django/utils/functional.py?

144 views
Skip to first unread message

Adam Smith

unread,
Nov 19, 2013, 9:33:01 PM11/19/13
to django-d...@googlegroups.com
Hi, I'm quite new to Python and Django, as I read through the django/utils/functional.py, I was wondering why not use `classmethod` as a class method decorator consistently, as line 334? Any specific reasons?

Like I said, I'm quite new to Python and this community, I'm not sure whether this is the right place to ask this kind of question.

Thanks.

Shai Berger

unread,
Nov 19, 2013, 10:05:02 PM11/19/13
to django-d...@googlegroups.com
Hi Adam,

(reordering quoted parts a little)

On Tuesday 19 November 2013 18:33:01 Adam Smith wrote:
> Hi, I'm quite new to Python and Django

Welcome aboard!

> Like I said, I'm quite new to Python and this community, I'm not sure
> whether this is the right place to ask this kind of question.
>

This list is intended for discussing the development of Django, so questions
about its implementation are exactly on topic.

> as I read through the django/utils/functional.py, I was wondering why not
> use `classmethod` as a class method decorator consistently, as line
> 334? Any specific reasons?
>

I assume you're referring to the places like line 122 (which you linked to)
and line 140, where instead of

@classmethod
def x(cls,...):
...

you see

def x(cls,...):
...
x = classmethod(x)

The reason for this is historic: Decorators were only introduced into Python
at version 2.4, and Django<1.2 still supported Python 2.3. Some code hasn't
changed since then. Now that you pointed it out, these specific lines are
likely to change soon :)

Thanks,
Shai.

Adam Smith

unread,
Nov 19, 2013, 10:21:51 PM11/19/13
to django-d...@googlegroups.com
I see. Thanks a lot Shai, for both your welcome and detailed explanation!

 

Adam Smith

unread,
Nov 20, 2013, 4:39:46 AM11/20/13
to django-d...@googlegroups.com
Hi Shai,

Just FYI, on github @charettes merge my PR replacing almost all `meth = classmethod(meth)` with `@classmethod`.
So I assume you guys are going to drop support for python2.4 and older, right?

Best Regards
Adam 
 
 

Baptiste Mispelon

unread,
Nov 20, 2013, 4:48:45 AM11/20/13
to django-d...@googlegroups.com
Hi Adam,

Django 1.6 only supports Python 2.6 and older [1] and Django 1.7 will support Python 2.7 onwards [2].

[1] https://docs.djangoproject.com/en/1.6/releases/1.6/#python-compatibility
[2] https://docs.djangoproject.com/en/dev/releases/1.7/#python-compatibility

Cheers,
Baptiste
--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/1fc2612a-d127-45f6-982c-81354e7d75cd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Adam Smith

unread,
Nov 20, 2013, 5:34:32 AM11/20/13
to django-d...@googlegroups.com
You are right, I should have checked out those release notes.

Thanks Baptiste!
Reply all
Reply to author
Forward
0 new messages