Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79883
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-10-28 22:15 -0700 |
| References | (4 earlier) <94e3143a-c9ab-433d-8b3d-6ab296de14d9@googlegroups.com> <CAKJDb-PEj4UWpFFTvJN_gh-AOTHJwS0D7+_WUdeLkWyQ-KsQVg@mail.gmail.com> <mailman.15282.1414556609.18130.python-list@python.org> <593c0099-770f-48cd-b7ba-22154b00f130@googlegroups.com> <mailman.15283.1414558776.18130.python-list@python.org> |
| Message-ID | <ed95d533-c4db-4081-bd32-61a93aaf797c@googlegroups.com> (permalink) |
| Subject | Re: What for -- for? (was A bug?) |
| From | Rustom Mody <rustompmody@gmail.com> |
On Wednesday, October 29, 2014 10:29:48 AM UTC+5:30, Zachary Ware wrote:
> On Tue, Oct 28, 2014 at 11:40 PM, Rustom Mody wrote:
> > On Wednesday, October 29, 2014 9:53:46 AM UTC+5:30, Zachary Ware wrote:
> >> On Tue, Oct 28, 2014 at 11:16 PM, Zachary Ware wrote:
> >> > def get_abc_map(cls):
> >> > return {n: issubclass(cls, getattr(abc, n)) for n in dir(abc) if
> >> > n[0].isupper()}
> >>
> >> Of course, Gmail decided to wrap my long line for me. In case it's
> >> not obvious, that should be a single line.
> >
> > Thanks
> >
> > Wrapping -- no problem.
> > But the isupper looks like black-magic :-)
> >
> > And removing the ' ... if n[0].isupper()'
> > breaks the code
>
> It's a terrible hack for 2/3 compatibility; in 3 I'd do "if not
> n.startswith('__')" since the Python 3 collections.abc module only
> contains ABCs (and the standard dunder names). Python 2 has all the
> ABCs mixed into the toplevel collections namespace with some other
> non-ABCs, but it happens that all the ABCs are capitalized, while the
> non-ABCs are not. The ABCs are imported into collections from
> _abcoll, but _abcoll also some uncapitalized non-ABCs as well.
>
> For somewhat greyer magic, do 'from abc import ABCMeta' and filter the
> collections<.abc> namespace with isinstance(obj, ABCMeta). I just
> used the above because it's short and sweet and keeps the name handy
> :)
Ha!
Thanks
Maybe nicer to filter out the false's with a filter-false thus??
def ff(d): return [n for n in d if d[n]]
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A bug? "umatrp@gmail.com" <trsexgl@gmail.com> - 2014-10-27 09:01 -0700
Re: A bug? Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-10-27 17:17 +0100
Re: A bug? Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-27 10:26 -0600
Re: A bug? Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-28 00:36 +0000
Re: A bug? Rustom Mody <rustompmody@gmail.com> - 2014-10-27 18:12 -0700
Re: A bug? Chris Angelico <rosuav@gmail.com> - 2014-10-28 12:25 +1100
Re: A bug? Rustom Mody <rustompmody@gmail.com> - 2014-10-27 19:13 -0700
Re: A bug? Joshua Landau <joshua@landau.ws> - 2014-10-28 01:29 +0000
Re: A bug? Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-29 02:17 +0000
What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-28 20:22 -0700
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-28 23:16 -0500
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-28 23:23 -0500
Re: What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-28 21:40 -0700
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-28 23:59 -0500
Re: What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-28 22:15 -0700
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-29 00:39 -0500
Re: What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-28 23:11 -0700
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-29 01:18 -0500
Finding way around ABCs (was What for -- for? (was A bug?)) Rustom Mody <rustompmody@gmail.com> - 2014-10-30 10:01 -0700
Re: Finding way around ABCs (was What for -- for? (was A bug?)) Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-30 11:09 -0600
Re: Finding way around ABCs (was What for -- for? (was A bug?)) Rustom Mody <rustompmody@gmail.com> - 2014-10-30 10:16 -0700
Re: Finding way around ABCs (was What for -- for? (was A bug?)) Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-30 11:11 -0600
Re: What for -- for? (was A bug?) Ben Finney <ben+python@benfinney.id.au> - 2014-10-29 16:27 +1100
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-29 00:42 -0500
Re: What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-28 22:57 -0700
Re: What for -- for? (was A bug?) Ben Finney <ben+python@benfinney.id.au> - 2014-10-29 17:02 +1100
Re: What for -- for? (was A bug?) Joshua Landau <joshua@landau.ws> - 2014-10-30 17:21 +0000
Re: What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-30 10:41 -0700
csiph-web