Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
rewrite_title
#10
(Dec-07-2016, 07:31 PM)roadrage Wrote: I totally agree... my code is the "ugly duckling" at this point...
hope "someday" it becomes the "beautiful duck" Smile

This won't happen because you'll have taken bad habits... Ugly code is hard to read (in the sense that it needs more brainpower), and hard to read code is more likely to have unnoticed bugs, because you have diverted your brainpower to futile task instead of concentrating on the code logic. You are just making your life difficult. When you write something like this, it is totally inefficient for you:
def rewrite_title(*args):
    """ Replace the HTML title contents with the given TITLE """
    htmlbody = args[0]
    newtitle = args[1]
because you have to remember the arguments order, and to call the whole function you have to look at 4 lines of code to make sure you have the arguments at the right places, while when you write the function like this:
def rewrite_title(htmlbody,newtitle):
    """ Replace the HTML title contents with the given TITLE """
everything needed is in the def line... and the more arguments you have, the more difficult you code style makes it.

Now, if you want to remain a code poseur, you can save some typing and vertical space like this:
def rewrite_title(*args):
    """ Replace the HTML title contents with the given TITLE """
    htmlbody,newtitle = args
but then it becomes quite silly....

PS: of course, until you start coding to universally accepted standards, you'll be coding alone
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
rewrite_title - by roadrage - Dec-05-2016, 08:26 PM
RE: rewrite_title - by nilamo - Dec-05-2016, 08:30 PM
RE: rewrite_title - by micseydel - Dec-05-2016, 08:32 PM
RE: rewrite_title - by roadrage - Dec-05-2016, 09:30 PM
RE: rewrite_title - by nilamo - Dec-05-2016, 10:44 PM
RE: rewrite_title - by micseydel - Dec-06-2016, 08:42 PM
RE: rewrite_title - by roadrage - Dec-07-2016, 06:32 PM
RE: rewrite_title - by nilamo - Dec-07-2016, 06:50 PM
RE: rewrite_title - by roadrage - Dec-07-2016, 07:31 PM
RE: rewrite_title - by Ofnuts - Dec-08-2016, 10:16 PM
RE: rewrite_title - by roadrage - Dec-21-2016, 04:21 PM
RE: rewrite_title - by snippsat - Dec-21-2016, 05:14 PM
RE: rewrite_title - by roadrage - Dec-21-2016, 06:47 PM

Forum Jump:

User Panel Messages

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