Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74025

Re: Why is it different from the example on the tutorial?

Newsgroups comp.lang.python
Date 2014-07-06 08:53 -0700
References <f949d1c4-98c4-417f-9abc-58fe72b4c0a0@googlegroups.com> <mailman.11537.1404651349.18130.python-list@python.org> <c8f935e5-cd8f-4589-a70c-b172a985e22b@googlegroups.com> <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> <roy-3DFFFC.10344406072014@news.panix.com>
Message-ID <6fd77d6a-3487-474b-bb96-8da6ab8008f5@googlegroups.com> (permalink)
Subject Re: Why is it different from the example on the tutorial?
From Rick Johnson <rantingrickjohnson@gmail.com>

Show all headers | View raw


On Sunday, July 6, 2014 9:34:44 AM UTC-5, Roy Smith wrote:

> * You can print dict(foo), which just prints out the attributes the 
> object has.

Looks like a typo there. 

I think you probably meant to say "dir(foo)"

============================================================
 INTERACTIVE SESSION: Python 2.x
============================================================
py> l = range(5)
py> l
[0, 1, 2, 3, 4]
py> dict(l)
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    dict(l)
TypeError: cannot convert dictionary update sequence element #0 to a sequence
py> dir(l)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
'__delslice__', '__doc__', '__eq__', '__format__', '__ge__',
'__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__',
'__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__',
'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
'__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__',
'__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend',
'index', 'insert', 'pop', 'remove', 'reverse', 'sort']



Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why is it different from the example on the tutorial? rxjwg98@gmail.com - 2014-07-06 05:13 -0700
  Re: Why is it different from the example on the tutorial? Tim Chase <python.list@tim.thechases.com> - 2014-07-06 07:54 -0500
    Re: Why is it different from the example on the tutorial? rxjwg98@gmail.com - 2014-07-06 06:38 -0700
      Re: Why is it different from the example on the tutorial? Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-06 07:18 -0700
        Re: Why is it different from the example on the tutorial? Roy Smith <roy@panix.com> - 2014-07-06 10:34 -0400
          Re: Why is it different from the example on the tutorial? Chris Angelico <rosuav@gmail.com> - 2014-07-07 00:45 +1000
          Re: Why is it different from the example on the tutorial? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-06 15:47 +0100
          Re: Why is it different from the example on the tutorial? Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-06 08:53 -0700
            Re: Why is it different from the example on the tutorial? Roy Smith <roy@panix.com> - 2014-07-06 12:01 -0400
        Re: Why is it different from the example on the tutorial? rxjwg98@gmail.com - 2014-07-06 08:03 -0700
          Re: Why is it different from the example on the tutorial? Peter Otten <__peter__@web.de> - 2014-07-06 17:46 +0200
          Re: Why is it different from the example on the tutorial? Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-06 09:02 -0700
          Re: Why is it different from the example on the tutorial? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-06 19:29 +0100
          Re: Why is it different from the example on the tutorial? Larry Hudson <orgnut@yahoo.com> - 2014-07-06 13:32 -0700
            Re: Why is it different from the example on the tutorial? rxjwg98@gmail.com - 2014-07-06 13:42 -0700
      Re: Why is it different from the example on the tutorial? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-06 15:25 +0100
  Re: Why is it different from the example on the tutorial? Rustom Mody <rustompmody@gmail.com> - 2014-07-06 09:01 -0700

csiph-web