Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'languages,': 0.04; 'syntax': 0.04; 'tree': 0.05; 'method.': 0.07; 'nested': 0.07; 'imported': 0.09; 'library?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'trees': 0.09; 'python': 0.11; 'jan': 0.12; 'ast': 0.16; 'heapq': 0.16; 'lisp': 0.16; 'modules.': 0.16; 'nodes': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'stdlib.': 0.16; 'wrote:': 0.18; 'module': 0.19; 'header:User-Agent:1': 0.23; "aren't": 0.24; 'forms.': 0.24; 'possibly': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'code': 0.31; 'depth': 0.31; 'node': 0.31; 'class': 0.32; 'lists': 0.32; 'implemented': 0.33; 'maybe': 0.34; 'add': 0.35; 'there': 0.35; 'useful': 0.36; 'example,': 0.37; 'represent': 0.38; 'lists.': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'such': 0.63; 'more': 0.64; 'specialized': 0.65; 'received:fios.verizon.net': 0.84; 'regarded': 0.84; 'these.': 0.91; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Trees Date: Tue, 20 Jan 2015 01:08:02 -0500 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-108-16-203-145.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421734095 news.xs4all.nl 2896 [2001:888:2000:d::a6]:53642 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84060 On 1/19/2015 5:06 PM, Zachary Gilmartin wrote: > Why aren't there trees in the python standard library? Sequences nested withing sequences can be regarded as trees, and Python has these. I regard Lisp as a tree processing languages, as it must be to manipulate, for example, code with nested structures. Nested structures in general represent trees or more general graph forms. The ast module uses Nodes with lists of subnodes to represent Abstract Syntax Trees. Priority queues are specialized trees implemented on top of lists. The heapq module is imported into 6 other modules. Others have answered as to why other special-purpose constrained-structure trees have not been added to the stdlib. It might possibly be useful to add a general Tree base class with pre-, in-, and post-order generators, and maybe interior and leaf node counters and max depth method. Finding uses for such a thing in the stdlib (ast?) would be a plus in favor. -- Terry Jan Reedy