Re: Trees

2015-01-20 Thread Nicholas Cole
On Mon, Jan 19, 2015 at 11:52 PM, Devin Jeanpierre wrote: > On Mon, Jan 19, 2015 at 3:08 PM, Steven D'Aprano > wrote: >> Zachary Gilmartin wrote: >> >>> Why aren't there trees in the python standard library? >> >> Possibly because they aren't needed? Under what circumstances would you use >> a tr

Re: Trees

2015-01-20 Thread Marko Rauhamaa
Terry Reedy : > Others have answered as to why other special-purpose > constrained-structure trees have not been added to the stdlib. Ordered O(log n) mappings are not special-purpose data structures. I'd say strings and floats are much more special-purpose than ordered mappings, and yet Python h

Re: Trees

2015-01-20 Thread Rustom Mody
On Tuesday, January 20, 2015 at 11:38:27 AM UTC+5:30, Terry Reedy wrote: > 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 pr

Re: Trees

2015-01-20 Thread Rustom Mody
On Tuesday, January 20, 2015 at 7:03:56 PM UTC+5:30, Rustom Mody wrote: > On Tuesday, January 20, 2015 at 11:38:27 AM UTC+5:30, Terry Reedy wrote: > > On 1/19/2015 5:06 PM, Zachary Gilmartin wrote: > > > Why aren't there trees in the python standard library? > > > > Sequences nested withing sequen

Re: Trees

2015-01-20 Thread TP
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence wrote: > I don't know if you've seen this http://kmike.ru/python-data-structures/ > but maybe of interest. > I haven't read but also possibly of interest: Data Structures and Algorithms in Python by Michael T. Goodrich, Roberto Tamassia, Michael H.

Re: Trees

2015-01-20 Thread Marko Rauhamaa
Rustom Mody : > Yeah python has trees alright. Does Python balance them for you? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Trees

2015-01-20 Thread Mark Lawrence
On 20/01/2015 05:19, Marko Rauhamaa wrote: Mark Lawrence : On 19/01/2015 22:06, Zachary Gilmartin wrote: Why aren't there trees in the python standard library? Probably because you'd never get agreement as to which specific tree and which specific implementation was the most suitable for inc

Re: Trees

2015-01-20 Thread Rustom Mody
On Tuesday, January 20, 2015 at 7:46:02 PM UTC+5:30, Marko Rauhamaa wrote: > Rustom Mody : > > > Yeah python has trees alright. > > Does Python balance them for you? No Does python support a menagerie of lists like C - singly linked, doubly linked, with header, without header etc? Or access to

Re: Random ALL CAPS posts on this group

2015-01-20 Thread Paul Rudin
Rick Johnson writes: > No one here would justify a public business refusing to > serve or employ a person based on race, religion, sex, or > otherwise. Depends on what you mean by "or otherwise". > So why would you so easily discriminate against speech? People discriminate amongst prospective

Re: Trees

2015-01-20 Thread Ian Kelly
On Tue, Jan 20, 2015 at 6:33 AM, Rustom Mody wrote: > from enum import Enum > class TreeTag(Enum): > I = 0 # An internal node > L = 1 # A leaf node > def __repr__(self): return self.name > > I = TreeTag.I > L = TreeTag.L Explicitly tagging nodes as internal or leaves is kind of ugl

Re: Trees

2015-01-20 Thread Paul Rubin
Marko Rauhamaa writes: > So in my Python software (both at work and at home) needs, I use a > Python AVL tree implementation of my own. My use case is timers. (GvR > uses heapq for the purpose.) Have you benchmarked your version against heapq or even the builtin sorting functions? -- https://mai

Re: Trees

2015-01-20 Thread Paul Rubin
Steven D'Aprano writes: > Possibly because they aren't needed? Under what circumstances would > you use a tree instead of a list or a dict or combination of both? I've sometimes wanted a functional tree in the sense of functional programming. That means the tree structure is immutable and you in

Student looking for a Scitki-Learn Numpy Tutor with a strong background in data science?

2015-01-20 Thread MK
In a Masters for Data Science and need the help using Python/R mainly. Please forward background(education, work) teaching experence in stats, linear algebra, programming (Scikit, Panda, Numpy), timezone, and rates. -- https://mail.python.org/mailman/listinfo/python-list

RE: Random ALL CAPS posts on this group

2015-01-20 Thread Clayton Kirkwood
>-Original Message- >From: Python-list [mailto:python-list- >bounces+crk=godblessthe...@python.org] On Behalf Of Rick Johnson >Sent: Monday, January 19, 2015 8:06 PM >To: python-list@python.org >Subject: Re: Random ALL CAPS posts on this group > >On Monday, January 19, 2015 at 8:16:01 PM

Re: Trees

2015-01-20 Thread Paul Rubin
Marko Rauhamaa writes: > As I said, I use ordered mappings to implement timers... The downside > of heapq is that canceled timers often flood the heapq structure..., > GvR mentioned a periodic "garbage collection" as a potentially > effective solution. You could look up the "timer wheel" approac

Re: Trees

2015-01-20 Thread Rustom Mody
On Tuesday, January 20, 2015 at 10:51:13 PM UTC+5:30, Ian wrote: > On Tue, Jan 20, 2015 at 6:33 AM, Rustom Mody wrote: > > from enum import Enum > > class TreeTag(Enum): > > I = 0 # An internal node > > L = 1 # A leaf node > > def __repr__(self): return self.name > > > > I = TreeTag

pickle and then object changes

2015-01-20 Thread James Smith
Say an object like this exists: class test: a = "" b = "" You pickle it. You change the object definition to have a new field: class test a = "" b = "" c = "" You read the pickled object. Will it load but ignore the new field? That is what I want. -- https://mail.python.org/

Re: Trees

2015-01-20 Thread Rustom Mody
On Tuesday, January 20, 2015 at 11:46:11 PM UTC+5:30, Rustom Mody wrote: > On Tuesday, January 20, 2015 at 10:51:13 PM UTC+5:30, Ian wrote: > > On Tue, Jan 20, 2015 at 6:33 AM, Rustom Mody wrote: > > > # Converting to generators is trivial > > > = > > > > :-) > > Less trivial

Re: pickle and then object changes

2015-01-20 Thread Peter Otten
James Smith wrote: > Say an object like this exists: > class test: > a = "" > b = "" > > You pickle it. > > You change the object definition to have a new field: > class test > a = "" > b = "" > c = "" > > You read the pickled object. > Will it load but ignore the new field?

Re: Trees

2015-01-20 Thread Ken Seehart
Exactly. There are over 23,000 different kinds of trees. There's no way you could get all of them to fit in a library, especially a standard one. Instead, we prefer to provide people with the tools they need to grow their own trees. http://caseytrees.org/programs/planting/ctp/ http://www.ncsu.

Re: Trees

2015-01-20 Thread Devin Jeanpierre
There are similarly many kinds of hash tables. For a given use case (e.g. a sorted dict, or a list with efficient removal, etc.), there's a few data structures that make sense, and a library (even the standard library) doesn't have to expose which one was picked as long as the performance is good.

Re: Trees

2015-01-20 Thread Chris Angelico
On Wed, Jan 21, 2015 at 7:15 AM, Ken Seehart wrote: > Exactly. There are over 23,000 different kinds of trees. There's no way you > could get all of them to fit in a library, especially a standard one. > Instead, we prefer to provide people with the tools they need to grow their > own trees. I'm

Re: Trees

2015-01-20 Thread Marko Rauhamaa
Paul Rubin : > Marko Rauhamaa writes: >> So in my Python software (both at work and at home) needs, I use a >> Python AVL tree implementation of my own. My use case is timers. (GvR >> uses heapq for the purpose.) > > Have you benchmarked your version against heapq or even the builtin > sorting fu

Re: Trees

2015-01-20 Thread Marko Rauhamaa
Paul Rubin : > You could look up the "timer wheel" approach used by the Linux kernel > and by Erlang. It's less general than an ordered map, but probably > faster in practice. > > https://lkml.org/lkml/2005/10/19/46 > > Has some info. I think the kernel uses a different method now though. I

How to run a python script with functions

