To see which version of Python 3 you have installed, open a command prompt and run $ python3 --version If you are using Ubuntu 16.10 or newer, then you can easily install Python 3.6 with the following commands: $ sudo apt-get update $ sudo apt-get install python3.6 If you're using another version of Ubuntu (e.g. the latest LTS release), we recommend using the deadsnakes … [Read more...] about Update Python for old Linux boxes
import inspect lines = inspect.getsource(magic_function) print(lines) … [Read more...] about How to get the Python source codelines?
NumPy is the fundamental package for scientific computing with Python. It contains among other things: a powerful N-dimensional array object; import numpy as np T = np.array([ [[1,2,3], [4,5,6], [7,8,9]], [[11,12,13], [14,15,16], [17,18,19]], [[21,22,23], [24,25,26], [27,28,29]], ]) print(T.shape) # (3,3,3) print(T.ndim) # 3 print(T.size) # 27 print(T) Each … [Read more...] about Tensor in NumPy and what may be useful to know about tensor shapes
This program is simple post and get request implementation. Since Python works almost anywhere this is a handy code to have. ''' This is a comment, If you see this, CGI is not working ''' import sys import urllib2 import urllib '''Pickling is the process converting object into a byte stream, and unpickling is the inverse operation.''' try: import cPickle as … [Read more...] about Post and Get requests in Python
Question is how to read HTML from some URL in Python. Here is the answer: try: r = urllib2.urlopen(url) except: print "Unexpected error, looks that URL isn't available or doesn't exist." sys.exit(0) html = r.read() Thanks … [Read more...] about Read HTML from URL