Re: [Tutor] help

2006-12-11 Thread Tor Hildrum
On 12/9/06, Kamran Haider <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> I have got some python related queries. I am working on an MRes project
> which involves a bit of programing in python. Actually, I am using a
> python program developed by someone, which gives pairwise genetic
> distances between a set of sequences (I don't know how...) and outputs a
> simple text file of the following format...
>
> s1,s2,s3,s4,s5
> 4,7,2,3
> 8,6,4
> 3,6
> 7
> where s1, s2, s3...represent sequences and the  second line describes
> the pairwise distance between s1 and all other sequences,thid line is
> for the distance between s2 and other sequences.
> and so on.
> 1. I want to read this line into a data structure(most probably by making a
> list of lists like [[s1,s2,4],[s1,s2,7],[s1,s3,2] and so on) which gives
> each pair and the corresponding pairwise distances. Of course, I would do
> this by writing a function that reads this file into a data structure which
> gives the all the pairs of sequences and theircorresponding distance values,
> but I am not sure how to do this.

This is a weighted graph.
see http://en.wikipedia.org/wiki/Glossary_of_graph_theory

Here is a nice text written for Python:
http://www.python.org/doc/essays/graphs.html

Should go a long way to solve your second problem as well.

Tor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] pyExcelerator and Graphs

2006-12-11 Thread Toon Pieton

Hey friendly users,

I have been using pyExcelerator for a short period now, and I'm very
satisfied with the results. There is one thing that I just can't do thought,
and that is making graphs. I want to add a column (horizontal) type graph.
Does anybody know how this can be achieved?

Thanks in advance for reading this!
Toon Pieton
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pyExcelerator and Graphs

2006-12-11 Thread Kent Johnson
Toon Pieton wrote:
> Hey friendly users,
> 
> I have been using pyExcelerator for a short period now, and I'm very 
> satisfied with the results. There is one thing that I just can't do 
> thought, and that is making graphs. I want to add a column (horizontal) 
> type graph. Does anybody know how this can be achieved?

In the readme this is listed as a future feature.

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Getting the directory the program is in

2006-12-11 Thread Toon Pieton

Hey friedly users!

I was wondering: how can I get the directory the program is in? For example
"C:\Python Programs\Calculator\".

Thanks in advance for reading,
Toon Pieton
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Getting the directory the program is in

2006-12-11 Thread Tor Hildrum
On 12/11/06, Toon Pieton <[EMAIL PROTECTED]> wrote:
> Hey friedly users!
>
> I was wondering: how can I get the directory the program is in? For example
> "C:\Python Programs\Calculator\".

>>> os.path.split.__doc__
'Split a pathname.  Returns tuple "(head, tail)" where "tail" is\n
everything after the final slash.  Either part may be empty.'

The full pathname is in sys.argv[0]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Getting the directory the program is in

2006-12-11 Thread Jordan Greenberg
Toon Pieton wrote:
> Hey friedly users!
> 
> I was wondering: how can I get the directory the program is in? For example
> "C:\Python Programs\Calculator\".
> 
> Thanks in advance for reading,
> Toon Pieton
> 

Slightly hackish and nasty, but seems to do the trick. Someone'll
probably suggest a better way, this is just the first thing I could come
up with:


from os.path import abspath
from sys import argv

print abspath(argv[0])
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Getting the directory the program is in

2006-12-11 Thread Jordan Greenberg
Tor Hildrum wrote:
> The full pathname is in sys.argv[0]
At least on my system, it only includes the filename if executed from
the current directory.

Example:

[EMAIL PROTECTED]:/$ cd ~
[EMAIL PROTECTED]:~$ cat > test.py
from sys import argv
print argv[0]
[EMAIL PROTECTED]:~$ python test.py
test.py
[EMAIL PROTECTED]:~$ cd /
[EMAIL PROTECTED]:/$ python test.py
/home/jordan/test.py
[EMAIL PROTECTED]:/$

So, if you _ALWAYS_ need an absolute path, just using sys.argv[0] might
not work.

Jordan Greenberg


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Getting the directory the program is in

2006-12-11 Thread Christopher Arndt
Jordan Greenberg schrieb:
> Slightly hackish and nasty, but seems to do the trick. Someone'll
> probably suggest a better way, this is just the first thing I could come
> up with:

No, IMHO it's perfectly normal and safe practice, though this gets the full
path name of the program. If you want the directory it is in, do this:

from os.path import abspath, dirname
import sys

app_dir = abspath(dirname(sys.argv[0]))

Of course you have to do this before you (or some other code in your program)
do anything siilar to os.chris('/somewhere/else').

Chris
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Getting the directory the program is in

2006-12-11 Thread Christopher Arndt
Christopher Arndt schrieb:
> Of course you have to do this before you (or some other code in your program)
> do anything siilar to os.chris('/somewhere/else').
   ^
That was some freudian slip of my narcissistic mind *LOL*

Of course, I mean:

os.chdir('/somewhere/else')


Chris
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Getting the directory the program is in

2006-12-11 Thread Tor Hildrum
On 12/11/06, Jordan Greenberg <[EMAIL PROTECTED]> wrote:
> Tor Hildrum wrote:
> > The full pathname is in sys.argv[0]
> At least on my system, it only includes the filename if executed from
> the current directory.

Hm, yeah, I thought the full path was standard behavior but I see it's not.

I need to go change some code :)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Video of recent talk by Guido van Rossum

2006-12-11 Thread Dick Moores


<
http://video.google.com/videoplay?docid=-8502904076440714866>

Dick Moores



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor