May-02-2017, 08:25 PM
Hi there,
First post here, i've been messing around with Python for a while now and recently decided to do an online class about it. I've been doing fine with all lessons and have been able to figure out/overcome most problems/questions I've ran into but now I'm stuck. In this one we're working with iters and creating a simple code to open a list of all .py files in terminal. The code he used was:
sh: dir: command not found
Traceback (most recent call last):
File "/users/james/python/otheriters.py", line 7, in <module>
print(next(fileit))
StopIteration
I'm very lost and am wondering if the sequence is different on a mac or what?? As I said, I relatively new to Python but have been loving working with it recently and really any help is appreciated. I am using Python 2.7.10 and running in Terminal on a Mac.
Thank you
First post here, i've been messing around with Python for a while now and recently decided to do an online class about it. I've been doing fine with all lessons and have been able to figure out/overcome most problems/questions I've ran into but now I'm stuck. In this one we're working with iters and creating a simple code to open a list of all .py files in terminal. The code he used was:
import os files = os.popen('dir *.py') fileit = iter(files) print(next(fileit))And when he saves it and runs it whatever is equivalent to terminal on a PC, it lists all of the .py files with no question. When I run it i get the follow error message in terminal:
sh: dir: command not found
Traceback (most recent call last):
File "/users/james/python/otheriters.py", line 7, in <module>
print(next(fileit))
StopIteration
I'm very lost and am wondering if the sequence is different on a mac or what?? As I said, I relatively new to Python but have been loving working with it recently and really any help is appreciated. I am using Python 2.7.10 and running in Terminal on a Mac.
Thank you