Re: tabs with tkinter

2014-11-29 Thread Terry Reedy

On 11/29/2014 2:50 AM, Peter Otten wrote:

Terry Reedy wrote:


On 11/28/2014 10:52 AM, Peter Otten wrote:

ast wrote:


I have been using tkinter for few weeks now and I didn't found
how to make some tabs on a window.

see this picture for a window with tabs
http://www.computerhope.com/jargon/t/tabs.gif

Isn't it feasible with tkinter ?


See 


Notebook is one of the newer, ttk-only widgets.


There is also an old "Python megawidgets" project that offers a notebook:

http://pmw.sourceforge.net/doc/NoteBook.html

To my surprise Python 3 is supported:

https://pypi.python.org/pypi/Pmw


idlelib also has TreeWidget.py which works on all branches.  However, if 
anyone wants to use it, they should copy it as it may disappear with a 
switch to ttk widgets.



--
Terry Jan Reedy

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


Re: tabs with tkinter

2014-11-29 Thread Steven D'Aprano
Terry Reedy wrote:

> idlelib also has TreeWidget.py which works on all branches.

Heh, I see what you did there :-)


-- 
Steven

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


Re: I love assert

2014-11-29 Thread Steven D'Aprano
MRAB wrote:

> On 2014-11-29 01:30, Steven D'Aprano wrote:
> [snip]
>> I stress that assertions aren't a replacement for unit testing, but they
>> compliment unit testing: assertions can help cover code missed by your
>> unit tests, and check that your unit tests are correct.
>>
> [snip]
> 
> I think you meant "complement". :-)

Somibody swappid thi i and e kiys on my kiboard.



-- 
Steven

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


Re: I love assert

2014-11-29 Thread Chris Angelico
On Sat, Nov 29, 2014 at 8:31 PM, Steven D'Aprano
 wrote:
> Somibody swappid thi i and e kiys on my kiboard.

You know the old rule. "I" before "E", except after "QW"...

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


Re: PyEval_GetLocals and unreferenced variables

2014-11-29 Thread Gregory Ewing

Kasper Peeters wrote:


I have something like

def fun():
   cfun_that_creates_q_in_local_scope()
   def fun2():
   cfun_that_wants_to_see_if_q_is_available()

So the Python side actually doesn't see 'q' directly at all.

I am willing to elaborate on this if you want


I think you will need to elaborate. There are several things
about the way local scopes and references to outer scopes are
implemented in Python that makes what you are asking for
extremely difficult.

If you explain the problem you're actually trying to solve,
we'll probably be able to suggest a better solution.

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


Re: I love assert

2014-11-29 Thread Albert van der Horst
In article <[email protected]>,
Marko Rauhamaa   wrote:
>Chris Angelico :
>
>> On Sat, Nov 15, 2014 at 11:12 AM, Marko Rauhamaa  wrote:
>>> Most importantly, assertion failures are not supposed to be recovered
>>> from (within the program). Assertion failures can result in the loss
>>> of life and limb. They can result in database corruption. They can
>>> result in monetary losses. They can result in smoke coming out of the
>>> monitor.
>>
>> Or, in theory, AssertionError just prevented any of the above from
>> happening.
>
>I'd advice against catching AssertionError and trying to recover from it
>within the program. You could catch it, log it and reraise it, but since
>the failure modes could be completely unexpected (really, by
>definition), I would move fault-tolerance outside the failing process
>and try to restore a coherent reality from there.
>
>Assertion errors are in the same class with CPython bugs, external
>signals (say, SIGKILL), security breaches, hardware failures and the
>like.
>
>For expected failure modes, other exceptions are a suitable facility.

I agree with you (also with your other posts) and I hate that disabling
asserts is considered a kind of "optimising".
Wasn't Dijkstra who said that while the ship is on the dock, we have
life vests on, and while we are at sea, the life vests stay on shore.

It is a defect in python that asserts are automatically removed with
a -O option. Maybe if there are six levels of optimization -O7 at
last would remove the asserts.
Then in the programmers manual of my company I would have:
"Programs are only allowed to use -O7 if there is a test that doing
so results in a substantial benefit in running time, and documented
as such."

And no: AssertionError is no exception to be thrown (such that an
irresponsible person might catch, or even ignore them.)

