Re: [Tutor] die or exit function?

2006-06-14 Thread francois schnell
On 13/06/06, Mike Hansen   <[EMAIL PROTECTED]> wrote:
> -Original Message-> From: tutor-bounces+mhansen=cso.atmel.com@python.org 
Wait a minute, is that "atmel" in your e-mail address the one I think of ?http://en.wikipedia.org/wiki/AtmelIf so please thank the AVR gurus for making the best quality/price microcontrollers in the world. I'm an happy user of an atmega8 and Python in this project: 
http://www.liberlab.net/If by any chance your going to europython 2006 I'll be glad to show you that.  I've  just been looking at your blog and I've seen the "Perl, the language I love to hate".
Personally I love this little cartoon about Perl :http://mirror5.escomposlinux.org/comic/ecol-13-e.pngAnd if you have Perl working colleges you want to protect from I found this on the web  ;)
http://scott.weston.id.au/software/pymissile-20060126/cheersfrancois 
> [mailto:[EMAIL PROTECTED]
] On> Behalf Of Andy Koch> Sent: Tuesday, June 13, 2006 8:42 AM> To: tutor@python.org> Subject: [Tutor] die or exit function?>> Bkgd: I've been doing PHP for the last several years.
>> Q: In PHP there are functions die and exit which terminate> processing of> a script with an optional string output.  Is there something> similar to> this in Python?>
sys.exit("something bad happened")Although it's probably better to catch the exception and deal with it andthen sys.exit() if need be.Mike
http://users.adelphia.net/~mahansen/programming/___Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python video?

2006-04-13 Thread francois schnell
Hello,I find Python411 an excellent podcast about Python:http://www.awaretek.com/python/index.html
and on general topics about IT:
http://www.itconversations.com/francoisOn 14/04/06, Steve Nelson <
[EMAIL PROTECTED]> wrote:On 4/13/06, Danny Yoo <
[EMAIL PROTECTED]> wrote:>>> On Wed, 12 Apr 2006, Hoffmann wrote:>> > I read this week on this forum about a kind of Python video in its> > website. Which view is that, and where could I find it? I search in
> > Python website, but I didn't find it. Is it a 'demo' of the language?>> It's a video with gushing praise over Python, made in the style of a Monty> Python skit.On a similar line, I've recently discovered "podcasts".  I spend a lot
of time driving, and have been listening through the "Security Now"broadcasts, and the last few days some stuff on Evolutionary Theory.Does anyone know of some good sources for programming-type discussions
- talks or lectures I could download and listen to?S.___Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Capture keyboard input even without python in focus

2006-04-01 Thread francois schnell
Hello,On windows OS I'm using the nice pyhook module:"The pyHook library wraps the low-level mouse and keyboard hooks in the Windows Hooking API for use in Python applications. "
See tutorial here:http://www.cs.unc.edu/~parente/tech/tr08.shtmlfrancois 
On 01/04/06, Ars <[EMAIL PROTECTED]
> wrote:







What commands could capture input from the keyboard 
(and the mouse while we're at it) even when the running python program isn't the 
program in focus? Sorta like a keylogger, though that's not my goal (wouldn't be 
very secret with a python console running anyways lol.)
 
-Jack

___Tutor maillist  -  Tutor@python.org

http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Simple way for i18n ?

2006-03-25 Thread francois schnell
Hello Micheal,I've  changed LANGUAGE in the shell , it worked at the beginning and then it stopped working ...Also os.environ.setdefault method still has no effect. I begin to wonder if it's specific to my distro (Ubuntu Breezy).
Anyway I managed to use "translation" but if I give None for languages (or nothing) he gives back an IOError.I'm finaly using a mix of "install" and "translation" through an exception handling 
and I can also change the language on the fly in the app.It works but it's probably not very "academic"  :)

