From 13807790e46d4b75b90d6da17e6c28f4ed9e5a49 Mon Sep 17 00:00:00 2001 From: DaKnOb Date: Fri, 2 Oct 2015 16:42:57 +0300 Subject: Add note about Python Module Order of Import --- python.html.markdown | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 352f7349..e306dabd 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -569,6 +569,12 @@ math.sqrt == m.sqrt == sqrt # => 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 c60ddc6ef5d80cc87b051b848ccce0b7f335f5f1 Mon Sep 17 00:00:00 2001 From: MDS Date: Tue, 20 Oct 2015 01:01:14 +1300 Subject: Updated official python docs to always use the latest version of python 2 --- python.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 675967f4..42a52bcf 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -707,7 +707,7 @@ print say(say_please=True) # Can you buy me a beer? Please! I am poor :( * [Automate the Boring Stuff with Python](https://automatetheboringstuff.com) * [Learn Python The Hard Way](http://learnpythonthehardway.org/book/) * [Dive Into Python](http://www.diveintopython.net/) -* [The Official Docs](http://docs.python.org/2.6/) +* [The Official Docs](http://docs.python.org/2/) * [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) * [Python Module of the Week](http://pymotw.com/2/) * [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) -- cgit v1.2.3 From a6eb459b611b67132c76e34095afd87a5aada78c Mon Sep 17 00:00:00 2001 From: Vipul Sharma Date: Tue, 20 Oct 2015 09:57:53 +0530 Subject: Modified string format [python/en] --- python.html.markdown | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 42a52bcf..01e5d481 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -123,8 +123,11 @@ not False # => True # A string can be treated like a list of characters "This is a string"[0] # => 'T' -# % can be used to format strings, like this: -"%s can be %s" % ("strings", "interpolated") +#String formatting with % +#Even though the % string operator will be deprecated on Python 3.1 and removed later at some time, it may still be #good to know how it works. +x = 'apple' +y = 'lemon' +z = "The items in the basket are %s and %s" % (x,y) # A newer way to format strings is the format method. # This method is the preferred way -- cgit v1.2.3 From b238a58c9768d3b7694c4f02cbfe5ba2cac0015a Mon Sep 17 00:00:00 2001 From: payet-s Date: Wed, 21 Oct 2015 17:48:04 +0200 Subject: [python/en] Fix typos --- python.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 42a52bcf..753d6e8c 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -15,8 +15,8 @@ executable pseudocode. Feedback would be highly appreciated! You can reach me at [@louiedinh](http://twitter.com/louiedinh) or louiedinh [at] [google's email service] Note: This article applies to Python 2.7 specifically, but should be applicable -to Python 2.x. Python 2.7 is reachong end of life and will stop beeign maintained in 2020, -it is though recommended to start learnign Python with Python 3. +to Python 2.x. Python 2.7 is reaching end of life and will stop being maintained in 2020, +it is though recommended to start learning Python with Python 3. For Python 3.x, take a look at the [Python 3 tutorial](http://learnxinyminutes.com/docs/python3/). It is also possible to write Python code which is compatible with Python 2.7 and 3.x at the same time, -- cgit v1.2.3 From e60a7d73e846e683bd4345cff4d1a514beab5b91 Mon Sep 17 00:00:00 2001 From: jxu093 Date: Sun, 25 Oct 2015 22:19:40 -0400 Subject: Added Python Resource --- python.html.markdown | 1 + 1 file changed, 1 insertion(+) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 42a52bcf..254235ab 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -712,6 +712,7 @@ print say(say_please=True) # Can you buy me a beer? Please! I am poor :( * [Python Module of the Week](http://pymotw.com/2/) * [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) +* [Fullstack Python](https://www.fullstackpython.com/) ### Dead Tree -- cgit v1.2.3 From db903ac5b6c80fa4b0e8502fb4b3abfd1bed07ee Mon Sep 17 00:00:00 2001 From: Srinivasan R Date: Wed, 28 Oct 2015 16:25:54 +0530 Subject: Add one more string formatting example --- python.html.markdown | 1 + 1 file changed, 1 insertion(+) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 753d6e8c..3d63183c 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -128,6 +128,7 @@ not False # => True # A newer way to format strings is the format method. # This method is the preferred way +"{} is a {}".format("This", "placeholder") "{0} can be {1}".format("strings", "formatted") # You can use keywords if you don't want to count. "{name} wants to eat {food}".format(name="Bob", food="lasagna") -- cgit v1.2.3 From cdd64ecee34af20ed101ba5dc8d7dc73a8189c15 Mon Sep 17 00:00:00 2001 From: Vipul Sharma Date: Thu, 29 Oct 2015 15:23:37 +0530 Subject: 80 char and proper commenting --- python.html.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 01e5d481..ff4471e9 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -124,7 +124,8 @@ not False # => True "This is a string"[0] # => 'T' #String formatting with % -#Even though the % string operator will be deprecated on Python 3.1 and removed later at some time, it may still be #good to know how it works. +#Even though the % string operator will be deprecated on Python 3.1 and removed +#later at some time, it may still be good to know how it works. x = 'apple' y = 'lemon' z = "The items in the basket are %s and %s" % (x,y) -- cgit v1.2.3 From 14c85ba0ffbb66d9c2a056006cedaa90df8f22f4 Mon Sep 17 00:00:00 2001 From: yihong Date: Fri, 30 Oct 2015 05:04:41 +0800 Subject: add more details on truthiness --- python.html.markdown | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 42a52bcf..7055689e 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -63,7 +63,7 @@ allow you to write Python 3 code that will run on Python 2, so check out the Pyt # to carry out normal division with just one '/'. from __future__ import division 11/4 # => 2.75 ...normal division -11//4 # => 2 ...floored division +11//4 # => 2 ...floored division # Modulo operation 7 % 3 # => 1 @@ -144,8 +144,16 @@ None is None # => True # very useful when dealing with primitive values, but is # very useful when dealing with objects. -# None, 0, and empty strings/lists all evaluate to False. -# All other values are True +# Any object can be used in a Boolean context. +# The following values are considered falsey: +# - None +# - zero of any numeric type (e.g., 0, 0L, 0.0, 0j) +# - empty sequences (e.g., '', (), []) +# - empty containers (e.g., {}, set()) +# - instances of user-defined classes meeting certain conditions +# see: https://docs.python.org/2/reference/datamodel.html#object.__nonzero__ +# +# All other values are truthy (using the bool() function on them returns True). bool(0) # => False bool("") # => False -- cgit v1.2.3 From 5bda926dcc79dea4e936cc752fd1ff00e29d71bb Mon Sep 17 00:00:00 2001 From: Elijah Karari Date: Sat, 31 Oct 2015 09:47:55 +0300 Subject: Minor correction calling li.index(2) with li as [1, 2, 3, 4, 5, 6] will return 1 not 3 --- python.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 541bd36d..80cef828 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -238,7 +238,7 @@ li.remove(2) # Raises a ValueError as 2 is not in the list li.insert(1, 2) # li is now [1, 2, 3, 4, 5, 6] again # Get the index of the first item found -li.index(2) # => 3 +li.index(2) # => 1 li.index(7) # Raises a ValueError as 7 is not in the list # Check for existence in a list with "in" -- cgit v1.2.3 From ab1acb1bb265577ea4f189d203ac35726f02970a Mon Sep 17 00:00:00 2001 From: Elijah Karari Date: Sat, 31 Oct 2015 09:56:06 +0300 Subject: Updated tuple examples for clarity --- python.html.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 541bd36d..b0add668 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -261,8 +261,9 @@ tup[:2] # => (1, 2) # You can unpack tuples (or lists) into variables a, b, c = (1, 2, 3) # a is now 1, b is now 2 and c is now 3 +d, e, f = 4, 5, 6 # you can leave out the parentheses # Tuples are created by default if you leave out the parentheses -d, e, f = 4, 5, 6 +g = 4, 5, 6 # => (4, 5, 6) # Now look how easy it is to swap two values e, d = d, e # d is now 5 and e is now 4 -- cgit v1.2.3 From 0049a475edba88f6537b2490ca9506df23b46368 Mon Sep 17 00:00:00 2001 From: Aayush Ranaut Date: Sat, 31 Oct 2015 22:20:51 +0530 Subject: Removed confusing comments --- python.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 5572e38e..abc461a2 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -404,7 +404,7 @@ add(y=6, x=5) # Keyword arguments can arrive in any order. # You can define functions that take a variable number of -# positional args, which will be interpreted as a tuple if you do not use the * +# positional args, which will be interpreted as a tuple def varargs(*args): return args @@ -412,7 +412,7 @@ varargs(1, 2, 3) # => (1, 2, 3) # You can define functions that take a variable number of -# keyword args, as well, which will be interpreted as a dict if you do not use ** +# keyword args, as well, which will be interpreted as a dict def keyword_args(**kwargs): return kwargs -- cgit v1.2.3 From a4a7b2dd8308a8d67722d8c93e4c1a8c052f7f6a Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 2 Nov 2015 16:30:15 +0300 Subject: fixed unintended opposite meaning --- python.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 2b43c5fc..f8f712d3 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -458,7 +458,7 @@ add(y=6, x=5) # Keyword arguments can arrive in any order. # You can define functions that take a variable number of -# positional args, which will be interpreted as a tuple if you do not use the * +# positional args, which will be interpreted as a tuple by using * def varargs(*args): return args @@ -466,7 +466,7 @@ varargs(1, 2, 3) # => (1, 2, 3) # You can define functions that take a variable number of -# keyword args, as well, which will be interpreted as a dict if you do not use ** +# keyword args, as well, which will be interpreted as a dict by using ** def keyword_args(**kwargs): return kwargs -- 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 --- python.html.markdown | 1 + 1 file changed, 1 insertion(+) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index d8f18e9b..1d6c0a19 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -726,6 +726,7 @@ print say(say_please=True) # Can you buy me a beer? Please! I am poor :( * [Python Module of the Week](http://pymotw.com/2/) * [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) +* [LearnPython](http://www.learnpython.org/) ### Dead Tree -- cgit v1.2.3 From 39c83718b14a768ed62a6644ed633c9a032ff9f6 Mon Sep 17 00:00:00 2001 From: sarthfrey Date: Mon, 25 Jan 2016 18:34:25 -0500 Subject: removed merge stuff --- python.html.markdown | 3 --- 1 file changed, 3 deletions(-) (limited to 'python.html.markdown') diff --git a/python.html.markdown b/python.html.markdown index 70f7f73f..2e7fd8be 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -726,11 +726,8 @@ print say(say_please=True) # Can you buy me a beer? Please! I am poor :( * [Python Module of the Week](http://pymotw.com/2/) * [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) -<<<<<<< HEAD * [LearnPython](http://www.learnpython.org/) -======= * [Fullstack Python](https://www.fullstackpython.com/) ->>>>>>> adambard/master ### Dead Tree -- cgit v1.2.3