Re: Monotheism - One God

2015-03-20 Thread Steve Hayes
On Thu, 19 Mar 2015 14:57:33 -0700 (PDT), [email protected] wrote:

>Monotheism - One God

There is no God but Monty, and Python is his prophet.



-- 
Terms and conditions apply. 

Steve Hayes
[email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: beautifulSoup 4.1

2015-03-20 Thread Sayth Renshaw
On Friday, 20 March 2015 15:20:41 UTC+11, Sayth Renshaw  wrote:
> HI
> 
> Probably very easy question.
> 
> If I have a section of html.
> 
> 
> App
> Approaching
> D/N
> Did nothing
> DGO
> Didn't go on
> DRO
> Didn't run on
> H/In
> Hung in
> H/Out
> Hung out
> 
> 
> I can easily get the class values out.
> 
> In [69]: soup.find_all("td", class_="abbreviation")
> Out[69]:
> [App,
>  D/N,
>  DGO,
>  DRO,
>  H/In,
>  H/Out,
>  H/S,
>  J awk,
>  k-up,
> 
> Or just values
> 
> In [70]: tds = soup.find_all("td", class_="abbreviation")
> 
> In [71]: for entry in tds:
>: print(entry.contents[0])
>:
> App
> D/N
> DGO
> DRO
> H/In
> H/Out
> H/S
> J awk
> k-up
> 
> But how can I get the value of the following td. That is for 
> 
> class="abbreviation">App I would get Approaching
> 
> So when creating a csv I could use
> 
> print App Approaching
> 
> __
> Abbr   | Meaning |
> __
> App| Approaching  |
> 
> 
> I know how to do the csv writing but not quite the wizz with soup yet reading 
> here 
> http://www.crummy.com/software/BeautifulSoup/bs4/doc/#searching-by-css-class
> 
> Thanks
> 
> Sayth

Just finding it odd that the next sibling is a "\n" and not the next  
otherwise that would be the perfect solution.

In [72]: tds = soup.find("td", class_="abbreviation")

In [73]: tds.next_sibling
Out[73]: u'\n'

In [74]: tds
Out[74]: App

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


Re: beautifulSoup 4.1

2015-03-20 Thread Denis McMahon
On Thu, 19 Mar 2015 21:20:30 -0700, Sayth Renshaw wrote:

> But how can I get the value of the following td

# find all tds with a class attribute of "abbreviation"

abbtds = soup.find_all("td", attrs={"class": "abbreviation"})

# display the text of each abbtd with the text of the next td

for td in abbtds:

print td.get_text(), td.find_next_sibling().get_text()

This works for the html fragment example given, once I fixed it up by 
removing the extra  at the end.

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: beautifulSoup 4.1

2015-03-20 Thread Denis McMahon
On Fri, 20 Mar 2015 07:23:22 +, Denis McMahon wrote:

> print td.get_text(), td.find_next_sibling().get_text()

A slightly better solution might even be:

print td.get_text(), td.find_next_sibling("td").get_text()

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: beautifulSoup 4.1

2015-03-20 Thread Denis McMahon
On Fri, 20 Mar 2015 00:18:33 -0700, Sayth Renshaw wrote:

> Just finding it odd that the next sibling is a "\n" and not the next
>  otherwise that would be the perfect solution.

Whitespace between elements creates a node in the parsed document. This 
is correct, because whitespace between elements will be interpreted as 
whitespace by a browser.

text1text2

will be displayed differently to

text1 text2

in a browser, because the space between the  two elements in the 
second case is a text node in the dom.

A newline has the same effect (because to a browser for display purposes 
it's just whitespace) but in the dom the text node will contain the 
newline rather than a space.

bs4 tries to parse the html the same way a browser does, so you get all 
the text nodes, including the whitespace between elements which includes 
any newlines.

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


DIPY 0.9.2 is ready for download!

2015-03-20 Thread Eleftherios Garyfallidis
Dear all,

We are very happy to announce a new release of Diffusion Imaging in Python
(DIPY)

Here is a quick summary of our new features.

DIPY 0.9.2 (Wednesday, 18 March 2015)

* Anatomically Constrained Tissue Classifiers for Tracking
* Massive speedup of Constrained Spherical Deconvolution (CSD)
* Recursive calibration of response function for CSD
* New experimental framework for clustering
* Improvements and 10X speedup for Quickbundles
* Improvements in Linear Fascicle Evaluation (LiFE)
* New implementation of Geodesic Anisotropy
* New efficient transformation functions for registration
* Sparse Fascicle Model supports acquisitions with multiple b-values

Detailed release notes can be found here:
http://dipy.org/release0.9.html

Enjoy the upgrade. If you are using Pypi you just need to do:

*pip install --upgrade dipy*

For any questions go to http://dipy.org, or https://neurostars.org or send
an e-mail to [email protected]

DIPY will be an official exhibitor at HBM 2015 in Honolulu. Come and meet
us!

On behalf of the DIPY developers,
Eleftherios Garyfallidis
http://dipy.org/developers.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: beautifulSoup 4.1

2015-03-20 Thread Sayth
Thanks. 
 
I couldn't get that second text out. 

You can use the simpler css class selector I used before in bs4 after 4.1 .

The longer version was used to overcome class clashing with the reserved 
keyword in previous versions. 

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


numpy array product driving me mad

2015-03-20 Thread Mr. Twister
Hi everyone.

Hope you can help me overcome this "noob" issue.

I have two numpy arrays:

>>> P
array([[[ 2,  3],
[33, 44],
[22, 11],
[ 1,  2]]])
>>> R
array([0, 1, 2, 3])

the values of these may of course be different. The important fact is that:

>>> P.shape
(1, 4, 2)
>>> R.shape
(4,)

where the number 4 in the shape of both P and R may be another number as well
(same on both).


What I'd like to get is a new array Q with same shape as P so that the nth pair
of Q is the nth pair of P multiplied by the nth element of R. I.e., in the above
case it should produce:

>>> Q
array([[[ 0,  0],
[33, 44],
[44, 22],
[ 3,  6]]])


Is there a direct, single expression command to get this result? I have tried
all I could imagine, including .T, extend_dims, h/vstack, repeat..., so far with
no success.

Please, any help will be welcomed.

Thanks.

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


Re: Deep comparison of dicts - cmp() versus ==?

2015-03-20 Thread Roy Smith
In article <[email protected]>,
 Steven D'Aprano  wrote:

> I cannot remember the details, and I don't have my copy of the Apple 
> Standard Numerics manual here to look it up

Amongst the details you don't remember is the correct name :-)  It was 
Standard Apple Numerics Environment (SANE).  I think I still have my 
copy of the manual somewhere.

> If you find that hard to believe, it's because you're spoiled by the 
> astonishing success of IEEE-754 floating point arithmetic.

There's two things we're spoiled by.  IEEE-754 is, of course, one of 
them.  But, more than that, are good math libraries built on top of it.

One of the truly unappreciated things to come out of the early BSD Unix 
releases was a C math library written by people who understood (and 
worried about) things like accurate FP calculations, rounding, corner 
cases, and all that gunk.  Sure, I could sit down with a C compiler and 
the Wikipedia Gamma function article and code up gamma().  It would work 
well enough to get a decent grade as a homework assignment for 
Introduction To Programming 101.  But, fundamentally, it would be a 
piece of crap because I know just enough about numerical programming to 
know that I should leave it to the experts.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: numpy array product driving me mad

2015-03-20 Thread Manolo Martínez
On 03/20/15 at 01:46pm, Mr. Twister wrote:
 
> I have two numpy arrays:
> 
> >>> P
> array([[[ 2,  3],
> [33, 44],
> [22, 11],
> [ 1,  2]]])
> >>> R
> array([0, 1, 2, 3])
> 
> the values of these may of course be different. The important fact is that:
> 
> >>> P.shape
> (1, 4, 2)
> >>> R.shape
> (4,)
> 
> where the number 4 in the shape of both P and R may be another number as well
> (same on both).
> 
> 
> What I'd like to get is a new array Q with same shape as P so that the nth 
> pair
> of Q is the nth pair of P multiplied by the nth element of R. I.e., in the 
> above
> case it should produce:
> 
> >>> Q
> array([[[ 0,  0],
> [33, 44],
> [44, 22],
> [ 3,  6]]])
> 
> 
> Is there a direct, single expression command to get this result? 

I think that you want 

P * R[;,None]

Read about broadcasting
(http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) for an
explanation. I'm never sure I understand it myself :)

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


Re: numpy array product driving me mad

2015-03-20 Thread Manolo Martínez
On 03/20/15 at 02:11pm, Manolo Martínez wrote:
> On 03/20/15 at 01:46pm, Mr. Twister wrote:
>  
> > I have two numpy arrays:

[...] 

> > Is there a direct, single expression command to get this result? 
> 
> I think that you want 
> 
> P * R[;,None]

Sorry, I meant 

P * R[:, None]

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


Re: Deep comparison of dicts - cmp() versus ==?

2015-03-20 Thread Rustom Mody
On Friday, March 20, 2015 at 10:39:48 AM UTC+5:30, Ben Finney wrote:
> Chris Angelico  writes:
> 
> > Real numbers, yes […] but not IEEE floating point. Be careful of that
> > distinction; we're talking about computers here, not mythical numbers.
> 
> So real numbers are mythical? IEEE floating point values are more real
> than real numbers? Just what are you saying, man?

In all fairness to Chris, there have been notable mathematicians in the last 100
years who have said more or less exactly what Chris is saying: "The set ℝ is 
nonsense."  In fact these fights are the very reason that CS came
into existence.

1880s: Kronecker and his student Cantor were working together when Cantor 
started off on 'set-theory'
For a while Cantor was bemused with the direction of his (favorite!) student.
But he soon found it unacceptable and started disagreeing with Cantor, first
privately then publicly.

His famous statement dates from this disagreement:
"The Good Lord made the Natural numbers. All the rest is the work of man"
He was specifically implying that things like ℝ are just nonsense.
At that time almost all mathematicians were Kroneckerians.
Cantor ended up in an 'institution.'
Other famous statements of that time were from Gordon who said:
"This sir, is not mathematics, its theology"
[referring to a standard construction of set theory called
Axiom of choice]

A couple of generations later things had turned.

Mainstream mathematicians all accepted set theory, except a few trouble-makers 
called constructivists.
The constructivists said that the other mathematicians who they called
'Platonist' which derisively signified mystic after the cave allegory of Plato
http://dwildepress.net/critica/mystic4.html were being ridiculously loose and 
sloppy in talking about infinity as though it exists.

Hilbert -- the head of the classicists/platonists -- was angry with this charge,
made the famous statement: "Nobody will drive us out of the paradise created by 
Cantor."

And (in what he thought was super-cleverness) formulated the Entscheidung 
problem:

If the questions about mathematics could be finitistically (ie mechanically) 
solved, then the constructivists' charge (of mysticism) could be kicked out

But then Gödel showed that the dream of a complete and consistent math was a 
pipe-dream.
A job that Turing completed by showing the unsolvability of the Entscheidung 
problem.
http://www.philocomp.net/home/hilbert.htm

From a math/logic pov these were all disastrous results.
But a side-effect of this disaster was that something called a 'universal-
machine' got invented…
viz a computer

An entertaining and longer account:
http://research.microsoft.com/en-us/um/people/gurevich/opera/123.pdf
Particularly note the Polya-Weyl bet
==
tl;dr "Real numbers are not real" is an argument at the creation of CS.
To find and work with a set that
- Does not have the nonsensical behaviors of floats
- Is not nonsensical in the sense of the constructivists' objections

is really a bit of an open problem:
http://www.encyclopediaofmath.org/index.php/Constructive_real_number
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: numpy array product driving me mad

2015-03-20 Thread Mr. Twister
>> I think that you want 
>>
>> P * R[;,None]
> 
> Sorry, I meant 
> 
> P * R[:, None]
> 
> Manolo

Muchísimas gracias, Manolo. Eres un genio y me has ayudado mucho. Te debo una.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Deep comparison of dicts - cmp() versus ==?

2015-03-20 Thread Rustom Mody
On Friday, March 20, 2015 at 12:06:00 PM UTC+5:30, Steven D'Aprano wrote:
> On Friday 20 March 2015 14:47, Rustom Mody wrote:
> > Not too many people are interested in float independent of ℝ except
> > perhaps hardware designers who need to design respecting the IEEE
> > standard.
> 
> I don't understand what you are trying to say here.

The reason for creating float (IEEE or previous hacks) is that people want to do
ℝ-ish stuff.
The only justification for float is that it is consistent with ℝ
[Is it? Aint it? Depends on how you squint]¹
Nobody wants to do float for the sake of float.
The only parties that (presumably) want to do "pure" float (ie ignore ℝ 
completely)
are the h/w-guys who need to get an "IEEE-compliant" stamp.

=
¹ Even the IEEE standard writers need to do a tight-rope walk between
- respecting ℝ
- making a spec that is 'hardware-able"
- And will not have us software-guys screaming

Ie There is no one (I can think of) except hw engineers who would care to think
float without minding ℝ.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Deep comparison of dicts - cmp() versus ==?

2015-03-20 Thread Marko Rauhamaa
Rustom Mody :

> In all fairness to Chris, there have been notable mathematicians in
> the last 100 years who have said more or less exactly what Chris is
> saying: "The set ℝ is nonsense."

Intuitionism is nonsense.

> In fact these fights are the very reason that CS came into existence.

I trace it to Hilbert's program.


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


Re: [OT] Weaknesses of distro package managers - was Re: Python 2 to 3 conversion - embrace the pain

2015-03-20 Thread Mario Figueiredo
On Fri, 20 Mar 2015 02:40:26 -0700 (PDT), [email protected] wrote:
>
>Python 3.x is excellent.
>Probably, the best language to show a
>poor and buggy Unicode implementation
>(Character Encoding Model).
>
>When I think other computer languages or
>Unicode related tools are all doing wrong.
>That's terrible.
>

Ah. So you are on the Python 3 unicode support sucks bandwagon too?

Bet you guys have a whole lot of fun there. Rave parties, trashing,
getting mad at something. Sounds fun.

Over here, on the Python 3 unicode support is just fine bandwagon, we
aren't so lucky. Things are just going smoothly, so they don't let us
party. We spend most of our time writting applications that don't
crash at runtime on the user hands because Python 3 is not permissive
and does force us to write well-formed encoding protocols.

Many times I though jumping to your side. Like I said, it sounds more
fun. But really, wife and kids need to eat.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] Weaknesses of distro package managers - was Re: Python 2 to 3 conversion - embrace the pain

2015-03-20 Thread Mario Figueiredo
On Fri, 20 Mar 2015 15:59:01 +0100, Mario Figueiredo
 wrote:

>
>Ah. So you are on the Python 3 unicode support sucks bandwagon too?
>
>Bet you guys have a whole lot of fun there. Rave parties, trashing,
>getting mad at something. Sounds fun.
>
>Over here, on the Python 3 unicode support is just fine bandwagon, we
>aren't so lucky. Things are just going smoothly, so they don't let us
>party. We spend most of our time writting applications that don't
>crash at runtime on the user hands because Python 3 is not permissive
>and does force us to write well-formed encoding protocols.
>
>Many times I though jumping to your side. Like I said, it sounds more
>fun. But really, wife and kids need to eat.


Forgot to mention:

At first it was crap. We couldn't really understand what the hell was
going on. WTF? We need to write more code now!? Screw this! We even
wrote a banner at the office: "Byte this Python 3!"

But we eventually, you know, adapted and shit. We just grew out of it.
Like I said, wife and kids need to eat.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python script output in file

2015-03-20 Thread Albert-Jan Roskam

-
On Thu, Mar 19, 2015 12:16 AM CET Steven D'Aprano wrote:

>On Thu, 19 Mar 2015 07:22 am, Albert-Jan Roskam wrote:
>
>> 
>> 
>> On Wed, Mar 18, 2015 7:06 PM CET Rustom Mody wrote:
>> 
>>On Wednesday, March 18, 2015 at 8:12:12 PM UTC+5:30, Robert Clove wrote:
>>> ./my_eth_script.pl eth0 M > a.txt
>>> 
>>> How can i run this command with subprocess.popen
>>
>>Something like this I guess?
>>
>>> proc = Popen("cat", shell=True, stdout=open(inname, "w"),
>>> stdin=open(outname,"r"))
>> 
>> 
>> How will the file object associated with in name be closed? (When is
>> close() method called?
>
>Depends on the interpreter.
>
>CPython (the one you are probably using) will notice immediately the proc
>object goes out of scope and is garbage-collected. That will free up the
>Popen stdout argument, which will garbage collect the file object, which
>will close the inname file immediately.
>
>Assuming there are no circular references involved. If there are, then the
>file won't be closed until the second garbage collector gets to run. It
>will break the circular reference and close the file, but there is no
>promise as to how often it will run. The user can configure how often it
>runs and even whether it runs at all.
>
>On the other hand, Jython will garbage-collect the file object, but the file
>itself may remain open until your code exits, and only be closed on
>interpreter-shutdown. Since the operator system probably has limits on how
>many files you can have open at once, you might actually run out.
>
>For quick and dirty scripts, it doesn't matter, but best practice is to
>explicitly close your files as soon as possible, preferably with a `with`
>statement:
>
>
># I think inname and outname are reversed...
>with open(inname, "w") as outfile, open(outname, "r") as infile:
>proc = Popen("cat", shell=True, stdout=outfile, stdin=infile)
># do stuff with proc
># when finished, save the stuff you care about
>result = ...
>
>print(result)
>
>
>Outside of the `with` block, proc's stdout and stdin will be automatically
>closed, even if the block exits with an exception.

Thanks, this is indeed what I was thinking about. I had no idea about the GC 
differences between cpython and jython (reference counting vs true, java GC). I 
am amazed that jython is just a version 2.3, is it tries to look like cpython 
2.3! But perhaps they're about to jump to 3.4


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


Re: [OT] Weaknesses of distro package managers - was Re: Python 2 to 3 conversion - embrace the pain

2015-03-20 Thread Mark Lawrence

On 20/03/2015 14:59, Mario Figueiredo wrote:

On Fri, 20 Mar 2015 02:40:26 -0700 (PDT), [email protected] wrote:


Python 3.x is excellent.
Probably, the best language to show a
poor and buggy Unicode implementation
(Character Encoding Model).

When I think other computer languages or
Unicode related tools are all doing wrong.
That's terrible.



Ah. So you are on the Python 3 unicode support sucks bandwagon too?

Bet you guys have a whole lot of fun there. Rave parties, trashing,
getting mad at something. Sounds fun.

Over here, on the Python 3 unicode support is just fine bandwagon, we
aren't so lucky. Things are just going smoothly, so they don't let us
party. We spend most of our time writting applications that don't
crash at runtime on the user hands because Python 3 is not permissive
and does force us to write well-formed encoding protocols.

Many times I though jumping to your side. Like I said, it sounds more
fun. But really, wife and kids need to eat.



Please don't feed the RUE.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: [OT] Weaknesses of distro package managers - was Re: Python 2 to 3 conversion - embrace the pain

2015-03-20 Thread Chris Angelico
On Sat, Mar 21, 2015 at 2:42 AM, Mark Lawrence  wrote:
> Please don't feed the RUE.

Yeah, you'll RUE the day you get sucked into a conversation with a troll...

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


Re: [PyQt] win32api.LoadKeyboardLayout; any solutions for OSX?

2015-03-20 Thread Timothy W. Grove
Thanks again. Macports didn't have the latest pyobjc, but pip updated my 
installation to the fixed version. Problem solved.


Tim

On 20/03/2015 00:18, michael h wrote:

Did you see this:

https://bitbucket.org/ronaldoussoren/pyobjc/issue/95/attributeerror-in-some-cases-when-checking



On Thu, Mar 19, 2015 at 12:20 PM, Timothy W. Grove > wrote:


A personal reply to my question sent me to the following link:

http://stackoverflow.com/questions/23729704/change-osx-keyboard-layoutinput-source-programmatically-via-terminal-or-appl.
I seem to have found a solution that worked using PyObjC.

I'm currently using Python 3.3 installed via macports, and I
installed the appropriate ports for my setup (py33-pyobjc,
py33-pyobjc-cocoa).

For my import statement:

from AppKit import NSTextInputContext

To find the current keyboard being used:

ic = NSTextInputContext.new()
current_keyboard = ic.selectedKeyboardInputSource()

To list the currently available keyboards:

keyboards = ic.keyboardInputSources()

To change the current keyboard (to 'Arabic', for example):

ic.setValue_forKey_('com.apple.keylayout.Arabic',
'selectedKeyboardInputSource')


Now, that is the good news! This all worked great in my source
code, but as an app bundle (created with cx_Freeze 4.3.2) it
wouldn't run at all. I'll include the full error trace at the end
of this email, but the problems seem to start with the import of
AppKit and end with objc/_lazyimport.py.

I'm not sure if this points to a 'bug' in objc or something else
which I've left out of my setup routine, but if anyone has any
ideas, I would be interested to hear from you.

Best regards,
Timothy Grove



On 05/03/2015 14:51, Timothy W. Grove wrote:

I was looking for a way to change keyboard layouts from within a
Python 3 / PyQt4 application. Win32api.LoadKeyboardLayout has
come to my rescue on Windows, but is anyone aware of a
cross-platform or OSX specific solution for Apple Mac? Thanks for
any suggestions.

Best regards,
Tim


Traceback (most recent call last):

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/cx_Freeze/initscripts/Console3.py",
line 27, in 

exec(code, m.__dict__)

  File "soosl.py", line 6, in 

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
line 1565, in _find_and_load

return _find_and_load_unlocked(name, import_)

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
line 1532, in _find_and_load_unlocked

loader.load_module(name)

  File
"/Users/timothygrove/Documents/workspace/SooSL/mainwindow.py",
line 19, in 

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
line 1565, in _find_and_load

return _find_and_load_unlocked(name, import_)

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
line 1532, in _find_and_load_unlocked

loader.load_module(name)

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/AppKit/__init__.py",
line 9, in 

import Foundation

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
line 1565, in _find_and_load

return _find_and_load_unlocked(name, import_)

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
line 1532, in _find_and_load_unlocked

loader.load_module(name)

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/Foundation/__init__.py",
line 9, in 

import CoreFoundation

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
line 1565, in _find_and_load

return _find_and_load_unlocked(name, import_)

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
line 1532, in _find_and_load_unlocked

loader.load_module(name)

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/CoreFoundation/__init__.py",
line 20, in 

}, ())

  File

"/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/objc/_lazyimport.py"

Threading: execute a callback function in the parent thread

2015-03-20 Thread massi_srb
Hi everyone,

just like the title says I'm searching for a mechanism which allows to call a 
callback function from a thread, being the callback executed in the parent 
thread (it can also be the main thread). I'm basically looking for something 
like the CallAfter method of the wx or the signal slot mechanism of the pyqt. 
Is there something similar but made only in native python? any workaround is 
welcome.

Thanks in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Automation of Windows app?

2015-03-20 Thread Grant Edwards
[I thought I'd seen a discussion of this recently, but I can't seem to
find the right keyword.]

I need to automate operation of a Windows application.  It's a
conformance test app from a standards organizaiton, and it's
_stunningly_ bad.  You have to sit it front of it like some sort of
brainless slave and click a button every 10-20 minutes.

At a minimum, I'd like to click the "run" button on a certain dialog
when it pops up so I can at least run one test multiple times.  It
would also be nice to be able to menu selections and enter data in
dialogs so that I can run multiple tests without human intervention.

I'm normally a Linux and embedded developer, but I have ActiveState
Python installed, and am hoping I can write some sort of Python
program to drive this awful Windows app...


There's no way to automate or script anything in this application, and
even the simplest features seem to be broken.  For example, there a
spot where you can enter how many times a test is to run.  But after
each run, a dialog box pops up and you have to click "run" again.
It's one of those programs that can only survive in such a state of
brokenness because there's a "standards" organization that forces you
to buy it and use it (I'm talking about _you_ ODVA).


-- 
Grant Edwards   grant.b.edwardsYow! Boys, you have ALL
  at   been selected to LEAVE th'
  gmail.comPLANET in 15 minutes!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Automation of Windows app?

2015-03-20 Thread Grant Edwards
On 2015-03-20, Grant Edwards  wrote:

> I need to automate operation of a Windows application.

I should have mentioned that I've found and am going to experiment
a bit with pywinauto-0.4.0, but if there is anything else I should
look at, suggestions would be welcome.

-- 
Grant Edwards   grant.b.edwardsYow! over in west
  at   Philadelphia a puppy is
  gmail.comvomiting ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Threading: execute a callback function in the parent thread

2015-03-20 Thread Ian Kelly
On Fri, Mar 20, 2015 at 11:29 AM,   wrote:
> Hi everyone,
>
> just like the title says I'm searching for a mechanism which allows to call a 
> callback function from a thread, being the callback executed in the parent 
> thread (it can also be the main thread). I'm basically looking for something 
> like the CallAfter method of the wx or the signal slot mechanism of the pyqt. 
> Is there something similar but made only in native python? any workaround is 
> welcome.

There's no general way to tell another thread to execute something,
because that thread is *already* executing something -- you can't just
interrupt it and say "here, do this instead". There has to be some
mechanism in place for scheduling the thing to be executed. You can do
this with the main thread of frameworks like wx because the main
thread in that case is running an event loop which enables the
callback to be scheduled.

If your target thread is not running an event loop or being used as an
executor (either of which should provide a specific API for this),
then you will need to have that thread explicitly checking a callback
queue from time to time to see if there's anything ready for it to
call.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows service in production?

2015-03-20 Thread Raymond Cote
Years and years ago we found a module called ntsvc which allows us to run as a 
Service on Windows.
We’ve been using it since well before 2011 to build 32-bit services on Windows 
with py2exe.
If you contact me directly, I’ll dig it out of our source tree and post it on a 
shared location.

Alternatively, you may want to look at a service manager such as: 
https://nssm.cc
This allows you to run a standard executable as a Windows Service.
We’ve just started looking down this path ourselves since we’re looking to move 
to Python 3.x and want to reduce our dependencies as much as possible.
—Ray


> On Mar 19, 2015, at 2:58 AM, [email protected] wrote:
> 
> On Tuesday, August 16, 2011 at 10:02:02 AM UTC+5:30, snorble wrote:
>> Anyone know of a Python application running as a Windows service in
>> production? I'm planning a network monitoring application that runs as
>> a service and reports back to the central server. Sort of a heartbeat
>> type agent to assist with "this server is down, go check on it" type
>> situations.
>> 
>> If using Visual Studio and C# is the more reliable way, then I'll go
>> that route. I love Python, but everything I read about Python services
>> seems to have workarounds ahoy for various situations (or maybe that's
>> just Windows services in general?). And there seem to be multiple
>> layers of workarounds, since it takes py2exe (or similar) and there
>> are numerous workarounds required there, depending on which libraries
>> and functionality are being used. Overall, reading about Windows
>> services in Python is not exactly a confidence inspiring experience.
>> If I knew of a reference example of something reliably running in
>> production, I'd feel better than copying and pasting some code from a
>> guy's blog.
> 
> Have you got any resolution for creating a service in windows 7 32bit
> --
> https://mail.python.org/mailman/listinfo/python-list



signature.asc
Description: Message signed with OpenPGP using GPGMail
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Automation of Windows app?

2015-03-20 Thread Jerry Hill
On Fri, Mar 20, 2015 at 2:10 PM, Grant Edwards  wrote:
> I need to automate operation of a Windows application.

I've used Sikuli (http://www.sikuli.org/) for similar things in the
past.  It's an automation framework built on Jython, and it worked
great for what I needed at the time.

I think AutoHotKey is also widely used for automating windows GUI
apps, but it's not related to python at all.

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


Re: Automation of Windows app?

2015-03-20 Thread Grant Edwards
On 2015-03-20, Jerry Hill  wrote:
> On Fri, Mar 20, 2015 at 2:10 PM, Grant Edwards  
> wrote:
>> I need to automate operation of a Windows application.
>
> I've used Sikuli (http://www.sikuli.org/) for similar things in the
> past.  It's an automation framework built on Jython, and it worked
> great for what I needed at the time.

Thanks, I'll keep Sikuli in mind.  So far, I've been able to get
pywinauto to do what I need to do [as long as I run programs from the
Windows cmd.exe prompt.  You apparently can't run Windows Python
programs from a Cygwin terminal or ssh session].

> I think AutoHotKey is also widely used for automating windows GUI
> apps, but it's not related to python at all.

-- 
Grant Edwards   grant.b.edwardsYow! I want to kill
  at   everyone here with a cute
  gmail.comcolorful Hydrogen Bomb!!
-- 
https://mail.python.org/mailman/listinfo/python-list


__iadd__ with 2 args?

2015-03-20 Thread Neal Becker
I can write a member 

F.__iadd__ (self, *args)

and then call it with 2 args:

f = F()
f.__iadd__ (a, b)

And then args is:
(a, b)

But it seems impossible to spell this as

f += a, b

That, instead, results in 

args = ((a, b),)

So should I just abandon the idea that += could be used this way?

-- 
Those who fail to understand recursion are doomed to repeat it

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


Re: __iadd__ with 2 args?

2015-03-20 Thread Ian Kelly
On Fri, Mar 20, 2015 at 3:25 PM, Neal Becker  wrote:
> I can write a member
>
> F.__iadd__ (self, *args)
>
> and then call it with 2 args:
>
> f = F()
> f.__iadd__ (a, b)
>
> And then args is:
> (a, b)
>
> But it seems impossible to spell this as
>
> f += a, b
>
> That, instead, results in
>
> args = ((a, b),)
>
> So should I just abandon the idea that += could be used this way?

Is there some reason you need the *? Just have it take one argument
which will be a tuple.

>>> class F:
...   def __iadd__(self, other):
... print(other)
...
>>> f = F()
>>> f += 1, 2
(1, 2)
-- 
https://mail.python.org/mailman/listinfo/python-list


Good PDF parser/form filler?

2015-03-20 Thread Cem Karan
Hi all, I'm currently looking for a PDF parser/writer library so I can 
programmatically fill in some PDF forms.  I've found PDF2 
(https://pypi.python.org/pypi/PyPDF2/1.24), and report lab 
(https://pypi.python.org/pypi/reportlab), and I can see that there are a LOT 
more PDF frameworks out there on pypi, but I wanted to know what kinds of 
experiences others have had with them so I can choose a reasonably good one.  
Note that I'm not creating brand-new PDF files, but filling in ones I've 
already gotten.

My requirements:
- Must work with python 3.4
- Must work on OS X (only a real problem for extension classes, etc.)
- Ideally pure python with few dependencies.
- NOT shoveling data out to the internet!  MUST be wholly contained on my 
machine!

Thanks in advance for any help!

Thanks,
Cem Karan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: __iadd__ with 2 args?

2015-03-20 Thread Steven D'Aprano
On Sat, 21 Mar 2015 08:25 am, Neal Becker wrote:

> I can write a member
> 
> F.__iadd__ (self, *args)
> 
> and then call it with 2 args:
> 
> f = F()
> f.__iadd__ (a, b)
> 
> And then args is:
> (a, b)


If you find yourself explicitly calling dunder methods like __iadd__, that's
a sign you are trespassing in the interpreter's area. With a few documented
exceptions, anything with leading and trailing double underscores is
reserved for the interpreter's use.

But having said that, dunder methods are ordinary methods. You can define
them any way you like:

def __iadd__(self, x, y, z, foo="Hello world", *args, **kw):
pass

and then call the method directly with the arguments you want. But what you
CANNOT do is change the way the Python interpreter uses the dunder method.

Python takes statements of the form:

x += expression

and calls type(x).__iadd__(x, expression). There is no way to force Python
to treat expression as multiple arguments, it will be passed to your method
as a tuple.

If you wish to write code like this:

x += a, b, c


then your __iadd__ method needs to look something like this:

def __iadd__(self, arg):
if not isinstance(arg, tuple):
arg = (arg,)
...


> But it seems impossible to spell this as
> 
> f += a, b
> 
> That, instead, results in
> 
> args = ((a, b),)

Correct. You use *args to collect multiple arguments, but Python only passes
a single argument, the tuple (a,b).


> So should I just abandon the idea that += could be used this way?

Yes, sorry.

 

-- 
Steven

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


OT Intuitionism+Platonism+Mysticism => CS (was Deep comparison of dicts...)

2015-03-20 Thread Rustom Mody
On Friday, March 20, 2015 at 7:40:31 PM UTC+5:30, Marko Rauhamaa wrote:
> Rustom Mody:
> 
> > In all fairness to Chris, there have been notable mathematicians in
> > the last 100 years who have said more or less exactly what Chris is
> > saying: "The set ℝ is nonsense."
> 
> Intuitionism is nonsense.

You are challenging me?!?! Come on lets have it out!!

On second thoughts Ive misplaced my boxing gloves.
[And my legs are more reliable than my arms..

]

> 
> > In fact these fights are the very reason that CS came into existence.
> 
> I trace it to Hilbert's program.

And on third thoughts: 
What was Hilbert's program in defence against?

Seriously:

I dont take a side on these matters [Or which side do you see me on?]

However I am talking some historical facts, viz:
Because some nuts did the 20th century equivalent of: 
"Break each others' heads about how many angels can dance on the head of a pin"
therefore much of the world around us exists as it does (for better or worse)
including my (and I guess your) degree and job.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT Intuitionism+Platonism+Mysticism => CS (was Deep comparison of dicts...)

2015-03-20 Thread Marko Rauhamaa
Rustom Mody :

> However I am talking some historical facts, viz: Because some nuts did
> the 20th century equivalent of: "Break each others' heads about how
> many angels can dance on the head of a pin" therefore much of the
> world around us exists as it does (for better or worse) including my
> (and I guess your) degree and job.

The deep philosophical questions around the year 1900 in both
mathematics and physics were left embarrassingly open. The way out was
to stop caring.

Mathematics gave up on defining numbers and settled with a standard
chain of beads:

   0 = {}
   1 = { 0 }
   2 = { 0, 1 }
   3 = { 0, 1, 2 }

   http://en.wikipedia.org/wiki/Set-theoretic_definition_o
   f_natural_numbers#Contemporary_standard>


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