Re: Cleaning up after failing to contructing objects

2009-07-09 Thread Mattias Brändström
On Jul 9, 7:30 pm, Lie Ryan wrote: > brasse wrote: > > Hello! > > I have been thinking about how write exception safe constructors in > > Python. By exception safe I mean a constructor that does not leak > > resources when an exception is raised within it. The following is an > > example of one po

Re: Cleaning up after failing to contructing objects

2009-07-08 Thread Mattias Brändström
On Jul 6, 11:15 pm, Scott David Daniels wrote: > brasse wrote: > > I have been thinking about how write exception safe constructors in > > Python. By exception safe I mean a constructor that does not leak > > resources when an exception is raised within it. > > ... >  > As you can see this is less

Vector, matrix, normalize, rotate. What package?

2007-02-27 Thread Mattias Brändström
Hello! I'm trying to find what package I should use if I want to: 1. Create 3d vectors. 2. Normalize those vectors. 3. Create a 3x3 rotation matrix from a unit 3-d vector and an angle in radians. 4. Perform matrix multiplication. It seems to me that perhaps numpy should be able to help me with t

Re: filecmp.cmp() cache

2007-02-15 Thread Mattias Brändström
On Feb 15, 11:43 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Mattias Brändström wrote: > > Just one small tought/question. How likely am I to run into trouble > > because of this? I mean, by setting _cache to another value I'm > > mucking about in filecmp&#

Re: filecmp.cmp() cache

2007-02-15 Thread Mattias Brändström
On Feb 15, 5:56 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > You can clear the cache with > > filecmp._cache = {} > > as a glance into the filecmp module would have shown. You are right, a quick glance would have enlighten me. Next time I will RTFS first. :-) > If you don't want to use the cache

filecmp.cmp() cache

2007-02-15 Thread Mattias Brändström
Hello! I have a question about filecmp.cmp(). The short code snippet blow does not bahave as I would expect: import filecmp f0 = "foo.dat" f1 = "bar.dat" f = open(f0, "w") f.write("1:2") f.close() f = open(f1, "w") f.write("1:2") f.close() print "cmp 1: " + str(filecmp.cmp(f0, f1, False)) f