Re: Dialog boxes in curses

2011-08-13 Thread fab
Thanks all for your suggestions, I'll look into them. See you. -- F. Delente -- http://mail.python.org/mailman/listinfo/python-list

Dialog boxes in curses

2011-08-13 Thread fab
Hello. I've googled for hints but I didn't find anything, I hope it's not an RTFM question :^) I want to have dialog boxes (a message with Yes/No/Cancel options, possibly with keyboard accels) in python + curses. Does anyone have a pointer to docs about this? Thanks! -- F. Delente -- http://

Re: Classes in a class: how to access variables from one in another

2010-10-18 Thread fab
Christian Heimes wrote: > Don't nest classes. Just don't. This might be a valid and good approach > in some programming languages but it's not Pythonic. Your code can > easily be implemented without nested classes. I think you're right. It would have been more aesthetically pleasant to me (a Hand

Re: Classes in a class: how to access variables from one in another

2010-10-18 Thread fab
Jean-Michel Pichavant wrote: > Always post working code, or at least something we can paste in the > python interpreter (even if it's buggy) Ok, noted. > class A: >class B: >x=2 >class C: >def __init__(self): >print A.B.x > > c = A.C() > > >2 Good, thanks.

Re: Classes in a class: how to access variables from one in another

2010-10-18 Thread fab
Gary Herron wrote: > Well, your code still doesn't make sense, but the generic answers are: I'll clarify what I need then: I'm drawing Bézier curves. I draw them on a zone that is defined as a subclass of GtkDrawingArea. In a zone, I define a system of coordinates by 4 values: xmin, xmax, ymin,

Re: Classes in a class: how to access variables from one in another

2010-10-18 Thread fab
Neil Cerutti wrote: >> I have a class A that contains two classes B and C: >> >> class A: >> class B: >> self.x = 2 >> >> class C: I only wanted to show the structure of the code, not the actual instructions. > That's not valid Python code. Do you mean: > > Class A: > Class B: >

Classes in a class: how to access variables from one in another

2010-10-18 Thread fab
Hello. I have a class A that contains two classes B and C: class A: class B: self.x = 2 class C: Is there a way to access the x defined in B in class C? Thanks. -- F. Delente -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python3] Reading a binary file and wrtiting the bytes verbatim?in an utf-8 file

2010-04-25 Thread fab
> Another possibility is to open the file in binary mode and do the > encoding yourself when writing text. This might actually be a better > solution, since I'm not sure RTF uses utf-8 by default. Yes, thanks for this suggestion, it seems the best to me. Actually RTF is not UTF-8 encoded, it's 8

Re: [Python3] Reading a binary file and wrtiting the bytes verbatim ?in an utf-8 file

2010-04-23 Thread fab
Thanks, I'll try this. > I have no idea how you'd go about reading the contents of such a file > in a sensible way. The purpose is to embed PNG pictures in an RTF file that will be read by OpenOffice. It seems that OpenOffice reads RTF in 8-bit, so it should be ok. The RTF is produced from a TeX

[Python3] Reading a binary file and wrtiting the bytes verbatim in an utf-8 file

2010-04-23 Thread fab
Hello. I have to read the contents of a binary file (a PNG file exactly), and dump it into an RTF file. The RTF-file has been opened with codecs.open in utf-8 mode. As I expected, the utf-8 decoder chokes on some combinations of bits; how can I tell python to dump the bytes as they are, without

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread fab
Thanks for your insights. I have taken the easy way out, I read on a page that python 3 worked by default in UTF-8, so I downloaded and installed it. Apart from a few surprises (print is not a funtion, and rules about mixing spaces and tabs in indentation are much more strict, and I guess more is

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread fab
> Change your string literals to unicode by adding the u-prefix and you should > be OK. Thanks, it solved the problem... for a while! I need now to know if s[i] gives the next byte or the next character, when I scan the string s. I've googled pages about python and unicode, but didn't find a sol

error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread fab
Hello. I read a string from an utf-8 file: fichierLaTeX = codecs.open(sys.argv[1], "r", "utf-8") s = fichierLaTeX.read() fichierLaTeX.close() I can then print the string without error with 'print s'. Next I parse this string: def parser(s): i = 0 while i < len(s): if s[i:i+1] == '\\':