Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > An assimilators guide to Python?

Reply
Thread Tools

An assimilators guide to Python?

 
 
Josef 'Jupp' SCHUGT
Guest
Posts: n/a
 
      02-05-2004
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


 
Reply With Quote
 
 
 
 
gabriele renzi
Guest
Posts: n/a
 
      02-05-2004
il Thu, 5 Feb 2004 10:39:37 +0900, "Josef 'Jupp' SCHUGT" <(E-Mail Removed)>
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' ?)
 
Reply With Quote
 
 
 
 
Charles Comstock
Guest
Posts: n/a
 
      02-05-2004
gabriele renzi wrote:

> il Thu, 5 Feb 2004 10:39:37 +0900, "Josef 'Jupp' SCHUGT" <(E-Mail Removed)>
> 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
 
Reply With Quote
 
gabriele renzi
Guest
Posts: n/a
 
      02-05-2004
il Thu, 05 Feb 2004 04:49:19 -0600, Charles Comstock
<(E-Mail Removed)> 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


 
Reply With Quote
 
Bermejo, Rodrigo
Guest
Posts: n/a
 
      02-05-2004
>
> 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











 
Reply With Quote
 
Bernard Delmée
Guest
Posts: n/a
 
      02-05-2004
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>

 
Reply With Quote
 
Joel VanderWerf
Guest
Posts: n/a
 
      02-05-2004
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'




 
Reply With Quote
 
ppi@amug.org
Guest
Posts: n/a
 
      02-05-2004
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 <(E-Mail Removed)> 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'



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mikhailtech Basic System Buyer's Guide - July 2005 Silverstrand Front Page News 0 07-27-2005 01:03 AM
AMD Athlon 64, 64 FX, x2 dual-core, Sempron processor guide Silverstrand Front Page News 0 07-25-2005 01:28 PM
Windows Desktop Heap Tweak Guide Posted! Silverstrand Front Page News 0 07-20-2005 10:46 PM
ATI PCIe Video Card Buyer's Guide at XYZ Computing Silverstrand Front Page News 1 06-27-2005 05:38 AM
Basic System Buyer's Guide - June 2005 Silverstrand Front Page News 0 06-22-2005 03:31 AM



Advertisments