Question about glob.glob <--newbie

Heather Coppersmith me at privacy.net
Tue May 4 06:41:37 EDT 2004


On Mon, 03 May 2004 23:09:27 -0400,
cookedm+news at physics.mcmaster.ca (David M. Cooke) wrote:

> At some point, "Sean Berry" <sean_berry at cox.net> wrote:
>>>>> r = glob.glob('/*')
>>>>> r
>> ['/dev', '/usr', '/stand', '/etc', '/cdrom', '/proc', '/bin', '/boot',
>> '/mnt', '/modules', '/root', '/sbin', '/tmp', '/var', '/sys', '/COPYRIGHT',
>> '/kernel.GENERIC', '/kernel', '/compat', '/home', '/kernel.old',
>> '/modules.old']
>>>>> 
>>>>> r = glob.glob('/usr/websites/*')
>>>>> r
>> []
>> 
>> I can do a
>>>>> import os
>>>>> dirs = os.system('ls /usr/websites')
>> 
>> and that works.  Why doesn't glob.glob work on /usr/websites?

> Somehow, I doubt that actually works. I'll bet that dirs == 0 -- os.system
> returns the status code of the command, not the output. You'll want
> commands.getoutput.

> What are the permissions on /usr/websites? What does 'ls -l
> /usr/websites' and 'ls -ld /usr/websites' give?

Possibly picking a nit, but is there a difference between 'ls
/usr/websites' (without the trailing slash) and 'ls /usr/websites/'
(with the trailing slash)?  Some OS's do strange things with some
symbolic links and/or mount points based on the presence/absence of that
slash.

HTH,
Heather

-- 
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli



More information about the Python-list mailing list