-1

I'd like to have some information about set of functions (maybe analog of the var_dump() in PHP) which I could use for looking at the content of variables on a server side in a way that they should be printed on server-side somehow during the work process, or on the client-side in the browser's console (chromelogger?).

I was recently involved into a new project, I'm a newbie in Python/Django, so I need to get familiar with the internal logic and hit the ground running.

I'm using extJS on front-end and Django 1.6 on backend.

Thank you!

Павел Иванов
  • 1,863
  • 5
  • 28
  • 51

4 Answers4

0

Just print them and they will appear at dev-server's console:

print some_var

Or, if some_var is a some kind of structure (dict or list), use the pprint module:

import pprint
pprint.pprint(some_var)
catavaran
  • 44,703
  • 8
  • 98
  • 85
0

I think you are looking for an IDE.. Go for pycharm or eclipse + pydev.

0

If you are looking to print the variable structure use dir.

If you want to print only the variable content use pretty print(pprint)

Riccardo
  • 1,490
  • 2
  • 12
  • 22
0

If you're trying to diagnose issues on a server or in a production-like environment (i.e., one where you can't just dump into an interactive debugger), might I suggest you use logging?

https://docs.djangoproject.com/en/1.7/topics/logging/ https://docs.python.org/2/library/logging.html (or https://docs.python.org/3/library/logging.html)

You can even go so far as to have an SMTP log handler that will automagically email you log output for certain handlers.

bmhkim
  • 754
  • 5
  • 16
  • Where does logging keep its log files? – Павел Иванов Mar 06 '15 at 08:40
  • I'm going to punt and refer you to the Django documentation on logging. If you follow their scheme, logfile locations, handlers, and more can all be defined in settings. This includes the ability to automagically get an email copy of error and higher log messages. This is often super handy, and also often super chatty and annoying. With great power.... – bmhkim Mar 06 '15 at 08:41