Re: Walking deeply nested lists

2010-08-28 Thread donn
On 28/08/2010 08:43, Peter Otten wrote: If you call functions within functions (or methods, it doesn't matter) they consume stack space Right, got it. Darn, but at least there's that setrecursionlimit call. Thanks, \e -- http://mail.python.org/mailman/listinfo/python-list

Re: Walking deeply nested lists

2010-08-28 Thread donn
On 28/08/2010 09:21, Arnaud Delobelle wrote: This flattens the list in the flatwalk method (which IMHO it should do given its name!): Heh, I often name things ahead of my actual capacity to implement them! el is child.flatwalk(): Ah, I see what you mean. I think 'is' is 'in', but I kind of

Re: Walking deeply nested lists

2010-08-28 Thread donn
On 28/08/2010 11:17, Carl Banks wrote: It's simple. Copy the object to flatten onto your stack. Pop one item off the stack. If the item you popped is a list, push each item of that list onto the stack. Otherwise yield the value. Loop until stack is empty. Nice. The reversed thing was throwing

Re: Walking deeply nested lists

2010-08-28 Thread donn
On 28/08/2010 12:03, Peter Otten wrote: But be warned that if you set the limit too high instead of giving you a RuntimeError your program will segfault. Silly question: is there any way to tell the future in this case? I mean, ask for X recursion limit, and catch an error (or something) if

Re: Walking deeply nested lists

2010-08-28 Thread donn
On 28/08/2010 14:41, Peter Otten wrote: BTW, I didn't expect it but I get different results on different runs. Clever code. I will give it a go soonest. Elec off for the next 24 hours in my neck of the woods. Urgh. Python can't import electricity just yet :) \d --

Walking deeply nested lists

2010-08-27 Thread donn
This is all about walking trees, recursion and generators. None of which fit my brain at all! From an XML tree (an SVG file) I build a bunch of Tag objects. [I use lxml, but I am combining multiple svg files into a 'forest' of trees, so I can't use the lxml walking methods because they all

Re: Trying to set a cookie within a python script

2010-08-04 Thread donn
On 04/08/2010 20:09, Dotan Cohen wrote: Don't forget that the Euro symbol is outside the Greek character set. I could make some kind of economic joke here, but I'm also broke :D \d -- http://mail.python.org/mailman/listinfo/python-list

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread donn
On 02/08/2010 17:35, Mark Lawrence wrote: aka the colon. :) Ha. This is a case of the colon being the appendix! \d -- http://mail.python.org/mailman/listinfo/python-list

Re: Hello [How to run your code]

2010-07-10 Thread donn
On 10/07/2010 13:05, Dani Valverde wrote: It could be a solution. But I am used to work with gEdit using the R statistical programming language plugin, and I am able to send the code to console instead of typing it in. To run your code, save it to a file 'mycode.py' (or whatever), then open a

Re: How to keep effects of image filters going for some seconds?

2010-03-21 Thread donn
On 21/03/2010 09:23, Ren Wenshan wrote: I have been learning Panda3D, an open source 3D engine, Ask on the Panda3D forums, you will get good help there. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating formatted output using picture strings

2010-02-10 Thread donn
On 10/02/2010 20:36, pyt...@bdurham.com wrote: def picture(s, pic, placeholder='@'): nextchar=iter(s).next return ''.join(nextchar() if i == placeholder else i for i in pic) Hell's teeth - even I understood that! Amazing solution. \d -- Fonty Python and Things! --

pyclutter anyone?

2010-02-05 Thread donn
Hi, this is a little bit of a cross-post. I posted to the clutter list, but there's little activity there. I am trying to make sense of pyClutter 1.0. Could anyone point me to an example (or post one) that shows clipping from a path applied to child objects? For example: A star shape that

Re: pyclutter anyone?

2010-02-05 Thread donn
No one uses pyClutter? I have some code, it does not work, but maybe this will start to help solve the problem: import clutter from clutter import cogl x,y=0,0 def boo(tl,frame,obj):#,evt): global x,y obj.set_position(x, y) def xy(obj,evt): global x,y x,y =

Re: Significant whitespace

2010-01-01 Thread Donn
On Saturday 02 January 2010 00:02:36 Dan Stromberg wrote: I put together a page about significant whitespace (and the lack thereof). The only thing about Python's style that worries me is that it can't be compressed like javascript can*, and perhaps that will prevent it becoming a browser-side

