Re: [Tutor] TRULY NEWBIE - MENTOR NEEDED (fwd)

2005-11-24 Thread Danny Yoo
-- Forwarded message -- Date: Wed, 23 Nov 2005 21:43:27 -0400 From: mike donato <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Re: [Tutor] TRULY NEWBIE - MENTOR NEEDED Thank You Danny I changed - and didnt get an executable, not sure what is supposed to be the output. Mike

Re: [Tutor] Gurus of one liner- MOVe (blah) from one token to another and REnumber tokens

2005-11-24 Thread Alan
Dear Gurus of python one liner innovator I have about 150 lines of python extracting text from large file, the problem I need a few lines to clean first to avoid the problem the script is facing Overview There is large text and I am trying to organize it for the python script to process, it is ba

Re: [Tutor] lil help please - updated (fwd)

2005-11-24 Thread Danny Yoo
[Slightly busy at the moment; can someone else help? Alan, in the future, don't send replies directly to me: send them to the Tutor list. It's an ad-hoc way to load-balance your questions across all the tutors.] -- Forwarded message -- Date: Thu, 24 Nov 2005 03:55:00 -0600 From:

[Tutor] getattr of functions

2005-11-24 Thread Negroup -
Hi all! I'm here again with a question about introspection. My module stores a set of functions. I need to know, from another script, if a particular function of this module "is enabled" (it means, if it shall be executed by the caller script). I looked for some introspective builtin/function, but

Re: [Tutor] getattr of functions

2005-11-24 Thread Liam Clarke
What do you mean enabled? If it's imported into the namespace you can call it... Err, can you clarify on the enabling, what context are you using it in, and what are you trying to achieve? On 11/25/05, Negroup - <[EMAIL PROTECTED]> wrote: > Hi all! I'm here again with a question about introspec

Re: [Tutor] getattr of functions

2005-11-24 Thread Negroup -
2005/11/24, Liam Clarke <[EMAIL PROTECTED]>: > What do you mean enabled? > > If it's imported into the namespace you can call it... > > Err, can you clarify on the enabling, what context are you using it > in, and what are you trying to achieve? Hi, sorry. I'll try to present the actors omitting t

[Tutor] Modifying Source Code while Program is Running

2005-11-24 Thread Ed Singleton
Is it feasible to change a program's source code whilst it is running without having to restart the program? Is it feasible to get a program to change it's own source code while it is running? For example, if you have a web server such as CherryPy that will (hopefully) be running for months at a

Re: [Tutor] getattr of functions

2005-11-24 Thread Kent Johnson
Negroup - wrote: > Hi all! I'm here again with a question about introspection. > > My module stores a set of functions. I need to know, from another > script, if a particular function of this module "is enabled" (it > means, if it shall be executed by the caller script). I looked for > some intros

Re: [Tutor] Modifying Source Code while Program is Running

