From 674284cfcb0fa3194ad854d711288ec9aa5b98e9 Mon Sep 17 00:00:00 2001 From: maniexx Date: Mon, 22 Dec 2014 15:24:09 +0100 Subject: Delete PYMOTW3 due to lack of content --- 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 f6babaff..8bcc85d1 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -609,7 +609,6 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( * [The Official Docs](http://docs.python.org/3/) * [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) -* [Python Module of the Week](http://pymotw.com/3/) * [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) ### Dead Tree -- cgit v1.2.3 From f4bd1bc8b462e09330ae22ae89a72c11354aa8ac Mon Sep 17 00:00:00 2001 From: suuuzi Date: Wed, 4 Feb 2015 15:32:55 -0200 Subject: Python 3: Changing 'the other tutorial' to a link refering the other tutorial --- 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 6b1d3156..0293d7d2 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -13,7 +13,7 @@ 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 3 specifically. Check out the other tutorial if you want to learn the old Python 2.7 +Note: This article applies to Python 3 specifically. Check out [here](http://learnxinyminutes.com/docs/python/) if you want to learn the old Python 2.7 ```python -- cgit v1.2.3 From 7e7a60d47ce0113e1a5b4ee8642984c60a08f569 Mon Sep 17 00:00:00 2001 From: Cornel Punga Date: Tue, 24 Mar 2015 12:29:01 +0200 Subject: Update python3.html.markdown. Changes to spacing and online resources 1. Some changes related to spacing 2. Added an online resource --- python3.html.markdown | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index 0293d7d2..e8913267 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -276,7 +276,7 @@ empty_set = set() # Initialize a set with a bunch of values. Yeah, it looks a bit like a dict. Sorry. some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4} -#Can set new variables to a set +# Can set new variables to a set filled_set = some_set # Add one more item to the set @@ -394,7 +394,6 @@ our_iterator.__next__() # Raises StopIteration list(filled_dict.keys()) #=> Returns ["one", "two", "three"] - #################################################### ## 4. Functions #################################################### @@ -410,7 +409,6 @@ add(5, 6) # => prints out "x is 5 and y is 6" and returns 11 # Another way to call functions is with keyword arguments add(y=6, x=5) # Keyword arguments can arrive in any order. - # You can define functions that take a variable number of # positional arguments def varargs(*args): @@ -418,7 +416,6 @@ def varargs(*args): varargs(1, 2, 3) # => (1, 2, 3) - # You can define functions that take a variable number of # keyword arguments, as well def keyword_args(**kwargs): @@ -636,6 +633,7 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( * [The Official Docs](http://docs.python.org/3/) * [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) * [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) +* [Python Course](http://www.python-course.eu/index.php) ### Dead Tree -- cgit v1.2.3 From 44c37d5531d42a73b0bde49525e586b413489caf Mon Sep 17 00:00:00 2001 From: Cornel Punga Date: Tue, 24 Mar 2015 19:26:19 +0200 Subject: [python3.html.mardown] Added a short statement about magic methods Terminology related to Python special functions --- python3.html.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index e8913267..56126ad3 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -498,7 +498,9 @@ class Human(object): # Basic initializer, this is called when this class is instantiated. # Note that the double leading and trailing underscores denote objects # or attributes that are used by python but that live in user-controlled - # namespaces. You should not invent such names on your own. + # namespaces. Methods(or objects or attributes) like: __init__, __str__, + # __repr__ etc. are called magic methods (or sometimes called dunder methods) + # You should not invent such names on your own. def __init__(self, name): # Assign the argument to the instance's name attribute self.name = name -- cgit v1.2.3 From d20eb1fb94c819283e610bbd9f1cf3cea834da46 Mon Sep 17 00:00:00 2001 From: Sriram Sundarraj Date: Thu, 23 Apr 2015 01:48:18 +0530 Subject: Adding strings without + added. --- python3.html.markdown | 2 ++ 1 file changed, 2 insertions(+) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index 56126ad3..6c5e1059 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -101,6 +101,8 @@ False or True #=> True # Strings can be added too! But try not to do this. "Hello " + "world!" # => "Hello world!" +# Strings can be added without using '+' +"Hello " "world!" # => "Hello world!" # A string can be treated like a list of characters "This is a string"[0] # => 'T' -- cgit v1.2.3 From 8cfb7ba02f7d53b6b33ff5e776289ee4fcb48618 Mon Sep 17 00:00:00 2001 From: Sriram Sundarraj Date: Thu, 23 Apr 2015 02:06:43 +0530 Subject: [python/en] Range function arguments. Range function with start and stop. --- python3.html.markdown | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index 6c5e1059..470eb6e4 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -339,6 +339,18 @@ prints: for i in range(4): print(i) +""" +"range(lower, upper)" returns a list of numbers +from the lower number to the upper number +prints: + 4 + 5 + 6 + 7 +""" +for i in range(4, 8): + print(i) + """ While loops go until a condition is no longer met. prints: -- cgit v1.2.3 From ffc5ac247c52071c3e4e639ecd363c4fca89bec9 Mon Sep 17 00:00:00 2001 From: Geoff Liu Date: Thu, 30 Apr 2015 23:44:09 -0600 Subject: Python3 doc cleanup --- python3.html.markdown | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'python3.html.markdown') diff --git a/python3.html.markdown b/python3.html.markdown index 470eb6e4..a112912f 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -39,7 +39,7 @@ Note: This article applies to Python 3 specifically. Check out [here](http://lea # Except division which returns floats by default 35 / 5 # => 7.0 -# Result of integer division truncated down both for positive and negative. +# Result of integer division truncated down both for positive and negative. 5 // 3 # => 1 5.0 // 3.0 # => 1.0 # works on floats too -5 // 3 # => -2 @@ -73,8 +73,8 @@ False or True #=> True # Note using Bool operators with ints 0 and 2 #=> 0 -5 or 0 #=> -5 -0 == False #=> True -2 == True #=> False +0 == False #=> True +2 == True #=> False 1 == True #=> True # Equality is == @@ -145,7 +145,7 @@ bool({}) #=> False # Python has a print function print("I'm Python. Nice to meet you!") -# No need to declare variables before assigning to them. +# No need to declare variables before assigning to them. # Convention is to use lower_case_with_underscores some_var = 5 some_var # => 5 @@ -186,7 +186,7 @@ li[2:] # => [4, 3] li[:3] # => [1, 2, 4] # Select every second entry li[::2] # =>[1, 4] -# Revert the list +# Return a reversed copy of the list li[::-1] # => [3, 4, 2, 1] # Use any combination of these to make advanced slices # li[start:end:step] @@ -196,7 +196,7 @@ del li[2] # li is now [1, 2, 3] # You can add lists # Note: values for li and for other_li are not modified. -li + other_li # => [1, 2, 3, 4, 5, 6] +li + other_li # => [1, 2, 3, 4, 5, 6] # Concatenate lists with "extend()" li.extend(other_li) # Now li is [1, 2, 3, 4, 5, 6] @@ -213,7 +213,7 @@ tup = (1, 2, 3) tup[0] # => 1 tup[0] = 3 # Raises a TypeError -# You can do all those list thingies on tuples too +# You can do most of the list operations on tuples too len(tup) # => 3 tup + (4, 5, 6) # => (1, 2, 3, 4, 5, 6) tup[:2] # => (1, 2) @@ -235,15 +235,15 @@ filled_dict = {"one": 1, "two": 2, "three": 3} # Look up values with [] filled_dict["one"] # => 1 -# Get all keys as a list with "keys()". -# We need to wrap the call in list() because we are getting back an iterable. We'll talk about those later. -# Note - Dictionary key ordering is not guaranteed. -# Your results might not match this exactly. +# Get all keys as an iterable with "keys()". We need to wrap the call in list() +# to turn it into a list. We'll talk about those later. Note - Dictionary key +# ordering is not guaranteed. Your results might not match this exactly. list(filled_dict.keys()) # => ["three", "two", "one"] -# Get all values as a list with "values()". Once again we need to wrap it in list() to get it out of the iterable. -# Note - Same as above regarding key ordering. +# Get all values as an iterable with "values()". Once again we need to wrap it +# in list() to get it out of the iterable. Note - Same as above regarding key +# ordering. list(filled_dict.values()) # => [3, 2, 1] @@ -281,7 +281,7 @@ some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4} # Can set new variables to a set filled_set = some_set -# Add one more item to the set +# Add one more item to the set filled_set.add(5) # filled_set is now {1, 2, 3, 4, 5} # Do set intersection with & @@ -328,7 +328,7 @@ for animal in ["dog", "cat", "mouse"]: print("{} is a mammal".format(animal)) """ -"range(number)" returns a list of numbers +"range(number)" returns an iterable of numbers from zero to the given number prints: 0 @@ -340,7 +340,7 @@ for i in range(4): print(i) """ -"range(lower, upper)" returns a list of numbers +"range(lower, upper)" returns an iterable of numbers from the lower number to the upper number prints: 4 @@ -458,14 +458,14 @@ all_the_args(**kwargs) # equivalent to foo(a=3, b=4) all_the_args(*args, **kwargs) # equivalent to foo(1, 2, 3, 4, a=3, b=4) -# Function Scope +# Function Scope x = 5 def setX(num): # Local var x not the same as global variable x x = num # => 43 print (x) # => 43 - + def setGlobalX(num): global x print (x) # => 5 @@ -512,8 +512,8 @@ class Human(object): # Basic initializer, this is called when this class is instantiated. # Note that the double leading and trailing underscores denote objects # or attributes that are used by python but that live in user-controlled - # namespaces. Methods(or objects or attributes) like: __init__, __str__, - # __repr__ etc. are called magic methods (or sometimes called dunder methods) + # namespaces. Methods(or objects or attributes) like: __init__, __str__, + # __repr__ etc. are called magic methods (or sometimes called dunder methods) # You should not invent such names on your own. def __init__(self, name): # Assign the argument to the instance's name attribute @@ -600,7 +600,7 @@ def double_numbers(iterable): # double_numbers. # Note range is a generator too. Creating a list 1-900000000 would take lot of # time to be made -# We use a trailing underscore in variable names when we want to use a name that +# We use a trailing underscore in variable names when we want to use a name that # would normally collide with a python keyword range_ = range(1, 900000000) # will double all numbers until a result >=30 found -- cgit v1.2.3