Re: Python tricks with applescript in OS-X

2009-12-16 Thread Juanre
Thanks for the pointers to appscript, and for the comments on the page. I have changed the examples at http://juanreyero.com/article/python/os-x-python.html to reflect them. Cheers, Juan -- http://juanreyero.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python tricks with applescript in OS-X

2009-12-11 Thread Kevin Walzer
On 12/11/09 3:13 AM, joa...@gmail.com wrote: Greetings, I've written a short document with some working examples of how to interface python with other applications in OS-X via applescript (had to spend some time figuring it out, and thought I might as well write it down). The examples include a

Re: Python tricks

2009-01-13 Thread Nick Craig-Wood
Scott David Daniels wrote: > RajNewbie wrote: > > On Jan 12, 6:51 pm, Tim Chase wrote: > [a perfectly fine reply which is how I'd solve it] > >> RajNewbie wrote: > >>> ... The solution that I had in mind is: > >>>while True: > >>> ... > >>> if : break > >>> if inifinte_l

Re: Python tricks

2009-01-12 Thread Robert Latest
RajNewbie wrote: > But, I still feel it would be much more aesthetically pleasing if I > can call a single procedure like > if infinite_loop() -> to do the same. You may find it aesthetically pleasing, and it may very well be, but it will obfuscate your code and make it less maintainable. robert

Re: Python tricks

2009-01-12 Thread Robert Latest
RajNewbie wrote: >Is there a way - a python trick - to have a check such that if the > loop goes for more than x number of steps, it will cause an exception? > >I do understand that we can use the code like - >i = 0 >while True: > i++ > if i > 200: raise infinite_Loop_Exce

Re: Python tricks

2009-01-12 Thread Scott David Daniels
RajNewbie wrote: On Jan 12, 6:51 pm, Tim Chase wrote: [a perfectly fine reply which is how I'd solve it] >> RajNewbie wrote: ... The solution that I had in mind is: while True: ... if : break if inifinte_loop(): raise infiinte_loop_exception Wherein infinite_loop is a ge

Re: Python tricks

2009-01-12 Thread John Machin
On Jan 13, 12:51 am, Tim Chase took a walk on the OT side: > > Could someone chip in with other suggestions? > > As an aside:  the phrase is "chime in"[1] (to volunteer > suggestions) "Chip in"[2] usually involves contributing money to > a common fund ("care to chip in $10 for Sally's wedding gif

Re: Python tricks

2009-01-12 Thread Paul Rubin
RajNewbie writes: >I do understand that we can use the code like - >i = 0 >while True: > i++ > if i > 200: raise infinite_Loop_Exception > ... > if : break > >But I am not very happy with this code for 3 reasons I prefer: from itertools import count fo

Re: Python tricks

2009-01-12 Thread RajNewbie
On Jan 12, 6:51 pm, Tim Chase wrote: > >    My code has a lot of while loops of the following format: > >    while True: > >      ... > >      if : break > > >    The danger with such a code is that it might go to an infinite loop > > - if the never occurs. > >    Is there a way - a python trick

Re: Python tricks

2009-01-12 Thread Tim Chase
My code has a lot of while loops of the following format: while True: ... if : break The danger with such a code is that it might go to an infinite loop - if the never occurs. Is there a way - a python trick - to have a check such that if the loop goes for more than x numbe

Re: Python tricks

2009-01-12 Thread Ben Finney
RajNewbie writes: > Could someone chip in with other suggestions? Set up an iterable that will end under the right conditions. Then, iterate over that with ‘for foo in that_iterable’. This idiom is usually far more expressive than any tricks with ‘while’ loops and ‘break’ statements. For tools