一番長いコマンド名

30分プログラム、その697。http://gauc.no-ip.org/awk-users-jp/blis.cgi/DoukakuAWK_239からの逆輸入です。
一番、長いコマンド名を探してみましょう。

使い方

$ python longest-command.py
powerpc-apple-darwin9.7.0-gfortran-mp-4.3

あー、アーキテクチャ名が付くと長くなるのはしょうがないよね。

ソースコード

#! /usr/bin/python
# -*- mode:python; coding:utf-8 -*-
#
# longest-command.py -
#
# Copyright(C) 2009 by mzp
# Author: MIZUNO Hiroki / mzpppp at gmail dot com
# http://howdyworld.org
#
# Timestamp: 2009/11/18 21:41:38
#
# This program is free software; you can redistribute it and/or
# modify it under MIT Lincence.
#

import sys
import os

def append_map(f,xs):
    for x in xs:
        for y in f(x):
            yield y

print max(append_map(os.listdir,
                     os.environ['PATH'].split(':')),
          key=len)