Re: Some PyCon videos won't play

2010-03-14 Thread Niels L. Ellegaard
Lee Harr miss...@hotmail.com writes:

 I am having a great time watching videos from PyCon. Thanks to
 everyone who presented, and to those who did such a great job
 putting the videos up at: http://pycon.blip.tv/

 My trouble is that, although most of the videos play perfectly,
 there are a few that refuse to play at all. Like:

I also had problems playing some of the videos (using gnash), but if you
press files and links, then you can download the talk as an ogv
file. Furthermore blip.tv provides an rss-feed with ogv-files for
each channel on their site.

http://pycon.blip.tv/rss

Thanks to the pycon people for putting all their nice videos on the web.

Niels

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append to an Excel file

2010-01-09 Thread Niels L. Ellegaard
pp parul.pande...@gmail.com writes:

 On Jan 9, 1:47 am, Jason Scheirer jason.schei...@gmail.com wrote:
 On Jan 9, 12:30 am, pp parul.pande...@gmail.com wrote:

  Hi All,

  How do I add a line to an existing file. This should append to the
  existing data in the excel file, which was saved previously.

  Thanks,
  PP

 http://pypi.python.org/pypi/xlwt

 Hi Jason and all,

 Thanks

 I have seen this.. my question is there a  way to append to a excel
 file which has been closed. Any specific modes which can be added to
 the sheet so that it adds a line to the data which was return in some
 earlier running of the program.

I may be wrong, but I think that you have to do the following

1) Use xlrd to read the file. This creates an xlrd.Book
2) Use xlutils to transform the xlrd.Book into a xlwt.WorkBook
3) Edit the xlwt.WorkBook
4) Save the xlwt.WorkBook

https://secure.simplistix.co.uk/svn/xlutils/trunk/xlutils/docs/copy.txt

  Niels



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help understanding the decisions *behind* python?

2009-07-20 Thread Niels L. Ellegaard
Phillip B Oldham phillip.old...@gmail.com writes:

 We often find we need to do manipulations like the above without
 changing the order of the original list, and languages like JS allow
 this. We can't work out how to do this in python though, other than
 duplicating the list, sorting, reversing, then discarding.

