On Sunday, November 19, 2017 at 2:05:12 PM UTC-5, Peng Yu wrote: > Hi, R has the functions head() and str() to show the brief content of > an object. Is there something similar in python for this purpose? > > For example, I want to inspect the content of the variable "train". > What is the best way to do so? Thanks. > > $ cat demo.py > from __future__ import division, print_function, absolute_import > > import tflearn > from tflearn.data_utils import to_categorical, pad_sequences > from tflearn.datasets import imdb > > # IMDB Dataset loading > train, test, _ = imdb.load_data(path='imdb.pkl', n_words=10000, > valid_portion=0.1) > > # > https://raw.githubusercontent.com/llSourcell/How_to_do_Sentiment_Analysis/master/demo.py > > -- > Regards, > Peng
Python is very good at giving you a string representation of any object. However, such capabilities do fall short every now and then. That is why when defining your own classes, you must also override the __init__() and _-repr__() methods so you can get a better suited string representation of such objects. You can read more at: https://stackoverflow.com/questions/12448175/confused-about-str-in-python -- https://mail.python.org/mailman/listinfo/python-list