On 11 Dec 2007 04:14:09 GMT, Stargaming <[EMAIL PROTECTED]> wrote: > On Mon, 10 Dec 2007 16:54:08 -0800, mosi wrote: > > > Python matrices are usually defined with numpy scipy array or similar. > > e.g. > >>>> matrix1 = [[1, 2], [3, 4], [5, 6]] > > I would like to have easier way of defining matrices, for example: > >>>> matrix = [1, 2; 3, 4; 5, 6] > > > >>>> matrix = > > [ 1, 2; > > 3, 4; > > 5, 6;] > > > > Any ideas how could this be done? The ";" sign is reserved, the "[ ]" is > > used for lists.
I think mosi was looking to dynamically modify the syntax of Python itself, as opposed to working around the existing syntax. This includes things like messing with reserved symbols and keywords. The interpreter is compiled with these definitions built in, so to change them would conceivably require a recompile. If this is the case, then mosi may be out of luck. Then again, people have done some interesting dynamic modifications to the interpreter during runtime without recompiling. Psyco is the best example of this that comes to mind. Maybe someone more versed in Psyco-esque interpreter voodoo would be able to help. -- nasser -- http://mail.python.org/mailman/listinfo/python-list