Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-18 Thread Terry Reedy

On 9/18/2016 2:45 AM, Steven D'Aprano wrote:


It doesn't matter whether you call them "accent" like most people do, or
"diacritics" as linguists do.


I am a native born American and I have never before heard or seen 
non-accent diacritic marks called 'accents'.  Accents indicate stress. 
Other diacritics indicate other pronunciation changes.  It is 
counterproductive to confuse the two groups.  Spanish, for instance, has 
vowel accents that change which syllable gets stressed.  A tilda is not 
an accent; rather, it softens the pronunciation of 'n' to 'ny', as in 
'canyon'.


Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Matt Wheeler
On Thu, 15 Sep 2016, 08:12 meInvent bbird,  wrote:

> how to automate java application in window using python
>
> 1. scroll up or down of scroll bar
> 2. click button
> 3. type text in textbox
>

I would recommend having a look at pywinauto
https://github.com/pywinauto/pywinauto

It presents a very nice pythonic interface to Windows and the controls
within them, allowing statements such as (copied from the Readme):

app.UntitledNotepad.MenuSelect("Help->About Notepad")
app.AboutNotepad.OK.Click()
app.UntitledNotepad.Edit.TypeKeys ("pywinauto Works!", with_spaces = True)

(I found it already quite stable when I first used it a couple of years
ago, and looking at the Readme now it's clearly still an active project,
the optional image capture feature using pillow is new)

>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Paul Rubin
Lawrence D’Oliveiro  writes:
>> The term "automation" is frequently used in the Windows world to mean
>> programming something that you would otherwise do manually through a GUI...
> Which is not something that GUIs are designed for. Therefore it is at
> best an unreliable exercise, at worst futile.

Windows applications often (usually?) provide automation interfaces,
which are what the rest of us would call API's.  This has been done in a
lot of ways: OLE and COM objects back in the day, .NET currently, other
things in between.  It's not done by screen scraping or anything stupid
like that.  It's actually pretty well thought out, though with the usual
layers of Microsoft and OOP bureaucracy around everything.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-18 Thread Christian Gollwitzer

Am 17.09.16 um 23:19 schrieb Thomas 'PointedEars' Lahn:

Peng Yu wrote:


Hi, I want to convert strings in which the characters with accents
should be converted to the ones without accents.


Why?


[…]
./main.py Förstemann


AFAIK, “ä”, “ö”, and “ü” are not accented characters in any natural
language, but characters of their own (umlauts).

In particular, I know for certain that they are not accented in Germanic
languages.  Swedish has been mentioned; I can add my native language,
German, to that list.


In German, they are letters, but they collate as either ae, oe, ue 
(rarely) or a, o, u (modern style). Ad dictionary or phone book does not 
have an "ö" section in Germany. Example from a German-Latin dictionary, 
printed in 1958


Laster -> vitium
Lästerer -> homo maledicus
lasterhaft -> vitiosus

If "ä" would sort as a single letter, "Lästerer" would be the last 
entry. If it would sort as "ae", it would be the first entry. Therfore, 
in this example it sorts as "a", with "ä" > "a" to resolve a tie only.



Christian
--
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Lawrence D’Oliveiro
On Sunday, September 18, 2016 at 9:25:53 PM UTC+12, Paul Rubin wrote:
>
> Lawrence D’Oliveiro writes:
>
>>> The term "automation" is frequently used in the Windows world to mean
>>> programming something that you would otherwise do manually through a GUI...
>>
>> Which is not something that GUIs are designed for. Therefore it is at
>> best an unreliable exercise, at worst futile.
> 
> Windows applications often (usually?) provide automation interfaces,
> which are what the rest of us would call API's.  This has been done in a
> lot of ways: OLE and COM objects back in the day, .NET currently, other
> things in between.  It's not done by screen scraping or anything stupid
> like that.  It's actually pretty well thought out, though with the usual
> layers of Microsoft and OOP bureaucracy around everything.

None of the different ways of which are either a) compatible or b) widely 
supported. Particularly not in Java, as the OP was asking.

Like I said, trying to automate a GUI is a waste of time. GUIs are designed for 
humans, not computers, to use.

That’s why we have command lines and scripting (which are all just programming 
at different layers, of course). That’s how you automate things, building 
higher-level abstract machines on top of lower-level ones. GUIs are the end of 
the abstraction chain: you cannot build anything more on top of them.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Christian Gollwitzer

Am 18.09.16 um 12:03 schrieb Lawrence D’Oliveiro:

Like I said, trying to automate a GUI is a waste of time. GUIs are
designed for humans, not computers, to use.


You don't always have a choice. Consider batch-processing a number of 
images (say, 30,000 movie frames) using a proprietary effect filter 
which works on single images only. It might be easier to drive the GUI 
than to recreate the commercial algorithm.



That’s why we have command lines and scripting (which are all just
programming at different layers, of course). That’s how you automate
things, building higher-level abstract machines on top of lower-level
ones. GUIs are the end of the abstraction chain: you cannot build
anything more on top of them.


Yes, you can. I agree with you that it is a shaky solution, but that 
doesn't make it impossible.


Christian
--
https://mail.python.org/mailman/listinfo/python-list


Functions Of Functions Returning Functions

2016-09-18 Thread Lawrence D’Oliveiro
The less code you have to write, the better. Less code means less
maintenance, and fewer opportunities for bugs. Here is an example of
how I was able to knock a few hundred lines off the size of a Python
module.

When I was writing my Python wrapper for HarfBuzz
, there were a lot of places where you
could define routines for HarfBuzz to make calls to, to customize the
type-shaping process in various ways.

Of course, HarfBuzz  is a library
written in C++, and it doesn’t know that the callbacks you pass are
actually written in Python. But ctypes
 provides an answer to
this: its CFUNCTYPE function lets you wrap Python functions so that
they become callable from C/C++ code.

When I said there were a lot of places for callbacks, I meant a lot of
places. For example, there is a HarfBuzz object called “hb_font_funcs”
, which
consists of nothing more than a container for 14 different action
callback routines. Not only that, but each one lets you pass a
separate “user data” pointer to the action callback, along with an
optional “destroy” callback which can do any necessary cleanup of this
data, which will be called when the hb_font_funcs object is disposed.

Imagine having to set all of these up by hand. Each API call to
install a callback would look something like this:

def set_xxx_callback(self, callback_func, user_data, destroy) :
"sets the xxx callback, along with an optional destroy callback" \
" for the user_data. The callback_func should be declared as 
follows:\n" \
"\n" \
"def callback_func(self, ... xxx-specific args ..., user_data)\n" \
"\n" \
"where self is the FontFuncs instance ... description of xxx-specific 
args."

def def_wrap_xxx_callback(self, callback_func, user_data)
# generates ctypes wrapper for caller-specified Python function.

@HB.font_get_xxx_func_t
def wrap_xxx_callback(... xxx-specific args ..., c_user_data) :
... convert xxx-specific args from ctypes representation to ...
... higher-level Python representation, pass to callback_func, 
...
... along with user_data, then convert any result to ctypes ...
... representation and return as my result ...
#end wrap_xxx_callback

#begin def_wrap_xxx_callback
return \
wrap_xxx_callback
#end def_wrap_xxx_callback

#begin set_xxx_callback
wrap_callback_func = def_wrap_xxx_callback(self, callback_func, 
user_data)
if destroy != None :
@HB.destroy_func_t
def wrap_destroy(c_user_data) :
destroy(user_data)
#end wrap_destroy
else :
wrap_destroy = None
#end if
# save references to wrapper objects to prevent them prematurely
# disappearing (common ctypes gotcha)
self._wrap_xxx_func = wrap_callback_func
self._wrap_xxx_destroy_func = wrap_destroy
hb.hb_font_funcs_set_xxx_func(self._hbobj, wrap_callback_func, None, 
wrap_destroy)
#end set_callback

Just think if you had to do this 14 times. And then there are a couple
of other HarfBuzz objects with their own similar collections of
callbacks as well...

Luckily, I figured out a way to cut the amount of code needed for this
by about half. It’s the recognition that the only part that is
different between all these callback-setting calls is the
“def_wrap_xxx_callback” function, together with a few different
attribute names elsewhere. So I encapsulated the common part of all
this setup into the following routine:

def def_callback_wrapper(celf, method_name, docstring, callback_field_name, 
destroy_field_name, def_wrap_callback_func, hb_proc) :
# Common routine for defining a set-callback method. These all have the 
same form,
# where the caller specifies
#  * the callback function
#  * an additional user_data pointer (meaning is up the caller)
#  * an optional destroy callback which is passed the user_data pointer
#when the containing object is destroyed.
# The only variation is in the arguments and result type of the 
callback.