Re: pyZui - anyone know about this?

2009-12-17 Thread Donn
On Thursday 17 December 2009 10:54:59 David Roberts wrote: Have you seen Eagle Mode[1]? Yes. It's a strange beast. Good start I think; but addicted to zooming, to the detriment of the managing aspects I think. Still, here I sit writing no code and pontificating! \d -- \/\/ave:

Re: pyZui - anyone know about this?

2009-12-17 Thread Donn
On Thursday 17 December 2009 19:46:41 Terry Reedy wrote: His idea was for a document rather than app centric plain. These days I find the notion of monolithic apps to be a pita. The concept of many small black boxes (but open source) that each do a single job and pipe in/out is so much more

Re: pyZui - anyone know about this?

2009-12-16 Thread Donn
On Wednesday 16 December 2009 09:42:14 David Roberts wrote: PyZUI 0.1 has been released: Magic! Grabbed a tarball yesterday. \d -- \/\/ave: donn.in...@googlewave.com home: http://otherwise.relics.co.za/ 2D vector animation : https://savannah.nongnu.org/projects/things/ Font manager :

Re: pyZui - anyone know about this?

2009-12-16 Thread Donn
On Wednesday 16 December 2009 07:03:19 David Roberts wrote: It involves scaling an image to various resolutions, and partitioning them into fixed-size tiles. It's roughly the same technique used by Google Maps/Earth. Thanks. That gives me something to go on. Wikipedia didn't like my search

Re: pyZui - anyone know about this?

2009-12-15 Thread Donn
On Tuesday 15 December 2009 04:29:39 David Roberts wrote: Yes, the toolkit used is PyQt. \me makes note to start learning PyQt asap. and employs pyramidal tiling for efficiency \me ... time to hit Wikipedia :) (I haven't used any Qt/KDE voodoo in this regard). Imho, your code should *become*

Re: pyZui - anyone know about this?

2009-12-15 Thread Donn
On Tuesday 15 December 2009 11:12:21 Martijn Arts wrote: You could do some really awesome stuff with that! I love the webpage example where you zoom in on the exclamation mark and there's a new page. It is very cool, but I would inject a note of caution here: I'd a hate a zui to become a

Re: pyZui - anyone know about this?

2009-12-14 Thread Donn
On Monday 14 December 2009 00:10:52 David Boddie wrote: Doesn't the author give his e-mail address at the end of the video? (Maybe I'm thinking of a different video.) Yes, in a quick and garbled way :) I have yet to try to contact the author or the youtube poster -- been too busy. I was

Re: pyZui - anyone know about this?

2009-12-14 Thread Donn
On Tuesday 15 December 2009 01:43:52 David Boddie wrote: I managed to catch his address and sent him a message saying that people were discussing PyZUI in this thread. Oooh. Sits,fidgets and waits. I want my socks back! (OP) :D \d -- \/\/ave: donn.in...@googlewave.com home:

Re: pyZui - anyone know about this?

2009-12-11 Thread Donn
On Friday 11 December 2009 12:38:46 Daniel Fetchinson wrote: Youtube has a link 'Send message' on the profile of users, maybe sending a message to the person who uploaded the video will give you a useful response. I'm a Tube-tard so that never crossed my mind. Will give it a go. \d --

pyZui - anyone know about this?

2009-12-10 Thread Donn
Hi, I happened upon this youtube link: http://www.youtube.com/watch?v=57nWm984wdY It fairly blew my socks off. In it a fellow by the name of David Roberts demos a zui written in Python. Aside from the zooming (which is impressive enough) it show embedding of images, pdf files, web pages and

Re: Python Go

2009-11-17 Thread Donn
On Saturday 14 November 2009 22:23:40 Paul Rubin wrote: they'll have to call it Go2 Lol. Or we could fork it and call it Gosub ... and never return! \d -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is python so sad?

