2011/3/4 Simon King <simon.k...@uni-jena.de>: > PS: > > On 4 Mrz., 09:06, Simon King <simon.k...@uni-jena.de> wrote: >> What about the following idea: >> 1. var(s) only accept strings and lists of strings, and for backwards >> compatibility one could also make it accept objects whose string >> representation does not contain commas or whitespace. So, >> var(QQ['t'].gen()) is fine, but with input like var(QQ['t']), an error >> is raised. >> 2. If the input is a valid identifier (all ascii) and not a reserved >> Python keyword, it will be inserted into the global namespace. >> 3. Otherwise, a variable with the given name is returned, but *not* >> put into the global namespace. We may think of printing a warning >> message in that case. In that way, alpha=var("α") would still work. > > No, that's a bad idea. It wouldn't change the current situation at > all. In particular, sin([])=[] would still "work" (but shouldn't). > > Perhaps the following is better: > Introduce an optional argument validate_name. If it is True (which is > the default), an error is raised if the name is no valid identifier or > if it is a reserved keyword. So, sin([])=[] or var('def') would result > in an error. > But if validate_name=False is used, then simply a variable of the > given name is returned (and not inserted into the global name space).
So one would have to do alpha=var("α", validate_name=False) to avoid an error? Also, I'd still like to avoid var("[]", ...) working at all. We could accept all valid Python3 identifiers, and print a warning if we were unable to insert them into the global namespace, e.g. they're not valid Python2 identifiers. (The warning could be suppressed if one did, say, var("α", inject=False).) - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org