Skip to content

Commit d1b27b7

Browse files
committed
module, venv, pip
1 parent 15328f3 commit d1b27b7

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

Python-Functions/intro.py

+8
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@ def student_info(*args, **kwargs):
4343
# print(**info)
4444

4545
student_info(*courses, **info)
46+
47+
48+
def hello_func(greeting, name="you"):
49+
return "{}, {}".format(greeting, name)
50+
51+
52+
print(hello_func("hello"))
53+
print(hello_func("hello", "Corey"))

Python-Imports/intro.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import sys
22

3-
# not the best way to add path
3+
# not the best way to add module path
44
sys.path.append("d:\\code_snippets\\Python-Imports\\modules")
55

6+
# in windows https://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-so-it-finds-my-modules-packages
7+
8+
9+
# this is the path, where python will look for modules to import
610
print(sys.path)
711

812
# import my_module as mm
913

1014
from my_module import find_index as fi, test
1115

12-
13-
# from my_module import * dont do that
16+
# dont do that, because we have hard time to know where the funtions come from
17+
# from my_module import *
1418

1519
courses = ["History", "Math", "Physics", "CompSci"]
1620

1721
# index = mm.find_index(courses, "Math")
1822
index = fi(courses, "History")
1923

20-
print(index)
24+
print("find history", index)
2125

2226
print(test)
23-
24-
# this is the path, where python will look for modules to import
25-
print(sys.path)

pip.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pip list -o
44
pip list --outdated
55

66

7-
7+
# give someone a lit of all the packages
88
pip freeze > requirements.txt
99

1010
pip install -r requirements.txt

venv.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
https://www.youtube.com/watch?v=N5vscPTWKOk&list=PL-osiE80TeTt2d9bfVyTiXJA-UTHn6WwU&index=14
2+
3+
pip list
4+
pip list -o
5+
6+
pip install virtualenv
7+
8+
9+
cd any folder
10+
11+
virtualenv project_1
12+
13+
project_1\Scripts\activate
14+
15+
deactivate
16+
17+
#export modules
18+
pip freeze --local > requirements.txt
19+
20+
virtualenv project_2
21+
22+
project_2\Scripts\activate
23+
24+
#import modules
25+
pip install -r requirements.txt

0 commit comments

Comments
 (0)