Re: decorator to prevent adding attributes to class?

2008-07-12 Thread rbossy
>> class Foo(Freezeable): >> def __init__(self): >> self.bar = 42 >> self.freeze() # ok, we set all variables, no more from here >> >> >> x = Foo() >> print x.bar >> x.bar = -42 >> print x.bar >> x.baz = "OMG! A typo!" >> > >Pretty nice, but unfortunately the subclass has to remember to call freeze

Re: Creating a file with $SIZE

2008-03-15 Thread rbossy
Quoting Bryan Olson <[EMAIL PROTECTED]>: > Robert Bossy wrote: > > Bryan Olson wrote: > >> Robert Bossy wrote: > Robert Bossy wrote: > > Indeed! Maybe the best choice for chunksize would be the file's buffer > > size... > >> > >> That bit strikes me as silly. > >> > > The size of the

Re: os.chdir

2008-03-08 Thread rbossy
Quoting "Martin v. Löwis" <[EMAIL PROTECTED]>: > >> os.chdir("~/dir1") > > > > It is not mentioned in the documentation but I'm pretty sure os.dir() > doesn't do > > tilde expansion since this is usually performed by a shell. > > > > You should use instead: > > > > os.chdir(os.join(os.environ['HOM

Re: os.chdir

2008-03-08 Thread rbossy
Quoting Maryam Saeedi <[EMAIL PROTECTED]>: > I have a problem using os.chdir on linux. What should I do if I want to > change to root directory? The below does not work: > > os.chdir("~/dir1") It is not mentioned in the documentation but I'm pretty sure os.dir() doesn't do tilde expansion since t

Re: DOM parsing not working!

2008-03-08 Thread rbossy
Quoting Mike D <[EMAIL PROTECTED]>: > Hello, I've spent the morning trying to parse a simple xml file and have the > following: > import sys > from xml.dom import minidom > > doc=minidom.parse('topstories.xml') > > items = doc.getElementsByTagName("item") > text='' > for i in items: > t = i.fi

Re: why not bisect options?

2008-03-04 Thread rbossy
Quoting Raymond Hettinger <[EMAIL PROTECTED]>: > [Robert Bossy] > > I thought it would be useful if insort and consorts* could accept the > > same options than list.sort, especially key and cmp. > > If you're going to do many insertions or searches, wouldn't it be > *much* more efficient to store

Re: why not bisect options?

2008-03-01 Thread rbossy
Selon Raymond Hettinger <[EMAIL PROTECTED]>: > [Robert Bossy] > > I thought it would be useful if insort and consorts* could accept the > > same options than list.sort, especially key and cmp. > > If you're going to do many insertions or searches, wouldn't it be > *much* more efficient to store yo

Re: Python Memory Manager

2008-02-18 Thread rbossy
Quoting Steve Holden <[EMAIL PROTECTED]>: > [...] > Not only that, but all pointers to an object have to be updated when it > is relocated. "Any problem in computer science can be solved by another level of indirection" -- David John Wheeler ;-) RB -- http://mail.python.org/mailman/listinfo/py

dictionary of operators

2008-02-14 Thread rbossy
Hi, In the standard library module "operator", it would be nice to have a dictionary mapping operators strings with their respective functions. Something like: { '+': add, '-': sub, 'in': contains, 'and': and_, 'or': or_, ... } Rationale: Recently I had to implemen