function inclusion problem
Chris Angelico
rosuav at gmail.com
Wed Feb 11 10:37:16 EST 2015
On Thu, Feb 12, 2015 at 2:07 AM, Dave Angel <d at davea.name> wrote:
> Similarly, if you import from more than one module, and use the import*
> form, they could conflict with each other. And the order of importing will
> (usually) determine which names override which ones.
Never mind about conflicts and order of importing... just try figuring
out code like this:
from os import *
from sys import *
from math import *
# Calculate the total size of all files in a directory
tot = 0
for path, dirs, files in walk(argv[1]):
# We don't need to sum the directories separately
for f in files:
# getsizeof() returns a value in bytes
tot += getsizeof(f)/1024.0/1024.0
print("Total directory size:", floor(tot), "MB")
Now, I'm sure some of the experienced Python programmers here can see
exactly what's wrong. But can everyone? I doubt it. Even if you run
it, I doubt you'd get any better clue. But if you could see which
module everything was imported from, it'd be pretty obvious.
ChrisA
More information about the Python-list
mailing list