Re: [Python-Dev] sys.implementation

2012-05-12 Thread Nick Coghlan
On Sat, May 12, 2012 at 12:40 PM, Eric Snow  wrote:
> If anyone has strong feelings for item-access over attribute-access,
> please elaborate.  I'm just not seeing it as that important and would
> rather finish up the PEP as simply as possible.

I object to adding a new type to the stdlib just for this PEP. Since
iterating over the keys is significantly more useful than iterating
over the values, that suggests a dictionary as the most appropriate
type.

If someone *really* wants a quick way to get dotted access to the
contents of dictionary:

>>> data = dict(a=1, b=2, c=3)
>>> ns = type('', (), data)
>>> ns.a
1
>>> ns.b
2
>>> ns.c
3

Cheers,
Nick.

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


Re: [Python-Dev] sys.implementation

2012-05-12 Thread Barry Warsaw
On May 12, 2012, at 10:04 PM, Nick Coghlan wrote:

>On Sat, May 12, 2012 at 12:40 PM, Eric Snow 
>wrote: > If anyone has strong feelings for item-access over attribute-access,
>> please elaborate.  I'm just not seeing it as that important and would >
>rather finish up the PEP as simply as possible.
>
>I object to adding a new type to the stdlib just for this PEP. Since
>iterating over the keys is significantly more useful than iterating over the
>values, that suggests a dictionary as the most appropriate type.

I'm okay with dropping immutability for sys.implementation, but I still think
attribute access is a more useful model.  You can easily support both getattr
and getitem with a class instance, so I think that's the way to go.

(FWIW, immutability would also be easy to support with an instance.)

-Barry


signature.asc
Description: PGP signature
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] sys.implementation

2012-05-12 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 05/12/2012 08:04 AM, Nick Coghlan wrote:
> On Sat, May 12, 2012 at 12:40 PM, Eric Snow
>  wrote:
>> If anyone has strong feelings for item-access over
>> attribute-access, please elaborate.  I'm just not seeing it as that
>> important and would rather finish up the PEP as simply as possible.
> 
> I object to adding a new type to the stdlib just for this PEP. Since 
> iterating over the keys is significantly more useful than iterating 
> over the values, that suggests a dictionary as the most appropriate 
> type.

Why would anyone want to iterate over either of them?


Tres.
- -- 
===
Tres Seaver  +1 540-429-0999  [email protected]
Palladion Software   "Excellence by Design"http://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+ulP8ACgkQ+gerLs4ltQ4OzACgwnmVgJzE+IdEdS0Ij1J357di
bnoAni5nUCIDcZt7dwEOfLLPUZoJQYF9
=t05/
-END PGP SIGNATURE-

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


Re: [Python-Dev] sys.implementation

2012-05-12 Thread Eric Snow
On Sat, May 12, 2012 at 6:04 AM, Nick Coghlan  wrote:
> On Sat, May 12, 2012 at 12:40 PM, Eric Snow  
> wrote:
>> If anyone has strong feelings for item-access over attribute-access,
>> please elaborate.  I'm just not seeing it as that important and would
>> rather finish up the PEP as simply as possible.
>
> I object to adding a new type to the stdlib just for this PEP.

And I agree with you.  :)  The only constraint is that it be an object
with attribute access.  That could be a named tuple, a module, an
uninstantiated class, or whatever.  A new type is not needed.  If it's
iterable or not is irrelevant with regards to the PEP.  For the
implementation I'd like it to have a good repr too, but even that's
not part of the proposal.

I've got the latest version of the PEP up now.  It pares down the type
discussion and eliminates "metadata".  I figure it's good enough for
what we need, and I've put adequate(?) warning that people shouldn't
mess with it (consenting adults, etc.).  Let me know what you think.

> Since
> iterating over the keys is significantly more useful than iterating
> over the values, that suggests a dictionary as the most appropriate
> type.
>
> If someone *really* wants a quick way to get dotted access to the
> contents of dictionary:
>
 data = dict(a=1, b=2, c=3)
 ns = type('', (), data)
 ns.a
> 1
 ns.b
> 2
 ns.c
> 3

That's pretty cool.  As a counter example, given a normal (dict-based)
object you can use vars() to turn it into a dict:

>>> data = SomeClass(a=1, b=2, c=3)
>>> ns = vars(data)
>>> ns['a']
1
>>> ns['b']
2
>>> ns['c']
3

I'll grant that it doesn't work for some objects (like named tuples),
but for sys.implementation I don't think it matters either way.

-eric
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] sys.implementation

2012-05-12 Thread Eric Snow
On Sat, May 12, 2012 at 8:35 AM, Barry Warsaw  wrote:
> I'm okay with dropping immutability for sys.implementation, but I still think
> attribute access is a more useful model.  You can easily support both getattr
> and getitem with a class instance, so I think that's the way to go.
>
> (FWIW, immutability would also be easy to support with an instance.)

Agreed on both counts.  The precedent in sys and elsewhere favors
attribute access for a fixed namespace like sys.implementation.  Also,
item access (a la mappings) implies a more volatile namespace.

-eric
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] sys.implementation

2012-05-12 Thread Eric Snow
On Sat, May 12, 2012 at 10:51 AM, Tres Seaver  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 05/12/2012 08:04 AM, Nick Coghlan wrote:
>> On Sat, May 12, 2012 at 12:40 PM, Eric Snow
>>  wrote:
>>> If anyone has strong feelings for item-access over
>>> attribute-access, please elaborate.  I'm just not seeing it as that
>>> important and would rather finish up the PEP as simply as possible.
>>
>> I object to adding a new type to the stdlib just for this PEP. Since
>> iterating over the keys is significantly more useful than iterating
>> over the values, that suggests a dictionary as the most appropriate
>> type.
>
> Why would anyone want to iterate over either of them?

Nick gave a pretty good example [1].  I just don't think it's
necessary for the PEP.

-eric


[1] http://mail.python.org/pipermail/python-dev/2012-May/119412.html
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] sys.implementation

2012-05-12 Thread Steven D'Aprano

Tres Seaver wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 05/12/2012 08:04 AM, Nick Coghlan wrote:

On Sat, May 12, 2012 at 12:40 PM, Eric Snow
 wrote:

If anyone has strong feelings for item-access over
attribute-access, please elaborate.  I'm just not seeing it as that
important and would rather finish up the PEP as simply as possible.
I object to adding a new type to the stdlib just for this PEP. Since 
iterating over the keys is significantly more useful than iterating 
over the values, that suggests a dictionary as the most appropriate 
type.


Why would anyone want to iterate over either of them?


1) I don't know what keys exist, so I use introspection on sys.implementation 
by iterating over the keys and/or values. E.g. dir(sys.implementation), or 
list(sys.implementation.keys()).


2) I know what keys exist, but I want to pretty-print the list of key/value 
pairs without having to explicitly write them out by hand:


print("spam", sys.implementation.spam)
print("ham", sys.implementation.ham)
print("cheese", sys.implementation.cheese)
# and so on...




--
Steven
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] sys.implementation

2012-05-12 Thread Glenn Linderman

On 5/12/2012 10:50 AM, Eric Snow wrote:

given a normal (dict-based)
object you can use vars() to turn it into a dict:


>>>  data = SomeClass(a=1, b=2, c=3)
>>>  ns = vars(data)
>>>  ns['a']

1

>>>  ns['b']

2

>>>  ns['c']

3

I'll grant that it doesn't work for some objects (like named tuples),


Why not?  Seems like it could, with a tweak to vars ...

named tuples already have a method to return a dict.
vars already has a special case to act like locals.

So why not add a special case to allow vars to work on named tuples?
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Preparation for VS2010 - MSDN for Windows build slaves, core devs

2012-05-12 Thread Brian Curtin
On Mon, Apr 2, 2012 at 9:12 PM, Brian Curtin  wrote:
> Hi all,
>
> If you are a running a build slave or otherwise have an MSDN account
> for development work, please check that your MSDN subscription is
> still in effect. If the subscription expired, please let me know in
> private what your subscriber ID is along with the email address you
> use for the account.
>
> Eventually we're switching to VS2010 so each slave will need to have
> that version of the compiler installed.
>
> Thanks

I heard back from our Microsoft contact that everyone who requested
renewals should have begun processing around a week ago. Since it
usually takes around a week, hopefully you've all received the
renewal. If not, let me know and I'll get you taken care of.

If build slave owners could let me know when their machine has VS2010
I'd appreciate it. I got the go-ahead to commit the port but want to
wait until the build slaves are ready for it.
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com