Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Cross-platform Functions Instead of Linux Only Shell Commands #73

Closed
BSalita opened this issue Dec 28, 2017 · 5 comments
Closed

Use Cross-platform Functions Instead of Linux Only Shell Commands #73

BSalita opened this issue Dec 28, 2017 · 5 comments

Comments

@BSalita
Copy link

BSalita commented Dec 28, 2017

There's a few places in Lesson 1 that uses Linux-only shell commands. This is an issue for Windows users. Why not use platform independent code? For example:

Linux only: !ls {PATH}
Cross-platform: os.listdir(PATH)

Linux only: !ls {PATH}valid
Cross-platform: os.listdir(PATH + 'valid')

Linux only: files = !ls {PATH}valid/cats | head
Cross-platform: files = os.listdir(PATH + 'valid/cats')

Linux only: !rm -rf {PATH}tmp
Cross-platform: os.removedirs(PATH + 'tmp')

@ChrisPalmerNZ
Copy link

ChrisPalmerNZ commented Dec 28, 2017

I agree with this comment, but what is the cross-platform version of this? (from the lesson4-IMDB notebook)
!find {TRN} -name '*.txt' | xargs cat | wc -w

@BSalita
Copy link
Author

BSalita commented Dec 28, 2017

May I answer a question with a question??? How would you perform this operation if shell commands weren't implemented in jupyter?

@ChrisPalmerNZ
Copy link

I don't know how - which is why I asked the original question :) - I guess I would have to write some Python code to do it...

@BSalita
Copy link
Author

BSalita commented Dec 29, 2017

Right. So far I'm able to code one-to-one replacements of non-portable shell commands with os functions. The example you gave requires some python code to replace the non-portable shell command. The downside of using shell commands is lack of portability which is problematic for a MOOC audience.

@jph00
Copy link
Member

jph00 commented Jan 5, 2018

I'd be happy to accept a PR that replaced shell commands with python x-platform equivalents :)

@jph00 jph00 closed this as completed Jan 23, 2018
kevinbird15 pushed a commit to ProblemSolversGuild/fastai that referenced this issue Mar 3, 2022
add docments to 33_text.models.core notebook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants