How to I print variables to the Bash console on PythonAnywhere?
<p>I have a weird issue at the moment where text I am inserting into my MySQL database in an action menu function in Django admin are getting an 'n' character attached to the left side of the string. This is only happening on PythonAnywhere. I am developing the app predominately on a localhost server on my own machine and the error does not show up there.</p>

<p>What I want to know mainly is how I can print out a variable to a Bash console instance so that I can diagnose what is going on. I tried writing print(word) in the action function, but the output was not echoed to the Bash console I had open in the Virtual Environment (django18) in which my app is running. Are there additional steps I must take before I can get variables to print to the console?</p>

<p>Alternatively, if anyone has some idea why an 'n' would be pre-pended to text I am inserting into my database, this would be very helpful information. At first I thought it was because the input variables were unicode text, but encoding them to utf-8 before inserting them made no difference.</p>

<p>The complete source for my action function is below:</p>

<pre><code>from django.contrib import admin
from django.forms import Textarea
from django.db import models

from .frequency import VocabularyProcess
from .models import School, Grade, Book, Bookmark, Word


# Action menu item
def process_content(modeladmin, request, queryset):
    # Get the text from the database bookmark item
    table = queryset.values_list('id', 'content')
    # Process each record in the queryset
    for record in table:
        bookmark_id = int(record[0])
        content_text = str(record[1].encode('ascii', 'ignore')).lower()
        # make it into a list of lines
        content_list = content_text.splitlines()
        # Process the text into a dictionary of words with counts
        vocabulary_obj = VocabularyProcess(content_list)
        words = vocabulary_obj.get_frequency_dict()
        # Update or create the words and counts in the Words table.
        for word, count in words.items():
            # Encode to utf-8 for compatibility with current DB char encoding
            word = word.encode('utf-8')
            if len(word) &lt;= 20:  # Ensure the word will fit in the DB record
                Word.objects.update_or_create(word=word, \
                           bookmark_id=bookmark_id, defaults={'count': count})
</code></pre>