2009-10-27 Thread Donn
def ...(...(: ... class ...(...(: I disagree. It looks like one smiley is drooling into the other smiley's mouth. Two smileys, one function? Yuk! That *def*initely has no *class* ... :P \d -- http://mail.python.org/mailman/listinfo/python-list

Re: how to write a unicode string to a file ?

2009-10-15 Thread Donn
On Friday 16 October 2009 01:59:43 Stephen Hansen wrote: Just to say, thanks for that post. I am an old ascii dog and this notion of encoding and decoding is taking such a lng time to penetrate my thick skull. Little snippets like your post are valuable insights. I have made a gnote of it!

Re: Unexpected exit of Python script

2009-10-14 Thread Donn
On Wednesday 14 October 2009 14:23:11 vicky wrote: I just want to know that, due to any reason if a script exits, is their some way to release all the resources acquired by the script during execution ? Python cleans-up after itself so I would not worry about that until you are an expert and

Re: What do I do now?

2009-10-11 Thread Donn
On Monday 12 October 2009 00:53:42 Someone Something wrote: 1) What should I start programming (project that takes 1-2 months, not very short term)? 2) Whtat are some good open source projects I can start coding for? These kinds of questions amaze me. Surely you are a kid in a candy shop when

Re: organizing your scripts, with plenty of re-use

2009-10-03 Thread Donn
Great description - wish the Python docs could be as clear. Thanks. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: SVG PIL decoder

2009-09-30 Thread Donn
On Wednesday 30 September 2009 18:01:50 Patrick Sabin wrote: I would like to open svg files with PIL, but svg doesn't seem to be supported. Does anyone know about a svg decoder for the PIL? Have a look at Cairo (python-cairo) in conjunction with librsvg (python-rsvg) -- that'll fix you up. You

Re: SVG PIL decoder

2009-09-30 Thread Donn
On Thursday 01 October 2009 01:08:28 Patrick Sabin wrote: Thanks for the tip. Got it work, although it was a bit tricky, as resizing doesn't seem to be supported by python-rsvg and cairo.ImageSurface.create_from_png doesn't allow StringIO or My best suggestions are to visit the Cairo website --

Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Donn
On Friday 25 September 2009 08:15:18 Olof Bjarnason wrote: Does anyone have any hint on a more economic way of creating single-file distribution packages You could use distutils (setup.py) and include a readme that explains what apt-get commands to use to install pygame, etc. Generally it's

Re: Getting return code for a Python script invoked from a Linux shell script

2009-09-23 Thread Donn
On Wednesday 23 September 2009 18:51:29 volcano wrote: exit_code = !$ I think it's $? to get the code. \d -- home: http://otherwise.relics.co.za/ 2D vector animation : https://savannah.nongnu.org/projects/things/ Font manager : https://savannah.nongnu.org/projects/fontypython/ --

Re: arrays in python

2009-09-23 Thread Donn
On Wednesday 23 September 2009 19:14:20 Rudolf wrote: I want to allocate an array and then populate it using a for loop. You don't need to allocate anything, just use the list or dictionary types. l=[] #empty list for x in range(1,500): l.append(x) \d --

Re: arrays in python

2009-09-23 Thread Donn
On Wednesday 23 September 2009 22:12:24 Ethan Furman wrote: Works great if you want 4,999,999 elements. ;-) Omit the '1' if you want all five million. Yes. Fenceposts always get me :) And I was just reminded that one can: l=range(500) \d -- home: http://otherwise.relics.co.za/ 2D vector

Re: how to truncate to get the 1st 5 chars from a string

2009-09-23 Thread Donn
On Thursday 24 September 2009 05:05:45 MacRules wrote: s=1234abcd print s[0:4] should do it. Not sure it's a function though. \d -- home: http://otherwise.relics.co.za/ 2D vector animation : https://savannah.nongnu.org/projects/things/ Font manager :

Re: easy question, how to double a variable

2009-09-22 Thread Donn
On Monday 21 September 2009 22:49:50 daggerdvm wrote: you brain needs error checking! try: return response() except Troll,e: raise dontFeed(anymore=True) \d -- home: http://otherwise.relics.co.za/ 2D vector animation : https://savannah.nongnu.org/projects/things/ Font manager :

Re: How to print without spaces?

2009-09-18 Thread Donn
print a+b \d -- http://mail.python.org/mailman/listinfo/python-list

Re: ImageFont family mojibake

2009-09-12 Thread Donn
On Saturday 12 September 2009 07:55:14 Lie Ryan wrote: f=ImageFont.truetype(FGTshgyo.TTF,1,encoding=utf-8) print f.font.family '?s' Are you sure that your terminal (Command Prompt/bash/IDLE/etc) supports utf-8 and that it is properly set up to display utf-8? Fairly sure... It's

