Links that might be useful
It is interesting to note that the tool Py2to3, always returns the same object that the function used in Python 2 did, even when it is unnecessary. A few examples of this are given below -
- dict(map(map_fun, cols, row))
+ dict(list(map(map_fun, cols, row)))
Python 2 returns a list when map is used and Python 3 returns a map object. The map object can be directly cast to a dictionary if needed.
- data.iteritems():
+ data.items():
Python 2 returns a generator for dict.iteritems() so the tool converts this in Python 3 to dict.items()
- data.items():
+ list(data.items()):
In this case however, dict.items() returns a list in Python 2 which is why the tool converted the generator returned by dict.items() explicitly to a list.
- data.keys()
+ list(data.keys())
Similar to the previous case. Explicit conversion to a list in case of dict.keys()
base64bytes.decode('utf-8')
This change is manual. Py2to3 does not take this into account. The b64encode function requires a byte-like object and returns one as well in Python 3, this was not the case for Python 2.
- urllib2.Request(url, json.dumps(data))
+ urllib.request.Request(url, json.dumps(data))
urllib2 has changed to urllib and it's functions have been moved to sub packages.
- httplib.HTTPConnection(self.host, timeout=25)
+ http.client.HTTPConnection(self.host, timeout=25)
- filter(lambda x: x[0] == '**match**', filters):
+ [x for x in filters if x[0] == '**match**']:
Filter like map now returns a filter object.
Specifically from a PTL stand point -
Link to Forum - http://community.pbspro.org/t/moving-to-python-3/1421
Project Documentation Main Page
Ignore this. We may use it later for page characterization. |