def set_callback(self, callback_func, user_data, destroy) :
# This becomes the actual set-callback method.
wrap_callback_func = def_wrap_callback_func(self, callback_func, 
user_data)
if destroy != None :
@HB.destroy_func_t
def wrap_destroy(c_user_data) :
destroy(user_data)
#end wrap_destroy
else :
wrap_destroy = None
#end if
setattr(self, callback_field_name, wrap_callback_func)
setattr(self, destroy_field_name, wrap_destro

Re: how to automate java application in window using python

2016-09-18 Thread Lawrence D’Oliveiro
On Sunday, September 18, 2016 at 10:13:41 PM UTC+12, Christian Gollwitzer wrote:
>
> Am 18.09.16 um 12:03 schrieb Lawrence D’Oliveiro:
>
>> Like I said, trying to automate a GUI is a waste of time. GUIs are
>> designed for humans, not computers, to use.
> 
> You don't always have a choice. Consider batch-processing a number of 
> images (say, 30,000 movie frames) using a proprietary effect filter 
> which works on single images only. It might be easier to drive the GUI 
> than to recreate the commercial algorithm.

Considering the power available in Free Software toolkits like ImageMagick, 
G’MIC and so on, not to mention libraries accessible from Python itself, let me 
suggest that such proprietary software simply isn’t worth bothering with any 
more.

> I agree with you that it is a shaky solution, but that 
> doesn't make it impossible.

Is it really something you want to entrust mission-critical business functions 
to?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Paul Rubin
Lawrence D’Oliveiro  writes:
>> lot of ways: OLE and COM objects back in the day, .NET currently,
> None of the different ways of which are either a) compatible or b)
> widely supported. Particularly not in Java, as the OP was asking.

I'm quite sure there are Java bindings for all those protocols.

> Like I said, trying to automate a GUI is a waste of time. GUIs are
> designed for humans, not computers, to use.

Automation doesn't simulate button presses or anything like that: the
automate objects expose higher level user actions.  E.g. the web browser
object has a navigate method and that sort of thing.

The classic automation example is embedding a chunk of an Excel
spreadsheet in the middle of a Word document, so it's displayed with
Word's fonts and formatting, but when you change a number in the
spreadsheet segment, the formulas run and the other numbers change.
What happens there is Word collects the numbers you type, then calls the
Excel automation interfaces to update the relevant spreadsheet cells and
read back new numbers.  There are various hacks in KDE, Gnome, etc.  to
do similar things under Linux.  It's all transparent to the user and
presents useful features.

> GUIs are the end of the abstraction chain: you cannot build anything
> more on top of them.

