473,513 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Classes and functions.

aditya shukla wrote:
Hello folks , i am using the newick module
http://www.daimi.au.dk/~mailund/newick.html.I am just learning to use it
and i have a question about it.

from newick.tree import parse_tree
from newick.tree import add_parent_links
from newick.tree import add_distance_from_root

import sys

t = parse_tree('((A:2,B:3):1,C:6);')

print t

deltas = add_distance_from_root(t)

now when i do this i can get the output like this
(('A' : 2.0, 'B' : 3.0) : 1.0, 'C' : 6.0)
None

This is the code of the add_distance_from_root(0

def add_distance_from_root(tree):
'''Extend all nodes with the distance (branch length) from the root'''
tree.distance_from_root = 0.0 # 'tree' is the root...

class V(TreeVisitor):
def pre_visit_edge(self,src,b,l,dst):
if l is None: l = 0
dst.distance_from_root = src.distance_from_root - l
I am puzzled why this class is inside the function and why -1 instead of
+1, but...
tree.dfs_traverse(V())

From here it is clear that the function does not return anything but i
wanna get the value of the distance from root.How can i get this?
I presume each node gets an attribute 'distance_from_root', so read that
attribute of whatever node.

Sep 26 '08 #1
0 723

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
8720
by: vrillusions | last post by:
I've been using functions since I first started using php, but I've been hearing more and more about classes, which I never really looked at that much. I understand the whole OO programming...
3
3437
by: Logan K. | last post by:
What is a PHP class? I've seen a lot of talk about these and how they can help you out, but I've never seen a very good explanation. I've been working with PHP for just over 6 months and usually...
1
741
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
7
2264
by: Bora | last post by:
I usually find that a number of unrelated classes require the same kind of operations. However, I don't want to duplicate code in multiple places. In Java, I've seen those "Utility Classes",...
45
3556
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes...
2
3019
by: Indiana Epilepsy and Child Neurology | last post by:
Before asking this questions I've spent literally _years_ reading (Meyer, Stroustrup, Holub), googling, asking more general design questions, and just plain thinking about it. I am truly unable to...
12
3065
by: Daedalus.OS | last post by:
Ok first I'm pretty new to OOP, so my question may sound stupid to some of you. If the only answer you can provide is "get a book about OOP" then don't loose your time and mine cause it's already...
1
1371
by: Simon Harris | last post by:
Hi All, I'm new to asp.net (Migrating from 'Classic' ASP) I'm having troubles working out classes, functions etc... Current situation is this: index.aspx displays datalist with links to...
4
1371
by: mharness | last post by:
Hello All, I've defined a number of classes that currently only include public variable declarations. I've been reluctant to add subroutines and functions for fear of taking a performance hit...
6
2919
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.