Indeed it should be treated like a parity fault in the memory of
a computer: don't drive because the brakes don't work.

And then Ben Finney wants us to remove the asserts as soon as
they are committed to source control. Please! It is a fallacy that
there are untested and tested, hence correct, programs.
There are just more or less tested, and more or less correct
programs.
If I deliver a program to source control it may not be solid.
If I give it a tag it is solid... until the company sets a junior
on it to add a feature. Then the assert may turn out to be
life saver, even literally.

>Marko
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

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


Help needed

2014-11-29 Thread Gautam R Bharadwaj
Here is the code in python, this code arranges the alphabets in descending 
order and now I want to encode each alphabet with 0 and next alphabet with 1, 
then 00,01,10,11,000,001 and so on. Please help me with that.

//
//CODE

from collections import defaultdict
import string
text ='intalks is an organization comprised of passionate 
students'.lower().translate(None,string.punctuation+' ')
c = defaultdict(int)
c.update({letter:0 for letter in string.lowercase[:26]}) 
for letter in text:
c[letter] += 1


for letter,freq in sorted(c.iteritems(),key=lambda (l,f): (-f,l)): 
print freq, letter

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


Re: I love assert

2014-11-29 Thread MRAB

On 2014-11-29 09:31, Steven D'Aprano wrote:

MRAB wrote:


On 2014-11-29 01:30, Steven D'Aprano wrote:
[snip]

I stress that assertions aren't a replacement for unit testing, but they
compliment unit testing: assertions can help cover code missed by your
unit tests, and check that your unit tests are correct.


[snip]

I think you meant "complement". :-)


Somibody swappid thi i and e kiys on my kiboard.


So you think it's spelled "complemint"? :-)
--
https://mail.python.org/mailman/listinfo/python-list


Re: Are you Looking for Instructor's Solution Manual ?

2014-11-29 Thread David H. Lipman

From: 


i need Solution Manual Discrete Mathematics with Applications, 4th Edition 
by Susanna S.

Epp


He is a spammer.  Please do not quote spam nor support their actions.

--
Dave
Multi-AV Scanning Tool - http://multi-av.thespykiller.co.uk
http://www.pctipp.ch/downloads/dl/35905.asp 


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


Re: I love assert

2014-11-29 Thread Ethan Furman
On 11/28/2014 05:30 PM, Steven D'Aprano wrote:
> alister wrote:
> 
>> And as may wiser people than me have already highlighted Assertions can
>> be switched off in python which means they cannot be relied upon in
>> production code invalidating the authors suggestion that they can
>> automate bug reports & "Extend testing into the lifetime of the product"
> 
> I'm afraid that you appear to have missed the point of assertions as tests.
> Since they should never be used to *enforce* correct behaviour, but only to
> *verify* behaviour is correct (i.e. as a form of testing), it doesn't
> matter if you disable them. If I turn them off, all that happens is that
> the tests won't run *for me*. The software will still be just as correct,
> or just as buggy, regardless of the assertions.

And you have missed the point that building an intricate error-reporting, 
program restarting framework on top of
'assert' is ridiculous.

--
~Ethan~



signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Suds Python 2.4.3 Proxy

2014-11-29 Thread Jerry Rocteur
Hi,

I posted this on the soap list but didn`t get a reply so I was hoping
perhaps someone from this list could help me.

I got my SOAP script working to GlobalSign, thanks to the help from
Dieter and I can now download certificates with the script.

I was running on Python 2.7 and it works great there but now I have to
deploy the script on some Redhat workstations running python 2.4.3
(which I am not allowed to upgrade)

When I create my client in my script I do it like this:

url = 'https://system.globalsign.com/cr/ws/GasOrderService?wsdl'
proxy = {'https': proxylog + ":" + proxypass + '@proxyhost.int:'}
globalClient = Client(url, proxy=proxy)


This works GREAT on 2.7 but when I run it on 2.4 I get:

  File "/usr/lib64/python2.4/urllib2.py", line 580, in proxy_open
if '@' in host:
TypeError: iterable argument required

I'm Googling it and I can see there are other ways to connect but
can't seem to get the syntax.

Can anyone  help.


Thanks in advance,

-- 
Jerry Rocteur

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