Skip to content

Commit 5fb9f04

Browse files
committed
move folder
1 parent 337da75 commit 5fb9f04

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

‎python_code_tips/misc/example1.py‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#! /usr/bin/env python
2+
"""Example Python script.
3+
4+
Copyright (c) 2018 Cisco and/or its affiliates."""
5+
6+
import os
7+
8+
def say_hello(name):
9+
"""Function that will say hello to someone.
10+
"""
11+
12+
# Print out a hello message to the name given
13+
print("Hello there {name}. It's great to see you.".format(name = name))
14+
15+
16+
17+
def script_details():
18+
"""Function that reports by printing to screen some details about the execution of the script."""
19+
# Get the current directory and print it out.
20+
cur_dir = os.getcwd()
21+
print("Current directory is {}".format(cur_dir))
22+
23+
# Get the User ID and Group List for the User
24+
user_id = os.getuid()
25+
group_list = os.getgroups()
26+
27+
# Print to screen
28+
print("The user id is {}".format(user_id))
29+
print("The user is a member of the following groups:")
30+
print(",".join(str(g) for g in group_list))
31+
32+
33+
if __name__ == "__main__":
34+
# If executed as a script, run this block.
35+
36+
# Check Script details
37+
script_details()
38+
39+
# List of names, and say hello to them
40+
names = ["Hank","Eric","Stuart","Bryan"]
41+
for name in names:
42+
say_hello(name)

0 commit comments

Comments
 (0)