require ‘rubygems’

require ‘rubygems’ will adjust the Ruby loadpath allowing you to successfully require the gems you installed through rubygems, without getting a LoadError: no such file to load — sinatra. From the rubygems-1.3.6 documentation: When RubyGems is required, Kernel#require is replaced with our own which is capable of loading gems on demand. When you call require … Read more

How to do multiple imports in Python?

For known module, just separate them by commas: import lib1, lib2, lib3, lib4, lib5 If you really need to programmatically import based on dynamic variables, a literal translation of your ruby would be: modnames = “lib1 lib2 lib3 lib4 lib5”.split() for lib in modnames: globals()[lib] = __import__(lib) Though there’s no need for this in your … Read more

Is require File.expand_path(…, __FILE__) the best practice?

In Ruby 1.9.2 + require_relative is probably the more correct way to do it. require was changed to not include your ‘.’ directory for security reasons. require_relative was added to provide a local-file solution for modules relative to your calling script’s path. You can search here on StackOverflow, particularly in “What is require_relative in Ruby?”, … Read more

Check if an include (or require) exists

I believe file_exists does work with relative paths, though you could also try something along these lines… if(!@include(“script.php”)) throw new Exception(“Failed to include ‘script.php'”); … needless to say, you may substitute the exception for any error handling method of your choosing. The idea here is that the if-statement verifies whether the file could be included, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)