Python Forum
Is it bad practice to return a variable and not use it?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it bad practice to return a variable and not use it?
#7
Use the conditional to decide if you want to use the returned object or not. If you do not use it GC will take care of it.

if condition:
    returned = my_func(*args,**kwargs) # use the returned object to back up the dict
else:
    my_func(*args,**kwargs) # the function returns an object but since there is not a reference to it, it will be GCed
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
RE: Is it bad practice to return a variable and not use it? - by wavic - Apr-04-2017, 04:15 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  best practice example data science mostafa705 1 882 Oct-13-2023, 04:44 AM
Last Post: KianLynch
  Practice coding through hackathon!! TheOutcast 0 1,553 Jun-11-2020, 12:03 PM
Last Post: TheOutcast
  Coding Practice BarakTu 2 3,360 Apr-14-2018, 05:31 AM
Last Post: buran
  is it considered good practice to ... Skaperen 9 6,349 May-10-2017, 02:42 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020