An assimilators guide to Python?

  • Thread starter Josef 'Jupp' SCHUGT
  • Start date
J

Josef 'Jupp' SCHUGT

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
 
G

gabriele renzi

il Thu, 5 Feb 2004 10:39:37 +0900, "Josef 'Jupp' SCHUGT" <[email protected]>
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 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 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' ?)
 
C

Charles Comstock

gabriele said:
il Thu, 5 Feb 2004 10:39:37 +0900, "Josef 'Jupp' SCHUGT" <[email protected]>
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 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 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
 
G

gabriele renzi

il Thu, 05 Feb 2004 04:49:19 -0600, Charles Comstock
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

;)
 
B

Bermejo, Rodrigo

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
 
J

Joel VanderWerf

Charles said:
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'
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top