IMHO you're not contributing useful insights through these incorrect
guesses about how Windows automation works.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-18 Thread Martin Schöön
Den 2016-09-17 skrev Marko Rauhamaa :
> Martin Schöön :
>> Related anecdote from Phoenix AZ. By now you have noticed my family
>> name: Schöön. On airline tickets and boarding passes in the U.S. it
>> gets spelled Schoeoen.
>
> Do Swedes do that German thing, too? If you have to write Finnish
> without ä and ö, you simply leave out the dots. (On the other hand, if
> you need š or ž and don't have them, you replace them with sh and zh.)
>
> Marko

This is a problem of the past I think. When the problem arises -- well
I am of aware of standard Swedish way.

American typographer Robert Bringhurst is not happy with the computer
guys who thought half as many glyphs as Gutemberg worked with was
enough back in the days when 7-bit ascii was conceived. See "The
Elements of Typographic Style".

/Martin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Christian Gollwitzer

Am 18.09.16 um 12:26 schrieb Lawrence D’Oliveiro:

On Sunday, September 18, 2016 at 10:13:41 PM UTC+12, Christian
Gollwitzer wrote:


Am 18.09.16 um 12:03 schrieb Lawrence D’Oliveiro:


Like I said, trying to automate a GUI is a waste of time. GUIs
are designed for humans, not computers, to use.


You don't always have a choice. Consider batch-processing a number
of images (say, 30,000 movie frames) using a proprietary effect
filter which works on single images only. It might be easier to
drive the GUI than to recreate the commercial algorithm.


Considering the power available in Free Software toolkits like
ImageMagick, G’MIC and so on, not to mention libraries accessible
from Python itself, let me suggest that such proprietary software
simply isn’t worth bothering with any more.


I was expecting that argument. Free software gives you a lot in this 
area, but there are commercial signal processing programs with unmatched 
quality. Examples:


https://ni.neatvideo.com/
 or for audio
http://www.celemony.com/en/melodyne/what-is-melodyne

Their business model relies on (nontrivial) secret algorithms. Even if 
the algorithm is published it might be too tedious to reimplement it 
from the scientific paper because it takes months of work or resources 
you don't have; for instance, this algorithm


http://graphics.cs.cmu.edu/projects/scene-completion/scene-completion.pdf

requires you to have millions of stock photo images, which you are 
allowed to use. If you are flickr, getty or Google, you have no problem. 
Otherwise it will be hard.





I agree with you that it is a shaky solution, but that doesn't make
it impossible.


Is it really something you want to entrust mission-critical business
functions to?


As always, it depends. I wouldn't rest my money on a bank account which 
is managed by driving Excel via Sikuli. OTOH, I wouldn't want to spend 
years of work to recreate NeatImage to denoise the photos of my last 
holiday trip. Here, driving the GUI is fine.


Christian

--
https://mail.python.org/mailman/listinfo/python-list


Re: Functions Of Functions Returning Functions

2016-09-18 Thread Steve D'Aprano
On Sun, 18 Sep 2016 08:28 pm, Lawrence D’Oliveiro wrote:

> This shows the power of functions as first-class objects. The concept
> is older than object orientation, and is often left out of
> object-oriented languages. I think Python benefits from the fact that
> it had functions before it had classes.

You're right about Python having functions first:

steve@runes:~$ python0.9.1
>>> def f():
... pass
...
>>> class A:
Parsing error: file , line 1:
class A:
^
Unhandled exception: run-time error: syntax error



However it only gained closures and nested scopes in Python 2.2, or with a
__future__ directive in 2.1.


https://www.python.org/dev/peps/pep-0227/




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Steve D'Aprano
On Sun, 18 Sep 2016 08:42 pm, Paul Rubin wrote:

> Lawrence D’Oliveiro  writes:
>>> lot of ways: OLE and COM objects back in the day, .NET currently,
>> None of the different ways of which are either a) compatible or b)
>> widely supported. Particularly not in Java, as the OP was asking.
> 
> I'm quite sure there are Java bindings for all those protocols.
> 
>> Like I said, trying to automate a GUI is a waste of time. GUIs are
>> designed for humans, not computers, to use.
> 
> Automation doesn't simulate button presses or anything like that: the
> automate objects expose higher level user actions.  E.g. the web browser
> object has a navigate method and that sort of thing.

Rather than saying that it *doesn't*, it might be better to say that it
doesn't *necessarily* simulate button presses.

The thing about simulating button presses is that:

(1) you can absolutely guarantee that it does exactly the same as what
happens when a user clicks the button, because there's no difference
between a mouseclick event caused by a human clicking the mouse, a
mouseclick event caused by a robot clicking the mouse, and a mouseclick
event generated by software. They're ALL generated by software, and the
application cannot tell them apart.

(2) It works even if the application doesn't offer an OLE, COM or scripting
interface.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there something similar to `set -v` of bash in python

2016-09-18 Thread Ned Batchelder
On Saturday, September 17, 2016 at 11:09:04 PM UTC-4, Peng Yu wrote:
> The manual says the following.
> 
> "The trace function is invoked (with event set to 'call') whenever a
> new local scope is entered; it should return a reference to a local
> trace function to be used that scope, or None if the scope shouldn’t
> be traced."
> 
> It means that one can not somehow settrace in one line and expect to
> get the trace function being called in the next line.
> 
> So something like `set -v` in bash sounds not possible. Is it so?

You've found a good reason why "set -v" would be very difficult if
not impossible in Python.

I'm curious though, why you would want to trace every line in a
program every time you (or anyone else) ran it? I view tracing lines
as a debugging technique. Once the program is behaving properly, why
do you want all the noise of the traced lines?

In Bash scripts we do it because some scripts are light automation
where the person running the script should have a clear idea of what
actions it is taking.  The actions in the script are commands that the
person might run themselves at other times, and so the difference
between running the script and running the commands is not great.

But in a Python program, presumably the difference is greater. I cannot
type out single Python lines at my shell prompt to perform the actions
the Python program does.

Perhaps you want to define an alias for "python -m trace -t $*" ?

--Ned.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there something similar to `set -v` of bash in python

2016-09-18 Thread Peng Yu
On Sunday, September 18, 2016, Ned Batchelder  wrote:

> On Saturday, September 17, 2016 at 11:09:04 PM UTC-4, Peng Yu wrote:
> > The manual says the following.
> >
> > "The trace function is invoked (with event set to 'call') whenever a
> > new local scope is entered; it should return a reference to a local
> > trace function to be used that scope, or None if the scope shouldn’t
> > be traced."
> >
> > It means that one can not somehow settrace in one line and expect to
> > get the trace function being called in the next line.
> >
> > So something like `set -v` in bash sounds not possible. Is it so?
>
> You've found a good reason why "set -v" would be very difficult if
> not impossible in Python.
>
> I'm curious though, why you would want to trace every line in a
> program every time you (or anyone else) ran it?


This is for debugging not for normal run. But I need the ability to control
the range of the code in which the debug message is printed.


> I view tracing lines
> as a debugging technique. Once the program is behaving properly, why
> do you want all the noise of the traced lines?
>
> In Bash scripts we do it because some scripts are light automation
> where the person running the script should have a clear idea of what
> actions it is taking.  The actions in the script are commands that the
> person might run themselves at other times, and so the difference
> between running the script and running the commands is not great.
>
> But in a Python program, presumably the difference is greater. I cannot
> type out single Python lines at my shell prompt to perform the actions
> the Python program does.
>
> Perhaps you want to define an alias for "python -m trace -t $*" ?
>
> --Ned.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Peng
-- 
https://mail.python.org/mailman/listinfo/python-list


Serialising an 8x8x8 array of pygame sounds

2016-09-18 Thread kerbingamer376
Is it possible to serialise an 8x8x8 array of pygame.mixer.Sound objects, so 
they stay at the same places in the array, but in a format that can be pickled, 
and then the opposite (read from that back to pygame.mixer.Sound objects)?

Thanks

(copied from stackoverflow question @ https://is.gd/JDtURe)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there something similar to `set -v` of bash in python

2016-09-18 Thread Ned Batchelder
On Sunday, September 18, 2016 at 8:29:38 AM UTC-4, Peng Yu wrote:
> On Sunday, September 18, 2016, Ned Batchelder  wrote:
> 
> > On Saturday, September 17, 2016 at 11:09:04 PM UTC-4, Peng Yu wrote:
> > > The manual says the following.
> > >
> > > "The trace function is invoked (with event set to 'call') whenever a
> > > new local scope is entered; it should return a reference to a local
> > > trace function to be used that scope, or None if the scope shouldn’t
> > > be traced."
> > >
> > > It means that one can not somehow settrace in one line and expect to
> > > get the trace function being called in the next line.
> > >
> > > So something like `set -v` in bash sounds not possible. Is it so?
> >
> > You've found a good reason why "set -v" would be very difficult if
> > not impossible in Python.
> >
> > I'm curious though, why you would want to trace every line in a
> > program every time you (or anyone else) ran it?
> 
> 
> This is for debugging not for normal run. But I need the ability to control
> the range of the code in which the debug message is printed.

There is a programmatic interface: 
https://docs.python.org/2/library/trace.html#programmatic-interface

If the section you want to trace is a function call, then you can make
it work.

--Ned.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Serialising an 8x8x8 array of pygame sounds

2016-09-18 Thread Steve D'Aprano
On Sun, 18 Sep 2016 11:20 pm, kerbingamer376 wrote:

> Is it possible to serialise an 8x8x8 array of pygame.mixer.Sound objects,
> so they stay at the same places in the array, but in a format that can be
> pickled, and then the opposite (read from that back to pygame.mixer.Sound
> objects)?

Can you seralise *one* Sound object?

If not, then you can't serialise an array of Sound objects either.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Chris Angelico
On Sun, Sep 18, 2016 at 8:03 PM, Lawrence D’Oliveiro
 wrote:
> Like I said, trying to automate a GUI is a waste of time. GUIs are designed 
> for humans, not computers, to use.

Okay, then. Come up with a way to end-to-end-test a GUI application
without some form of GUI automation.

Sometimes, coming up with a more computer-friendly way to do something
fundamentally defeats the purpose.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Serialising an 8x8x8 array of pygame sounds

2016-09-18 Thread kerbingamer376
On Sunday, September 18, 2016 at 2:59:10 PM UTC+1, Steve D'Aprano wrote:
> On Sun, 18 Sep 2016 11:20 pm, kerbingamer376 wrote:
> 
> > Is it possible to serialise an 8x8x8 array of pygame.mixer.Sound objects,
> > so they stay at the same places in the array, but in a format that can be
> > pickled, and then the opposite (read from that back to pygame.mixer.Sound
> > objects)?
> 
> Can you seralise *one* Sound object?
> 
> If not, then you can't serialise an array of Sound objects either.
> 
> 
> 
> -- 
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.

That's my problem, the Sound object can't be picked, I was wondering if a way 
existed to convert said object to a serialize-able format.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Serialising an 8x8x8 array of pygame sounds

2016-09-18 Thread Peter Otten
kerbingamer376 wrote:

> On Sunday, September 18, 2016 at 2:59:10 PM UTC+1, Steve D'Aprano wrote:
>> On Sun, 18 Sep 2016 11:20 pm, kerbingamer376 wrote:
>> 
>> > Is it possible to serialise an 8x8x8 array of pygame.mixer.Sound
>> > objects, so they stay at the same places in the array, but in a format
>> > that can be pickled, and then the opposite (read from that back to
>> > pygame.mixer.Sound objects)?
>> 
>> Can you seralise *one* Sound object?
>> 
>> If not, then you can't serialise an array of Sound objects either.
>> 
>> 
>> 
>> --
>> Steve
>> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
>> enough, things got worse.
> 
> That's my problem, the Sound object can't be picked, I was wondering if a
> way existed to convert said object to a serialize-able format.

If the Sound object exposes enough of its state to build an equivalent one 
from that state there's a way to write and register your own serialization 
routine. See

https://docs.python.org/2/library/copy_reg.html

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Paul Rubin
Steve D'Aprano  writes:
>> Automation doesn't simulate button presses
> Rather than saying that it *doesn't*, it might be better to say that it
> doesn't *necessarily* simulate button presses.

I'm no Windoze guru but I always understood Automation (sometimes
written with a capital A) to refer to a specific set of interfaces.
I.e. it's not a generic term for driving one program with another.  As
with almost everything, there's a wiki article:

  https://en.wikipedia.org/wiki/OLE_Automation

