markpasc (markpasc) wrote,
markpasc
markpasc

  • Music:

Python r0xx0rz j00r Perl d00d

AKA "Why list comprehensions are an affront to Pythonicity:"

from imp import get_suffixes
extensions = [suffix[0] for suffix in get_suffixes()]
 
from os import listdir
from imp import find_module, load_module
for f in [f[:f.rfind('.')] for f in listdir(__path__[0]) if not f.startswith('_') and f[f.rfind('.'):] in extensions]:
    apply(load_module, (f,) + find_module(f, __path__))

I also find it funny that there's an imp.get_magic function. But I'm like that, amn't I?

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 6 comments