2005-11-24 Thread Kent Johnson
Ed Singleton wrote: > Is it feasible to change a program's source code whilst it is running > without having to restart the program? Is it feasible to get a > program to change it's own source code while it is running? > > For example, if you have a web server such as CherryPy that will > (hopefu

Re: [Tutor] Modifying Source Code while Program is Running

2005-11-24 Thread Ed Singleton
On 24/11/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Ed Singleton wrote: > > Is it feasible to change a program's source code whilst it is running > > without having to restart the program? Is it feasible to get a > > program to change it's own source code while it is running? > > > > For exampl

Re: [Tutor] sort list alphabetically

2005-11-24 Thread lmac
Ok. That's the point. I think i meant case-sensitive. There are some ways described here that will me help out. Yes, the list is sorted when i print it out. It was my fault, sorry guys. Thank you a lot. mac ___ Tutor maillist - Tutor@python.org http:/

Re: [Tutor] Pretty XML

2005-11-24 Thread Negroup -
2005/11/23, Greg Lindstrom <[EMAIL PROTECTED]>: > something that would read in my XML file and format it in a similar manner > to "pretty print" so I can verify the correct information is being pulled. > My immediate concern is to read in an XML stream from a file and format it > with indentatio

Re: [Tutor] Modifying Source Code while Program is Running

2005-11-24 Thread Kent Johnson
Ed Singleton wrote: > Hmmm, that's discouraging. Do you know if it's feasible to just keep > changes to code in memory synchronised with changes nto the source > code? So rather than reload source code, make sure that the source > code reflects what is running in memory? > > For example if your

Re: [Tutor] Modifying Source Code while Program is Running

2005-11-24 Thread Kent Johnson
Ed Singleton wrote: > Is it feasible to change a program's source code whilst it is running > without having to restart the program? Is it feasible to get a > program to change it's own source code while it is running? You can change a class while it is running. > > For example, if you have a we

Re: [Tutor] lil help please - updated (fwd)

2005-11-24 Thread Chris or Leslie Smith
| I have about 150 lines of python extracting text from large file, the | problem I need a few lines to clean first to avoid the problem the | script is facing Hello, This seems like a well laid out task. If you post what you are trying and the problems you are encountering, that would be helpfu

Re: [Tutor] TRULY NEWBIE - MENTOR NEEDED (fwd)

2005-11-24 Thread Danny Yoo
> I changed - and didnt get an executable, not sure what is supposed to be > the output. Hi Mike, The main way to run a Python program is to run it through its interpreter. That is, there's no need to build a separate executable: the source is the distributable. If you really need to make an .E

[Tutor] Convert integer number to binary representation

2005-11-24 Thread Alberto Troiano
Hey all I want to know how can I convert an integer number to a binary number. Like this example: +10 (decimal representationinteger) = 1010 (binary representation) Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mai

Re: [Tutor] reduce with comprehension

2005-11-24 Thread Alan Gauld
Hi John, > Everything is possible with list comprehensions! >>> [x for z in a for y in z for x in y] > [1, 2, 3, 31, 32, 4, 5, 6, 7, 71, 72, 8, 9] impressive! But in the general case can you do the same job as reduce in a list comprehension? ie apply an operation to the first two elements of

Re: [Tutor] TRULY NEWBIE - MENTOR NEEDED (fwd)

2005-11-24 Thread Alan Gauld
> I changed - and didnt get an executable, not sure what is supposed to be > the > output. I'm not sure what you expect to get, but an executable file is definitely not going to be it... >> > class String(str, Object): If you inherit from str you don't need to inherit from object since str alre

Re: [Tutor] Modifying Source Code while Program is Running

2005-11-24 Thread Alan Gauld
There are many ways of doing this, few of them very nice IMHO. > without having to restart the program? Is it feasible to get a > program to change it's own source code while it is running? Yes, you can overwrite an existing module then call reload from within the program. > For example, if yo

Re: [Tutor] Modifying Source Code while Program is Running

2005-11-24 Thread Alan Gauld
> For example if your program is running, and you make a change to a > class, is it possible to create the necessary class definition and > save it to a file? You can do that but even if you do follow the LSP closely, you still can have problems, especially when you subtract functions or data ra

Re: [Tutor] reduce with comprehension

2005-11-24 Thread John Fouhy
On 22/11/05, Alan Gauld <[EMAIL PROTECTED]> wrote: > But in the general case can you do the same job as > reduce in a list comprehension? ie apply an operation > to the first two elements of a sequence and replace > them with the result, then repeat until the list becomes > a single value? Well ..

Re: [Tutor] files - strings - lists

2005-11-24 Thread Andrzej Kolinski
  OK, I made some progress I think. I added a few lines to Kent's script to get closer what I really am after: == lines = open('liga050926.sbk')   # to get the data from a real file #lines = iter(data)  # getting data from a string, you don't need this whe

Re: [Tutor] reduce with comprehension

2005-11-24 Thread Nick Lunt
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > >>> def f(x, y): > ... return x + y > ... > >>> arr = range(10) > >>> sum(arr) # Our target > 45 > >>> tmp = [0] > >>> [f(x, y) for x in arr for y in [tmp[-1]] if tmp.append(f(x, > y)) or True][-1] >

Re: [Tutor] reduce with comprehension

2005-11-24 Thread John Fouhy
On 25/11/05, Nick Lunt <[EMAIL PROTECTED]> wrote: > > -Original Message- > > >>> def f(x, y): > > ... return x*y > > ... > > >>> arr = range(1, 10)# Don't want to include 0! > > >>> reduce(f, arr) # Our target > > 362880 > > >>> tmp = [1] > > >>> [f(x, y) for x in arr for y i

Re: [Tutor] reduce with comprehension

2005-11-24 Thread Alan Gauld
> But in the general case can you do the same job as > reduce in a list comprehension? >>> def f(x, y): ... return x + y ... >>> tmp = [0] >>> [f(x, y) for x in arr for y in [tmp[-1]] if tmp.append(f(x, y)) or >>> True][-1] 45 Let's try some more... >>> def f(x, y): ... return x*y ... >>> tmp

Re: [Tutor] Convert integer number to binary representation

2005-11-24 Thread John Fouhy
On 25/11/05, Alberto Troiano <[EMAIL PROTECTED]> wrote: > I want to know how can I convert an integer number to a binary number. > Like this example: Hi Alberto, There's no builtin function to do this (like there is for hex or oct). There are a few recipes in the Cookbook on ActiveState that wil

Re: [Tutor] lil help please - updated (fwd)

2005-11-24 Thread Kent Johnson
> From: Alan <[EMAIL PROTECTED]> > > I have about 150 lines of python extracting text from large file, the > problem I need a few lines to clean first to avoid the problem the > script is facing > > Overview > There is large text and I am trying to organize it for the python script > to process,

[Tutor] lil help please - updated (|H|F|R) (Chris or Leslie Smith) TASK1 one relocate/move

2005-11-24 Thread Alan
Smiles Thanks a thousands Let us do one task at a time= task 1 relocate/move any words in |H between (...) to the end of |R rating and before the next line of |H sorry the master python script wants one | before H and F and R in any place however some |H |F |R do not come in the beginning in