Re: [Python-Dev] Grammar change in classdef

2006-09-17 Thread Nick Coghlan
Talin wrote:
 Nick Coghlan wrote:
 As for the reason: it makes it possible to use the same style for classes 
 without bases as is used for functions without arguments. Prior to this 
 change, there was a sharp break in the class syntax, such that if you got 
 rid 
 of the last base class you had to get rid of the parentheses as well.
 
 Is the result a new-style or classic-style class? It would be nice if 
 using the empty parens forced a new-style class...

This was considered  rejected by Guido as too subtle a distinction. So you 
still need to set __metaclass__=type (or inherit from such a class) to get a 
new-style class.

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
 http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Grammar change in classdef

2006-09-16 Thread Fabio Zadrozny
I've been porting the grammar for pydev to version 2.5 and I've seen
that you can now declare a class in the format: class B():pass
(without the testlist)

-- from the grammar: classdef: 'class' NAME ['(' [testlist] ')'] ':' suite

I think that this change should be presented at
http://docs.python.org/dev/whatsnew/whatsnew25.html

I'm saying that because I've only stumbled upon it by accident -- and
I wasn't able to find any explanation on the reason or semantics of
the change...

Thanks,

Fabio
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Grammar change in classdef

2006-09-16 Thread Lawrence Oluyede
 I think that this change should be presented at
 http://docs.python.org/dev/whatsnew/whatsnew25.html

It's already listed there: http://docs.python.org/dev/whatsnew/other-lang.html


-- 
Lawrence
http://www.oluyede.org/blog
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Grammar change in classdef

2006-09-16 Thread Nick Coghlan
Fabio Zadrozny wrote:
 I've been porting the grammar for pydev to version 2.5 and I've seen
 that you can now declare a class in the format: class B():pass
 (without the testlist)
 
 -- from the grammar: classdef: 'class' NAME ['(' [testlist] ')'] ':' suite
 
 I think that this change should be presented at
 http://docs.python.org/dev/whatsnew/whatsnew25.html
 
 I'm saying that because I've only stumbled upon it by accident -- and
 I wasn't able to find any explanation on the reason or semantics of
 the change...

Lawrence already noted that this is already covered by the What's New document 
(semantically, it's identical to omitting the parentheses entirely).

As for the reason: it makes it possible to use the same style for classes 
without bases as is used for functions without arguments. Prior to this 
change, there was a sharp break in the class syntax, such that if you got rid 
of the last base class you had to get rid of the parentheses as well.

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
 http://www.boredomandlaziness.org
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Grammar change in classdef

2006-09-16 Thread Talin
Nick Coghlan wrote:
 As for the reason: it makes it possible to use the same style for classes 
 without bases as is used for functions without arguments. Prior to this 
 change, there was a sharp break in the class syntax, such that if you got rid 
 of the last base class you had to get rid of the parentheses as well.

Is the result a new-style or classic-style class? It would be nice if 
using the empty parens forced a new-style class...

-- Talin
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Grammar change in classdef

2006-09-16 Thread Gustavo Carneiro
On 9/16/06, Talin [EMAIL PROTECTED] wrote:
 Nick Coghlan wrote:
  As for the reason: it makes it possible to use the same style for classes
  without bases as is used for functions without arguments. Prior to this
  change, there was a sharp break in the class syntax, such that if you got 
  rid
  of the last base class you had to get rid of the parentheses as well.

 Is the result a new-style or classic-style class? It would be nice if
 using the empty parens forced a new-style class...

  That was my first thought as well.  Unfortunately a quick test shows
that class Foo(): creates an old style class instead :(

-- 
Gustavo J. A. M. Carneiro
The universe is always one step beyond logic.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Grammar change in classdef

2006-09-16 Thread Fabio Zadrozny
On 9/16/06, Lawrence Oluyede [EMAIL PROTECTED] wrote:
  I think that this change should be presented at
  http://docs.python.org/dev/whatsnew/whatsnew25.html

 It's already listed there: http://docs.python.org/dev/whatsnew/other-lang.html


Thanks... also, I don't know if the empty yield statement is mentioned
too (I couldn't find it either).

Cheers,

Fabio
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Grammar change in classdef

2006-09-16 Thread Lawrence Oluyede
   That was my first thought as well.  Unfortunately a quick test shows
 that class Foo(): creates an old style class instead :(

I think that's because until it'll be safe to break things we will
stick with classic by default...

-- 
Lawrence
http://www.oluyede.org/blog
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Grammar change in classdef

2006-09-16 Thread Talin
Lawrence Oluyede wrote:
   That was my first thought as well.  Unfortunately a quick test shows
 that class Foo(): creates an old style class instead :(
 
 I think that's because until it'll be safe to break things we will
 stick with classic by default...

But in this case nothing will be broken, since the () syntax was 
formerly not allowed, so it won't appear in any existing code. So it 
would have been a good opportunity to shift over to increased usage 
new-style classes without breaking anything.

Thus, 'class Foo:' would create a classic class, but 'class Foo():' 
would create a new-style class.

However, once it's released as 2.5 that will no longer be the case, as 
people might start to use () to indicate a classic class. Oh well.

-- Talin
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Grammar change in classdef

2006-09-16 Thread Greg Ewing
Talin wrote:
 Is the result a new-style or classic-style class? It would be nice if 
 using the empty parens forced a new-style class...

No, it wouldn't, IMO. Too subtle a clue.

Best to just wait for Py3k when all classes will
be new-style.

--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Grammar change in classdef

2006-09-16 Thread Brett Cannon
On 9/16/06, Talin [EMAIL PROTECTED] wrote:
Lawrence Oluyede wrote: That was my first thought as well.Unfortunately a quick test shows that class Foo(): creates an old style class instead :( I think that's because until it'll be safe to break things we will
 stick with classic by default...But in this case nothing will be broken, since the () syntax wasformerly not allowed, so it won't appear in any existing code. So itwould have been a good opportunity to shift over to increased usage
new-style classes without breaking anything.Thus, 'class Foo:' would create a classic class, but 'class Foo():'would create a new-style class.However, once it's released as 2.5 that will no longer be the case, as
people might start to use () to indicate a classic class. Oh well.We didn't want there to suddenly be a way to make a new-style class that didn't explicitly subclass 'object'.-Brett

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com