Re: code of a function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anand Patil

    Re: code of a function


    On May 29, 2008, at 9:38 AM, Gary Herron wrote:
    Dark Wind wrote:
    >Hi,
    >>
    >Is there any command in Python which gives the code for a function
    >like just typing the name of a function (say svd) in R returns its
    >code.
    >>
    >Thank you
    >
    Nope.
    If you're using IPython, you can do svd?? .

  • Alan Isaac

    #2
    Re: code of a function

    Anand Patil wrote:
    If you're using IPython, you can do svd?? .



    hth,
    Alan Isaac

    Comment

    • alex23

      #3
      Re: code of a function

      On May 30, 8:54 am, Alan Isaac <ais...@america n.eduwrote:
      Anand Patil wrote:
      If you're using IPython, you can do svd?? .
      >

      >
      hth,
      Alan Isaac
      That wasn't a question :) In IPython, '<entity>?' is roughly
      equivalent to 'help(<entity>) ', whereas '<entity>??' displays the
      code, if possible:

      IPython 0.8.2 -- An enhanced Interactive Python.
      ? -Introduction and overview of IPython's features.
      %quickref -Quick reference.
      help -Python's own help system.
      object? -Details about 'object'. ?object also works, ?? prints
      more.

      In [1]: from functools import wraps

      In [2]: wraps??
      Type: function
      Base Class: <type 'function'>
      String Form: <function wraps at 0x00CF31B0>
      Namespace: Interactive
      File: c:\python25\lib \functools.py
      Definition: wraps(wrapped, assigned=('__mo dule__', '__name__',
      '__doc__'), updated=('__dic t__',))
      Source:
      def wraps(wrapped,
      assigned = WRAPPER_ASSIGNM ENTS,
      updated = WRAPPER_UPDATES ):
      """Decorato r factory to apply update_wrapper( ) to a wrapper
      function

      Returns a decorator that invokes update_wrapper( ) with the
      decorated
      function as the wrapper argument and the arguments to wraps()
      as the
      remaining arguments. Default arguments are as for
      update_wrapper( ).
      This is a convenience function to simplify applying partial()
      to
      update_wrapper( ).
      """
      return partial(update_ wrapper, wrapped=wrapped ,
      assigned=assign ed, updated=updated )

      Which is very handy, like most of IPython.

      Comment

      • Pete Forman

        #4
        Re: code of a function

        alex23 <wuwei23@gmail. comwrites:
        Which is very handy, like most of IPython.
        +1 QOTW
        --
        Pete Forman -./\.- Disclaimer: This post is originated
        WesternGeco -./\.- by myself and does not represent
        pete.forman@wes terngeco.com -./\.- the opinion of Schlumberger or
        http://petef.22web.net -./\.- WesternGeco.

        Comment

        Working...