Movatterモバイル変換
[0]ホーム
why does activestate (win98) python not support globbing
Robert AmeszrcameszREMOVETHIS at dds.removethistoo.nl
Fri Apr 13 19:28:59 EDT 2001
Steve Holden wrote:>If you *don't* glob by default then Unix works OK. But DOS/Windows>passes you unglobbed names, expecting you to glob them, so you don't>find the files.>>Perhaps I should have said "ugly"? The environments aren't>consistent"Ugly" describes it to a tee, I'd say. You'd need to test in which environment your script is running, and glob only if you're in a non-globbing environment.Lets see... The standard os.py checks for 'posix', 'nt', 'dos', 'os2', 'mac' and 'ce' environments. I'm not 100% sure, so correct me if I'm wrong, but of those I believe only posix globs. That would present us a solution of limited ugliness:import sys,globdef GetGlobbedArgs(): if 'posix' in sys.builtin_module_names: return sys.argv first = 1 for name in sys.argv: if first: newargs = [name] first=0 else: newargs.append(glob.glob(name)) return newargs(It's untested so caveats apply in full.)Wouldn't it be a good idea to have a function like that somewhere in the standard library?>but-when-did-vendors-try-to-be-consistent-ly y'rs ->[Ss][Tt][Ee][Vv][Ee]Hey, a regex'ed, case insensitive first name! Why not make it into [Ss][Tt][Ee]+[Vv][Ie]?[Ee] In that case it also matches the way your mother used to call you when dinner was ready. <g>Robert Amesz-- Sorry, couldn't resist
More information about the Python-listmailing list
[8]ページ先頭