http://www.flickr.com/photos/frenchy/117229913/Thanks francoisOn 24/03/06, Michael Lange <
[EMAIL PROTECTED]> wrote:On Thu, 23 Mar 2006 23:58:58 +0100"francois schnell" <
[EMAIL PROTECTED]> wrote:>> Now I'd like to be able to change language without loging out, change> language, log in.>> Martelli says in his book that to set the default language for the app I
> just need to do:>> >>> os.environ.setdefault('LANG', 'fr_FR')>> and Python doesn't complain (but doesn't work) but if I then do:>> >>> print locale.getdefaultlocale
()>> Python says : ('en_GB', 'utf-8')  # meaning that really couldn't work ?>> How can I have my app in French even if I'm still in the GB version of> Ubuntu (change the language for the app) ?
>Hi Francois,I tried to do so with one of my apps (on Mandrake) and found that I have to changethe LANGUAGE environment variable, changing LANG had no effect on this.>From the python gettext docs I found:
If languages is not given, then the following environment variables are searched: LANGUAGE, LC_ALL, LC_MESSAGES, and LANG.So it looks like the easiest may be to do$ LANGUAGE=en_GBin the shell before you start your app.
> I've also tried the "translation" way instead of the "install" way:>> if I do:> gettext.install("myapp", localedir) #it translates in French when I'm in the
> French Ubuntu> but if I do instead: gettext.translation("myapp", localedir,> languages="fr_FR") #with the same localedir which worked before> =>> Python complains:
> "gettext.translation("myapp", localedir, languages="fr_FR")>   File "/usr/lib/python2.4/gettext.py", line 480, in translation> raise IOError(ENOENT, 'No translation file found for domain', domain)
> IOError: [Errno 2] No translation file found for domain: 'myapp' ">> I find it strange that "install" finds it but not "translation" (for the> same localedir) ?>
I admit I nevered bothered to find out how to use gettext.translation() since gettext.install()works that fine for me. Maybe you should set "languages" to "fr" instead of "fr_FR" (just a guess though)?
I hope this helpsMichael___Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Simple way for i18n ?

2006-03-23 Thread francois schnell
Thanks both for your help,

I managed to find one book which talk about i18n for Python: "Python in a Nutshell" (few pages for i18n)

I've used sys.prefix on my ubuntu box to find the default directory and it works fine this way:
http://www.flickr.com/photos/frenchy/116742621/

I've also done like you said:
gettext.install(domain, localedir)
and now it works fine also with a locale directory   :)

Then what I've got now is:
- I log on the french version of Ubuntu I've got the french app  version
- I log on the UK version of Ubuntu I've got the original app version in English

Now I'd like to be able to change language without loging out, change language, log in.

Martelli says in his book that to set the default language for the app I just need to do:

>>> os.environ.setdefault('LANG', 'fr_FR')
 
and Python doesn't complain (but doesn't work) but if I then do:

>>> print locale.getdefaultlocale()

Python says : ('en_GB', 'utf-8')  # meaning that really couldn't work ?

How can I have my app in French even if I'm still in the GB version of Ubuntu (change the language for the app) ?

I've also tried the "translation" way instead of the "install" way:

if I do:
gettext.install("myapp", localedir) #it translates in French when I'm in the French Ubuntu
but if I do instead: gettext.translation("myapp", localedir, languages="fr_FR") #with the same localedir which worked before
=>
Python complains:
"    gettext.translation("myapp", localedir, languages="fr_FR")
  File "/usr/lib/python2.4/gettext.py", line 480, in translation
    raise IOError(ENOENT, 'No translation file found for domain', domain)
IOError: [Errno 2] No translation file found for domain: 'myapp' "

I find it strange that "install" finds it but not "translation" (for the same localedir) ?

Thanks in advance If you can help.

francois