> The thing about simulating button presses is that:
> (1) you can absolutely guarantee that it does exactly the same as what

Yes, this is valuable for UI testing and there were/are several testing
systems that work that way.  Automation is something different.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to convert 'ö' to 'oe' or 'o' (or other si =?utf-8?Q?milar_things)_in_a_string??=

2016-09-18 Thread Thorsten Kampe
* Terry Reedy (Sun, 18 Sep 2016 03:51:40 -0400)
> 
> On 9/18/2016 2:45 AM, Steven D'Aprano wrote:
> 
> > It doesn't matter whether you call them "accent" like most people do, or
> > "diacritics" as linguists do.
> 
> I am a native born American and I have never before heard or seen 
> non-accent diacritic marks called 'accents'.  Accents indicate stress. 
> Other diacritics indicate other pronunciation changes.  It is 
> counterproductive to confuse the two groups.  Spanish, for instance, has 
> vowel accents that change which syllable gets stressed.  A tilda is not 
> an accent; rather, it softens the pronunciation of 'n' to 'ny', as in 
> 'canyon'.

Had to be said. Nothing to add.

Thorsten

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-18 Thread Marko Rauhamaa
Thorsten Kampe :

> * Terry Reedy (Sun, 18 Sep 2016 03:51:40 -0400)
>> On 9/18/2016 2:45 AM, Steven D'Aprano wrote:
>> > It doesn't matter whether you call them "accent" like most people do, or
>> > "diacritics" as linguists do.
>> 
>> I am a native born American and I have never before heard or seen 
>> non-accent diacritic marks called 'accents'.  Accents indicate stress. 
>> Other diacritics indicate other pronunciation changes.  It is 
>> counterproductive to confuse the two groups.  Spanish, for instance, has 
>> vowel accents that change which syllable gets stressed.  A tilda is not 
>> an accent; rather, it softens the pronunciation of 'n' to 'ny', as in 
>> 'canyon'.
>
> Had to be said. Nothing to add.

