Re: [Tutor] File like object for Windows registry

2006-08-03 Thread Alan Gauld
> My app should run on debian and windows platforms. Hard lines :-( > For storing the configuration data, I use the ConfigParser module. > What I find difficult is to determine a place for my configuration > file. Config parser basically produces an .in file. The rules that Windows uses to loca

Re: [Tutor] File like object for Windows registry

2006-08-03 Thread Henry Finucane
On 8/3/06, Andre Roberge <[EMAIL PROTECTED]> wrote: > On 8/3/06, Henry Finucane <[EMAIL PROTECTED]> wrote: > > On 8/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Hello! > > > > > > My app should run on debian and windows platforms. For storing the > > > configuration data, I use the Con

Re: [Tutor] File like object for Windows registry

2006-08-03 Thread Andre Roberge
On 8/3/06, Henry Finucane <[EMAIL PROTECTED]> wrote: > On 8/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello! > > > > My app should run on debian and windows platforms. For storing the > > configuration data, I use the ConfigParser module. > > > > What I find difficult is to determine

Re: [Tutor] File like object for Windows registry

2006-08-03 Thread Henry Finucane
On 8/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello! > > My app should run on debian and windows platforms. For storing the > configuration data, I use the ConfigParser module. > > What I find difficult is to determine a place for my configuration file. On > debian, it is simply > > o

[Tutor] File like object for Windows registry

2006-08-03 Thread K . Weinert
Hello! My app should run on debian and windows platforms. For storing the configuration data, I use the ConfigParser module. What I find difficult is to determine a place for my configuration file. On debian, it is simply os.path.join(os.path.expanduser("~")),"myconfig") but what am I suppose

Re: [Tutor] file-like object

2005-01-14 Thread Terry Carroll
On Fri, 14 Jan 2005, Terry Carroll wrote: > Is this for loop a safe technique, where the list you're enumerating over > in the for statement is the same as the one being updated in the loop > body? Rather than cluttering the list by making three replies, I'd just like to thank Danny, Alan and J

Re: [Tutor] file-like object

2005-01-14 Thread Alan Gauld
> > for n,v in enumerate(self.list): > > self.list[n]=v+'\n' > > > Is this for loop a safe technique, where the list you're enumerating over > in the for statement is the same as the one being updated in the loop > body? I always avoid things like that. Its not changing the li

Re: [Tutor] file-like object

2005-01-14 Thread Chad Crabtree
Danny Yoo wrote: >Using the default parameter 'n' in the readline() method isn't safe: all >class instances will end up using the same 'n'. You may want to put the >current line number as part of an instance's state, since two instances of >a macroString should be able to keep track of their line

Re: [Tutor] file-like object

2005-01-14 Thread Jeff Shannon
Terry Carroll wrote: On Fri, 14 Jan 2005, Chad Crabtree wrote: class _macroString(object): def __init__(self,s): self.macro=s self.list=self.macro.split("\n") for n,v in enumerate(self.list): self.list[n]=v+'\n' Is this for loop a safe technique, where the list

Re: [Tutor] file-like object

2005-01-14 Thread Danny Yoo
On Fri, 14 Jan 2005, Terry Carroll wrote: > > class _macroString(object): > > def __init__(self,s): > > self.macro=s > > self.list=self.macro.split("\n") > > for n,v in enumerate(self.list): > > self.list[n]=v+'\n' > > Is this for loop a safe technique, wh

Re: [Tutor] file-like object

2005-01-14 Thread Danny Yoo
On Fri, 14 Jan 2005, Chad Crabtree wrote: > I have created a file-like object out of a triple quoted string. I was > wondering if there is a better way to implement readline than what I > have below? It just doesn't seem like a very good way to do this. > > class _macroString(object): > def

Re: [Tutor] file-like object

2005-01-14 Thread Terry Carroll
On Fri, 14 Jan 2005, Chad Crabtree wrote: > class _macroString(object): > def __init__(self,s): > self.macro=s > self.list=self.macro.split("\n") > for n,v in enumerate(self.list): > self.list[n]=v+'\n' Is this for loop a safe technique, where the list you

Re: [Tutor] file-like object

2005-01-14 Thread Alan Gauld
> class _macroString(object): > def __init__(self,s): > self.macro=s > self.list=self.macro.split("\n") > for n,v in enumerate(self.list): > self.list[n]=v+'\n' > def readline(self,n=[-1]): > n[0]+=1 > return self.list[n[0]] Why not just

Re: [Tutor] file-like object

2005-01-14 Thread Chad Crabtree
Thank you KentBot. That was what I wanted. Kent Johnson wrote: > Best: use the StringIO or cStringIO module instead, this is exactly > what it is for. If you really need len() you could maybe subclass > StringIO to do what you want. > > Next best: Use an iterator. Something like this (Warning!

Re: [Tutor] file-like object

2005-01-14 Thread Kent Johnson
Best: use the StringIO or cStringIO module instead, this is exactly what it is for. If you really need len() you could maybe subclass StringIO to do what you want. Next best: Use an iterator. Something like this (Warning! not tested!): class _macroString(object): def __init__(self,s):

[Tutor] file-like object

2005-01-14 Thread Chad Crabtree
I have created a file-like object out of a triple quoted string. I was wondering if there is a better way to implement readline than what I have below? It just doesn't seem like a very good way to do this. class _macroString(object): def __init__(self,s): self.macro=s self.l