Re: ImageFont family mojibake

2009-09-12 Thread Donn
On Saturday 12 September 2009 17:30:19 garabik- news-2005...@kassiopeia.juls.savba.sk wrote: apt-get install unicode unicode 0100.. Nice tip, thanks. if you see a lot of accented letters (and not squares or question marks), you can be sure I see the accented chars -- so now I am more certain

Re: Why can't I run this test class?

2009-09-11 Thread Donn
On Friday 11 September 2009 09:30:42 Kermit Mei wrote: Do this: class Test(object): t1 = Test And this: t1 = Test() That makes an instance and runs the __init__ \d -- home: http://otherwise.relics.co.za/ 2D vector animation : https://savannah.nongnu.org/projects/things/ Font manager :

Re: Simple unicode-safe version of str(exception)?

2008-04-28 Thread Donn Cave
', extending it to fall back to repr() whatever goes wrong. def xtr(a): try: return str(a) except: return repr(a) ... self.setState(self.Failed, xtr(e)) Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: py3k concerns. An example

2008-04-25 Thread Donn Cave
for your mastery of it, but you need a better dictionary. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: py3k s***s

2008-04-16 Thread Donn Cave
ways, but I think if you were to apply a sort of conspiracy analysis to the situation - who benefits from language change - this would be a couple items down on the list of motivations. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: py3k s***s

2008-04-16 Thread Donn Cave
thereafter. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: py3k s***s

2008-04-15 Thread Donn Cave
, but of course it has its costs too. Anyone who might be thinking about using Python for an application should seriously think about this. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: pty.spawn directs stderr to stdout

2008-04-11 Thread Donn Cave
for some reason. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Orphaned child processes

2008-04-07 Thread Donn Cave
than one child process. Since the parent holds the write end of the pipe, subsequently forked child processes could easily inherit it, and they'll hold it open and spoil the effect. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Summary of threading for experienced non-Python programmers?

2008-03-31 Thread Donn Cave
just a terminological thing. kqueue(2) on MacOS X mentions an EVFILT_AIO option. It isn't supported on that platform, but maybe that's a vestige of some other platform that does support asynchronous, blocking with aio -- as VAX/VMS did (and presumably still does), with event flags. Donn Cave

Re: Summary of threading for experienced non-Python programmers?

2008-03-28 Thread Donn Cave
have the copying to do. I don't see even this much in asyncore.py, but I just gave it a glance. thanks, Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: What Programming Languages Should You Learn Next?

2008-03-20 Thread Donn Cave
in languages like C++, but today, it makes me appreciate Haskell's potential for complex projects. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: KeyboardInterrupt should not kill subprocess

2008-02-21 Thread Donn Cave
try posix.setsid(), from the child fork. The object is to get the child fork out of the foreground process group for the Berkeley terminal driver. This defines who gets signals, when they originate in terminal control keys. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo

Re: piping into a python script

2008-01-25 Thread Donn Ingle
Nick Craig-Wood wrote: This iterates over the lines of all files listed in sys.argv[1:], defaulting to sys.stdin if the list is empty. If a filename is '-', it is also replaced by sys.stdin. To specify an alternative list of filenames, pass it as the first argument to input(). A single file

Re: piping into a python script

2008-01-25 Thread Donn
Andrew, Thanks for your tips. I managed to get a working script going. I am sure there will be stdin 'issues' to come, but I hope not. If anyone wants to have a look, it's on the cheese shop at: http://pypi.python.org/pypi/fui \d -- You know, I've gone to a lot of psychics, and they've told me

Re: piping into a python script

2008-01-25 Thread Donn Ingle
Hexamorph wrote: It's a bit clumsy, but seems to do what I guess you want. Hey, thanks for that! I will have a go. \d -- http://mail.python.org/mailman/listinfo/python-list

piping into a python script

2008-01-24 Thread Donn Ingle
Hi, (Gnu/Linux - Python 2.4/5) Given these two examples: 1. ./fui.py *.py 2. ls *.py | ./fui.py How can I capture a list of the arguments? I need to get all the strings (file or dir names) passed via the normal command line and any that may come from a pipe. There is a third case: 3. ls *.jpg |