http://www.merriam-webster.com/dictionary/accent>

   5 a : a mark (as ´, `, ˆ) used in writing or printing to indicate a
 specific sound value, stress, or pitch, to distinguish words
 otherwise identically spelled, or to indicate that an ordinarily
 mute vowel should be pronounced
 b : an accented letter


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Michael Torrie
On 09/18/2016 04:03 AM, Lawrence D’Oliveiro wrote:
> Like I said, trying to automate a GUI is a waste of time. GUIs are
> designed for humans, not computers, to use.

Well then we have a huge problem.  Especially for users who are
visually-impaired. Fortunately almost all GUIs (Windows, Linux, and Mac)
are automate-able these days and can be interfaced with with screen
readers and scriptable event generators.  This is very very common, even
though you seem to think it's not.

One of the most mature tools for driving GUIs (which we used all the
time when doing scripted installs of Windows) was AutoIt.  Works pretty
well actually.

> That’s why we have command lines and scripting (which are all just
> programming at different layers, of course). That’s how you automate
> things, building higher-level abstract machines on top of lower-level
> ones. GUIs are the end of the abstraction chain: you cannot build
> anything more on top of them.

What a nice simplistic view of the world you have.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Lawrence D’Oliveiro
On Monday, September 19, 2016 at 2:12:14 AM UTC+12, Chris Angelico wrote:
>
> On Sun, Sep 18, 2016 at 8:03 PM, Lawrence D’Oliveiro wrote:
>
>> Like I said, trying to automate a GUI is a waste of time. GUIs are designed
>> for humans, not computers, to use.
> 
> Okay, then. Come up with a way to end-to-end-test a GUI application
> without some form of GUI automation.

There isn’t one. Have you noticed GUI apps are particularly buggy?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Lawrence D’Oliveiro
On Monday, September 19, 2016 at 8:00:43 AM UTC+12, Michael Torrie wrote:
>
> On 09/18/2016 04:03 AM, Lawrence D’Oliveiro wrote:
>
>> Like I said, trying to automate a GUI is a waste of time. GUIs are
>> designed for humans, not computers, to use.
> 
> Well then we have a huge problem.  Especially for users who are
> visually-impaired.

I know one blind computer user who is quite capable with the command line, and 
who has little fondness for GUI apps. You should see how quickly he works...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Lawrence D’Oliveiro
On Sunday, September 18, 2016 at 11:02:57 PM UTC+12, Christian Gollwitzer wrote:
>
> Am 18.09.16 um 12:26 schrieb Lawrence D’Oliveiro:
>
>> Considering the power available in Free Software toolkits like
>> ImageMagick, G’MIC and so on, not to mention libraries accessible
>> from Python itself, let me suggest that such proprietary software
>> simply isn’t worth bothering with any more.
> 
> I was expecting that argument. Free software gives you a lot in this 
> area, but there are commercial signal processing programs with unmatched 
> quality. Examples:
> 
> https://ni.neatvideo.com/
>   or for audio
> http://www.celemony.com/en/melodyne/what-is-melodyne

If these tools are so wonderful, why don’t they offer command-line versions?

I’ll tell you why: because it would likely mean they would sell fewer copies.

Unless they put in a whole bunch of additional restrictions in the EULA, such as
  * You can’t run the program via SSH or a PTY, because this would allow
multiple machines to make use of a single copy, which is not allowed.
  * Shell scripts are allowed, but any loop invoking the cheaper version of the
tool is only allowed a maximum of 100 iterations. Also you must write the
scripts using csh, not bash.
  * Pipes are limited to a maximum transfer of one gigabyte per day.

A CLI gives the user power over the computer. While a GUI is a great way to 
give the computer, and proprietary software companies, power over the user.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Ned Batchelder
On Sunday, September 18, 2016 at 6:45:32 PM UTC-4, Lawrence D’Oliveiro wrote:
> A CLI gives the user power over the computer. While a GUI is a great way to 
> give the computer, and proprietary software companies, power over the user.

This is completely beside the point of the original question.

--Ned.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Michael Torrie
On 09/18/2016 02:22 PM, Lawrence D’Oliveiro wrote:
> I know one blind computer user who is quite capable with the command
> line, and who has little fondness for GUI apps. You should see how
> quickly he works...

Good for him.  This is very good that there are tools like that that he
and many others can use, including ourselves.  There are also good tools
for those that want or need to use MS Windows or GUI applications.

And, to get back on topic, there are good tools for automating testing
and driving of GUI apps.  One I've used is AutoIt.  There is even a
Python-based one that Matt Wheeler talked about.  I suspect it will work
more or less with the Java apps the original poster needs to work with.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Lawrence D’Oliveiro
On Monday, September 19, 2016 at 11:32:25 AM UTC+12, Michael Torrie wrote:
> One I've used is AutoIt.



Like I said, this kind of thing can never work reliably...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-18 Thread not1xor1

Il 18/09/2016 08:45, Steven D'Aprano ha scritto:

integral part of the letter, like the horizonal stroke in English t or the
vertical bar in English p and b, and in some languages they are modifiers,


well... that is the Latin alphabet

English has no T, P or B (or any other character) but is just 
(mis)using the Latin alphabet (which is just a few centuries older 
than the English language itself) :-)


--
bye
!(!1|1)
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-18 Thread Steven D'Aprano
On Sunday 18 September 2016 17:51, Terry Reedy wrote:

> On 9/18/2016 2:45 AM, Steven D'Aprano wrote:
> 
>> It doesn't matter whether you call them "accent" like most people do, or
>> "diacritics" as linguists do.
> 
> I am a native born American and I have never before heard or seen
> non-accent diacritic marks called 'accents'.  Accents indicate stress.
> Other diacritics indicate other pronunciation changes.  It is
> counterproductive to confuse the two groups.  Spanish, for instance, has
> vowel accents that change which syllable gets stressed.

Then you're better educated than most people I've met. Most folks I know call 
any of those "funny dots and squiggles" on letters "accents".


> A tilda is not
> an accent; rather, it softens the pronunciation of 'n' to 'ny', as in
> 'canyon'.

Hmmm. I'm not a Spanish speaker, but to me, 'canyon' is pronounced can-yen and 
the n is pronounced no differently from the n in 'can', 'man', 'men', 'pan', 
'panel', 'moon', 'nut', etc.

(P.S. it's tilde. Tilda is short for Matilda, as in Tilda Swinton the actor.)

But what do I know? My missus says I have a tin-ear, and I'm no linguist. But I 
can read Wikipedia:

https://en.wikipedia.org/wiki/Diacritic

and it makes it clear that diacritics including accents can have many different 
effects on pronunciation, including none at all.

E.g. French là ("there") versus la ("the") are both pronounced /la/. In English 
the diaereses found in naïve, Noël, Zoë, coöperate etc. is used to show that 
the marked vowel is pronounced separately from the preceding vowel (e.g. co-
operate rather than coop-erate), and accents used to indicate that a vowel 
which normally isn't pronounced at all should be, as in saké or Moist von 
Lipwig's wingèd hat[1].


Make of that what you will.




[1] A running gag from "Going Postal", one of the Discworld series.


-- 
Steven
git gets easier once you get the basic idea that branches are homeomorphic 
endofunctors mapping submanifolds of a Hilbert space.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to automate java application in window using python

2016-09-18 Thread Christian Gollwitzer

Am 19.09.16 um 00:45 schrieb Lawrence D’Oliveiro:

On Sunday, September 18, 2016 at 11:02:57 PM UTC+12, Christian Gollwitzer wrote:


Am 18.09.16 um 12:26 schrieb Lawrence D’Oliveiro:


Considering the power available in Free Software toolkits like
ImageMagick, G’MIC and so on, not to mention libraries accessible
from Python itself, let me suggest that such proprietary software
simply isn’t worth bothering with any more.


I was expecting that argument. Free software gives you a lot in this
area, but there are commercial signal processing programs with unmatched
quality. Examples:

https://ni.neatvideo.com/
  or for audio
http://www.celemony.com/en/melodyne/what-is-melodyne


If these tools are so wonderful,


They are.


why don’t they offer command-line versions?

I’ll tell you why: because it would likely mean they would sell fewer copies.


I agree with you.






A CLI gives the user power over the computer. While a GUI is a great
way to give the computer, and proprietary software companies, power
over the user.


I mostly agree with you. Doesn't change the fact, that IF you are in the 
situation that you have a program without a reasonable command line 
interfacem and IF you need to process some data in an automated fashion 
which can't be done from the GUI, then there is room for a "GUI 
automation" tool or whatever you call it.


Don't get it wrong, we all like free software and sane APIs and a Python 
binding to the mowing robot. Still, sometimes you just need to get the 
job done and it doesn't matter how.


Christian
--
https://mail.python.org/mailman/listinfo/python-list


Re: Functions Of Functions Returning Functions

2016-09-18 Thread dieter
Lawrence D’Oliveiro  writes:
> The less code you have to write, the better. Less code means less
> maintenance, and fewer opportunities for bugs.

While I agree with you in general, sometimes less code can be harder
to maintain (when it is more difficult to understand).

Some time ago, we had a (quite heated) discussion here about
a one line signature transform involving a triply nested lambda construction.
It was not difficult for me to understand what the construction did;
however, the original poster found it very difficult to grasp.

Often, functions returning functions are more difficult to understand
than "first order" functions (those returning simple values only) --
at least for people not familiar with higher abstraction levels.

-- 
https://mail.python.org/mailman/listinfo/python-list