Re: [Tutor] Tix and Table printing

2005-01-14 Thread Alan Gauld
I'm not yet used to search in the cookbook... and I though such basic widget would have been implemented directly in Tk or Tix... A bit of historic perspective. John Ousterhout invented TCl/Tk to provide a control language for his electrical engineering projects. Thus its focus is on GUIs to

RE: [Tutor] reinitializing namespace

2005-01-14 Thread Dimitri D'Or
Dear Kent, Consider I'm working with an interactive session during which I have already run some scripts. Those scripts have produced several variables, say, e.g., a and b. Now I execute myscript which also creates variables named a and b, but with a possibly different type or content. To be sure

[Tutor] l10n and Windows

2005-01-14 Thread Stéphane Brunet
Hi, After searching a while for a solution on the web and the archive of this newgroups, I haven't found any answer to my questions... So here are they... Here is a command line session of Python on a Windows XP computer : Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on

[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

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):

Re: [Tutor] Referer file from import

2005-01-14 Thread Kent Johnson
You could use trackback.extract_stack() to get the current stack trace. If you inspect this from within the imported module you could probably figure out who is importing you. Do you really want the module where the import was done (the place where the import statement is)? Or are you trying to

Re: [Tutor] Referer file from import

2005-01-14 Thread Chad Crabtree
Ok I will investigate this. Thank you that is probably what I needed. I am trying to make a macro expander for python based on BOO's facility for this. I thought it was neat. In addition I think it would be helpful to simulate adding keywords so that all these bloggers talking about proposed

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! not

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 create a

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

Re: [Tutor] Tix and Table printing

2005-01-14 Thread Michael Lange
On Fri, 14 Jan 2005 08:47:49 - Alan Gauld [EMAIL PROTECTED] wrote: Tk was written in the 80's so given its origins was not likely to have a table. Of course it would be nice if they added one now!!! It looks like they are already working on it: http://wiki.tcl.tk/12753 Regards

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 list, its

Re: [Tutor] style question: when to hide variable, modules

2005-01-14 Thread Kent Johnson
A few thoughts: - you might want to make a configuration object that you can pass around, this is probably better than passing around an instance of the main Burn class. - typical Python style is *not* to define setter and getter functions. If you need to mediate attribute access you can do it

Re: [Tutor] Hi. Is there another mailing list like this one?

2005-01-14 Thread Alan Gauld
I'm am bored and people are not asking enough questions/answering them to keep my mind busy. Is there any other mailing list that I can subscribe to like this one that lets anyone ask and answer questions? I assume you'vve checked the Python newsgroup? It should be busy enough for anyone! Of

[Tutor] Help

2005-01-14 Thread john stanley
This is my first attempt at programing and my first program sort of did work hear is the program and if any one can tell me what i did wrong or forgot i would appreciate it a = input(Type in the Grose: ) b = input(type in the Miles: ) print a * 0.74 / b is a*0.74/b as you can see it should

Re: [Tutor] Matrix

2005-01-14 Thread Hugo González Monteverde
Brian van den Broek wrote: 2) To get around that, and be more efficient with matricies with many empty cells: . my_matrix_as_dict = {(1,1):4, (1,2):6, (1,3):8, (2,1):56, (2,3):12, (3,1):3, (3,2):3} . my_matrix_as_dict[(3,1)] 3 . my_matrix_as_dict[(2,1)]

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

Re: [Tutor] Help

2005-01-14 Thread Max Noel
On Jan 10, 2005, at 14:31, john stanley wrote: This is my first attempt at programing and my first program sort of did work hear is the program and if any one can tell me what i did wrong or forgot i would appreciate it a = input(Type in the Grose: ) b = input(type in the Miles: ) print a *

Re: [Tutor] Faster procedure to filter two lists . Please help

2005-01-14 Thread kumar s
Hi Danny: Thank you for your suggestion. I tried creating a dictionary of 'what' list and searched keys with has_key method and it is pretty fast. Thanks again. following is the piece of code. K cors = [] intr = [] for i in range(len(what)): ele = split(what[i],'\t')

[Tutor] Intro for interfacing with Microsoft Access?

2005-01-14 Thread Terry Carroll
Does anyone know of any online resource that explains how to interface to Microsoft Access via Python, where the intended audience is someone who knows Python, but not the Microsoft innards? I've found http://starship.python.net/crew/bwilk/access.html (which doesn't work for me, and presumably

Re: [Tutor] Intro for interfacing with Microsoft Access?

2005-01-14 Thread Kent Johnson
A couple of minutes of googling for 'python odbc' finds the ODBC driver that comes with win32all. It seems to have a fairly simple interface. The download from this page has an example: http://py.vaults.ca/apyllo2.py/D906422565 HTH Kent Terry Carroll wrote: Does anyone know of any online

Re: [Tutor] Intro for interfacing with Microsoft Access?

2005-01-14 Thread Terry Carroll
On Fri, 14 Jan 2005, Kent Johnson wrote: A couple of minutes of googling for 'python odbc' finds the ODBC driver that comes with win32all. It seems to have a fairly simple interface. The download from this page has an example: http://py.vaults.ca/apyllo2.py/D906422565 Thanks, Kent. I'm