Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Using Databases in Python Gettin' CRUD-y With It View and Search Entries

Can't view entry?

Hey there, I've been following along with the video, but every time I view any of the entries for the diary app it returns this:

Thursday June 25, 2015 06:09PM
'==========================='

< built-in method strip of str object at 0x7f7b18b9a770 >

As you can see the content of the entry isn't shown, here's my code for the add and view entries:

def add_entry():
    """Add an entry"""
    print("Enter your entry. Press ctrl+d when you're done.")
    data = sys.stdin.read().strip()

    if data:
        if input('\nSave entry? [Y/N] ').lower() != 'n':
            Entry.create(content = data)
            print("Saved successfully")



def view_entries():
    """View previous entries"""
    entries = Entry.select().order_by(Entry.timestamp.desc())

    for entry in entries:
        timestamp = entry.timestamp.strftime('%A %B %d, %Y %I:%M%p')
        print(timestamp)
        print('='*len(timestamp))
        print(entry.content)
        print('n) next entry')
        print('q) return to main menu')


        next_action = input('Action: [N/q] ').lower().strip()
        if next_action == 'q':

Any help is appreciated, thanks!

1 Answer

Problem solved! I left of some parentheses on the .strip