Re: Python's and and Pythons or

2013-10-10 Thread Peter Cacioppi
On Wednesday, October 9, 2013 4:54:03 PM UTC-7, Peter Cacioppi wrote: > I really like the logic that Pythons "or" is not only short-circuit but > non-typed. > > > > So I can say > > > > y = override or default > > > > and y won't necc be True or False. If override boolean evaluates to Tru

Re: Python's and and Pythons or

2013-10-10 Thread Ethan Furman
On 10/09/2013 11:12 PM, Peter Cacioppi wrote: I'm trying to think of a good example usage of echo-argument and. Maybe something like possible = foo and foo.allowsit() if (possible is None) : print "foo not provided" if (possible is False) : print "foo doesn't allow it" A bit awkward,

Re: Cookie gets changed when hit comes from a referrer

2013-10-10 Thread Steven D'Aprano
On Wed, 09 Oct 2013 22:36:54 -0700, rusi wrote: > On Thursday, October 10, 2013 6:40:19 AM UTC+5:30, Steven D'Aprano > wrote: >> >> I have no objection to encouraging people to read the fine manual, and >> I don't intend to be Nikos' (or anyone else's) unpaid full-time help >> desk and troublesho

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Marco Buttu
On 10/09/2013 06:47 PM, Ned Batchelder wrote: >>> class B(A): ... def bfoo(*args): ... super().afoo(*args[1:]) ... >>> B().bfoo(1, 2, 3) Traceback (most recent call last): File "", line 1, in File "", line 3, in bfoo RuntimeError: super(): no arguments How come? The no-args s

Re: Cookie gets changed when hit comes from a referrer

2013-10-10 Thread Steven D'Aprano
On Thu, 10 Oct 2013 17:01:25 +1100, Ben Finney wrote: > There are limits to how much disruption and obstinacy this community > should tolerate from a given individual. I think we are in violent agreement :-) It's possible we disagree about where to draw the line, and whether persistent clueless

Re: Python's and and Pythons or

2013-10-10 Thread Terry Reedy
On 10/10/2013 2:45 AM, Chris Angelico wrote: On Thu, Oct 10, 2013 at 5:12 PM, Peter Cacioppi wrote: I'm trying to think of a good example usage of echo-argument and. Maybe something like A bit awkward, echo-argument or is more naturally useful to me then echo-argument and. first_element

Learning about HTTP [was: Cookie gets changed when hit comes from a referrer]

2013-10-10 Thread Tim Golden
On 10/10/2013 00:48, Steven D'Aprano wrote: > So, for the benefit of anyone, not just Nikos, who wants to learn about > how browsers connect to web sites and how to run a web server, does > anyone have any recommendation for tutorials, mailing lists, web forums > or books which are suitable? Pre

Re: Python's and and Pythons or

2013-10-10 Thread Chris Angelico
On Thu, Oct 10, 2013 at 6:43 PM, Terry Reedy wrote: > y = x and 1/x > One just has to remember that y==0 effectively means y==+-infinity ;-). Good example. Extremely appropriate to situations where you're showing a set of figures and their average: Foo 1 Bar 3 Quux 7 Asdf 9 = 5 Let th

Re: I am never going to complain about Python again

2013-10-10 Thread Frank Millman
"Steven D'Aprano" wrote in message news:52562ee3$0$2931$c3e8da3$76491...@news.astraweb.com... > Just came across this little Javascript gem: > > ",,," == Array((null,'cool',false,NaN,4)); > > => evaluates as true > > http://wtfjs.com/2011/02/11/all-your-commas-are-belong-to-Array > > I swear, I

Re: Cookie gets changed when hit comes from a referrer

2013-10-10 Thread Antoon Pardon
Op 10-10-13 03:10, Steven D'Aprano schreef: > On Thu, 10 Oct 2013 00:31:06 +, Denis McMahon wrote: >> >> If Nikos can't even figure out the right queries to feed into a search >> engine to get started on such matters as looking at the cookie jar in a >> browser or enabling cookie logging on a s

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Ned Batchelder
On 10/10/13 3:22 AM, Marco Buttu wrote: On 10/09/2013 06:47 PM, Ned Batchelder wrote: >>> class B(A): ... def bfoo(*args): ... super().afoo(*args[1:]) ... >>> B().bfoo(1, 2, 3) Traceback (most recent call last): File "", line 1, in File "", line 3, in bfoo RuntimeError: super()

Re: I am never going to complain about Python again

