Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100801
| From | Andrew Farrell <armorsmith42@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: need some basic help |
| Date | 2015-12-23 21:58 -0600 |
| Message-ID | <mailman.104.1450965772.2237.python-list@python.org> (permalink) |
| References | <90cc0071-7c78-4974-88ad-60ff89649c95@googlegroups.com> |
This code snippet is a method on a class. What is a method? This chapter of the book Think Python <http://www.greenteapress.com/thinkpython/html/thinkpython018.html> does a good job of explaining it. Without understanding this foundation, it isn't possible to really answer your question, so definitely read at least that chapter. Think Python was the book I first learned from and if you are new to python, I recommend it among the other python tutorials to consider. In this case, this method takes two things: 0) The object that it is a method of (by python convention, this is called "self") 1) a collection of message objects (probably a list, maybe a tuple, probably not a set) 2) a time It then, goes through all of them and tells each one "you were received at some particular time." by calling a method on each of the message objects. The object that it is a method of seems to have a list of messages it has received. So, this method sticks the collection of new message objects onto the list of already-received messages. On Wed, Dec 23, 2015 at 7:53 PM, Qurrat ul Ainy <qurratul.ainy1@gmail.com> wrote: > Hello, > > Can someone please explain this code below. I am new at Python . > Thanks > > > def receive_messages(self, msgs, time): > for msg in msgs: > msg.set_recv_time(time) > self.msgs_received.extend(msgs) > -- > https://mail.python.org/mailman/listinfo/python-list >
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
need some basic help Qurrat ul Ainy <qurratul.ainy1@gmail.com> - 2015-12-23 17:53 -0800
Re: need some basic help Benjamin Kulas <bkulbismuth@gmail.com> - 2015-12-23 20:24 -0800
Re: need some basic help Qurrat ul Ainy <qurratul.ainy1@gmail.com> - 2015-12-24 11:33 -0800
Re: need some basic help Qurrat ul Ainy <qurratul.ainy1@gmail.com> - 2015-12-24 11:38 -0800
Re: need some basic help Terry Reedy <tjreedy@udel.edu> - 2015-12-24 17:14 -0500
Re: need some basic help Steven D'Aprano <steve@pearwood.info> - 2015-12-24 22:58 +1100
Re: need some basic help Andrew Farrell <armorsmith42@gmail.com> - 2015-12-23 21:58 -0600
csiph-web