Better way / regex to extract values form a dictionary
Thomas Jollans
tjol at tjol.eu
Sun Jul 22 06:21:25 EDT 2018
On 21/07/18 14:39, Ganesh Pal wrote:
>> The dictionary is irrelevant to your question. It doesn't matter whether
>> the path came from a dict, a list, read directly from stdin, an
>> environment variable, extracted from a CSV file, or plucked directly from
>> outer space by the programmer. The process remains the same regardless of
>> where the path came from.
>>
>
>
> Thanks I was ignorant about this , your solution looks cool . One last
> question , does it makes sense to check if the values are not none ( If I
> plan to use the value for next computation )
No, they won't end up being None. However, if there is no '_' in the
file name you'll get an exception.
>
> if not all(filename, testcase):
> raise ValueError("Error getting filename or testcase no")
>
>
> Regards,
> Ganesh
>
More information about the Python-list
mailing list