Dean Christian Armada
Dean Christian Armada

Reputation: 7384

Print type of variable in python3.5 on django 1.8

I am having a hard time of determining the type of my variable since I am used on python2 and have just migrated to python3

from django.http import HttpResponse

def myview(request):
    x = "Name"
    print (x)
    print type(x)
    return HttpResponse("Example output")

This code will throw an error because of print type(x). However if you changed that syntax line to type(x). The type does not return an output on the runserver of django.

Upvotes: 14

Views: 42701

Answers (1)

knbk
knbk

Reputation: 53719

print in Python 3 is no longer a statement, but a function. You need to call it using parentheses:

print(type(x))

Upvotes: 33

Related Questions