Re: [Tutor] What is this [] construction?

2009-03-02 Thread Andre Engels
On Tue, Mar 3, 2009 at 4:54 AM, Wayne Watson wrote: > What is this: d = [ int(x) for x in s.split(":") ] > I see in the program I'm looking at, the [] construction can be much more > complicated, as in: >    self.recent_events = [ event for event in self.recent_events >    

Re: [Tutor] What is this [] construction?

2009-03-02 Thread John Fouhy
2009/3/3 Wayne Watson : > What is this: d = [ int(x) for x in s.split(":") ] It's a list comprehension: http://docs.python.org/tutorial/datastructures.html#list-comprehensions -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mail

[Tutor] What is this [] construction?

2009-03-02 Thread Wayne Watson
Title: Signature.html What is this: d = [ int(x) for x in s.split(":") ] I see in the program I'm looking at, the [] construction can be much more complicated, as in:    self.recent_events = [ event for event in self.recent_events    if os.path.exists(event) and

Re: [Tutor] Difference in minutes between two time stamps

2009-03-02 Thread Chris Fuller
Use time.strptime() to parse them into seconds since the start of epoch, and then an ordinary numeric subtraction will work. Cheers On Monday 02 March 2009 19:45, Judith Flores wrote: > Hello, > >I can't seem to figure out the syntax to calculate the difference in > minutes between two time

Re: [Tutor] Difference in minutes between two time stamps

2009-03-02 Thread John Fouhy
2009/3/3 Judith Flores : > > Hello, > >   I can't seem to figure out the syntax to calculate the difference in > minutes between two time stamps. I already read the documentation about > datetime and time modules, but I was unable to implement the code. > > My code will be fed with two timestamps

[Tutor] Difference in minutes between two time stamps

2009-03-02 Thread Judith Flores
Hello, I can't seem to figure out the syntax to calculate the difference in minutes between two time stamps. I already read the documentation about datetime and time modules, but I was unable to implement the code. My code will be fed with two timestamps (as styrings): start="09:35:23" end

Re: [Tutor] Add elements to list and display it [Very newbie question]

2009-03-02 Thread Kent Johnson
On Mon, Mar 2, 2009 at 5:36 PM, Network Administrator wrote: > I appreciate your explanation about the reserved word "list" as well as the > code you gently wrote to me. Now, I want to show everybody what I did: > > #!/usr/bin/env python > # > # This function fills any given li

Re: [Tutor] Add elements to list and display it [Very newbie question]

2009-03-02 Thread Network Administrator
Thanks, Eric for your help! I appreciate your explanation about the reserved word "list" as well as the code you gently wrote to me. Now, I want to show everybody what I did: #!/usr/bin/env python # # This function fills any given list # mylist = [] x = 0 while (x != 't2'):

Re: [Tutor] [Edited] Plug-in enabled Program

2009-03-02 Thread Alan Gauld
"Daniele" wrote have is how to adapt it to multiple plugins related to the same interface. There are a few approaches. There is a design pattern (facade from memory) that allows this but you can also implement the plugin calls as a list of objects. So instead of calling theInteface.foo

Re: [Tutor] [Edited] Plug-in enabled Program

2009-03-02 Thread Daniele
> -- Messaggio inoltrato -- > From: "Alan Gauld" > To: tu...@python.org > Subject: Re: [Tutor] Tutor Digest, Vol 61, Issue 3 > > OK, To do that you need to provide an intrerface in your code > that the plug-in can use. That is to say you must call a documented > set of functions/me

Re: [Tutor] Tutor Digest, Vol 61, Issue 3

2009-03-02 Thread Lie Ryan
Daniele wrote: >> From: W W >> Subject: Re: [Tutor] modular program > >>> Where can I find some "best practices" for writing modular programs? >>> I thought about a txt file containing function calls that my program will >>> parse and execute in order, or is it better just to execute every .py fi