Python get UTC offset for when only naive date time objects are available
Take advantage of Python operator overloading

is_behind_utc = time_now &lt; time_utc


If the current time is less the the UTC time then we are behind UTC time.

There is no need to use logic concerning seconds.

Longer names > comments

# Flag variable to hold if the current time is behind UTC.
is_behind_utc = False


Let's analyze the comment:


Flag variable : this can easily be deduced as it is a boolean
to hold if : each variable holds something
the current time : valuable information
is behind UTC : already present in the variable name


So I could write:

current_time_is_behind_utc = time_now &lt; time_utc


The name incorporates the valuable information in the comment, avoids the unnecessary and the repetition of the same concept.

Use ternary when sensible

if is_behind_utc:
    pos_neg_prefix = "-"
else:
    pos_neg_prefix = "+"


I cringe because such verbosity obscures what is simple:

pos_neg_prefix = '-' if current_time_is_behind_utc else '+'


Simplify avoiding too many variables

utc_offset_fmt = time.strftime("%H:%M", utc_offset)
utc_offset_str = pos_neg_prefix + utc_offset_fmt

return utc_offset_str


Can simply be:

return pos_neg_prefix + time.strftime("%H:%M", utc_offset)


I think that each additional variable is an addition burden and point of failure in the code being another layer of indirection, and tend to avoid too many variables when sensible.