# Python for Ruby programmers

**URL:** <https://www.ruby-forum.com/t/python-for-ruby-programmers/76330>\
**Category:** Ruby\
**Created:** [March 3, 2006, 7:29pm UTC](https://www.ruby-forum.com/t/python-for-ruby-programmers/76330 "2006-03-03T19:29:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [March 3, 2006, 7:29pm UTC](https://www.ruby-forum.com/t/python-for-ruby-programmers/76330/1 "2006-03-03T19:29:23Z")

</div>

Hi,

I need to write a GUI for a vanilla RHEL3 box (with no extra software  
installed on it). I figure Python / pygtk2 is a good choice for this,  
as it’s installed by default. (Ruby is 1.6.8 on that box, and  
ruby-gnome2 isn’t installed). The GUI will do various RPM-related  
things – it’s a program that will examine a machine’s configuration  
and figure out what additional RPMs need to be installed before a user  
can run our software.

I don’t know much python, although I did write a small program in it a  
few years ago. Any pointers on where I could get a quick introduction  
to it? I don’t need an introduction to programming, I need an  
introduction to Python (and preferably from a Rubyist POV).

Joe

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [March 3, 2006, 11:49pm UTC](https://www.ruby-forum.com/t/python-for-ruby-programmers/76330/2 "2006-03-03T23:49:53Z")

</div>

On 3/3/06, Joe Van D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I don’t know much python, although I did write a small program in it a  
> few years ago. Any pointers on where I could get a quick introduction  
> to it? I don’t need an introduction to programming, I need an  
> introduction to Python (and preferably from a Rubyist POV).

What’s the Ruby equivalent of this?

for f in filter(lambda f: f(-1)\>=f(1),  
[lambda x:x, lambda x:x **2, lambda x:x** 3]):  
for x in range(-10, 11):  
print x, f(x)

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [March 3, 2006, 11:55pm UTC](https://www.ruby-forum.com/t/python-for-ruby-programmers/76330/3 "2006-03-03T23:55:55Z")

</div>

Joe Van D. wrote:

> > 
> 
> ```
> print x, f(x)
> 
> ```

-10.upto(10){ |n| puts “#{n} #{n\*\*2}” }

> 🙂

Dan

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [March 4, 2006, 12:20am UTC](https://www.ruby-forum.com/t/python-for-ruby-programmers/76330/4 "2006-03-04T00:20:14Z")

</div>

On Mar 3, 2006, at 5:47 PM, Joe Van D. wrote:

> > user
> 
> for f in filter(lambda f: f(-1)\>=f(1),  
> [lambda x:x, lambda x:x **2, lambda x:x** 3]):  
> for x in range(-10, 11):  
> print x, f(x)

Well after struggling with mapping the results of the code to the  
meaning I came up with this, which is pretty much a “word-for-word”  
translation to ruby:

[lambda { |x| x }, lambda { |x| x **2 }, lambda { |x| x** 3 }].select  
{ |f| f.call(-1) \>= f.call(1) }.each do |f|  
(-10…11).each do |x|  
puts “#{x} #{f.call(x)}”  
end  
end
