feature req: call_in_new_context doesn't trim label names
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
feature req: call_in_new_context doesn't trim label names
As seen in this thread, it seems renpy.call_in_new_context doesn't trim the name of the label that's passed in - meaning that if there's a trailing or leading space, the call fails.
Admittedly there shouldn't be a trailing or leading space, but since labels can't have trailing or leading spaces anyway, it doesn't seem to me that there's any value in not trimming the input, and it would help out in circumstances like that one.
Admittedly there shouldn't be a trailing or leading space, but since labels can't have trailing or leading spaces anyway, it doesn't seem to me that there's any value in not trimming the input, and it would help out in circumstances like that one.
Server error: user 'Jake' not found
-
- Regular
- Posts: 188
- Joined: Wed Jul 07, 2010 5:49 pm
- Completed: Mobile Food Madness, Super Otome Quest
- Location: Pacific Northwest
- Contact:
Re: feature req: call_in_new_context doesn't trim label name
Just curious. Do other methods that take a label such as renpy.jump or ui.callsinnewcontext automatically strip trim? If so, I would agree that renpy.call_in_new_context should behave in a similar manner for consistency.
Don't Blame Me. I Voted for Vermin Supreme.
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: feature req: call_in_new_context doesn't trim label name
No, we never strip labels - I don't think we should, since there's an admittedly slight performance cost.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: feature req: call_in_new_context doesn't trim label name
Leaving aside that it's a very minor cost at a point where it's very unlikely to make any significant difference, couldn't something like this feasibly even be done as a precompiler step, at least for string-literal parameters to those functions?PyTom wrote:I don't think we should, since there's an admittedly slight performance cost.
I realise it's a bit of a fringe case anyway, but it's things like this which do confuse people who aren't used to programming - the idea that "blah" is different from " blah" is quite an odd concept to a lot of people.
Server error: user 'Jake' not found
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: feature req: call_in_new_context doesn't trim label name
I don't think it could be done as a precompiler step, as we don't have any real understanding of functions until just before they're run. (This is python, so there isn't a static analysis phase to speak of.)
It's also a sort of regularity thing. If " foo" matches "foo" when we go to call a label, then why wouldn't " Jake" match "Jake" in code like:
It's also a sort of regularity thing. If " foo" matches "foo" when we go to call a label, then why wouldn't " Jake" match "Jake" in code like:
Code: Select all
$ name = " Jake"
if name == "Jake":
...
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: feature req: call_in_new_context doesn't trim label name
Because when you're jumping to a label it's entirely possible to work out whether or not the spaces are valid (because they always aren't, and will never be intentional) and when you're doing arbitrary operations on strings it's not possible.PyTom wrote: It's also a sort of regularity thing. If " foo" matches "foo" when we go to call a label, then why wouldn't " Jake" match "Jake" in code like:
As the old saying goes - be liberal in what you accept, and conservative in what you do.
Server error: user 'Jake' not found
-
- Veteran
- Posts: 206
- Joined: Tue Dec 30, 2008 9:18 am
- Projects: iichan erogame
- Contact:
Re: feature req: call_in_new_context doesn't trim label name
Jake, you can just call
instead of
But it wouldn't save you from troubles like tabs or newline symbols. Also it is still case sensitive, etc. =)
Code: Select all
renpy.call_in_new_context(x.strip(" ").rstrip(" "))
Code: Select all
renpy.call_in_new_context(x)
Re: feature req: call_in_new_context doesn't trim label name
I know. And I wouldn't pass a label name with spaces in the first place, because I know what I'm doing.iichan_lolbot wrote:Jake, you can just call
I started the thread 'cause a guy who wasn't a programmer was trying to use a Cookbook script and had left a space in the string, and it occurred to me that there was no reason Ren'Py couldn't strip it, since spaces aren't valid parts of label names anyway... and therefore, it would be better and more useful for newbies to strip.
Server error: user 'Jake' not found
Who is online
Users browsing this forum: Ahrefs [Bot]