In python after imports, one can see the file, that has been loaded/where the module comes from.
>>> import os
>>> os.__file__
'/Users/tm/lib/python2.6/os.pyc'
What would be the equivalent in ruby?
>> require 'xmlrpc/client'
=> true
>> ...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s nothing exactly equivalent.
All files that have been
requiredare listed in$LOADED_FEATURESin the order they wererequired. So, if you want to know where a file came from directly after it wasrequired, you simply need to look at the end:However, unless you record every call to
requireit’s going to be hard to figure out which entry corresponds to which call. Also, if a file is already in$LOADED_FEATURES, it will not get loaded again:Also, many libraries aren’t contained in a single file. So, the
required files might themselves contain calls torequire. In my case, for example,require 'yaml'not only loadsyaml.rbbut a whole bunch of files (15 to be exact):C:/Program Files/Ruby/lib/ruby/1.9.1/i386-mingw32/stringio.soC:/Program Files/Ruby/lib/ruby/1.9.1/i386-mingw32/syck.soC:/Program Files/Ruby/lib/ruby/1.9.1/syck/error.rbC:/Program Files/Ruby/lib/ruby/1.9.1/syck/basenode.rbC:/Program Files/Ruby/lib/ruby/1.9.1/syck/syck.rbC:/Program Files/Ruby/lib/ruby/1.9.1/syck/tag.rbC:/Program Files/Ruby/lib/ruby/1.9.1/syck/stream.rbC:/Program Files/Ruby/lib/ruby/1.9.1/syck/constants.rbC:/Program Files/Ruby/lib/ruby/1.9.1/date/format.rbC:/Program Files/Ruby/lib/ruby/1.9.1/date.rbC:/Program Files/Ruby/lib/ruby/1.9.1/syck/rubytypes.rbC:/Program Files/Ruby/lib/ruby/1.9.1/syck/types.rbC:/Program Files/Ruby/lib/ruby/1.9.1/yaml/syck.rbC:/Program Files/Ruby/lib/ruby/1.9.1/syck.rbC:/Program Files/Ruby/lib/ruby/1.9.1/yaml.rb