Re: piping into a python script

2008-01-24 Thread Donn Ingle
Try the fileinput module. I did give the fileinput module a go, but I can't find much info on it and the help is ... well, it's python help ;) in goes to its stdin where it is processed if it has an argument of - fileinput works that way Okay, I did think of the dash, but did not know how to

Re: piping into a python script

2008-01-24 Thread Donn Ingle
Paddy wrote: ls *.a | ./fui.py -f - *.b To be sure I grok this: I am seeing the single dash as a placeholder for where all the piped filenames will go, so *.b happens after *.a has been expanded and they all get fed to -f, right? I'm also guessing you mean that I should detect the single dash

Re: piping into a python script

2008-01-24 Thread Donn Ingle
Paddy wrote: fileinput is set to process each file a line at a time unfortunately. Wow. So there seems to be no solution to my OP. I'm amazed, I would have thought a simple list of strings, one from stdin and one from the args, would be easy to get. I *really* don't want to open each file, that

Re: piping into a python script

2008-01-24 Thread Donn
wget -i - it doesn't do anything, just waits for your input. Your applications probably should behave the same. Okay, that works for me. Paddy wrote: ls *.a | ./fui.py -f - *.b It doesn't seem to me that -f parameter is necessary for your application. Yes and no, I have another option

Re: piping into a python script

2008-01-24 Thread Donn
Thanks for the tips, I'll decode and try 'em all out. Ah yes, Groo. Ever wonder who would win if Groo and Forrest Gump fought each other? Heh ;) I reckon they'd both die laughing. Be fun to watch -- if anyone else survived! \d -- A computer without Windows is like chocolate cake without

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-14 Thread Donn
Can you please type paf = ['/home/donn/.fontypython/M\xc3\x96gul.pog'] f = open(paf, r) I think I was getting a ghost error from another try somewhere higher up. You are correct, this does open the file - no matter what the locale is. I have decided to keep the test for a decode error

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-14 Thread Donn
Given that getlocale() is not to be used, what's the best way to get the locale later in the app? I need that two-letter code that's hidden in a typical locale like en_ZA.utf8 -- I want that 'en' part. BTW - things are hanging-together much better now, thanks to your info. I have it running in

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-14 Thread Donn
You get the full locale name with locale.setlocale(category) (i.e. without the second argument) Ah. Can one call it after the full call has been done: locale.setlocale(locale.LC_ALL,'') locale.setlocale(locale.LC_ALL) Without any issues? I need that two-letter code that's hidden in a

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-13 Thread Donn
Martin, Thanks, food for thought indeed. On Unix, yes. On Windows, NTFS and VFAT represent file names as Unicode strings always, independent of locale. POSIX file names are byte strings, and there isn't any good support for recording what their encoding is. I get my filenames from two

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-13 Thread Donn
Martin, Yes. It does so when it fails to decode the byte string according to the file system encoding (which, in turn, bases on the locale). That's at least one way I can weed-out filenames that are going to give me trouble; if Python itself can't figure out how to decode it, then I can also

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-13 Thread Donn
So on *your* system, today: what encoding are the filenames encoded in? We are not talking about arbitrary files, right, but about font files? What *actual* file names do these font files have? On my system, all font files have ASCII-only file names, even if they are for non-ASCII

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-13 Thread Donn
If you can all ls them, and if the file names come out right, then they'll have the same encoding. Could it not be that the app doing the output (say konsole) could be displaying a filename as best as it can (doing the ignore/replace) trick and using whatever fonts it can reach) and this would

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-13 Thread Donn
No. It may use replacement characters (i.e. a question mark, or an empty square box), but if you don't see such characters, then the terminal has successfully decoded the file names. Whether it also correctly decoded them is something for you to check (i.e. do they look right?) Okay. So, the

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-13 Thread Donn
Martin, I want to thank you for your patience, you have been sterling. I have an overview this evening that I did not have this morning. I have started fixing my code and the repairs may not be that extreme after all. I'll hack-on and get it done. I *might* bug you again, but I'll resist at

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-13 Thread Donn
Well, that didn't take me long... Can you help with this situation? I have a file named MÖgul.pog in this directory: /home/donn/.fontypython/ I set my LANG=C Now, I want to open that file from Python, and I create a path with os.path.join() and an os.listdir() which results in this byte string

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-13 Thread Donn
Now you are mixing two important concepts - the *contents* of the file with the *name* of the file. Then I suspect the error may be due to the contents having been written in utf8 from previous runs. Phew! It's bedtime on my end, so I'll try it again when I get a chance during the week.

