[Twisted-Python] need explanation in tutorial

litnimax litnimax at fromru.com
Fri Aug 13 11:08:38 EDT 2004

Hi all, sorry for silly question.
I started learning twisted, and have a question.
(from evolving finger part 2)

class FingerSetterProtocol(basic.LineReceiver):
      def connectionMade(self): self.lines = []
      def lineReceived(self, line): self.lines.append(line)
      def connectionLost(self, reason):
          # first line: user    second line: status

What is "*self.lines[:2]"?
Why is there asterisk?
If I remove * from parameters, I get functions take 2 arguments.
  From python I know that if parameter is coming with *, that means a tuple
of parameters, if with ** - dict of parameters.

>>> a
{1: '22'}
>>> a.__setitem__(*[1,'22222'])
>>> a
{1: '22222'}
>>> *[1,'22']
    File "<stdin>", line 1
SyntaxError: invalid syntax

How this code is working!!??  :))
How can *[1,'22'] work??

Thanks much in advance :)

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/

More information about the Twisted-Python mailing list