From 879337f9be2ef3c6ea2b01d34d2a21ad325c6cc4 Mon Sep 17 00:00:00 2001 From: DaKnOb Date: Fri, 9 Oct 2015 13:43:57 +0300 Subject: Add Python Order Of Module Import for Python 3 --- python3.html.markdown | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index b3acb122..f21604e4 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -591,6 +591,11 @@ math.sqrt(16) == m.sqrt(16) # => True import math dir(math) +# If you have a Python script named math.py in the same +# folder as your current script, the file math.py will +# be loaded instead of the built-in Python module. +# This happens because the local folder has priority +# over Python's built-in libraries. #################################################### ## 7. Advanced -- cgit v1.2.3 From d2d89cfa9742ef437e45885498677038563d56f5 Mon Sep 17 00:00:00 2001 From: Ankit Aggarwal Date: Mon, 19 Oct 2015 11:47:24 +0530 Subject: Adding documentation on ternary operator --- python3.html.markdown | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index 2398e7ac..6d657395 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -174,6 +174,10 @@ some_var # => 5 # See Control Flow to learn more about exception handling. some_unknown_var # Raises a NameError +# if can be used as an expression +# Equivalent of C's '?:' ternary operator +"yahoo!" if 3 > 2 else 2 # => "yahoo!" + # Lists store sequences li = [] # You can start with a prefilled list -- cgit v1.2.3 From 646eb2a2a19c4cecc20f680c959dd42da1a2961f Mon Sep 17 00:00:00 2001 From: Leslie Zhang Date: Sat, 7 Nov 2015 16:57:44 +0800 Subject: Correct math.sqrt(16) math.sqrt(16) returns 4.0 instead of 4 --- python3.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index 2398e7ac..1f9d0e42 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -689,7 +689,7 @@ i.age # => raises an AttributeError # You can import modules import math -print(math.sqrt(16)) # => 4 +print(math.sqrt(16)) # => 4.0 # You can get specific functions from a module from math import ceil, floor -- cgit v1.2.3 From 30e364f4108fc077343a8722f3d80150f0d250fe Mon Sep 17 00:00:00 2001 From: Louis Christopher Date: Sat, 21 Nov 2015 19:28:59 +0530 Subject: Fixed erroneous output stated in a comment range( start = lower limit, End is < Upper limit , Step) The upper limit is never printed. Fixed the error. --- python3.html.markdown | 1 - 1 file changed, 1 deletion(-) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index 1f9d0e42..3ba57738 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -425,7 +425,6 @@ by step. If step is not indicated, the default value is 1. prints: 4 6 - 8 """ for i in range(4, 8, 2): print(i) -- cgit v1.2.3 From 3c4a2ff91c6d52ccc928e1c26a28e1fdcbc7c064 Mon Sep 17 00:00:00 2001 From: Louis Christopher Date: Sat, 21 Nov 2015 19:44:23 +0530 Subject: Fixed erroneous output and added a little clarity on the matter list.index(argument) would return the index of the item in the list that first matched the argument It will not return the value stored at the index of the argument as it was prior. Added some more clarity to the subject as well. --- python3.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index 3ba57738..8cc03320 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -224,8 +224,8 @@ li.remove(2) # Raises a ValueError as 2 is not in the list # Insert an element at a specific index li.insert(1, 2) # li is now [1, 2, 3] again -# Get the index of the first item found -li.index(2) # => 3 +# Get the index of the first item found matching the argument +li.index(2) # => 1 li.index(4) # Raises a ValueError as 4 is not in the list # You can add lists -- cgit v1.2.3 From 299d064ecf7598144e49ef336e0abd00ccc4ae16 Mon Sep 17 00:00:00 2001 From: sarthfrey Date: Wed, 16 Dec 2015 16:41:07 -0500 Subject: Added Python Resources --- python3.html.markdown | 1 + 1 file changed, 1 insertion(+) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index 8cc03320..f8c22047 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -780,6 +780,7 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) * [30 Python Language Features and Tricks You May Not Know About](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) * [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) +* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/) ### Dead Tree -- cgit v1.2.3 From 15a7e7ace2e61470c5b0de667d33d06a1223ba46 Mon Sep 17 00:00:00 2001 From: SWalls Date: Sun, 10 Jan 2016 17:22:32 -0700 Subject: Changed a to b in comment about list assignment, and pluralized 'variable'. --- python3.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index 8cc03320..31b5bbe1 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -97,13 +97,13 @@ False or True # => True 1 < 2 < 3 # => True 2 < 3 < 2 # => False -# (is vs. ==) is checks if two variable refer to the same object, but == checks +# (is vs. ==) is checks if two variables refer to the same object, but == checks # if the objects pointed to have the same values. a = [1, 2, 3, 4] # Point a at a new list, [1, 2, 3, 4] b = a # Point b at what a is pointing to b is a # => True, a and b refer to the same object b == a # => True, a's and b's objects are equal -b = [1, 2, 3, 4] # Point a at a new list, [1, 2, 3, 4] +b = [1, 2, 3, 4] # Point b at a new list, [1, 2, 3, 4] b is a # => False, a and b do not refer to the same object b == a # => True, a's and b's objects are equal -- cgit v1.2.3