An assimilators guide to Python?

Discussion in 'Ruby' started by Josef 'Jupp' SCHUGT, Feb 5, 2004.

  1. Hi!

    I now and then come across Python and Perl programs with permitting
    licenses that seemingly contain code I would like to assimilate. As
    far as Perl is concerned this is no problem, my knowledge of Perl is
    good enough (actually the development of rubric started with an
    assimilation of a Perl program :)

    The problem with Python is that Python's syntax looks awful to me
    and don't like the idea of learn more Python than necessary for
    assimilation. Is there an online Python tutorial that just describes
    the skeleton and what which function is good for?

    Josef 'Jupp' SCHUGT
    --
    http://oss.erdfunkstelle.de/ruby/ - German comp.lang.ruby-FAQ
    http://rubyforge.org/users/jupp/ - Ruby projects at Rubyforge
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    Germany 2004: To boldly spy where no GESTAPO / STASI has spied before
     
    Josef 'Jupp' SCHUGT, Feb 5, 2004
    #1
    1. Advertising

  2. il Thu, 5 Feb 2004 10:39:37 +0900, "Josef 'Jupp' SCHUGT" <>
    ha scritto::


    >The problem with Python is that Python's syntax looks awful to me
    >and don't like the idea of learn more Python than necessary for
    >assimilation. Is there an online Python tutorial that just describes
    >the skeleton and what which function is good for?


    look at the kanguage reference:
    http://python.org/doc/current/ref/ref.html
    that should explain you the basic syntax.

    About functions: just open python as interactive shell and use
    help()like this

    >>> help(str)

    Help on class str in module __builtin__:

    class str(basestring)
    | str(object) -> string
    |
    | Return a nice string representation of the object.
    | If the argument is a string, the return value is the same object.
    ....

    or

    >>> help([].sort)

    Help on built-in function sort:

    sort(...)
    L.sort(cmpfunc=None) -- stable sort *IN PLACE*; cmpfunc(x, y) ->
    -1, 0, 1


    (btw, why the hell list.sort() in python returns 'None' ?)
     
    gabriele renzi, Feb 5, 2004
    #2
    1. Advertising

  3. Irb Ri integration (Was: An assimilators guide to Python?)

    gabriele renzi wrote:

    > il Thu, 5 Feb 2004 10:39:37 +0900, "Josef 'Jupp' SCHUGT" <>
    > ha scritto::
    >
    >
    >
    >>The problem with Python is that Python's syntax looks awful to me
    >>and don't like the idea of learn more Python than necessary for
    >>assimilation. Is there an online Python tutorial that just describes
    >>the skeleton and what which function is good for?

    >
    >
    > look at the kanguage reference:
    > http://python.org/doc/current/ref/ref.html
    > that should explain you the basic syntax.
    >
    > About functions: just open python as interactive shell and use
    > help()like this
    >
    >
    >>>>help(str)

    >
    > Help on class str in module __builtin__:
    >
    > class str(basestring)
    > | str(object) -> string
    > |
    > | Return a nice string representation of the object.
    > | If the argument is a string, the return value is the same object.
    > ...
    >
    > or
    >
    >
    >>>>help([].sort)

    >
    > Help on built-in function sort:
    >
    > sort(...)
    > L.sort(cmpfunc=None) -- stable sort *IN PLACE*; cmpfunc(x, y) ->
    > -1, 0, 1
    >
    >
    > (btw, why the hell list.sort() in python returns 'None' ?)


    Now that we have alot of the standard docs in ri format available in
    general do we have any integration between ri and irb? That would be
    nice to be able to easily call them from within irb. I mean I suppose
    you could just call `ri Array` or whatever, but nonetheless it seems
    some integration is possible.

    Charles Comstock
     
    Charles Comstock, Feb 5, 2004
    #3
  4. Re: Irb Ri integration (Was: An assimilators guide to Python?)

    il Thu, 05 Feb 2004 04:49:19 -0600, Charles Comstock
    <> ha scritto::
    ?)
    >
    >Now that we have alot of the standard docs in ri format available in
    >general do we have any integration between ri and irb? That would be
    >nice to be able to easily call them from within irb. I mean I suppose
    >you could just call `ri Array` or whatever, but nonetheless it seems
    >some integration is possible.



    go vote 'in favor of rcr 197:
    http://rcrchive.net/rcr/RCR/RCR197

    ;)
     
    gabriele renzi, Feb 5, 2004
    #4
  5. Re: Irb Ri integration (Was: An assimilators guide to Python?)

    >
    > Now that we have alot of the standard docs in ri format available in
    > general do we have any integration between ri and irb? That would be
    > nice to be able to easily call them from within irb. I mean I suppose
    > you could just call `ri Array` or whatever, but nonetheless it seems
    > some integration is possible.
    >
    > Charles Comstock



    My wish ...

    module RDE
    #ruby development environment
    rde = %w(irb gems ri rdoc )
    end


    class vi_rad << vi
    include RDE
    end

    class emacs_rad << emacs
    include RDE
    end
     
    Bermejo, Rodrigo, Feb 5, 2004
    #5
  6. For a very straight-forward example, you might like to have
    a look at the html-parser library which is a line by line
    translation of the similarly-named module bundled with the
    python standard library.

    <http://raa.ruby-lang.org/list.rhtml?name=html-parser-2>
     
    Bernard Delmée, Feb 5, 2004
    #6
  7. Re: Irb Ri integration (Was: An assimilators guide to Python?)

    Charles Comstock wrote:
    > Now that we have alot of the standard docs in ri format available in
    > general do we have any integration between ri and irb? That would be
    > nice to be able to easily call them from within irb. I mean I suppose
    > you could just call `ri Array` or whatever, but nonetheless it seems
    > some integration is possible.


    Put something this in your .irbrc file:

    ==== .irbrc ====
    def ri arg
    puts `ri #{arg}`
    end

    class Module
    def ri(meth=nil)
    if meth
    if instance_methods(false).include? meth.to_s
    puts `ri #{self}##{meth}`
    else
    super
    end
    else
    puts `ri #{self}`
    end
    end
    end
    ===============

    Then you can do:

    irb> String.ri
    irb> ri String # same as above
    irb> String.ri 'reverse'
    irb> ri 'File.new'
     
    Joel VanderWerf, Feb 5, 2004
    #7
  8. Josef 'Jupp' SCHUGT

    Guest

    Re: Irb Ri integration (Was: An assimilators guide to Python?)

    I tried this and it works great!

    Thanks, Joel, for a most useful tip.

    Mark Lindsay

    On Fri, Feb 06, 2004 at 04:46:19AM +0900, Joel VanderWerf <> wrote:
    > Charles Comstock wrote:
    > >Now that we have alot of the standard docs in ri format available in
    > >general do we have any integration between ri and irb? That would be
    > >nice to be able to easily call them from within irb. I mean I suppose
    > >you could just call `ri Array` or whatever, but nonetheless it seems
    > >some integration is possible.

    >
    > Put something this in your .irbrc file:
    >
    > ==== .irbrc ====
    > def ri arg
    > puts `ri #{arg}`
    > end
    >
    > class Module
    > def ri(meth=nil)
    > if meth
    > if instance_methods(false).include? meth.to_s
    > puts `ri #{self}##{meth}`
    > else
    > super
    > end
    > else
    > puts `ri #{self}`
    > end
    > end
    > end
    > ===============
    >
    > Then you can do:
    >
    > irb> String.ri
    > irb> ri String # same as above
    > irb> String.ri 'reverse'
    > irb> ri 'File.new'
     
    , Feb 5, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Seberino
    Replies:
    21
    Views:
    1,679
    Stephen Horne
    Oct 27, 2003
  2. Ian Bicking
    Replies:
    2
    Views:
    1,026
    Steve Lamb
    Oct 23, 2003
  3. Ian Bicking
    Replies:
    2
    Views:
    730
    Michael Hudson
    Oct 24, 2003
  4. Maxim Khesin

    python style guide?

    Maxim Khesin, Dec 4, 2003, in forum: Python
    Replies:
    0
    Views:
    346
    Maxim Khesin
    Dec 4, 2003
  5. GHUM
    Replies:
    3
    Views:
    295
    Panzerlurch
    Apr 2, 2008
Loading...

Share This Page