help() on stdout.closed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pekka Karjalainen

    #1

    help() on stdout.closed

    Python 2.4.1 (#1, May 16 2005, 15:19:29)
    [GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
    Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
    >>> from sys import stdout
    >>> help (stdout.closed)[/color][/color][/color]

    If I do this, it gives me help on the bool object. Also:
    [color=blue][color=green][color=darkred]
    >>> stdout.closed._ _doc__[/color][/color][/color]
    'bool(x) -> bool\n\nReturns True when the argument x is true, False
    otherwise.\nThe builtins True and False are the only two instances of the
    class bool.\nThe class bool is a subclass of the class int, and cannot be
    subclassed.'

    What's going on here? Other docstrings in sys.stdout work fine.

    Pekka (uses 2.4.3 on another comp)
  • Jon Ribbens

    #2
    Re: help() on stdout.closed

    In article <slrne9i5l7.j5t .pkarjala@lastu 30.oulu.fi>, Pekka Karjalainen wrote:[color=blue][color=green][color=darkred]
    >>>> from sys import stdout
    >>>> help (stdout.closed)[/color][/color]
    >
    > If I do this, it gives me help on the bool object.[/color]

    stdout.closed is a bool. What were you expecting it to show you?

    Comment

    • Fredrik Lundh

      #3
      Re: help() on stdout.closed

      Pekka Karjalainen wrote:
      [color=blue][color=green][color=darkred]
      >>>> from sys import stdout
      >>>> help (stdout.closed)[/color][/color]
      >
      > If I do this, it gives me help on the bool object.[/color]

      that's probably because "sys.stdout.clo sed" *is* a bool object:
      [color=blue][color=green][color=darkred]
      >>> sys.stdout.clos ed[/color][/color][/color]
      False[color=blue][color=green][color=darkred]
      >>> type(sys.stdout .closed)[/color][/color][/color]
      <type 'bool'>

      there's no way the reflection system can figure out how a given boolean was
      created; all it knows is that it gets an object of a given type.
      [color=blue]
      > Other docstrings in sys.stdout work fine.[/color]

      have you tried things like
      [color=blue][color=green][color=darkred]
      >>> help(sys.stdout .name)[/color][/color][/color]

      and
      [color=blue][color=green][color=darkred]
      >>> help(sys.stdout .write("hello") )[/color][/color][/color]

      ?

      </F>



      Comment

      • Pekka Karjalainen

        #4
        Re: help() on stdout.closed

        On 2006-06-21, Fredrik Lundh <fredrik@python ware.com> wrote:[color=blue]
        > have you tried things like[/color]
        [...]

        I have now. I'm not sure what the results are supposed to tell me, but I
        am not going to press the issue.

        Suppose I had no idea what sys.stdout.clos ed was and wanted to find out.
        Where would I look it up?

        Pekka


        Comment

        • Marc 'BlackJack' Rintsch

          #5
          Re: help() on stdout.closed

          In <slrne9ibq3.jer .pkarjala@lastu 30.oulu.fi>, Pekka Karjalainen wrote:
          [color=blue]
          > Suppose I had no idea what sys.stdout.clos ed was and wanted to find out.
          > Where would I look it up?[/color]

          `sys.stdout` is a file (like) object:



          Ciao,
          Marc 'BlackJack' Rintsch

          Comment

          • Fredrik Lundh

            #6
            Re: help() on stdout.closed

            Pekka Karjalainen wrote:
            [color=blue]
            > Suppose I had no idea what sys.stdout.clos ed was and wanted to find out.
            > Where would I look it up?[/color]
            [color=blue][color=green][color=darkred]
            >>> help(sys.stdout )[/color][/color][/color]
            ....
            | closed = <attribute 'closed' of 'file' objects>
            | True if the file is closed
            ....

            in case anyone feels like hacking, support for something like
            [color=blue][color=green][color=darkred]
            >>> help(sys.stdout , "closed")[/color][/color][/color]

            might be useful, I think.

            </F>



            Comment

            • Nick Craig-Wood

              #7
              Re: help() on stdout.closed

              Marc 'BlackJack' Rintsch <bj_666@gmx.net > wrote:[color=blue]
              > In <slrne9ibq3.jer .pkarjala@lastu 30.oulu.fi>, Pekka Karjalainen wrote:
              >[color=green]
              > > Suppose I had no idea what sys.stdout.clos ed was and wanted to find out.
              > > Where would I look it up?[/color]
              >
              > `sys.stdout` is a file (like) object:
              >
              > http://docs.python.org/lib/bltin-file-objects.html[/color]

              Since the OP is using linux he may prefer to look this up using
              "info". Info contains all the same stuff as the web pages and it is
              terminal friendly.

              To find the below I typed

              info
              CTRL-S pytho
              Cursor down to "Python2.3-lib:" and press ENTER
              CTRL-S closed
              CTRL-S, CTRL-S until correct entry found (the 4th one)

              ....

              File objects also offer a number of other interesting attributes.
              These are not required for file-like objects, but should be implemented
              if they make sense for the particular object.

              `closed'
              bool indicating the current state of the file object. This is a
              read-only attribute; the `close()' method changes the value. It
              may not be available on all file-like objects.

              --
              Nick Craig-Wood <nick@craig-wood.com> -- http://www.craig-wood.com/nick

              Comment

              Working...