2013-10-10 Thread MRAB
On 10/10/2013 09:23, Frank Millman wrote: "Steven D'Aprano" wrote in message news:52562ee3$0$2931$c3e8da3$76491...@news.astraweb.com... Just came across this little Javascript gem: ",,," == Array((null,'cool',false,NaN,4)); => evaluates as true http://wtfjs.com/2011/02/11/all-your-commas-ar

Re: I am never going to complain about Python again

2013-10-10 Thread Tim Chase
On 2013-10-10 12:10, MRAB wrote: > Re "==", this page: > > http://php.net/manual/en/language.operators.comparison.php > > states: > > """If you compare a number with a string or the *comparison involves > numerical strings*, then each string is converted to a number and > the comparison per

Re: I am never going to complain about Python again

2013-10-10 Thread Frank Millman
"MRAB" wrote in message news:52568b30.8040...@mrabarnett.plus.com... > On 10/10/2013 09:23, Frank Millman wrote: >> >> "Steven D'Aprano" wrote in message >> news:52562ee3$0$2931$c3e8da3$76491...@news.astraweb.com... >>> Just came across this little Javascript gem: >>> >>> ",,," == Array((null,'

Re: Good Python Book

2013-10-10 Thread kristof leroux
Python in Practice - Mark Summerfield On Wednesday, October 9, 2013 2:55:17 PM UTC+2, Schneider wrote: > Hi List, > > > > I'm looking for a good advanced python book. Most books I looked at up > > to now are on beginners level. > > I don't need a reference (that's online) or a book explainin

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Marco Buttu
On 10/10/2013 01:04 PM, Ned Batchelder wrote: On 10/10/13 3:22 AM, Marco Buttu wrote: >>> import inspect >>> class B(A): ... def bfoo(*args): ... frame = inspect.currentframe() ... for obj, value in frame.f_locals.items(): ... print(obj, value, sep=' --> ') ...

Re: I am never going to complain about Python again

2013-10-10 Thread Roy Smith
In article <52562ee3$0$2931$c3e8da3$76491...@news.astraweb.com>, Steven D'Aprano wrote: > Just came across this little Javascript gem: > > ",,," == Array((null,'cool',false,NaN,4)); > > => evaluates as true > > http://wtfjs.com/2011/02/11/all-your-commas-are-belong-to-Array > > I swear, I am

Re: Good Python Book

2013-10-10 Thread David
On 9 October 2013 23:55, Schneider wrote: > > I'm looking for a good advanced python book. Most books I looked at up to > now are on beginners level. > I don't need a reference (that's online) or a book explaining how to use the > interpreter or how to use list comprehensions on the one side and s

Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Chris Angelico
On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith wrote: > BTW, one of the earliest things that turned me on to Python was when I > discovered that it uses j as the imaginary unit, not i. All > right-thinking people will agree with me on this. I've never been well-up on complex numbers; can you elabor

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Robin Becker
On 10/10/2013 14:25, Chris Angelico wrote: On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith wrote: BTW, one of the earliest things that turned me on to Python was when I discovered that it uses j as the imaginary unit, not i. All right-thinking people will agree with me on this. I've never been w

Re: Cookie gets changed when hit comes from a referrer

2013-10-10 Thread Denis McMahon
On Thu, 10 Oct 2013 01:10:19 +, Steven D'Aprano wrote: >> If Nikos wants to write programs that communicate using internet >> protocols, Nikos really needs to learn where internet protocols are >> defined, how to read and interpret those protocol definitions, and how >> to check that the data

How to make Tkinter Listbox entry insensitive?

2013-10-10 Thread Skip Montanaro
I have a pair of Listboxes, each with ranges of the same text. For example: ABCABC DEFDEF GHIGHI JKLJKL (My apologies, I'm sure Gmail is going to butcher that.) If I select "ABC" from the first list, only the last three values in the second list are appropriate selections. Is th

closure = decorator?

2013-10-10 Thread Tim
I've read a couple of articles about this, but still not sure. When someone talks about a closure in another language (I'm learning Lua on the side), is that the same concept as a decorator in Python? It sure looks like it. thanks, --Tim -- https://mail.python.org/mailman/listinfo/python-list

Re: closure = decorator?

2013-10-10 Thread Chris Angelico
On Fri, Oct 11, 2013 at 12:51 AM, Tim wrote: > I've read a couple of articles about this, but still not sure. > When someone talks about a closure in another language (I'm learning Lua on > the side), is that the same concept as a decorator in Python? No, they're quite different. A decorator (le

Skipping decorators in unit tests

2013-10-10 Thread Gilles Lenfant
Hi, (explaining the title) : my app has functions and methods (and maybe classes in the future) that are decorated by decorators provided by the standard library or 3rd party packages. But I need to test "undecorated" functions and methods in my unit tests, preferably without adding "special s

Re: closure = decorator?

2013-10-10 Thread Jussi Piitulainen
Tim writes: > I've read a couple of articles about this, but still not sure. > > When someone talks about a closure in another language (I'm learning > Lua on the side), is that the same concept as a decorator in Python? > > It sure looks like it. I don't see how. Wikipedia's opening paragraph o

Re: How to make Tkinter Listbox entry insensitive?

2013-10-10 Thread Chris Angelico
On Fri, Oct 11, 2013 at 12:50 AM, Skip Montanaro wrote: > Does Tk > perhaps use a word other than "insensitive" to describe an item which > you'd normally be able to click? Other synonyms from GUI toolkits are "inactive" and "disabled". I don't know if that'll be any help though. ChrisA -- http

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Grant Edwards
On 2013-10-10, Chris Angelico wrote: > On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith wrote: >> BTW, one of the earliest things that turned me on to Python was when I >> discovered that it uses j as the imaginary unit, not i. All >> right-thinking people will agree with me on this. > > I've never b

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Chris Angelico
On Fri, Oct 11, 2013 at 1:12 AM, Grant Edwards wrote: > Nope. "i" is electical current (though it's more customary to use > upper case). "j" is the square root of -1. > >> and that hypercomplex numbers include i, j, k, and maybe even other >> terms, and I never understood where j comes from. Why

Re: closure = decorator?

2013-10-10 Thread Jussi Piitulainen
Chris Angelico writes: > def outer(x): > x += 1 > def inner(): > return x > return inner ... > The terminology is that inner() "closes over" x, if I have that > correct (I've not been all that big in functional programming and > lambda calculus). Someone will correct me if I'm

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread David
On 11 October 2013 00:25, Chris Angelico wrote: > On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith wrote: > > I've never been well-up on complex numbers; can you elaborate on this, > please? All I know is that I was taught that the square root of -1 is > called i, and that hypercomplex numbers include

Re: Python's and and Pythons or

2013-10-10 Thread Ethan Furman
On 10/10/2013 12:43 AM, Terry Reedy wrote: On 10/10/2013 2:45 AM, Chris Angelico wrote: On Thu, Oct 10, 2013 at 5:12 PM, Peter Cacioppi wrote: I'm trying to think of a good example usage of echo-argument and. Maybe something like A bit awkward, echo-argument or is more naturally useful to

Re: How to make Tkinter Listbox entry insensitive?

2013-10-10 Thread Skip Montanaro
> Other synonyms from GUI toolkits are "inactive" and "disabled". I > don't know if that'll be any help though. Thanks. "disabled" did the trick. Turns out you can't disable individual items. Instead, you have to (hackishly) change the display of entries somehow to indicate their inappropriateness

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread rusi
On Thursday, October 10, 2013 8:04:00 PM UTC+5:30, David wrote: > I have never heard the term "hypercomplex" numbers. I guess you > are referring to vectors with more dimensions than two. A three A generalization of quaternions : http://en.wikipedia.org/wiki/Hypercomplex_number http://en.wikipedia

Re: How to make Tkinter Listbox entry insensitive?

2013-10-10 Thread Chris “Kwpolska” Warrick
On Thu, Oct 10, 2013 at 4:37 PM, Skip Montanaro wrote: > Thanks. "disabled" did the trick. Turns out you can't disable > individual items. Instead, you have to (hackishly) change the display > of entries somehow to indicate their inappropriateness... Removing inappropriate entries is not much of

Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread Isaac Gerg
I have a function that looks like the following: #- filename = 'c:\testfile.h5' f = open(filename,'r') data = f.read() q = multiprocessing.Queue() p = multiprocess.Process(target=myFunction,args=(data,q)) p.start() result = q.get() p.join() q.close() f.close() os

Passing C pionters to Python for use with cffi

2013-10-10 Thread Eric Frederich
Hello, I'm extending an application that supports customization using the C language. I am able to write standalone python applications that use the C API's using cffi. This is good, but only a first step. This application allows me to register code that will run on various events but it has to b

Re: I am never going to complain about Python again

2013-10-10 Thread Neil Cerutti
On 2013-10-10, Roy Smith wrote: > In article <52562ee3$0$2931$c3e8da3$76491...@news.astraweb.com>, > Steven D'Aprano wrote: > >> Just came across this little Javascript gem: >> >> ",,," == Array((null,'cool',false,NaN,4)); >> >> => evaluates as true >> >> http://wtfjs.com/2011/02/11/all-your-

Re: I am never going to complain about Python again

2013-10-10 Thread Rotwang
On 10/10/2013 16:51, Neil Cerutti wrote: [...] Mixed arithmetic always promotes to the wider type (except in the case of complex numbers (Ha!)). r == c is equivalent to r == abs(c), which returns the magintude of the complex number. What? >>> -1 == -1 + 0j True >>> -1 == abs(-1 + 0j) False >

Re: I am never going to complain about Python again

2013-10-10 Thread MRAB
On 10/10/2013 16:57, Rotwang wrote: On 10/10/2013 16:51, Neil Cerutti wrote: [...] Mixed arithmetic always promotes to the wider type (except in the case of complex numbers (Ha!)). r == c is equivalent to r == abs(c), which returns the magintude of the complex number. What? >>> -1 == -1 +

Re: closure = decorator?

2013-10-10 Thread Piet van Oostrum
Jussi Piitulainen writes: > I don't actually know for sure what the most correct terminology is, > but I like to think that a closure is a procedure (function) closed in > the environment (namespace) where it was created, so even when it is > called from another environment, it uses the one where

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread William Ray Wing
On Oct 10, 2013, at 10:12 AM, Grant Edwards wrote: > On 2013-10-10, Chris Angelico wrote: >> On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith wrote: >>> BTW, one of the earliest things that turned me on to Python was when I >>> discovered that it uses j as the imaginary unit, not i. All >>> right-t

Re: Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread Piet van Oostrum
Isaac Gerg writes: > I have a function that looks like the following: That doesn't look like a function > > #- > filename = 'c:\testfile.h5' Your filename is most probably wrong. It should be something like: filename = 'c:/testfile.h5' filename = 'c:\\testfile.

Re: Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread Isaac Gerg
Sorry, I am just providing pseudo code since I the code i have is quite large. As I mentioned, the code works fine when I remove the multirpcessing stuff so the filename is not the issue (though you are right in your correction). Someone with the same problem posted a smaller, more complete exam

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Grant Edwards
On 2013-10-10, Chris Angelico wrote: > On Fri, Oct 11, 2013 at 1:12 AM, Grant Edwards > wrote: >> Nope. "i" is electical current (though it's more customary to use >> upper case). "j" is the square root of -1. >> >>> and that hypercomplex numbers include i, j, k, and maybe even other >>> terms

Re: I am never going to complain about Python again

2013-10-10 Thread Neil Cerutti
On 2013-10-10, MRAB wrote: > On 10/10/2013 16:57, Rotwang wrote: >> On 10/10/2013 16:51, Neil Cerutti wrote: >>> [...] >>> >>> Mixed arithmetic always promotes to the wider type (except in >>> the case of complex numbers (Ha!)). >>> >>> r == c is equivalent to r == abs(c), which returns the magint

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Ethan Furman
On 10/10/2013 07:20 AM, Chris Angelico wrote: On Fri, Oct 11, 2013 at 1:12 AM, Grant Edwards wrote: Nope. "i" is electical current (though it's more customary to use upper case). "j" is the square root of -1. and that hypercomplex numbers include i, j, k, and maybe even other terms, and I n

Re: How to make Tkinter Listbox entry insensitive?

2013-10-10 Thread Skip Montanaro
> Removing inappropriate entries is not much of a hack. True, but then I have to go through the trouble of adding them back in should they become valid again. :-) Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: I am never going to complain about Python again

2013-10-10 Thread Ian Kelly
On Thu, Oct 10, 2013 at 11:48 AM, Neil Cerutti wrote: > On 2013-10-10, MRAB wrote: >> On 10/10/2013 16:57, Rotwang wrote: >>> On 10/10/2013 16:51, Neil Cerutti wrote: [...] Mixed arithmetic always promotes to the wider type (except in the case of complex numbers (Ha!)). >

Re: class implementation

2013-10-10 Thread markotaht
kolmapäev, 9. oktoober 2013 2:55.28 UTC+3 kirjutas Cameron Simpson: > On 08Oct2013 01:20, wrote: > > > I cant just subclassing doesent work. It seem the init method of the source > > class also calls out another class. And the problem is, i can subclass the > > other class to with the required

Re: Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread Ned Batchelder
On 10/10/13 12:44 PM, Isaac Gerg wrote: Sorry, I am just providing pseudo code since I the code i have is quite large. As I mentioned, the code works fine when I remove the multirpcessing stuff so the filename is not the issue (though you are right in your correction). Someone with the same pr

Re: I am never going to complain about Python again

2013-10-10 Thread Neil Cerutti
On 2013-10-10, Ian Kelly wrote: > On Thu, Oct 10, 2013 at 11:48 AM, Neil Cerutti wrote: >> Woah. I thought I was going by what the docs say: >> >> Python fully supports mixed arithmetic: when a binary >> arithmetic operator has operands of different numeric types, >> the operand with the ?n

Re: Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread Isaac Gerg
On Thu, Oct 10, 2013 at 2:41 PM, Ned Batchelder wrote: > On 10/10/13 12:44 PM, Isaac Gerg wrote: > >> Sorry, I am just providing pseudo code since I the code i have is quite >> large. >> >> As I mentioned, the code works fine when I remove the multirpcessing >> stuff so the filename is not the iss

Re: Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread Isaac Gerg
On Thu, Oct 10, 2013 at 2:49 PM, Isaac Gerg wrote: > > > > On Thu, Oct 10, 2013 at 2:41 PM, Ned Batchelder wrote: > >> On 10/10/13 12:44 PM, Isaac Gerg wrote: >> >>> Sorry, I am just providing pseudo code since I the code i have is quite >>> large. >>> >>> As I mentioned, the code works fine when

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Christian Gollwitzer
Am 10.10.13 18:54, schrieb Grant Edwards: On 2013-10-10, Chris Angelico wrote: On Fri, Oct 11, 2013 at 1:12 AM, Grant Edwards wrote: Nope. "i" is electical current (though it's more customary to use upper case). "j" is the square root of -1. and that hypercomplex numbers include i, j, k,

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Oscar Benjamin
On 10 October 2013 15:34, David wrote: > On 11 October 2013 00:25, Chris Angelico wrote: >> On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith wrote: >> >> I've never been well-up on complex numbers; can you elaborate on this, >> please? All I know is that I was taught that the square root of -1 is >>

Re: Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread Piet van Oostrum
Isaac Gerg writes: > Sorry, I am just providing pseudo code since I the code i have is quite large. > > As I mentioned, the code works fine when I remove the multirpcessing stuff so > the filename is not the issue (though you are right in your correction). > > Someone with the same problem poste

Re: I am never going to complain about Python again

2013-10-10 Thread Oscar Benjamin
On 10 October 2013 18:48, Neil Cerutti wrote: > I guess the "if appropriate" part eluded my eye. When *is* it > appropriate? Apparently not during an equal test. > 5.0 == abs(3 + 4j) > False If the above is genuine output then it's most likely floating point error. I wouldn't expect any erro

Re: I am never going to complain about Python again

2013-10-10 Thread Neil Cerutti
On 2013-10-10, Oscar Benjamin wrote: > On 10 October 2013 18:48, Neil Cerutti wrote: >> I guess the "if appropriate" part eluded my eye. When *is* it >> appropriate? Apparently not during an equal test. >> > 5.0 == abs(3 + 4j) >> False > > If the above is genuine output then it's most likely

Re: UnicodeEncodeError: SOLVED

2013-10-10 Thread Walter Hurry
On Thu, 10 Oct 2013 01:47:52 +, Steven D'Aprano wrote: > On Wed, 09 Oct 2013 14:41:53 +, Walter Hurry wrote: > >> Many thanks to those prepared to forgive my transgression in the >> 'Goodbye' thread. I mentioned there that I was puzzled by a >> UnicodeEncodeError, and said I would rise it

Re: Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread Isaac Gerg
Hi Piet, Here is a real code example: http://stackoverflow.com/questions/948119/preventing-file-handle-inheritance-in-multiprocessing-lib As I said before, I had provide pseudocode. I cannot close the file after reading because it is part of a class and other threads may be calling member func

Re: How to make Tkinter Listbox entry insensitive?

2013-10-10 Thread Jason Swails
On Thu, Oct 10, 2013 at 2:29 PM, Skip Montanaro wrote: > > Removing inappropriate entries is not much of a hack. > > True, but then I have to go through the trouble of adding them back in > should they become valid again. :-) > It seems that this could be handled fairly straight-forwardly by sub

Re: class implementation

2013-10-10 Thread Cameron Simpson
On 10Oct2013 11:34, markot...@gmail.com wrote: > OK so I did a took time of and read the pykkar code through. abd > I found that there is a third class i have to implement. > This Is the pykkar sourcecode [... lots and lots of docstring and code ...] [... and finally a little more messgae ...] > I

Re: I am never going to complain about Python again

2013-10-10 Thread Cameron Simpson
On 10Oct2013 17:48, Neil Cerutti wrote: > On 2013-10-10, MRAB wrote: > > If r is real (float) and c is complex: > > r == c means r == c.real and c.imag == 0.0 > > Woah. I thought I was going by what the docs say: > > Python fully supports mixed arithmetic: when a binary > arithmetic op

Re: Skipping decorators in unit tests

2013-10-10 Thread Cameron Simpson
On 10Oct2013 07:00, Gilles Lenfant wrote: > (explaining the title) : my app has functions and methods (and > maybe classes in the future) that are decorated by decorators > provided by the standard library or 3rd party packages. > > But I need to test "undecorated" functions and methods in my uni

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread David
On 11 October 2013 06:29, Oscar Benjamin wrote: > > I learned to use i for sqrt(-1) while studying theoretical physics. > When I later found myself teaching maths to engineers I asked why j > was used and was given this explanation. I'm still unconvinced by it > though. Please don't be. We need d

Re: Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread mapoe
On Thu, 10 Oct 2013 08:31:21 -0700, Isaac Gerg wrote: > I have a function that looks like the following: > > #- > filename = 'c:\testfile.h5' > f = open(filename,'r') > data = f.read() it seems kind of obvious from your sample: add: f.close() > q = multiprocessin

Re: Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread mapoe
On Thu, 10 Oct 2013 18:16:07 -0500, mapoe wrote: > On Thu, 10 Oct 2013 08:31:21 -0700, Isaac Gerg wrote: > >> I have a function that looks like the following: >> >> #- >> filename = 'c:\testfile.h5' >> f = open(filename,'r') >> data = f.read() > > it seems kind o

Re: class implementation

2013-10-10 Thread Piet van Oostrum
markot...@gmail.com writes: > > OK so I did a took time of and read the pykkar code through. abd I found that > there is a third class i have to implement. [...] > So I have come up with this code > from pykkar import * > > create_world(""" > > # # > # v# > # # > #

Re: Skipping decorators in unit tests

2013-10-10 Thread Ned Batchelder
On 10/10/13 6:12 PM, Cameron Simpson wrote: On 10Oct2013 07:00, Gilles Lenfant wrote: (explaining the title) : my app has functions and methods (and maybe classes in the future) that are decorated by decorators provided by the standard library or 3rd party packages. But I need to test "undecor

Re: class implementation

2013-10-10 Thread Ben Finney
Piet van Oostrum writes: > from import * is considered bad practice anyway. It is better just to import > the things you need. > > from pykkar import World, Pykkar, _WorldProper Or, even better, be explicit: import pykkar … foo = pykkar.World() -- \ “Computer perspect

Re: closure = decorator?

2013-10-10 Thread Roy Smith
In article , Piet van Oostrum wrote: > I usually say that a closure is a package, containing a function with > some additional data it needs. The data usually is in the form of name > bindings. That's pretty close to the way I think about it. The way it was originally described to me is, "A c

Re: I am never going to complain about Python again

2013-10-10 Thread Roy Smith
In article , Neil Cerutti wrote: > >>> 5.0 == abs(3 + 4j) > False I'd like an argument, please. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to make Tkinter Listbox entry insensitive?

2013-10-10 Thread Skip Montanaro
> It seems that this could be handled fairly straight-forwardly by subclassing either Listbox or Frame to implement your own, custom widget. I will freely admit that I am far from facile with Tk widgets. I've been using GTK for most GUI apps for a long while (when I need to write such things), but

Re: Skipping decorators in unit tests

2013-10-10 Thread Terry Reedy
On 10/10/2013 10:00 AM, Gilles Lenfant wrote: To add to the other two responses so far... (explaining the title) : my app has functions and methods (and maybe classes in the future) that are decorated by decorators provided by the standard library or 3rd party packages. But I need to test "u

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Steven D'Aprano
On Fri, 11 Oct 2013 00:25:27 +1100, Chris Angelico wrote: > On Fri, Oct 11, 2013 at 12:09 AM, Roy Smith wrote: >> BTW, one of the earliest things that turned me on to Python was when I >> discovered that it uses j as the imaginary unit, not i. All >> right-thinking people will agree with me on t

Re: Python's and and Pythons or

2013-10-10 Thread Terry Reedy
On 10/10/2013 9:33 AM, Ethan Furman wrote: On 10/10/2013 12:43 AM, Terry Reedy wrote: On 10/10/2013 2:45 AM, Chris Angelico wrote: first_element = some_list[0]# Oops, may crash some_list[0:1] always works, and sometimes is usable, but you still cannot index the slice. Not if some_l

Re: Python 3.2 | WIndows 7 -- Multiprocessing and files not closing

2013-10-10 Thread Terry Reedy
On 10/10/2013 2:49 PM, Isaac Gerg wrote: Additionally, is there a place on the web to view this conversation and reply? Currently, I am only able to access this list through email. news.gmane.org newsgroup gmane.lang.python.general Look at the headers for this message. The site also has a sea

Re: I am never going to complain about Python again

2013-10-10 Thread Steven D'Aprano
On Thu, 10 Oct 2013 09:09:42 -0400, Roy Smith wrote: > BTW, here's a Python equality oddity: > r = 0.0 c = 0 + 0j r == c > True Mathematically, this is only to be expected. int(r) == int(c) > Traceback (most recent call last): > File "", line 1, in > TypeError: can't con

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Steven D'Aprano
On Thu, 10 Oct 2013 07:04:38 -0400, Ned Batchelder wrote: > super() with no args is a kind of hack to begin with. It involves a > special case in the compiler (so that using the name "super" as a > function call will act as if you had accessed the name "__class__" so > that super can find it late

Re: I am never going to complain about Python again

2013-10-10 Thread Steven D'Aprano
On Thu, 10 Oct 2013 17:48:16 +, Neil Cerutti wrote: > >>> 5.0 == abs(3 + 4j) > False Did you maybe accidentally rebind abs? If not, what version of Python are you using? [steve@ando ~]$ for a in 2.4 2.5 2.6 2.7 3.2 3.3 ; do > python$a -c "print( 5.0 == abs(3 + 4j) )" ; > done True True Tr

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Ian Kelly
On Thu, Oct 10, 2013 at 8:11 PM, Steven D'Aprano wrote: > One of the side-effects of this being a hack is that this doesn't work: > > class X(Y): > def method(self, arg): > f = super > f().method(arg) Actually, that works just fine. The compiler sees that super is accessed wi

Re: Skipping decorators in unit tests

2013-10-10 Thread Cameron Simpson
On 10Oct2013 19:44, Ned Batchelder wrote: > On 10/10/13 6:12 PM, Cameron Simpson wrote: > >Speaking for myself, I would be include to recast this code: > > > > @absolutize > > def addition(a, b): > > return a + b > > > >into: > > > > def _addition(a, b): > > return a + b > > > >

Re: Python's and and Pythons or

2013-10-10 Thread Ethan Furman
On 10/10/2013 06:41 PM, Terry Reedy wrote: On 10/10/2013 9:33 AM, Ethan Furman wrote: On 10/10/2013 12:43 AM, Terry Reedy wrote: On 10/10/2013 2:45 AM, Chris Angelico wrote: first_element = some_list[0]# Oops, may crash some_list[0:1] always works, and sometimes is usable, but you st

Re: Skipping decorators in unit tests

2013-10-10 Thread Steven D'Aprano
On Fri, 11 Oct 2013 09:12:38 +1100, Cameron Simpson wrote: > On 10Oct2013 07:00, Gilles Lenfant wrote: >> (explaining the title) : my app has functions and methods (and maybe >> classes in the future) that are decorated by decorators provided by the >> standard library or 3rd party packages. >>

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Steven D'Aprano
On Thu, 10 Oct 2013 20:33:37 -0600, Ian Kelly wrote: > On Thu, Oct 10, 2013 at 8:11 PM, Steven D'Aprano > wrote: >> One of the side-effects of this being a hack is that this doesn't work: >> >> class X(Y): >> def method(self, arg): >> f = super >> f().method(arg) > > Actually

Re: Skipping decorators in unit tests

2013-10-10 Thread Roy Smith
On 10Oct2013 19:44, Ned Batchelder wrote: > > I have to admit I'm having a hard time understanding why you'd need > > to test the undecorated functions. After all, the undecorated > > functions aren't available to anyone. All that matters is how they > > behave with the decorators. In article ,

Re: Skipping decorators in unit tests

2013-10-10 Thread Cameron Simpson
On 11Oct2013 02:55, Steven D'Aprano wrote: > On Fri, 11 Oct 2013 09:12:38 +1100, Cameron Simpson wrote: > > Speaking for myself, I would be include to recast this code: > > > > @absolutize > > def addition(a, b): > > return a + b > > > > into: > > > > def _addition(a, b): > >

Re: Skipping decorators in unit tests

2013-10-10 Thread Ben Finney
Cameron Simpson writes: > On 11Oct2013 02:55, Steven D'Aprano > wrote: > > def undecorate(f): > > """Return the undecorated inner function from function f.""" > > return f.func_closure[0].cell_contents > > Whereas this feels like black magic. Is this portable to any decorated > function

Is this the room for an argument?

2013-10-10 Thread John Ladasky
On Thursday, October 10, 2013 5:07:11 PM UTC-7, Roy Smith wrote: > I'd like an argument, please. 'Receptionist' (Rita Davies) - Yes, sir? 'Man' (Michael Palin) - I'd like to have an argument please. 'Receptionist' - Certainly sir, have you been here before...? 'Man' - No, this is my first time. 'R

Re: Skipping decorators in unit tests

2013-10-10 Thread Cameron Simpson
On 11Oct2013 14:42, Ben Finney wrote: > Cameron Simpson writes: > > On 11Oct2013 02:55, Steven D'Aprano > > wrote: > > > def undecorate(f): > > > """Return the undecorated inner function from function f.""" > > > return f.func_closure[0].cell_contents > > > > Whereas this feels like bla

Re: Skipping decorators in unit tests

2013-10-10 Thread Steven D'Aprano
On Fri, 11 Oct 2013 14:13:19 +1100, Cameron Simpson wrote: > On 11Oct2013 02:55, Steven D'Aprano > wrote: >> On Fri, 11 Oct 2013 09:12:38 +1100, Cameron Simpson wrote: >> > Speaking for myself, I would be include to recast this code: >> > >> > @absolutize >> > def addition(a, b): >> >

Re: Skipping decorators in unit tests

2013-10-10 Thread Steven D'Aprano
On Fri, 11 Oct 2013 15:36:29 +1100, Cameron Simpson wrote: > But is it reliable? Will it work on any decorated function? *Any* decorated function? No, of course not, since decorators can do anything they like: def decorate(func): return lambda *args: "Surprise!" @decorate def something_use

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Chris Angelico
On Fri, Oct 11, 2013 at 11:13 AM, Dennis Lee Bieber wrote: > On Fri, 11 Oct 2013 01:20:01 +1100, Chris Angelico > declaimed the following: > >> >>This belongs in the Izzet League, I think. >> > Was that an MtG reference? It most assuredly was. The Ravnican guild known as the Izzet League

Multi-threading in Python vs Java

2013-10-10 Thread Peter Cacioppi
Could someone give me a brief thumbnail sketch of the difference between multi-threaded programming in Java. I have a fairly sophisticated algorithm that I developed as both a single threaded and multi-threaded Java application. The multi-threading port was fairly simple, partly because Java ha

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Chris Angelico
On Fri, Oct 11, 2013 at 2:00 PM, Steven D'Aprano wrote: > I'll now go and write "I will always test my code snippets before > posting" on the blackboard one hundred times. print("I will always test my code snippets before posting\n"*100) ChrisA PS. Irony would be having a bug in that because I

Re: Passing C pionters to Python for use with cffi

2013-10-10 Thread dieter
Eric Frederich writes: > I'm extending an application that supports customization using the C > language. > I am able to write standalone python applications that use the C API's > using cffi. > This is good, but only a first step. > > This application allows me to register code that will run on

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Marco Buttu
On 10/11/2013 04:33 AM, Ian Kelly wrote: On Thu, Oct 10, 2013 at 8:11 PM, Steven D'Aprano >One of the side-effects of this being a hack is that this doesn't work: > >class X(Y): > def method(self, arg): > f = super > f().method(arg) Actually, that works just fine. The

Re: super in Python 3 and variadic arguments

2013-10-10 Thread Marco Buttu
On 10/11/2013 04:11 AM, Steven D'Aprano wrote: super() with no arguments is*completely* a hack[1], and one where GvR has said "Never again!" if I remember correctly. I don't think he regrets allowing the super compile-time magic, just that it really is magic and he doesn't want to make a habit

Debug (sympy-Function; lambdify)

2013-10-10 Thread Surbhi Gupta
This is the code I m trying to run: from sympy import * import numpy as np from sympy import symbols def deriv(x,t): a = array(x) for i in range(0,len(x)): temp = x[i] a[i] = temp[0].diff(t) return a def matrixmult (A, B): C = [[0 for row in range(len(A))] for col

  1   2   >