LANG, locale, unicode, setup.py and Debian packaging

2008-01-12 Thread Donn Ingle
Hello, I hope someone can illuminate this situation for me. Here's the nutshell: 1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale. 2. If this returns C or anything without 'utf8' in it, then things start to go downhill: 2a. The app assumes unicode objects internally. i.e.

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-12 Thread Donn
Martin, I really appreciate your reply. I have been working in a vacuum on this and without any experience. I hope you don't mind if I ask you a bunch of questions. If I can get over some conceptual 'humps' then I'm sure I can produce a better app. That's a bug in the app. It shouldn't assume

Re: i18n questions

2007-12-29 Thread Donn Ingle
Thorsten Kampe wrote: gettext.textdomain('optparse') gettext.install('script', unicode = True) They speak of a 'global' domain in the docs, but (as is my usual beef with the Python docs -- see PHP docs for sterling help) there is no clarity. It *sounds* like there can be a .mo file for

i18n questions

2007-12-28 Thread Donn Ingle
Hi, A soon-to-be happy new year to everyone! I'm 100% new to this i18n lark and my approach so far has been to create a .mo file per module in my app. My thinking was, why load one huge .mo file when a single module only needs a few strings? Since then, it seems, I have made the wrong

Re: i18n questions

2007-12-28 Thread Donn Ingle
Thanks for taking the time to post those links. I have read most of them before. They don't seem to cover the basic issue in my OP, but i18n on Python is a dark art and maybe there's something I missed. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: i18n questions

2007-12-28 Thread Donn Ingle
Is there a group better suited to gettext/i18n questions of this sort? Just wondering because I have little time left to finish my December project! How does one 'merge' gettext.translations objects together? Or is that insane? What's the best way to handle a project with multiple domain.mo

Sorting Objects by property using locale

2007-12-21 Thread Donn Ingle
Hi, Well, I'm beat. I can't wrap my head around this stuff. I need to create a list that will contain objects sorted by a name property that is in the alphabetical order of the user's locale. I used to have a simple list that I got from os.listdir and I could do this: l = os.listdir(.)

Re: Sorting Objects by property using locale

2007-12-21 Thread Donn Ingle
In follow-up: I think this should work: # -*- coding: utf8 -*- import locale locale.setlocale( locale.LC_ALL, ) class Test(object): def __init__(self,nam): self.name = nam def __cmp__(self, other): return cmp(self.name, other.name) l = [ Test(ABILENE.ttf),

Re: Sorting Objects by property using locale

2007-12-21 Thread Donn Ingle
Which is even more correct than I hoped for -- in Norwegian, aa is pronounced the same as å (which is the 29th letter in the Norwegian alphabet) and is sorted according to pronunciation. Much appreciated bjorn. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: import X between submodules in a package

2007-12-19 Thread Donn Ingle
Chris wrote: print cli.os.environ['HOME'] I was really confused by your reply until I saw the cli.os part. Okay, I see what you mean. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: import X between submodules in a package

2007-12-19 Thread Donn Ingle
would be a VeryBadThing(tm). :) Having explicits imports in each module is good wrt/ readability. Okay, I can accept that. I worry that it's opening the module file over and over again - or does it open it once and kind of re-point to it when it hits a second import of the same thing?

Re: import X between submodules in a package

2007-12-19 Thread Donn Ingle
You guess. When fisrt imported, the module's source is executed, a module object is created and stored in sys.modules, and the needed names are inserted into the importing module's namespace. Next times the module is served directly from sys.modules. Peachy, thanks. \d --

import X between submodules in a package

2007-12-18 Thread Donn Ingle
Hi, I'm sure this is a FAQ, but I have just not found clarity on the web/docs. (using monospaced type to show the tree) trunk:$ tree . fp |-- fontypython | |-- __init__.py | |-- cli.py | |-- config.py (I start it all with ./fp) fp says: import cli cli.py says: import os import config

Re: Gnu/Linux dialogue boxes in python

