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


Groups > comp.lang.python > #28116

Re: Beginners question

References <k1nk8s$3l4$1@speranza.aioe.org> <mailman.3964.1346328894.4697.python-list@python.org> <k1nnj1$cal$1@speranza.aioe.org>
Date 2012-08-30 23:06 +1000
Subject Re: Beginners question
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3969.1346331996.4697.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Aug 30, 2012 at 10:50 PM,  <boltar2003@boltar.world> wrote:
> On Thu, 30 Aug 2012 13:14:57 +0100
> MRAB <python@mrabarnett.plus.com> wrote:
>>What don't you ask Python? I'm sure you'' get something like this:
>>
>> >>> type(s)
>><class 'posix.stat_result'>
>
> Umm , no I don't.
>
>>>> type(s)
> <type 'posix.stat_result'>
>
> Which isn't terrible helpful.

That's actually the same thing, except for a slight difference between
Python 2 and Python 3.

> If its a class , why is it when I create my own class I get a completely
> different output with print and type?
>
>>>>
>>>> class foo(object):
> ..     def __init__(self):
> ..             pass
> ..
>>>> f=foo()
>>>> print f
> <__main__.foo object at 0xb743956c>
>>>> type(f)
> <class '__main__.foo'>

Yep, you're using Python 2. A few things are subtly different. Unless
you have good reason not to, do consider moving to Python 3; all sorts
of things are easier. Python 2 is basically not being developed any
more.

http://www.python.org/dev/peps/pep-0404/

Alternatively, accept that what people are going to quote to you here
may be slightly different from what you see.

In any case, Python's introspection facilities and help() features are
available on both branches, so most of what has been said in this
thread still applies.

ChrisA

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


Thread

Beginners question boltar2003@boltar.world - 2012-08-30 11:54 +0000
  Re: Beginners question MRAB <python@mrabarnett.plus.com> - 2012-08-30 13:14 +0100
    Re: Beginners question Roy Smith <roy@panix.com> - 2012-08-30 08:23 -0400
    Re: Beginners question boltar2003@boltar.world - 2012-08-30 12:50 +0000
      Re: Beginners question Chris Angelico <rosuav@gmail.com> - 2012-08-30 23:06 +1000
        Re: Beginners question boltar2003@boltar.world - 2012-08-30 13:16 +0000
      Re: Beginners question Dave Angel <d@davea.name> - 2012-08-30 09:23 -0400
      Re: Beginners question Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-08-30 14:30 +0100
      Re: Beginners question Terry Reedy <tjreedy@udel.edu> - 2012-08-30 14:22 -0400
  Re: Beginners question Dave Angel <d@davea.name> - 2012-08-30 08:25 -0400
    Re: Beginners question boltar2003@boltar.world - 2012-08-30 12:53 +0000
  Re: Beginners question Chris Angelico <rosuav@gmail.com> - 2012-08-30 22:32 +1000
  Re: Beginners question Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-30 14:49 +0200
    Re: Beginners question Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-30 16:41 +0200
    Re: Beginners question Hans Mulder <hansmu@xs4all.nl> - 2012-08-30 17:38 +0200
  Re: Beginners question charvigroups@gmail.com - 2012-09-04 23:28 -0700
    Re: Beginners question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-05 09:03 +0100
    Re: Beginners question Dave Angel <d@davea.name> - 2012-09-05 09:21 -0400

csiph-web