Python Forum

Full Version: <function notes_counter at 0x0000024E06FC51F0
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a little problem, if I set the global variable sys_note the results into sys_notes Label are printed in tuple format (3,).  I want to have a plane number without brackets, however, when I use the function I'm getting an error: <function notes_counter at 0x0000024E06FC51F0> 
I'm a beginner with Python Cry

# Global Variable
sys_note = cur.execute("SELECT count(*) FROM notes").fetchone()


# With fucntion
def notes_counter():
    sys_note = cur.execute("SELECT count(*) FROM notes").fetchone()
 
 
# Label Statistic - System Notes
self.sys_notes = Label(self.footer, text = ' |  Notes: ' + str(notes_counter), fg = '#b3b3b3', bg = '#333', font = 'Helvetica 10 bold')
self.sys_notes.grid(row = 0, column = 3)
It is not an error, the function notes_counter has not been called you need to do notes_counter() to call the function, then you will need to add return to the function otherwise it will return None.
(Oct-14-2020, 05:20 AM)Yoriz Wrote: [ -> ]It is not an error, the function notes_counter has not been called you need to do notes_counter() to call the function, then you will need to add return to the function otherwise it will return None.
I appreciate your help and effort. I added 'return' to the function and the function is called into the label but i'm still getting None value.  

def notes_counter():
    sys_note = cur.execute("SELECT count(*) FROM notes").fetchone()
    return


class Application(object):
......

        # Label Statistic - System Notes

        self.sys_notes = Label(self.footer, text = ' |  Notes: ' + str(notes_counter()), fg = '#b3b3b3', bg = '#333', font = 'Helvetica 10 bold')
        self.sys_notes.grid(row = 0, column = 3)
....
The function returns None because you haven't told it what to return.  Do you want it to return the value of your sys_note variable?  If so, your return statement should be "return sys_note" instead of just "return" (which, as you have seen, returns None by default).
(Oct-14-2020, 11:10 AM)GOTO10 Wrote: [ -> ]The function returns None because you haven't told it what to return.  Do you want it to return the value of your sys_note variable?  If so, your return statement should be "return sys_note" instead of just "return" (which, as you have seen, returns None by default).

Thank you for your feedback! I learned something new today!