You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is not. Currently it returns the value from " ".join([]), which is an empty string. It would be pretty easy to make it do that though. Of course, you could do it easily too with something like name.title or None, but maybe there's some case where that's inconvenient? Idk, maybe it would be fine to make it always return None instead of an empty string? I don't have a strong preference.
For instance when you store the name components in a database and you want to store that values as NULL and not as empty string, it's easier when the module directly returns None.
Maybe it's an idea to modify line 122: Do a .replace(CONSTANTS.empty_attribute_default, "") first; since you probably don't want to have an output like 'None John None Doe None (None)' when printing the hole name.
I posted the results of the tests when CONSTANTS.empty_attribute_default = None over on the pull request. Take a look and let me know if you think there's something better we could do or maybe it's all fine.
Activity
derek73 commentedon Mar 18, 2016
There is not. Currently it returns the value from
" ".join([]), which is an empty string. It would be pretty easy to make it do that though. Of course, you could do it easily too with something likename.title or None, but maybe there's some case where that's inconvenient? Idk, maybe it would be fine to make it always return None instead of an empty string? I don't have a strong preference.Xennis commentedon Mar 19, 2016
For instance when you store the name components in a database and you want to store that values as
NULLand not as empty string, it's easier when the module directly returnsNone.derek73 commentedon Mar 19, 2016
Turns out the change breaks a bunch of tests, mostly to do with string formatting, so I just added a configuration option for it, documented here:
http://nameparser.readthedocs.org/en/latest/modules.html#nameparser.config.Constants.empty_attribute_default
Xennis commentedon Mar 19, 2016
Maybe it's an idea to modify line 122: Do a
.replace(CONSTANTS.empty_attribute_default, "")first; since you probably don't want to have an output like'None John None Doe None (None)'when printing the hole name.remove default attribute from formatted string (#44)
derek73 commentedon Mar 19, 2016
Thanks for the suggestion. I gave it a shot but my attempt doesn't pass the test. I made a branch and pull request: #45
Here's the failed Travis build:
https://travis-ci.org/derek73/python-nameparser/builds/117161574
derek73 commentedon Mar 19, 2016
I figured it out. It was a problem with the tests and me forgetting how to use my own software.
derek73 commentedon Mar 19, 2016
I posted the results of the tests when
CONSTANTS.empty_attribute_default = Noneover on the pull request. Take a look and let me know if you think there's something better we could do or maybe it's all fine.Xennis commentedon Mar 20, 2016
Thanks for you friendly support. I am now using this module for some days and it is quite nice.
The code changes looks fine.
I think you are right. Probably you should test for
hn.C.empty_attribute_defaultinstead.Merge pull request #45 from derek73/44_none_default
derek73 commentedon Mar 21, 2016
Just released v0.3.15 that should take care of all this
docs(rules): topic-review amendments from the 1.x stink-test session …