2007-12-18 Thread Donn Ingle
I've now uploaded a new release of the desktop module which is now, in fact, a package: Thanks Paul, I saw it via the cheese shop rss. I have been too busy to read this list for a week. I will have a look in due course. \d -- http://mail.python.org/mailman/listinfo/python-list

pprinting objects

2007-12-08 Thread Donn Ingle
Hi, Is there a way to get a dump of the insides of an object? I thought pprint would do it. If I had a class like this: class t: def __init__(self): self.x=1 self.y=2 self.obj = SomeOtherObj() Then it could display it as: class t, x,1, y,2, obj,class SomeOtherObj Or something like

Re: pprinting objects

2007-12-08 Thread Donn Ingle
AFAIK you have to roll your own. Here is a very rudimentary example: Very cool, thanks. \d -- http://mail.python.org/mailman/listinfo/python-list

setattr getattr confusion

2007-12-08 Thread Donn Ingle
Hi, Here's some code, it's broken: class Key( object ): def __init__(self): self.props = KeyProps() def __getattr__(self, v): return getattr( self.props,v ) def __setattr__(self,var,val): object.__setattr__(self.props,var,val) class KeyProps(object):

Re: setattr getattr confusion

2007-12-08 Thread Donn Ingle
So you might want to describe your use-case. Um.. I wanted an object with Key to hold other data. I wanted a way to set that *other* data within Key without having to specify the object in-between everytime. k1.x = ni! should perform: k1.props.x = ni! and print k1.x should perform: print

Re: pprinting objects

2007-12-08 Thread Donn Ingle
Define a __repr__ or __str__ method for the class Yes, then I could include the code John Machin suggested in there: for attr, value in sorted(self.__dict__.iteritems()): blah That will do nicely. Thanks all. \d -- http://mail.python.org/mailman/listinfo/python-list

callback confusion

2007-12-08 Thread Donn Ingle
Hi, I have two modules, the second is imported by the first. Let's call them one.py and two.py (two being my API) In the first I register a function into the second. [in one.py] def boo(): ... ... two.register( boo ) two.startLoop() In two.py it starts a loop (GTK timeout), so processing

Re: setattr getattr confusion

2007-12-08 Thread Donn Ingle
class Key(object): def __init__self): self.__dict__['props'] = KeyProps() Okay - that's weird. Is there another way to spin this? def __setattr__(self,var,val): setattr(self.props,var,val) Perhaps by changing this one? \d -- http://mail.python.org/mailman/listinfo/python-list

Re: Basic animation in Python - how to

2007-12-08 Thread Donn Ingle
Please refer me to some basic Python code for animation like that . You are in for a wild ride! Depending on your platform you can use dozens of different tools. Try wxPython, pyCairo, pyGTK and PIL (Python Imaging Library) for the most capable. Basically you are looking at a fairly complex

Re: setattr getattr confusion

2007-12-08 Thread Donn Ingle
Thanks Bruno, I had to keep coding, so I used the long form [Object.subobject.property = blah] anyway. It's long-winded, but unambiguous. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: callback confusion

2007-12-08 Thread Donn Ingle
As far as I can tell, you have a bit more code in boo, and somewhere in that code (after the print statement), you rebind the name 'kills'. Okay, yes: def boo() kills += 1 print kills the absence of a global declaration, this makes this name a local variable. I think I see what you mean:

i18n a Python app

2007-12-02 Thread Donn Ingle
Hi, I have been going spare looking for a tutorial or howto from my pov as a total beginner to i18n. I understand that one must use gettext, but there seems to be no good info about *how* one uses it. What command line utilities does one use to: 1. make a .pot file 2. make a .mo file Are there

Re: i18n a Python app

2007-12-02 Thread Donn Ingle
Another thought, how would one provide translations for doc strings? class Boo: This class goes Boo! Can one do this, which does not seem likely: class Boo: _( This class goes Boo! ) \d -- http://mail.python.org/mailman/listinfo/python-list

Re: Gnu/Linux dialogue boxes in python

2007-12-02 Thread Donn Ingle
But why?  Either (a) your program has a GUI and can display a dialogue box by itself (b) your program has a GUI but has problems opening even a tiny part of it (missing modules?), and should output diagnostics on the terminal (c) your program is console-based, or a daemon or something, and

  1   2   3   4   5   >