Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":10987,"date":"2015-04-16T14:30:24","date_gmt":"2015-04-16T19:30:24","guid":{"rendered":"https:\/\/manuelmadrigal.withknown.com\/2015\/mastery-29-validated-user-input-in-python"},"modified":"2015-04-16T14:30:24","modified_gmt":"2015-04-16T19:30:24","slug":"mastery-29-validated-user-input-in-python","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2015\/2015\/mastery-29-validated-user-input-in-python\/","title":{"rendered":"Mastery 29. Validated User input in Python"},"content":{"rendered":"
\n

There are some cases where we create a function in our program destined to receive an special type of value. Here is where we want to ensure that the user enters the correct value and not any other type that will cause our program to crash, thats why we validate the user input by using some tools that I will show you.<\/p>\n

Lets see the next example:\"\"<\/p>\n

In this case we want our user to enter a positive integer number.<\/p>\n

There are 3 possible cases in this input:<\/p>\n

a) The user enters a positive integer number: In this case, the input will be correct and Python will get out of the loop, continuinh with the rest of the code.<\/p>\n

 <\/p>\n

b) The user enters a negative integer number: In this case the input will be validated with the built-in type “int” function and it will not return any error, but as it is not positive, it will enter in the loop, asking the user to enter a positive number instead of a negative one.<\/p>\n

 <\/p>\n

c) The user does not enter an integer number: Any value different from an integer value will return “ValueError” because we are using the built-in type “int” function. As the program tries this value and returns the “ValueError” it will passes to the “except” statement, where it will tell the user his mistake and will send the user to the beginning again, entering in the “try” statement.<\/p>\n

 <\/p>\n

This is just an example of validating user inputs, but there may be many variants, depending on what value you want to get from the user. You can use as many different of built-in type functions as you wish, it is just matter of playing with the “try” and “except”statements.<\/p>\n

 <\/p>\n

#TC1014<\/a> #mastery29<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"

There are some cases where we create a function in our program destined to receive an special type of value. Here is where we want to ensure that the user enters the correct value and not any other type that will cause our program to crash, th… Continue reading →<\/span><\/a><\/p>\n","protected":false},"author":64,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3,25],"tags":[227,45],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/10987"}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/comments?post=10987"}],"version-history":[{"count":7,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/10987\/revisions"}],"predecessor-version":[{"id":18956,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/10987\/revisions\/18956"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/media?parent=10987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/categories?post=10987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/tags?post=10987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}