GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • [ date ]
  • [ thread ]
  • [ subject ]
  • [ author ]

This view

  • Original page
  • New address

GeezerVison is showing mail.python.org — [Python-Dev] Iterable String Redux (aka String ABC)

[Python-Dev] Iterable String Redux (aka String ABC)

Raymond Hettinger python at rcn.com
Wed May 28 02:31:04 CEST 2008

  • Previous message: [Python-Dev] Iterable String Redux (aka String ABC)
  • Next message: [Python-Dev] Iterable String Redux (aka String ABC)
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

> Steven D'Aprano" <limeguin at pearwood.info>
> If built-in objects grew an __atomic__ attribute, you could 
> simplify the atomic() function greatly:

I may not have been clear enough in my previous post.
Atomicity is not an intrinsic property of an object or class.
How could you know in advance what various applications
would want to consider atomic?  The decision is application
specific and best left to the caller of the flattener:

def flatten(obj, predicate=None):
    if predicate is not None and predicate(obj):
        yield obj
    else:
        for item in obj:
            for i in flatten(item):
                yield i

> However atomic() is defined, now flatten() is easy:

Rule of thumb:  if you find a need to change the language
(adding a new builtin, adding a new protocol, and adding a
property to every builtin and pure python container) just to
implement a simple recipe, then it is the recipe that needs fixing,
not the language.


Raymond

P.S. You're on the right track by factoring the decision
away from the internals of flatten(); however, the atomic()
predicate needs to be user definable for a given application
not hardwired into the language itself.

  • Previous message: [Python-Dev] Iterable String Redux (aka String ABC)
  • Next message: [Python-Dev] Iterable String Redux (aka String ABC)
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

More information about the Python-Dev mailing list
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.