Firstly, please ask programming questions on Stackoverflow unless they are specific to Unix/Linux shell programming.
Python doesn’t execute main
(or any other) function by default.
You can either just do:
#!/usr/bin/env python3 import sys sys.stdout.write("Hello")
or if you want to keep the function, but call it when the script is run:
#!/usr/bin/env python3 import sys def main(): sys.stdout.write("Hello") if __name__ == '__main__': main()
The second method should be used if you are going to import the script into some other file, but otherwise, use the first one.
Also, you can just use the Python print
function, which writes to stdout by default.
#!/usr/bin/env python3 print("Hello")
Related Posts:
- ping: google.com: Temporary failure in name resolution [closed]
- Docker System has not been booted with systemd as init system
- CentOS vs. Ubuntu [closed]
- How to install python3 version of package via pip on Ubuntu?
- Docker error : no space left on device
- How to establish ssh key pair when “Host key verification failed”
- localhost/phpinfo.php
- After installing with pip, “jupyter: command not found”
- gpg: no valid OpenPGP data found
- gpg: no valid OpenPGP data found
- E: Unable to locate package mongodb-org
- How to open the terminal in Atom?
- Valgrind permission denied on file
- nginx – nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
- ImportError: No module named ‘xlrd’
- How to install Boost on Ubuntu
- How to verify if nginx is running or not?
- pdflatex not found. pdflatex is needed for pdf output
- Nginx: stat() failed (13: permission denied)
- PIP Could not find any downloads that satisfy the requirement SQLAlchemy
- MySQL: How to reset or change the MySQL root password?
- Removing all installed OpenCV libs
- Vim: No write since last change, even though I changed the file
- How to kill a process on a port on ubuntu
- whats the meaning of curl “-s” and “-m”
- How do I ask apt-get to skip any interactive post-install configuration steps?
- How to view all ssl certificates in a bundle?
- How to remove the “installed manually” flag and revert to “automatically installed” with apt-get?
- How do I get apt-get to ignore some dependencies?
- How do I auto-start docker containers at system boot?
- How do I reattach to Ubuntu Server’s ‘do-release-upgrade’ process?
- How to determine JAVA_HOME on Debian/Ubuntu?
- How to start/stop iptables on Ubuntu?
- Which ports do I need to open in the firewall to use NFS?
- list all packages from a repository in ubuntu / debian
- dpkg-reconfigure: unable to re-open stdin: No file or directory
- How can I edit the welcome message when ssh start?
- How does Ubuntu keep track of the “System restart required” flag in motd?
- Amazon Linux vs. Ubuntu for Amazon EC2 [closed]
- Automate the installation of postfix on Ubuntu
- Best location to keep SSL certificates and private keys on Ubuntu servers?
- Why is ssh agent forwarding not working?
- SyntaxError: unexpected EOF while parsing
- How to use filter, map, and reduce in Python 3
- converting time from UTC to CST
- Use Gif Logo For Loading Screen In Kivy
- Praw & Discord.py: The bot keep sending the same meme. I want the bot to send different meme whenever it is asked
- How can I make a time delay in Python? [duplicate]
- Python – TypeError: ‘int’ object is not iterable
- Understanding the main method of python [duplicate]
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- How to open a file using the open with statement
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
- How to install pip with Python 3?
- What is the difference between rw+ and r+
- Convert bytes to a string
- How can I represent an ‘Enum’ in Python?
- Python – TypeError: ‘int’ object is not iterable
- Import Error: No module named numpy
- Python3 – ModuleNotFoundError: No module named ‘numpy’
- Relative imports – ModuleNotFoundError: No module named x
- Python: ‘ModuleNotFoundError’ when trying to import module from imported package
- Relative imports – ModuleNotFoundError: No module named x
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- How to uninstall a package installed with pip install –user
- How do I upgrade the Python installation in Windows 10?
- Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?
- not all arguments converted during string formatting.. NO % variables
- How do I use raw_input in Python 3
- Python Variable Declaration
- Relative imports in Python 3
- Relative imports in Python 3
- How do I split a string on a delimiter in Bash?
- How do I tell if a regular file does not exist in Bash?
- working of \n in python [duplicate]
- Pip freeze vs. pip list
- TypeError: list indices must be integers or slices, not list
- Best way to convert string to bytes in Python 3?
- Best way to convert string to bytes in Python 3?
- What does the list() function do in Python?
- TypeError: not all arguments converted during string formatting python
- PermissionError: [Errno 13] Permission denied
- ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
- How can I sandbox Python in pure Python?
- What is setup.py?
- How is Anaconda related to Python?
- Undefined function mysql_connect()
- PermissionError: [Errno 13] in Python
- ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
- How to run a PowerShell script
- How to find which version of TensorFlow is installed in my system?
- FileNotFoundError: [WinError 2] The system cannot find the file specified:
- Undefined function mysql_connect()
- ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
- Invalid character in identifier
- error: command ‘gcc’ failed with exit status 1 while installing eventlet
- Should I put #! (shebang) in Python scripts, and what form should it take?
- Why do you need to put #!/bin/bash at the beginning of a script file?
- error: command ‘gcc’ failed with exit status 1 while installing eventlet