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

Support both mac and windows in the same file #3

Open
bowbahdoe opened this issue Jun 8, 2018 · 1 comment
Open

Support both mac and windows in the same file #3

bowbahdoe opened this issue Jun 8, 2018 · 1 comment

Comments

@bowbahdoe
Copy link

You can import put platform specific code behind an if that will only execute if you are on a specific os.

This post on stackoverflow should be a good reference.

This way people can run the same file regardless of their machine.

Feel free to reach out with questions about this or anything else related to python; I am always happy to help.

@Nebulino
Copy link

Nebulino commented Jun 13, 2018

I suggest to use platform
For example:

import platform
os_used = platform.system()

# Other code... Now Check what kind of OS we are running

if os_used == "Windows":
# Do something for windows...
pass
elif os_used == "Darwin":
# Do something for Mac OS...
pass
elif os_used == "Linux":
# Do something for Mac OS...
pass

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

2 participants