2015-01-20 Thread faiz . lotfy
Hi I have a file with a python scripts that has many functions in it. To run the script I did the following: 1. $ python (to initiate python, using the python command) 2. >>> import file_name (without .py) 3. >>> file_name.function_name(argument) (to run the function_name with argument (argument

Re: How to run a python script with functions

2015-01-20 Thread André Roberge
On Tuesday, 20 January 2015 17:11:58 UTC-4, faiz@gmail.com wrote: > Hi > > I have a file with a python scripts that has many functions in it. To run the > script I did the following: > 1. $ python (to initiate python, using the python command) > 2. >>> import file_name (without .py) > 3. >>>

Re: Trees

2015-01-20 Thread Mario
In article , rustompm...@gmail.com says... > > Yeah python has trees alright. > > Heres' some simple tree-code Didn't you just demonstrate that Python has no trees and instead you have to implement them yourself (or use a third-party implementation)? I don't know what's the point of all this

Re: How to run a python script with functions

2015-01-20 Thread faiz . lotfy
On Tuesday, January 20, 2015 at 3:22:55 PM UTC-6, André Roberge wrote: > On Tuesday, 20 January 2015 17:11:58 UTC-4, faiz@gmail.com wrote: > > Hi > > > > I have a file with a python scripts that has many functions in it. To run > > the script I did the following: > > 1. $ python (to initiate

Re: Random ALL CAPS posts on this group

2015-01-20 Thread Denis McMahon
On Mon, 19 Jan 2015 16:15:58 -0800, Luke Tomaneng wrote: > Has anyone noticed these? There have been about three of them recently > and they don't seem to have anything to do with Python at all. Does > anyone know if there is a good reason they are here? Abusive spam from idiots. I have a regex t

Re: Trees

2015-01-20 Thread Sturla Molden
On 20/01/15 01:49, Dan Stromberg wrote: I think probably the most common need for a tree is implementing a cache, That is probably true, at least if you're a squirrel. -- https://mail.python.org/mailman/listinfo/python-list

Re: Trees

2015-01-20 Thread Joshua Landau
On 20 January 2015 at 04:21, Dan Stromberg wrote: > On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence > wrote: >> >> I don't know if you've seen this http://kmike.ru/python-data-structures/ but >> maybe of interest. > > I've seen it. It's a nice page. > > I attempted to get my treap port in there s

Re: Trees

2015-01-20 Thread Rustom Mody
On Wednesday, January 21, 2015 at 3:18:03 AM UTC+5:30, Mario wrote: > rustompmody says... > > > > Yeah python has trees alright. > > > > Heres' some simple tree-code > > Didn't you just demonstrate that Python has no trees and instead you > have to implement them yourself (or use a third-party

Re: Trees

2015-01-20 Thread Paul Rubin
Rustom Mody writes: > ## The depth first algorithm > dfs (L x) = [x] > dfs (B x lst rst) = [x] ++ dfs lst ++ dfs rst Cute. I can't resist posting the similar breadth first algorithm: bfs (L x) = [x] bfs (B x lst rst) = bfs lst ++ [x] ++ bfs rst > *Main> dfs t > [6,2,1,4,3,5,8,7,9] *

Re: Trees

2015-01-20 Thread Rustom Mody
On Wednesday, January 21, 2015 at 7:19:39 AM UTC+5:30, Paul Rubin wrote: > Rustom Mody writes: > > ## The depth first algorithm > > dfs (L x) = [x] > > dfs (B x lst rst) = [x] ++ dfs lst ++ dfs rst > > Cute. I can't resist posting the similar breadth first algorithm: > > bfs (L x) = [x]

Re: Trees

2015-01-20 Thread Terry Reedy
On 1/20/2015 4:47 PM, Mario wrote: In article , rustompm...@gmail.com says... Yeah python has trees alright. Heres' some simple tree-code Didn't you just demonstrate that Python has no trees and instead you have to implement them yourself (or use a third-party implementation)? I don't know

Re: Trees

2015-01-20 Thread Mark Lawrence
On 21/01/2015 01:22, Joshua Landau wrote: On 20 January 2015 at 04:21, Dan Stromberg wrote: On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence wrote: I don't know if you've seen this http://kmike.ru/python-data-structures/ but maybe of interest. I've seen it. It's a nice page. I attempted to

python traceroute

2015-01-20 Thread Chandrakant Tiwari
in the program below i want it to make it work the same way as TRACERT command . but i am not able to make it work the same way . for which i need your help thank you here is the program #!/usr/bin/python import socket import struct import sys # We want unbuffered stdout so we can pr

Re: python traceroute

2015-01-20 Thread Steven D'Aprano
On Tue, 20 Jan 2015 19:37:26 -0800, Chandrakant Tiwari wrote: > in the program below i want it to make it work the same way as TRACERT > command . but i am not able to make it work the same way . for which i > need your help thank you What is the difference between TRACERT and your Python s

Re: Trees

2015-01-20 Thread Dan Stromberg
On Tue, Jan 20, 2015 at 5:22 PM, Joshua Landau wrote: > On 20 January 2015 at 04:21, Dan Stromberg wrote: >> On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence >> wrote: >>> >>> I don't know if you've seen this http://kmike.ru/python-data-structures/ but >>> maybe of interest. >> >> I've seen it. I

Re: Concerning Dictionaries and += in Python 2.x

2015-01-20 Thread Denis McMahon
On Mon, 19 Jan 2015 16:12:57 -0800, Luke Tomaneng wrote: > I have been having a bit of trouble with the things mentioned in the > title. I've uploaded a slightly different approach to your code at: http://www.sined.co.uk/tmp/shop.py.txt -- Denis McMahon, denismfmcma...@gmail.com -- https://ma

Re: python traceroute

2015-01-20 Thread Denis McMahon
On Tue, 20 Jan 2015 19:37:26 -0800, Chandrakant Tiwari wrote: > in the program below i want it to make it work the same way as TRACERT > command. As an observation, you're re-inventing a wheel that already works perfectly well, in that any failings of tracert tend to be more down to the way r

Re: Trees

2015-01-20 Thread Stephen Hansen
On Tue, Jan 20, 2015 at 1:45 AM, Marko Rauhamaa wrote: > Terry Reedy : > > > Others have answered as to why other special-purpose > > constrained-structure trees have not been added to the stdlib. > > Ordered O(log n) mappings are not special-purpose data structures. I'd > say strings and floats