If you just want a one-liner, and you don't care about speed you can
do the following (but I don't think this is considered best practice)

 x = [2,1,3]
 print list(sorted(x))   
[1, 2, 3]
 print x
[2, 1, 3]

 Niels
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Automatic debugging of copy by reference errors?

2006-12-09 Thread Niels L Ellegaard
Gabriel Genellina wrote:
 I think you got in trouble with something and you're trying to avoid it
 again - but perhaps this is not the right way. Could you provide some
 example?

I have been using scipy for some time now, but in the beginning I made
a few mistakes with copying by reference. The following example is
exagerated
for clarity, but the principle is the same:

import os
output=[]
firstlines =[0,0]
for filename in os.listdir('.'):
try:
firstlines[0] = open(filename,r).readlines()[0]
firstlines[1] = open(filename,r).readlines()[1]
   output.append((filename,firstlines))
except:continue
print output

Now some of my fortran-using friends would like to use python to
analyze their data files. I wanted them to avoid making the same
mistakes as I did so I thought it would be good if they could get some
nanny-like warnings saying: Watch out young man. If do this, then
python will behave differently from fortran and matlab. That could
teach them to do things the right way.

I am not an expert on all this, but I guessed that it would be possible
to make a set of constraints that could catch a fair deal of simple
errors such as the one above, but still allow for quite a bit of
programming.

  Niels

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Automatic debugging of copy by reference errors?

2006-12-09 Thread Niels L Ellegaard
Marc 'BlackJack' Rintsch wrote:
 In [EMAIL PROTECTED], Niels L
 Ellegaard wrote:
  I have been using scipy for some time now, but in the beginning I made
  a few mistakes with copying by reference.
 But copying by reference is the way Python works.  Python never copies
 objects unless you explicitly ask for it.  So what you want is a warning
 for *every* assignment.

Maybe I am on the wrong track here, but just to clarify myself:

I wanted  a each object to know whether or not it was being referred to
by a living object, and I wanted to warn the user whenever he tried to
change an object that was being refered to by a living object.  As far
as I can see the garbage collector module would allow to do some of
this, but one would still have to edit the assignment operators of each
of the standard data structures:

http://docs.python.org/lib/module-gc.html

Anyway you are probably right that the end result would be a somewhat
crippled version of python


  Niels

-- 
http://mail.python.org/mailman/listinfo/python-list


Automatic debugging of copy by reference errors?

2006-12-08 Thread Niels L Ellegaard
Is there a module that allows me to find errors that occur due to copy
by reference? I am looking for something like the following:

 import mydebug
 mydebug.checkcopybyreference = True
 a=2
 b=[a]
 a=4
Traceback (most recent call last):
  File stdin, line 1, in ?
CopyByReferenceError: Variable b refers to variable a, so please do not
change variable a.

Does such a module exist?
Would it be possible to code such a module?
Would it be possible to add the functionality to array-copying in
numpy?
What would be the extra cost in terms of memory and CPU power?

I realize that this module would disable some useful features of the
language. On the other hand it could be helpful for new python users.

 Niels

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: About alternatives to Matlab

2006-12-03 Thread Niels L Ellegaard
Jon Harrop wrote:
 So I'm keen to learn what Python programmers would want/expect from F# and
 OCaml.

I think this discussion becoming is a little misguided.

The real strength of scipy is the elegant notation rather than speed.
Being raised with Matlab I find scipy nicely familiar, and its fast
enough for many tasks. Some would argue that the strength of scipy is
the weakness of ocaml. Others would disagree. That is a question of
taste.

My only grudge about strongly recommending scipy to friends is the way
that two arrays can share the same data. This can lead to subtle errors
that I will eventually be blamed for. I don't know if arrays in Matlab
(or Octave) can share data, but if they do, then everything happens
behind the scenes and the user does not have to worry. I would love to
see a future version of numpy that was 50% slower and had a more
foolproof approach to array copying.

http://www.scipy.org/Tentative_NumPy_Tutorial#head-1529ae93dd5d431ffe3a1001a4ab1a394e70a5f2


  Niels

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: About alternatives to Matlab

2006-11-27 Thread Niels L Ellegaard
Filip Wasilewski wrote:
 As far as the speed comparison is concerned I totally agree that NumPy
 can easily outperform Matlab in most cases. Of course one can use
 compiled low-level extensions to speed up specific computations in
 Matlab, but it's a lot easier and/or cheaper to find very good tools
 for Python.

These benchmarks are interesting. Perhaps someone could elaborate: When
is python faster than Matlab and when is it slower? As far as I
understand, recent versions of Matlab include a jit, but cpython does
not (unless you use psyco). Can python do faster do-loops than matlab?
Does the matrix backend of python perform faster than a the matrix
backend of Matlab? What is going on?

Thanks in advance

  Niels

BTW: I feel obliged to provide a small link to your upcoming wavelet
code for scipy. It looks promising:
http://wavelets.scipy.org/moin/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Python Molecular Viewer - 1.4.3

2006-09-19 Thread Niels L Ellegaard
[EMAIL PROTECTED] wrote:
 More information can be found on our web site at
 http://mgltools.scripps.edu

I had some trouble finding the license of the code on the webpage, but
it looks like the software is free for non-commercial use. Could I
convince you to make the license more visible? Please write it in the
FAQ and preferably also on the home page.

Thanks in advance, and good luck with the project

Niels

-- 
http://mail.python.org/mailman/listinfo/python-list


[[x,f(x)] for x in list that maximizes f(x)] --newbie help

2005-12-01 Thread Niels L Ellegaard
I just started learning python and I have been wondering. Is there a
short pythonic way to find the element, x, of a list, mylist, that
maximizes an expression f(x).

In other words I am looking for a short version of the following:

pair=[mylist[0],f(mylist[0])]
for x in mylist[1:]:
 if f(x)  pair[1]:
   pair=[x,f(x)]

-- 
http://mail.python.org/mailman/listinfo/python-list


Writing an xmgr/grace file as text (not interactive)

2005-10-10 Thread Niels L Ellegaard
Can someone suggest a package that allows me to write a data file for
xmgr.

So far I have found some  packages that allow me to start an
interactive xmgrace session from python, but I would rather have a
package that write a text file.

I realize that xmgr can read text-files, and that the format of an
xmgr-file is easy to read, but if someone has allready done this work
then I would rather steal it and save my own time :)

Thanks in advance

  Niels

-- 
http://mail.python.org/mailman/listinfo/python-list