Re: [matplotlib-devel] Unicode to Tex symbols, Type1 names, and vice versa
On 6/22/06, John Hunter <[EMAIL PROTECTED]> wrote: > Since you asked :-) > > I may not have mentioned this but the style conventions for mpl code > are > > functions : lower or lower_score_separated > variables and attributes : lower or lowerUpper > classes : Upper or MixedUpper OK > Also, I am not too fond of the dict of dicts -- why not use variable > names? I used a dict of dicts because this allowed me to generate separate picle files (for each one of the dicts in the top-level dict) and anything else (see the final script) by their coresponding top-level dict name. I thought it was better, for practical/speed reasons, to have separate pickle files, for every dict. > for line in file(fname): > if line[:2]!=' 0': continue # using continue avoids unneccesary indent Thanks for the tip! > uninum = line[2:6].strip().lower() > type1name = line[12:37].strip() > texname = line[83:110].strip() > > uninum = int(uninum, 16) I thought that the idea was to allow users to write unicode strings directly in TeX (OK, this isn't much of an excuse :). That's why I used the eval approach, to get the dict keys (or values) to be unicode strings. I'm also aware that indexing by ints is faster, and that the underlying FT2 functions work with ints... OK, I'm now convinced that your approach is better :) > pickle.dump((uni2type1, type12uni, uni2tex, tex2uni), > file('unitex.pcl','w')) > > # An example > unichar = int('00d7', 16) > print uni2tex.get(unichar) > print uni2type1.get(unichar) > > Also, I am a little hesitant to use pickle files for the final > mapping. I suggest you write a script that generates the python code > contains the dictionaries you need (that is how much of _mathext_data > was generated. The reason why I used pickle - from the Python docs: = Strings can easily be written to and read from a file. Numbers take a bit more effort, since the read() method only returns strings, which will have to be passed to a function like int(), which takes a string like '123' and returns its numeric value 123. However, when you want to save more complex data types like lists, dictionaries, or class instances, things get a lot more complicated. Rather than have users be constantly writing and debugging code to save complicated data types, Python provides a standard module called pickle. This is an amazing module that can take almost any Python object (even some forms of Python code!), and convert it to a string representation; this process is called pickling. Reconstructing the object from the string representation is called unpickling. Between pickling and unpickling, the string representing the object may have been stored in a file or data, or sent over a network connection to some distant machine. = So I thought that pickling was the obvious way to go. And, of course, unpickling with cPickle is very fast. I also think that no human being should change the automaticaly generated dicts. Rather, we should put a separate python file (i.e. _mathtext_manual_data.py) where anybody who wants to manually override the automaticaly generated values, or add new (key, value) pairs can do so. The idea: _mathtext_manual_data.py: === uni2text = {key1:value1, key2:value2} tex2uni = {} uni2type1 = {} type12uni = {} uni2tex.py: === from cPickle import load uni2tex = load(open('uni2tex.cpl')) try: import _mathtext_manual_data uni2tex.update(_mathtext_manual_data.uni2tex) except (TypeError, SyntaxError): # Just these exceptions should be raised raise except: # All other exceptions should be silent pass = Finally, I added lines for automatically generating pretty much everything that can be automatically generated stix-tbl2py.py === '''A script for seemlesly copying the data from the stix-tbl.ascii* file to a set of python dicts. Dicts are then pickled to coresponding files, for later retrieval. Currently used table file: http://www.ams.org/STIX/bnb/stix-tbl.ascii-2005-09-24 ''' import pickle tablefilename = 'stix-tbl.ascii-2005-09-24' dictnames = ['uni2type1', 'type12uni', 'uni2tex', 'tex2uni'] dicts = {} # initialize the dicts for name in dictnames: dicts[name] = {} for line in file(tablefilename): if line[:2]!=' 0': continue uninum = int(line[2:6].strip().lower(), 16) type1name = line[12:37].strip() texname = line[83:110].strip() if type1name: dicts['uni2type1'][uninum] = type1name dicts['type12uni'][type1name] = uninum if texname: dicts['uni2tex'][uninum] = texname dicts['tex2uni'][texname] = uninum template = '''# Automatically generated file. from cPickle import load %(name)s = load(open('%(name)s.pcl')) try: import _mathtext_manual_data %(name)s.update(_mathtext_manual_data.%(name)s) except (TypeError, SyntaxError): # Just these exceptions should be raised raise except: # All other exceptions should be silent pass ''' # pickling t
Re: [matplotlib-devel] patches for: bar() and barh() ignore rcparams patch.facecolor and patch.endcolor
> "Martin" == Martin Spacek <[EMAIL PROTECTED]> writes: Martin> I suppose I'm a bit jaded towards edges because I tend to Martin> make histograms and not bar graphs, but we can have it Martin> both ways. I can live with that -- did you test your work with the table_demo? Martin> Sure. Here they are against their latest rev (2508 for Martin> both). Never done logs before, hope they're alright. What Martin> do you mean by "the rest"? "the rest", meaning the work you had already done. I'm having trouble applying your patch because of the way the file names are coded. If somebody knows the magic patch command to make it go through, please commit it. Otherwise, Martin, can you make a patch with svn diff from the mpl root dir (the one that setup.py lives in)? Thanks, JDH Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Unicode to Tex symbols, Type1 names, and vice versa
> "Edin" == Edin Salkovi§ <[EMAIL PROTECTED]> writes: Edin> The reason why I used pickle - from the Python docs: = I have had bad experiences in the past with pickle files created with one version that don't load with another. I don't know if that is a common problem or if others have experienced it, but it has made me wary of them for mpl, where we work across platforms and python versions. Maybe this concern is unfounded. I still do not understand what the downside is of simply creating a dictionary in a python module as we do with latex_to_bakoma. JDH Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Unicode to Tex symbols, Type1 names, and vice versa
> "Edin" == Edin Salkovi§ <[EMAIL PROTECTED]> writes: Edin> I thought that the idea was to allow users to write unicode Edin> strings directly in TeX (OK, this isn't much of an excuse No, this is not the reason. Someone may want to do that one day so it is good to keep the possibility in the back of your mind. The point of this work is to decouple mathtext from the bakoma fonts. Right now the mathtext data has a hard mapping from texnames->bakoma glyph info. By setting up the encoding from texnames->unicode, then with a little more work we can use any set of fonts that provide the unicode names. Once we jettison bakoma, we can get nicer glyphs and kerning with a decent set of fonts. Once we have that, we can work on the layout algorithms. JDH Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Unicode to Tex symbols, Type1 names, and vice versa
On 6/23/06, John Hunter <[EMAIL PROTECTED]> wrote: > > "Edin" == Edin Salkovi§ <[EMAIL PROTECTED]> writes: > Edin> The reason why I used pickle - from the Python docs: = > > I have had bad experiences in the past with pickle files created with > one version that don't load with another. I don't know if that is a > common problem or if others have experienced it, but it has made me > wary of them for mpl, where we work across platforms and python > versions. Maybe this concern is unfounded. I still do not understand > what the downside is of simply creating a dictionary in a python > module as we do with latex_to_bakoma. The most common way pickle breaks is when you pickle an instance and later modify the class it belongs to such that some attribute disappears or is renamed. Since pickling works by 'fully qualified name', meaning that it only saves the name of the class and the instance data, but it doesn't actually save the original class, in this scenario the pickle can't be unpickled since there are attributes that the new class doesn't have anymore. If you are strictly pickling data in one of the builtin python types, you are /probably/ OK, as I don't see python removing attributes from dicts, and the builtin data types don't really have any special instance attributes with much metadata that can change. But it's still true that there's a window for problems with pickle that simply isn't there with a pure auto-generated source module. And the speed argument is, I think moot: when you import something, python marshals the source into binary bytecode using something which I think is quite similar to cPickle, and probably just as fast (if not faster, since marshal is simpler than pickle). I'm not 100% sure on the details of bytecode marshalling, so please correct me if this part is wrong. HTH, f Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] patches for: bar() and barh() ignore rcparams patch.facecolor and patch.endcolor
John Hunter wrote: > I can live with that -- did you test your work with the table_demo? I just tried table_demo, looks good, bars are nicely centered (had to set my rcparams axes.hold to True to get all four colours of bars). I'm having trouble applying your patch because of the way the file names are coded. If somebody knows the magic patch command to make it go through, please commit it. Otherwise, Martin, can you make a patch with svn diff from the mpl root dir (the one that setup.py lives in)? Ah, I was just working off the axes.py file from viewcvs. I've checked out now from /trunk/matplotlib/ (using tortoise svn). Hopefully this new patch file will work. Cheers, Martin Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (revision 2514) +++ lib/matplotlib/axes.py (working copy) @@ -2364,114 +2364,213 @@ def bar(self, left, height, width=0.8, bottom=0, -color='b', yerr=None, xerr=None, ecolor='k', capsize=3 +color=None, edgecolor=None, yerr=None, xerr=None, ecolor=None, capsize=3, +align='edge', orientation='vertical' ): """ BAR(left, height, width=0.8, bottom=0, -color='b', yerr=None, xerr=None, ecolor='k', capsize=3) +color=None, edgecolor=None, yerr=None, xerr=None, ecolor=None, capsize=3, +align='edge', orientation='vertical') -Make a bar plot with rectangles at +Make a bar plot with rectangles bounded by - left, left+width, 0, height + left, left+width, bottom, bottom+height (left, right, bottom and top edges) -left and height are Numeric arrays. +left, height, width, and bottom can be either scalars or sequences Return value is a list of Rectangle patch instances BAR(left, height, width, bottom, -color, yerr, xerr, capsize, yoff) +color, edgecolor, yerr, xerr, ecolor, capsize, +align, orientation) +left - the x coordinates of the left sides of the bars + +height - the heights of the bars + +Optional arguments + +width - the widths of the bars + +bottom - the y coordinates of the bottom edges of the bars + +color specifies the colors of the bars + +edgecolor specifies the colors of the bar edges + xerr and yerr, if not None, will be used to generate errorbars - on the bar chart +on the bar chart -color specifies the color of the bar - ecolor specifies the color of any errorbar capsize determines the length in points of the error bar caps +align = 'edge' | 'center' -The optional arguments color, width and bottom can be either -scalars or len(x) sequences +orientation = 'vertical' | 'horizontal' +For vertical bars, 'edge' aligns bars by their left edges in left, +while 'center' interprets these values as the x coordinates of the bar centers. +For horizontal bars, 'edge' aligns bars by their bottom edges in bottom, +while 'center' interprets these values as the y coordinates of the bar centers. + +The optional arguments color, edgecolor, yerr, and xerr can be either +scalars or sequences of length equal to the number of bars + This enables you to use bar as the basis for stacked bar charts, or candlestick plots """ if not self._hold: self.cla() -# left = asarray(left) - width/2 +def make_iterable(x): +if not iterable(x): +return [x] +else: +return x + +# make them safe to take len() of +left = make_iterable(left) +height = make_iterable(height) +width = make_iterable(width) +bottom = make_iterable(bottom) + +if orientation == 'vertical': +# size width and bottom according to length of left +nbars = len(left) +if len(width) == 1: +width *= nbars +if len(bottom) == 1: +bottom *= nbars +elif orientation == 'horizontal': +# size left and height according to length of bottom +nbars = len(bottom) +if len(left) == 1: +left *= nbars +if len(height) == 1: +height *= nbars +else: +raise ValueError, 'invalid orientation: %s' % orientation + left = asarray(left) height = asarray(height) +width = asarray(width) +bottom = asarray(bottom) -patches = [] - - # if color looks like a color string, an RGB tuple or a -# scalar, then repeat it by len(x) +# scalar, then repeat it by nbars if (is_string_like(color)
Re: [matplotlib-devel] patches for: bar() and barh() ignore rcparams patch.facecolor and patch.endcolor
> "Martin" == Martin Spacek <[EMAIL PROTECTED]> writes: Martin> Ah, I was just working off the axes.py file from Martin> viewcvs. I've checked out now from /trunk/matplotlib/ Martin> (using tortoise svn). Hopefully this new patch file will Martin> work. Making progress - I was able to apply this and check it in, but I only got a patch for axes.py (no CHANGELOG, API_CHANGES, modified examples, etc). Also, examples/barh_demo.py is now broken after application of this partial patch). Could you get a fresh checkout from svn (revision 2515) and see what is missing and then provide an updated patch? Thanks! JDH Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] patches for: bar() and barh() ignore rcparams patch.facecolor and patch.endcolor
Whoops. Forgot to include the patches for CHANGELOG and API_CHANGES. I updated barh_demo.py as well, and tested the rest of the bar demos. Here's the combined patch against 2515. Sorry for the hassle, I'm a bit new at this. Cheers, Martin John Hunter wrote: "Martin" == Martin Spacek <[EMAIL PROTECTED]> writes: Martin> Ah, I was just working off the axes.py file from Martin> viewcvs. I've checked out now from /trunk/matplotlib/ Martin> (using tortoise svn). Hopefully this new patch file will Martin> work. Making progress - I was able to apply this and check it in, but I only got a patch for axes.py (no CHANGELOG, API_CHANGES, modified examples, etc). Also, examples/barh_demo.py is now broken after application of this partial patch). Could you get a fresh checkout from svn (revision 2515) and see what is missing and then provide an updated patch? Thanks! JDH Index: API_CHANGES === --- API_CHANGES (revision 2515) +++ API_CHANGES (working copy) @@ -1,3 +1,18 @@ +barh: x and y args have been renamed to width and bottom +respectively, and their order has been swapped to maintain +a (position, value) order. + +bar and barh: now accept kwarg 'edgecolor'. + +bar and barh: The left, height, width and bottom args can +now all be scalars or sequences; see docstring. + +barh: now defaults to edge aligned instead of center +aligned bars + +bar, barh and hist: Added a keyword arg 'align' that +controls between edge or center bar alignment. + Collections: PolyCollection and LineCollection now accept vertices or segments either in the original form [(x,y), (x,y), ...] or as a 2D numerix array, with X as the first column Index: CHANGELOG === --- CHANGELOG (revision 2515) +++ CHANGELOG (working copy) @@ -1,3 +1,19 @@ +2006-06-22 Various changes to bar(), barh(), and hist(). + Added 'edgecolor' keyword arg to bar() and barh(). + The x and y args in barh() have been renamed to width + and bottom respectively, and their order has been swapped + to maintain a (position, value) order ala matlab. left, + height, width and bottom args can now all be scalars or + sequences. barh() now defaults to edge alignment instead + of center alignment. Added a keyword arg 'align' to bar(), + barh() and hist() that controls between edge or center bar + alignment. Fixed ignoring the rcParams['patch.facecolor'] + for bar color in bar() and barh(). Fixed ignoring the + rcParams['lines.color'] for error bar color in bar() + and barh(). Fixed a bug where patches would be cleared + when error bars were plotted if rcParams['axes.hold'] + was False. - MAS + 2006-06-22 Added support for numerix 2-D arrays as alternatives to a sequence of (x,y) tuples for specifying paths in collections, quiver, contour, pcolor, transforms. Index: examples/barh_demo.py === --- examples/barh_demo.py (revision 2515) +++ examples/barh_demo.py (working copy) @@ -2,19 +2,19 @@ # make a horizontal bar chart from pylab import * -x = 3+10*rand(5)# the bar lengths -y = arange(5)+.5# the bar centers on the y axis +val = 3+10*rand(5)# the bar lengths +pos = arange(5)+.5# the bar centers on the y axis figure(1) -barh(x,y) -yticks(y, ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')) +barh(pos,val, align='center') +yticks(pos, ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')) xlabel('Perfomance') title('How fast do you want to go today?') grid(True) figure(2) -barh(x,y, xerr=rand(5)) -yticks(y, ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')) +barh(pos,val, xerr=rand(5), align='center') +yticks(pos, ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')) xlabel('Perfomance') show() Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] patches for: bar() and barh() ignore rcparams patch.facecolor and patch.endcolor
> "Martin" == Martin Spacek <[EMAIL PROTECTED]> writes: Martin> Whoops. Forgot to include the patches for CHANGELOG and Martin> API_CHANGES. I updated barh_demo.py as well, and tested Martin> the rest of the bar demos. Here's the combined patch Martin> against 2515. Martin> Sorry for the hassle, I'm a bit new at this. OK, great. They are in 2516. Thanks! JDH Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] One short question
In the Non-PostScript font classes in mathtext.py the set_canvas_size is def set_canvas_size(self, w, h): 'Dimension the drawing canvas; may be a noop' self.width = int(w) self.height = int(h) for font in self.fonts.values(): font.set_bitmap_size(int(w), int(h)) While in the PS class: def set_canvas_size(self, w, h, pswriter): 'Dimension the drawing canvas; may be a noop' self.width = w self.height = h self.pswriter = pswriter Why is the float converted to int in the first case, and not in the second? Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Unicode to Tex symbols, Type1 names, and vice versa
Thanks John and Fernando, You're right. I'll change the scripts to generate pure Python modules, but I'll leave the "manual" module. As for Unicode, I fully understand what you mean John, and I'm planing to try to get mathtext to work with the fonts I mentioned to you a while ago: http://canopus.iacp.dvo.ru/~panov/cm-unicode/ although they don't have almost any pure math characters (like integral etc.), but at least they'll be usefull for testing the module. They have some very exotic characters. The maintainer said that, if I (or anybody) want to, I can send him patches for the math symbols (not for this SoC :). Edin On 6/23/06, Fernando Perez <[EMAIL PROTECTED]> wrote: > On 6/23/06, John Hunter <[EMAIL PROTECTED]> wrote: > > > "Edin" == Edin Salkovi§ <[EMAIL PROTECTED]> writes: > > Edin> The reason why I used pickle - from the Python docs: = > > > > I have had bad experiences in the past with pickle files created with > > one version that don't load with another. I don't know if that is a > > common problem or if others have experienced it, but it has made me > > wary of them for mpl, where we work across platforms and python > > versions. Maybe this concern is unfounded. I still do not understand > > what the downside is of simply creating a dictionary in a python > > module as we do with latex_to_bakoma. > > The most common way pickle breaks is when you pickle an instance and > later modify the class it belongs to such that some attribute > disappears or is renamed. Since pickling works by 'fully qualified > name', meaning that it only saves the name of the class and the > instance data, but it doesn't actually save the original class, in > this scenario the pickle can't be unpickled since there are > attributes that the new class doesn't have anymore. > > If you are strictly pickling data in one of the builtin python types, > you are /probably/ OK, as I don't see python removing attributes from > dicts, and the builtin data types don't really have any special > instance attributes with much metadata that can change. > > But it's still true that there's a window for problems with pickle > that simply isn't there with a pure auto-generated source module. And > the speed argument is, I think moot: when you import something, python > marshals the source into binary bytecode using something which I think > is quite similar to cPickle, and probably just as fast (if not faster, > since marshal is simpler than pickle). I'm not 100% sure on the > details of bytecode marshalling, so please correct me if this part is > wrong. > > HTH, > > f > Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Unicode to Tex symbols, Type1 names, and vice versa
Look what happened to my beautiful code :( '''A script for seemlesly copying the data from the stix-tbl.ascii* file to a set of python dicts. Dicts are then saved to .py coresponding files, for later retrieval. Currently used table file: http://www.ams.org/STIX/bnb/stix-tbl.ascii-2005-09-24 ''' tablefilename = 'stix-tbl.ascii-2005-09-24' dictnames = ['uni2type1', 'type12uni', 'uni2tex', 'tex2uni'] dicts = {} # initialize the dicts for name in dictnames: dicts[name] = {} for line in file(tablefilename): if line[:2]!=' 0': continue uninum = int(line[2:6].strip().lower(), 16) type1name = line[12:37].strip() texname = line[83:110].strip() if type1name: dicts['uni2type1'][uninum] = type1name dicts['type12uni'][type1name] = uninum if texname: dicts['uni2tex'][uninum] = texname dicts['tex2uni'][texname] = uninum template = '''# Automatically generated file. # Don't edit this file. Edit _mathtext_manual_data.py instead %(name)s = {%(pairs)s } try: from _mathtext_manual_data import _%(name)s %(name)s.update(_%(name)s) except (TypeError, SyntaxError): # Just these exceptions should be raised raise except: # All other exceptions should be silent. Even ImportError pass ''' # automatically generating .py module files, used by importers for name in ('uni2type1', 'uni2tex'): pairs = '' for key, value in dicts[name].items(): value = value.replace("'","\\'") value = value.replace('"','\\"') pair = "%(key)i : r'%(value)s',\n"%(locals()) pairs += pair file(name + '.py','w').write(template%{'name':name, 'pairs':pairs}) for name in ('type12uni', 'tex2uni'): pairs = '' for key, value in dicts[name].items(): key = key.replace("'","\\'") key = key.replace('"','\\"') pair = "r'%(key)s' : %(value)i,\n"%(locals()) pairs += pair file(name + '.py','w').write(template%{'name':name, 'pairs':pairs}) # An example from uni2tex import uni2tex from uni2type1 import uni2type1 unichar = u'\u00d7' uninum = ord(unichar) print uni2tex[uninum] print uni2type1[uninum] Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel