0

I am trying to use the rubypython gem. Not sure how to call standard python functions like len and set. In the python examples I see len(text3) and set(text3).

How do I call these in rubypython?

Here is the link to rubypython: http://rubypython.rubyforge.org/

nilanjan
  • 661
  • 3
  • 9
  • 18
  • Have you tried reading the documentation on that site? – khagler Dec 09 '12 at 03:08
  • I did read the overview, which had limited examples. Since I am not familar with python, kind of difficult to read the reference. Anyway, I found waht I was looking for - see below. – nilanjan Dec 11 '12 at 01:00

2 Answers2

2

Well, my Ruby knowledge is limited, and my knowledge of the rubypython gem is non-existent. However, I do know the standard functions you refer to a part of the __builtin__ module, which is automatically imported into the python namespace. Fortunately, there's nothing preventing you from importing it explicitly again (which is perfectly safe in Python). You then might be able do something like __builtin__.set(). No guarantees, though.

grainednoise
  • 261
  • 1
  • 1
  • Thanks. I managed to find a method to access the __builtin__ namespace. I can now call the standard python methods. The odds of posting here and finding the related information are probably close to 0 :-) – nilanjan Dec 11 '12 at 00:57
1

RubyPython::PyMainClass has a public instance method builtin() You can use that to call the standard functions.

nilanjan
  • 661
  • 3
  • 9
  • 18