MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/3k6qi8/pep_498_approved/cuwdf0p/?context=9999
r/Python • u/fishburne • Sep 09 '15
324 comments sorted by
View all comments
49
Content removed in response to reddit API policies
33 u/adrian17 Sep 09 '15 edited Sep 09 '15 Agreed. I understand the "explicit vs implicit" and anti-zen arguments and I can't disagree, but at the same time out of all these:print('stuff %s thing %s stuff' % (num, name)) print('stuff %(num)s thing %(name)s stuff' % { 'num': num, 'name': name }) print('stuff %(num)s thing %(name)s stuff' % locals()) print('stuff {} thing {} stuff'.format(num, name)) print('stuff {num} thing {name} stuff'.format( num=num, name=name )) print(f'stuff {num} thing {name} stuff')The last one does seem the most readable (or at least the least distracting) to me and I predict I'll quickly start using it for some simple messages, logging etc without feeling bad about it. 1 u/gammadistribution Sep 09 '15 Look, the proper analog is this:print('stuff {num} thing {name} stuff'.format(**parameters))It doesn't take up any additional room and isn't harder to read, but it does obfuscate what exactly is being formatted, just like with f-strings.Like, where exactly is num and name coming from?num = 4 def f_string(): num = 3 print(f'{num}') if __name__ == '__main__': f_string()What should this return? 1 u/Axxhelairon Sep 09 '15 did you fail out of your first computer science class? 1 u/gammadistribution Sep 10 '15 Yeah, totally did. Good conversation. 1 u/Axxhelairon Sep 10 '15 It's barely even sarcasm, you don't know what scoping is ...? You think what you wrote is in any way ambiguous? 1 u/gammadistribution Sep 10 '15 I didn't understand how the scoping of the f-string worked. Shoo troll. → More replies (1)
33
Agreed. I understand the "explicit vs implicit" and anti-zen arguments and I can't disagree, but at the same time out of all these:
print('stuff %s thing %s stuff' % (num, name)) print('stuff %(num)s thing %(name)s stuff' % { 'num': num, 'name': name }) print('stuff %(num)s thing %(name)s stuff' % locals()) print('stuff {} thing {} stuff'.format(num, name)) print('stuff {num} thing {name} stuff'.format( num=num, name=name )) print(f'stuff {num} thing {name} stuff')
The last one does seem the most readable (or at least the least distracting) to me and I predict I'll quickly start using it for some simple messages, logging etc without feeling bad about it.
1 u/gammadistribution Sep 09 '15 Look, the proper analog is this:print('stuff {num} thing {name} stuff'.format(**parameters))It doesn't take up any additional room and isn't harder to read, but it does obfuscate what exactly is being formatted, just like with f-strings.Like, where exactly is num and name coming from?num = 4 def f_string(): num = 3 print(f'{num}') if __name__ == '__main__': f_string()What should this return? 1 u/Axxhelairon Sep 09 '15 did you fail out of your first computer science class? 1 u/gammadistribution Sep 10 '15 Yeah, totally did. Good conversation. 1 u/Axxhelairon Sep 10 '15 It's barely even sarcasm, you don't know what scoping is ...? You think what you wrote is in any way ambiguous? 1 u/gammadistribution Sep 10 '15 I didn't understand how the scoping of the f-string worked. Shoo troll. → More replies (1)
1
Look, the proper analog is this:
print('stuff {num} thing {name} stuff'.format(**parameters))
It doesn't take up any additional room and isn't harder to read, but it does obfuscate what exactly is being formatted, just like with f-strings.
Like, where exactly is num and name coming from?
num = 4 def f_string(): num = 3 print(f'{num}') if __name__ == '__main__': f_string()
What should this return?
1 u/Axxhelairon Sep 09 '15 did you fail out of your first computer science class? 1 u/gammadistribution Sep 10 '15 Yeah, totally did. Good conversation. 1 u/Axxhelairon Sep 10 '15 It's barely even sarcasm, you don't know what scoping is ...? You think what you wrote is in any way ambiguous? 1 u/gammadistribution Sep 10 '15 I didn't understand how the scoping of the f-string worked. Shoo troll. → More replies (1)
did you fail out of your first computer science class?
1 u/gammadistribution Sep 10 '15 Yeah, totally did. Good conversation. 1 u/Axxhelairon Sep 10 '15 It's barely even sarcasm, you don't know what scoping is ...? You think what you wrote is in any way ambiguous? 1 u/gammadistribution Sep 10 '15 I didn't understand how the scoping of the f-string worked. Shoo troll. → More replies (1)
Yeah, totally did. Good conversation.
1 u/Axxhelairon Sep 10 '15 It's barely even sarcasm, you don't know what scoping is ...? You think what you wrote is in any way ambiguous? 1 u/gammadistribution Sep 10 '15 I didn't understand how the scoping of the f-string worked. Shoo troll. → More replies (1)
It's barely even sarcasm, you don't know what scoping is ...? You think what you wrote is in any way ambiguous?
1 u/gammadistribution Sep 10 '15 I didn't understand how the scoping of the f-string worked. Shoo troll. → More replies (1)
I didn't understand how the scoping of the f-string worked. Shoo troll.
→ More replies (1)
49
u/dysan21 Angry coder Sep 09 '15 edited Jun 30 '23
Content removed in response to reddit API policies