How can I simplify this conversion from underscore to camelcase in Python?
<p>I have written the function below that converts underscore to camelcase with first word in lowercase, i.e. "get_this_value" -> "getThisValue". Also I have requirement to preserve leading and trailing underscores and also double (triple etc.) underscores, if any, i.e.</p>

<pre><code>"_get__this_value_" -&gt; "_get_ThisValue_".
</code></pre>

<p>The code:</p>

<pre><code>def underscore_to_camelcase(value):
    output = ""
    first_word_passed = False
    for word in value.split("_"):
        if not word:
            output += "_"
            continue
        if first_word_passed:
            output += word.capitalize()
        else:
            output += word.lower()
        first_word_passed = True
    return output
</code></pre>

<p>I am feeling the code above as written in non-Pythonic style, though it works as expected, so looking how to simplify the code and write it using list comprehensions etc.</p>

<p>Thanks a lot.</p>
