Re: [Tutor] Dynamic inheritance?

2005-11-23 Thread Kent Johnson
Jan Eden wrote: > Jan Eden wrote on 22.11.2005: >>Kent Johnson wrote on 20.11.2005: >> >>>Use getattr() to access attributes by name. SiteA is an attribute >>>of Templates and Page is an attribute of SiteA so you can get use >>>getattr() twice to get what you want: >>> >>>site = getattr(Templates,

[Tutor] Introspection (modules and functions)

2005-11-23 Thread Negroup -
Hi. My application hosts a module A that contains only a (variable) number of functions. In another part of this application I need to know which functions are defined inside module A. Initially I thought to use __dict__, but along with the functions of module A are listed all the builtins too. H

[Tutor] files - strings - lists

2005-11-23 Thread Andrzej Kolinski
I want to create a program that uses data from text files, makes appropriate calculations and produces report. First I need to find out what is the right way to retrieve appropriate information from an input file. This is a typical format of the input file: 1 Polonijna Liga Mistrzow        |from

Re: [Tutor] Introspection (modules and functions)

2005-11-23 Thread Frank Moore
Negroup - wrote: >Hi. > >My application hosts a module A that contains only a (variable) number >of functions. In another part of this application I need to know which >functions are defined inside module A. Initially I thought to use >__dict__, but along with the functions of module A are listed

[Tutor] Pretty XML

2005-11-23 Thread Greg Lindstrom
Hello- I am in the process of creating an XML document from information stored in our database.  One of my colleagues will use the record to format our information (health care claims) into all sorts of forms, reports, etc.  He is partial to PHP5 but I like Python and would like to know if there is

Re: [Tutor] Introspection (modules and functions)

2005-11-23 Thread Ewald Ertl
Hi! I quick solution for a name module could be: >>> import os >>> for d in os.__dict__: ... a="os." + d ... if callable( eval(a) ): ... print "Callable %s" % ( eval(a)) but there should also be a recipe on activestate for that problem. I think I've red something in the Pytho

Re: [Tutor] files - strings - lists

2005-11-23 Thread Kent Johnson
Andrzej Kolinski wrote: > > I want to create a program that uses data from text files, makes > appropriate calculations and produces report. First I need to find out > what is the right way to retrieve appropriate information from an input > file. This is a typical format of the input file: >

Re: [Tutor] Pretty XML

2005-11-23 Thread Frank Moore
Greg Lindstrom wrote: > Hello- > I am in the process of creating an XML document from information > stored in our database. One of my colleagues will use the record to > format our information (health care claims) into all sorts of forms, > reports, etc. He is partial to PHP5 but I like Pytho

Re: [Tutor] files - strings - lists

2005-11-23 Thread Chris or Leslie Smith
| | With these tools the solution is pretty simple. I agree that handling this with Python is pretty straightforward, but I'm wondering if there exists some sort of mechanism for reading these types of well structured (though not XML format, etc...) files. Something like a reverse template, s

[Tutor] sort list alphabetically

2005-11-23 Thread lmac
Hallo, i have a list with the dirs/files from the current path. When i use sort() to sort the list alphabetically the list is still unsorted. How to use ? dirs_files = os.listdir(os.getcwd()) print dirs_files dirs_files.sort() print dirs_files Thank you. _

Re: [Tutor] command in menu and button

2005-11-23 Thread Double Six
Hi John and Alan, I got it! Thank you both for explaining this situation. Thanks, Joe Get your own "800" number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag On Tue, 22 Nov 2005, [EMAIL PROTECTED] ([EMAIL PROTECTED]

Re: [Tutor] sort list alphabetically

2005-11-23 Thread Danny Yoo
On Wed, 23 Nov 2005, lmac wrote: > i have a list with the dirs/files from the current path. When i use > sort() to sort the list alphabetically the list is still unsorted. How > to use ? > > dirs_files = os.listdir(os.getcwd()) > print dirs_files > dirs_files.sort() > print dirs_files Hi lmac,

Re: [Tutor] files - strings - lists

2005-11-23 Thread Danny Yoo
On Wed, 23 Nov 2005, Chris or Leslie Smith wrote: > I agree that handling this with Python is pretty straightforward, but > I'm wondering if there exists some sort of mechanism for reading these > types of well structured (though not XML format, etc...) files. Hi Chris, Yes, take a look at "pa

[Tutor] How to discover which OS my python is running?

2005-11-23 Thread Diego Galho Prestes
Hi! I'm using a program that I want to know if I'm running the program in Linux or Windows. How can I do this? I want this because I created all my program in Linux but if someone runs it in Windows I have to do some things to make it work well, and I want to do this verification automatically. Th

Re: [Tutor] Pretty XML

2005-11-23 Thread Ismael Garrido
Greg Lindstrom wrote: > Hello- > I am in the process of creating an XML document from information > stored in our database. One of my colleagues will use the record to > format our information (health care claims) into all sorts of forms, > reports, etc. He is partial to PHP5 but I like Pytho

Re: [Tutor] files - strings - lists

2005-11-23 Thread Chris or Leslie Smith
Danny Yoo wrote: | On Wed, 23 Nov 2005, Chris or Leslie Smith wrote: | || I agree that handling this with Python is pretty straightforward, but || I'm wondering if there exists some sort of mechanism for reading || these types of well structured (though not XML format, etc...) files. | | Hi Chris

Re: [Tutor] Introspection (modules and functions)

2005-11-23 Thread Kent Johnson
Negroup - wrote: > Hi. > > My application hosts a module A that contains only a (variable) number > of functions. In another part of this application I need to know which > functions are defined inside module A. Initially I thought to use > __dict__, but along with the functions of module A are li

Re: [Tutor] How to discover which OS my python is running?

2005-11-23 Thread Kent Johnson
Diego Galho Prestes wrote: > Hi! I'm using a program that I want to know if I'm running the program > in Linux or Windows. How can I do this? I want this because I created > all my program in Linux but if someone runs it in Windows I have to do > some things to make it work well, and I want to do t

Re: [Tutor] How to discover which OS my python is running?

2005-11-23 Thread Danny Yoo
On Wed, 23 Nov 2005, Kent Johnson wrote: > Diego Galho Prestes wrote: > > Hi! I'm using a program that I want to know if I'm running the program > > in Linux or Windows. How can I do this? I want this because I created > > all my program in Linux but if someone runs it in Windows I have to do >

Re: [Tutor] files - strings - lists

2005-11-23 Thread Danny Yoo
> Great links, Danny. Thanks. I had seen mxTextTools before but didn't > search for the right thing before raising the question. The pyparsing > seems very interesting. The code that I attach below is a very > light-weight version of a formatted reader. It assumes that you just > want to pluck

Re: [Tutor] files - strings - lists

2005-11-23 Thread Andrzej Kolinski
Thank you Kent, Chris, Danny, This is superb, let me work on my part for now and I promise get back to the group with more ...          _/_/      _/     _/   _/       _/  _/   _/  _/_/_/_/  _/ _/ _/      _/  _/   _/ _/     _/  _/      _/ Andrzej Kolinski wrote: > > I want to create a

Re: [Tutor] sort list alphabetically

2005-11-23 Thread bob
At 09:55 AM 11/23/2005, lmac wrote: >i have a list with the dirs/files from the current path. When i use >sort() to sort the list alphabetically the list is still unsorted. When you say "unsorted" - are the list members in the same order as before the sort? >dirs_files = os.listdir(os.getcwd())

Re: [Tutor] sort list alphabetically

2005-11-23 Thread John Fouhy
On 24/11/05, Danny Yoo <[EMAIL PROTECTED]> wrote: > The files that start with uppercase come first because of the way those > strings compare to lowercase strings. If we want a case-insensitive sort, > we can do something like this: > > ## > >>> def case_insensitive_cmp(a, b): > ... return

Re: [Tutor] sort list alphabetically

2005-11-23 Thread Danny Yoo
> In python2.4, you can also use the key= keyword argument: > > ### > def toUpper(s): > return s.upper() > files.sort(key=toUpper) > ### > > This is more efficient, I believe, because the key function is only > called once for each element, whereas cmp is called more than once. > > (we could use

Re: [Tutor] How to discover which OS my python is running?

2005-11-23 Thread bob
At 06:31 PM 11/23/2005, Diego Galho Prestes wrote: >Hi! I'm using a program that I want to know if I'm running the program >in Linux or Windows. How can I do this? I want this because I created >all my program in Linux but if someone runs it in Windows I have to do >some things to make it work well

Re: [Tutor] files - strings - lists

2005-11-23 Thread Chris or Leslie Smith
Danny wrote: | Hi Chris, | | Yes, I suspect that this happens a lot. I have my own little formatting | reader that simulates some of the features of C's scanf, for example: | |http://hkn.eecs.berkeley.edu/~dyoo/python/scanf/ | | so I think it's one of those little exercises that everyone e