From: Jason R. Coombs Date: Sun, 8 Sep 2013 16:54:33 +0000 (-0400) Subject: Issue #18978: A more elegant technique for resolving the method X-Git-Tag: v3.4.0a3~27^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aae6a1d76fd1336137981cd66acded01d3c36f09;p=python Issue #18978: A more elegant technique for resolving the method --- diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 049f48d532..bceb3297c8 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -321,12 +321,8 @@ class Request: def get_method(self): """Return a string indicating the HTTP request method.""" - if getattr(self, 'method', None) is not None: - return self.method - elif self.data is not None: - return "POST" - else: - return "GET" + default_method = "POST" if self.data is not None else "GET" + return getattr(self, 'method', default_method) def get_full_url(self): return self.full_url