On 23/03/06, Michael Lange <[EMAIL PROTECTED]> wrote:
On Wed, 22 Mar 2006 17:41:14 +0100"francois schnell" <[EMAIL PROTECTED]> wrote:> Hello all,>> I wish to translate a Python script from English to French. I've read the
> offical documentation (python.org doc) but I must admit that I'm lost now> ...> I've found some simple explanations here but I can't make it work:> 
http://karrigell.sourceforge.net/en/internationalization.htm>> Here's where I'm stuck:>> Let's imagine my app is: myapp.py> --> import gettext> _ = gettext.gettext>
> print _("hello friends")> print _("Bye Bye")> --->> Here are my folders on a windows box:>> C:\myappfolder\> ---\Translations\francais\LC_MESSAGES
>> My myapp.py is in myappfolder>> In this folder I've used pygettext.py to produce a messages.pot file => I> add the translation in it => I have a messages.po file.> I then used 
msgfmt.py to produce messages.mo file.>> I then copied messages.po and messages.mo in LC_MESSAGES folder> C:\myappfolder\> ---\Translations\francais\LC_MESSAGES>> I now come back to 
myapp.py and add two lines:>> ---> import gettext> _ = gettext.gettext>> t=gettext.translation("messages","c:\myappfolder\Translations","francais")
> t.install()>> print _("hello friends")> print _("Bye Bye")> --->> When I do that Python anwers:>> >>>> Traceback (most recent call last):
>   File "C:\myappfolder\myapp.py", line 4, in ?> t=gettext.translation> ("messages","c:\myappfolder\Translations","francais")>   File "C:\Python24\lib\gettext.py", line 456, in translation
> raise IOError(ENOENT, 'No translation file found for domain', domain)> IOError: [Errno 2] No translation file found for domain: 'messages'> >>>>Hi Francois,not sure if it is different on windows, on linux I simply do:
  import gettext  gettext.install(domain, localedir)to install _() into my application's global namespace,where localedir in your case was "c:\myappfolder\Translations".The path that contains the french translation should be "..\fr\LC_MESSAGES" instead of "..\francais\LC_MESSAGES"
I think (at least that is true on linux).I hope this helpsMichael___Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Simple way for i18n ?

2006-03-22 Thread francois schnell
Hello all,I wish to translate a Python script from English to French. I've read the offical documentation (python.org doc) but I must admit that I'm lost now ...I've found some simple explanations here but I can't make it work:
http://karrigell.sourceforge.net/en/internationalization.htmHere's where I'm stuck:Let's imagine my app is: myapp.py --
import gettext_ = gettext.gettextprint _("hello friends")print _("Bye Bye")---Here are my folders on a windows box:C:\myappfolder\---\Translations\francais\LC_MESSAGES
My myapp.py is in myappfolderIn this folder I've used pygettext.py to produce a messages.pot file => I add the translation in it => I have a messages.po file.I then used msgfmt.py to produce messages.mo
 file.I then copied messages.po and messages.mo in LC_MESSAGES folderC:\myappfolder\
---\Translations\francais\LC_MESSAGESI now come back to myapp.py and add two lines:---import gettext_ = gettext.gettextt=gettext.translation("messages","c:\myappfolder\Translations","francais")
t.install()print _("hello friends")print _("Bye Bye")---When I do that Python anwers:>>> Traceback (most recent call last):  File "C:\myappfolder\myapp.py", line 4, in ?
    t=gettext.translation("messages","c:\myappfolder\Translations","francais")  File "C:\Python24\lib\gettext.py", line 456, in translation    raise IOError(ENOENT, 'No translation file found for domain', domain)
IOError: [Errno 2] No translation file found for domain: 'messages'>>> I'm stuck here.I understand it doesn't find the translation file but I can't figure out why.Can you tell me what I'm doing wrong or direct me to an URL (or a Python book) where simple internationalisation for Python is gently explained
Thanks francois (...from France)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] need some help with ascii hex

2005-08-18 Thread francois schnell
On 19/08/05, Alan G <[EMAIL PROTECTED]> wrote:
If you are on the tutor list you are a tutor. We don't have anydivisionof role, everyone helps and everuone can ask for help
Ok I wasn't sure about the [Tutor] stuff  :)
. We are allequals.

Well, actually  this is not true:  it is well  known
here in France  that the French are far superior  to the
Brits ! ... ;) 

And your advice was spot on so you see, you are a tutor! :-)
That is Pythonesque !!!  ;) 

Thanks
Cheers

francois
Alan GAuthor of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] need some help with ascii hex

2005-08-18 Thread francois schnell
Hello,

I'm not a Tutor but I found this wich could help you:

Source:
http://mail.python.org/pipermail/tutor/2003-March/021123.html


  To convert character data to integers, you can use the ord()function, and to convert a number to hex notation you can use thehex() function.Example:>>> data ="" "hello"
>>> for char in data:>>> print hex(ord(char))Note that hex() returns a string, not a number.


francois
On 18/08/05, nephish <[EMAIL PROTECTED]> wrote:
Hey there,i am using the serial module and trying to get some info over an RS232port. Seems to be comming in ok, but when i print it out, its in ASCIIinstead of hex. is there a way to have python read serial in hex bytes
instead of ASCII ?thanks.shawn___Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor