Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip input strings to remove extra \n #667

Open
mostaphaRoudsari opened this issue Nov 21, 2017 · 3 comments
Open

Strip input strings to remove extra \n #667

mostaphaRoudsari opened this issue Nov 21, 2017 · 3 comments

Comments

@mostaphaRoudsari
Copy link
Member

This has been an issue for users who are getting started with Grasshopper. It's an easy fix and we need to implement it to all the components with string inputs. Here is an example.

@saeranv
Copy link
Member

saeranv commented Nov 21, 2017

@mostaphaRoudsari Should we strip all white spaces, or just beginning and end?

Just the beginning and end:

filenamestr = "   hello world\n\t "
filenamestr = filenamestr.strip() # removes whitepsace from beginning and end
>> print filenamestr
>> "hello world"

All white spaces:

"".join(filenamestr.split()) # removes all white space from string
>> print filenamestr
>> "helloworld"

The argument for stripping all white spaces is to prevent white spaces in your path creating trouble with the way python reads file paths. Unless we treat file names very carefully with raw strings, or the python os.path module, we can quickly run into very hard-to-detect interoperability issues with white spaces. We will have to explicitly tell users not to use white spaces in their file names, but it could cause us less headaches in the future...

@mostaphaRoudsari
Copy link
Member Author

@saeranv we should use re to catch all these cases and give a warning. Fixing it for user without giving proper warning can end up creating other issues. Here is how it's implemented in honeybee[+].

@saeranv
Copy link
Member

saeranv commented Nov 21, 2017

That's perfect @mostaphaRoudsari

I know I've said it before, but I have to say, I love the coding practices you guys are integrating into honeybee[+]. What a great foundation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants