On Sunday, May 10, 2015 at 11:02:05 PM UTC+2, vdelecroix wrote: > > Should we just allow the creation of such variable name but add a > warning in the inject_variables function? >
IMHO yes, both var and R.<x,y> = QQ[] and anything else that injects globals should fail at the injection only. If you don't inject then any identifier should be allowed as variable label. > > I am worried of making impossible the use of 'as' or 'or' as variable > names. The following looks like a plausible Sage usage > > sage: alpha ='abcdefghijklmnopqrstuvwxyz' > sage: PolynomialRing(ZZ, [i+j for i in alpha for j in alpha]) > > On 10/05/15 22:54, Volker Braun wrote: > > The checking in symbolic rings should be moved to sage.repl.user_globals > > and hooked into set_global. > > > > As for part 2, "None" is not a reserved keyword in Python2 so its in > > principle perfectly legal to use as identifier. Though it was later on > > specifically disallowed to assign to None, but assignment to True/False > is > > still possible. This is fixed in Python3 where None, True, False become > > keywords. > > > > We should probably exclude Python builtin names for that as well, i.e. > > dir(__builtin__), not because its not legal but because its mighty > > confusing to redefine int/str/id/all/... > > > > On Sunday, May 10, 2015 at 10:26:25 PM UTC+2, vdelecroix wrote: > >> > >> Hello, > >> > >> What should we do with variable names like 'or', 'and', ... This does > >> not break uniformly > >> > >> The symbolic ring refuses the creation of such variable > >> {{{ > >> sage: SR.var('and') > >> Traceback (most recent call last): > >> ... > >> ValueError: The name "and" is not a valid Python identifier. > >> }}} > >> > >> whereas polynomial rings silently fail > >> {{{ > >> sage: R = PolynomialRing(QQ, ('and', 'or')) > >> sage: R.inject_variables() > >> Defining and, or > >> sage: and > >> ... > >> SyntaxError: invalid syntax > >> sage: 'and' in globals() > >> True > >> }}} > >> > >> Vincent > >> > > > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.