4 ms·
If you really need it to be short you could write: (libpaths or '').split(":") I would be in favor of just using an if-else though, if the None case is spec
by thijsvandien 8y ago
If you really need it to be short you could write:
(libpaths or '').split(":")
I would be in favor of just using an if-else though, if the None case is special, to emphasize that. If it isn't, then you shouldn't be writing this in the first place and just make sure that libpaths is always a string; otherwise you'd be expressing the same state in two ways.
- Silhouette 8y ago(libpaths or '').split(":") This isn't quite the same: if libpaths is None, the above will evaluate to [''], while the original evaluated to []. Of course, the original code was rather awkward itself, redefining the same variable to have a completely different meaning, as well as potentially involving four different representations of nothingness. I'm not sure the syntax is the biggest problem here...