On 9/22/06, Steve Nelson <[EMAIL PROTECTED]> wrote: > In the end I just did: > > def fsUsage(dir): > """Returns the % usage of a given filesystem""" > stat = os.statvfs(dir) > from statvfs import F_BLOCKS, F_BFREE > total = stat[F_BLOCKS] > avail = stat[F_BFREE] > used = total-avail > percent = used/total*100 > return percent
Can someone explain how I manged to import F_BLOCKS and F_BFREE? I want to do the same with pwd and grp: >>> gstat = grp.getgrgid(1) >>> dir(gstat) ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__str__', 'gr_gid', 'gr_mem', 'gr_name', 'gr_passwd', 'n_fields', 'n_sequence_fields', 'n_unnamed_fields'] >>> gstat[0] 'staff' >>> gstat[GR_GID] Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'GR_GID' is not defined What's the difference? It just seems that specifying the location in the tuple is not very clear or self-documenting, and using GR_GID is better. S. > S. > > > > hope this helps a little! > > -- wesley > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > "Core Python Programming", Prentice Hall, (c)2007,2001 > > http://corepython.com > > > > wesley.j.chun :: wescpy-at-gmail.com > > python training and technical consulting > > cyberweb.consulting : silicon valley, ca > > http://cyberwebconsulting.com > > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor