Re: Trees

2015-01-21 Thread Ian Kelly
On Wed, Jan 21, 2015 at 11:56 PM, Ian Kelly wrote: > Since each element is associated with a node, the question could > equally be phrased as "How do you create a tree containing an even > number of elements under this constraint?" Of course I meant to write "nod

Re: Trees

2015-01-21 Thread Ian Kelly
On Wed, Jan 21, 2015 at 10:20 PM, Rustom Mody wrote: > On Thursday, January 22, 2015 at 4:25:03 AM UTC+5:30, Ian wrote: >> On Tue, Jan 20, 2015 at 6:23 PM, Rustom Mody wrote: >> > The Haskell is bullseye¹ in capturing the essense of a tree because >> > conceptually a tree of type t is recursive in

Re: kivy secret of mana game

2015-01-22 Thread Ian Kelly
On Thu, Jan 22, 2015 at 10:13 AM, Automn wrote: > The graphics have been licensed for this. Really? I'm surprised Square-Enix would even give consideration to licensing something like this. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python is DOOMED! Again!

2015-01-22 Thread Ian Kelly
On Thu, Jan 22, 2015 at 7:16 AM, Steven D'Aprano wrote: >> Meanwhile, there's the strange decision to implement type hints for >> local variables # comment lines. I have an hard time wrapping my head >> around this one. Really, comments!? > > Yes, really. There is plenty of prior art for machine-m

Re: Python is DOOMED! Again!

2015-01-22 Thread Ian Kelly
On Thu, Jan 22, 2015 at 2:56 PM, Emile van Sebille wrote: > I've been lightly scanning and following the PEP 484 discussion, and one > point I don't think I've seen mentioned is how you might hint a function > that accepts different types, eg: > > def adder(a,b): return a+b > > This is one of the

Re: Python is DOOMED! Again!

2015-01-22 Thread Ian Kelly
On Thu, Jan 22, 2015 at 3:08 PM, Ian Kelly wrote: > On Thu, Jan 22, 2015 at 2:56 PM, Emile van Sebille wrote: >> I've been lightly scanning and following the PEP 484 discussion, and one >> point I don't think I've seen mentioned is how you might hint a function &

Re: Python is DOOMED! Again!

2015-01-22 Thread Ian Kelly
On Thu, Jan 22, 2015 at 3:27 PM, Chris Kaynor wrote: > Or use Any, which is basically the same thing: > > def adder(a: Any, b: Any) -> Any: > return a + b Yeah, but this just seems like extra noise since it's not going to help the type checker at all. -- https://mail.python.org/mailman/listi

Re: Python is DOOMED! Again!

2015-01-23 Thread Ian Kelly
On Thu, Jan 22, 2015 at 7:59 PM, Rustom Mody wrote: > PS Ian for a hot thread like this its good to put quotes carefully > You are quoting Steven quoting somebody -- dunno who that somebody is I include quote that only for context to Steven's quote. Since I'm not replying to it, I don't care who

Re: Comparisons and sorting of a numeric class....

2015-01-23 Thread Ian Kelly
On Fri, Jan 23, 2015 at 8:31 AM, Rustom Mody wrote: > Can you tell me what of the following code does not satisfy your requirements? > [Needs python 3.4] > > from enum import IntEnum class B4(IntEnum): > F1 = 0 > F2 = 0 > F3 = 0 > T = 1 This strikes me a

Re: Comparisons and sorting of a numeric class....

2015-01-23 Thread Ian Kelly
On Fri, Jan 23, 2015 at 4:46 AM, Andrew Robinson wrote: > Although, I have to laugh -- Verilog can syntheze a CPU -- implement memory > -- and then load a program and run python on the virtual machine. When the > pentium was first developed, I watched as Intel actually booted up MS-DOS > under u

Re: Comparisons and sorting of a numeric class....

2015-01-23 Thread Ian Kelly
On Fri, Jan 23, 2015 at 10:03 AM, Rustom Mody wrote: > On Friday, January 23, 2015 at 10:22:06 PM UTC+5:30, Ian wrote: >> On Fri, Jan 23, 2015 at 8:31 AM, Rustom Mody wrote: >> > Can you tell me what of the following code does not satisfy your >> > requirements? >> > [Needs python 3.4] >> > >> >

Re: Comparisons and sorting of a numeric class....

2015-01-23 Thread Ian Kelly
On Fri, Jan 23, 2015 at 10:45 AM, Rustom Mody wrote: > No disagreement with the 'hack' > As for "no use case for equal but distinct tokens" - thats a strange > view given this thread If you want equal but distinct, you can give them distinct values and define an __eq__ method that compares them a

Re: Loading a module from a subdirectory

2015-01-23 Thread Ian Kelly
On Fri, Jan 23, 2015 at 11:23 AM, Automn wrote: > On 2014-03-10, Virgil Stokes wrote: >> [SNIP] > > I don't think you understand what Mr. Otten said, it is not undefined > behaviour, > maybe you could demangle your import statement. The post you're replying to is 10 months old. One way or anoth

Re: __bases__ misleading error message

2015-01-24 Thread Ian Kelly
On Sat, Jan 24, 2015 at 2:14 PM, Mario Figueiredo wrote: > In article <54c39366$0$13006$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> > AttributeError: 'Sub' instance has no attribute '__bases__', >> > AttributeError: 'foo' object has no att

Re: Python is DOOMED! Again!

2015-01-24 Thread Ian Kelly
On Sat, Jan 24, 2015 at 2:14 PM, alister wrote: >> >> Either that, or make up change with 20¢, 10¢ and 5¢ (we practice >> round-to-nearest-5-cents here). > > I suppose if you all pay 35¢ it at least gives the waitress a tip. """ In the Pacific States they have made a bolder push for complexity,

Re: __bases__ misleading error message

2015-01-24 Thread Ian Kelly
On Sat, Jan 24, 2015 at 3:02 PM, Mario Figueiredo wrote: > In article , > tjre...@udel.edu says... >> >> > "__main__" >> > from module import a_name >> >> A module is a namespace associating names with objects. This statememt >> says to import the a_name to object association from modul

Re: __bases__ misleading error message

2015-01-25 Thread Ian Kelly
On Jan 25, 2015 2:37 PM, "Terry Reedy" wrote: > 2. the second array is a compact array of entries in insertion order, such as > > [hash, ptr to 'x', ptr to 23] > [hash, ptr to 'colour', ptr to 'red'] > [hash, ptr to the string 'y', ptr to the int 42] > > Iteration would use the compact

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Ian Kelly
On Mon, Jan 26, 2015 at 8:50 AM, Adam Funk wrote: > On 2015-01-26, Peter Otten wrote: > >> Adam Funk wrote: >> >>> On 2015-01-09, Ned Batchelder wrote: for b in options.bar or (): do_stuff(b) >>> >>> Do you mean "for b in options.bar or []:" ? >> >> Doesn't matter; in the c

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Ian Kelly
On Mon, Jan 26, 2015 at 10:18 AM, Mark Lawrence wrote: > IIRC, and probably from this list, creating tuples is way faster than > creating lists, but accessing items is slower. Can anybody confirm this for > us? The first seems to be true as long as the tuples are small. $ python3 -m timeit 't =

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-26 Thread Ian Kelly
On Mon, Jan 26, 2015 at 11:23 AM, Ian Kelly wrote: > $ python3 -m timeit 't = (1000, 2000, 3000)' > 1 loops, best of 3: 0.0147 usec per loop > $ python3 -m timeit 't = [1000, 2000, 3000]' > 1000 loops, best of 3: 0.0678 usec per loop > $ pytho

Re: Fwd: Re: Comparisons and sorting of a numeric class....

2015-01-26 Thread Ian Kelly
On Jan 26, 2015 6:42 AM, "Andrew Robinson" wrote: > ... If you're going to descend into insults and name-calling, then I'm not going to waste any more of my time on this thread. The restriction on inheriting from bool isn't likely to change. There have been several suggestions as to how you can d

Re: Comparisons and sorting of a numeric class....

2015-01-26 Thread Ian Kelly
On Mon, Jan 26, 2015 at 4:47 PM, Andrew Robinson wrote: > Hmmm That's not much different than the tuple object I made as a > container and which Ian complained about. In fact, you did overload the > comparison operators, just like I did... Yeah, I know I said I was done with this thread, bu

Re: Python simple Code

2015-01-27 Thread Ian Kelly
On Tue, Jan 27, 2015 at 4:22 PM, Salem Alqahtani wrote: > I appreciate your answers and the output that I am expected from my simple > code is the following: > > ['salem','Ali','sultan'] > ['salem','sultan','Ali'] > ['Ali','sultan','salem'] > ['Ali','salem','sultan'] > ['sultan','Ali','salem'] >

Re: An object is an instance (or not)?

2015-01-27 Thread Ian Kelly
On Tue, Jan 27, 2015 at 5:17 PM, Mario Figueiredo wrote: > In article , > n...@nedbatchelder.com says... >> What does "participate in OOP" mean? > > Means the object is capable of participating in inheritance and/or > polymorphism. An instance of an object is capable of doing so, per its > class d

Re: Python is DOOMED! Again!

2015-01-28 Thread Ian Kelly
On Wed, Jan 28, 2015 at 8:04 AM, Mario Figueiredo wrote: > In article <54c83ab4$0$12982$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> >> Mario Figueiredo wrote: >> >> > Static analysis cannot and should not clutter executable code. >> >> (1) It isn't clutte

Re: why zip64_limit defined as 1<<31 -1?

2015-01-28 Thread Ian Kelly
On Wed, Jan 28, 2015 at 11:53 AM, jesse wrote: > should not it be 1<<32 -1(4g)? > > normal zip archive format should be able to support 4g file. Bugs can be filed at http://bugs.python.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: An object is an instance (or not)?

2015-01-29 Thread Ian Kelly
On Thu, Jan 29, 2015 at 12:16 AM, Steven D'Aprano wrote: > Besides, descriptors are > handled by the metaclass, so we could write a metaclass that doesn't handle > them. Maybe this doesn't affect your argument, but they're actually handled by the class's __getattribute__, not by the metaclass. >

Re: Python is DOOMED! Again!

2015-01-29 Thread Ian Kelly
On Thu, Jan 29, 2015 at 1:34 AM, Mario Figueiredo wrote: > In article <54c980cd$0$12981$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> >> Ian, that's obvious. Just open your eyes: >> >> Scala >> def addInt( a:Int, b:Int ) : Int >> >> Python >> def addInt( a:

Re: why zip64_limit defined as 1<<31 -1?

2015-01-29 Thread Ian Kelly
On Wed, Jan 28, 2015 at 5:55 PM, jesse wrote: > the official zip format spec states clearly that normal zip file should be > <= 4G size instead 2G. I just can not believe Python has such an obvious > bug. > > People suggested monkey patch the ZIP64_LIMIT value to pass 2G, I am not > sure what wil

Re: why zip64_limit defined as 1<<31 -1?

2015-01-29 Thread Ian Kelly
On Wed, Jan 28, 2015 at 2:36 PM, Chris Angelico wrote: > On Thu, Jan 29, 2015 at 5:53 AM, jesse wrote: >> should not it be 1<<32 -1(4g)? >> >> normal zip archive format should be able to support 4g file. >> >> thanks > > 1<<31-1 is the limit for a signed 32-bit integer. You'd have to look > into

Re: why zip64_limit defined as 1<<31 -1?

2015-01-29 Thread Ian Kelly
On Thu, Jan 29, 2015 at 12:12 PM, jesse wrote: > > On Jan 29, 2015 9:27 AM, "Ian Kelly" wrote: >> >> On Wed, Jan 28, 2015 at 2:36 PM, Chris Angelico wrote: >> > On Thu, Jan 29, 2015 at 5:53 AM, jesse wrote: >> >> should not it be 1<<32

Re: The Most Diabolical Python Antipattern

2015-01-29 Thread Ian Kelly
On Thu, Jan 29, 2015 at 10:32 AM, Tim Chase wrote: > On 2015-01-29 17:17, Mark Lawrence wrote: >> The author is quite clear on his views here >> https://realpython.com/blog/python/the-most-diabolical-python-antipattern/ >> but what do you guys and gals think? > > I just read that earlier today and

Re: The Most Diabolical Python Antipattern

2015-01-30 Thread Ian Kelly
On Thu, Jan 29, 2015 at 11:16 PM, Marko Rauhamaa wrote: > Ian Kelly : > >> At least use "except Exception" instead of a bare except. Do you >> really want things like SystemExit and KeyboardInterrupt to get turned >> into 0? > > How about: >

Re: The Most Diabolical Python Antipattern

2015-01-30 Thread Ian Kelly
On Fri, Jan 30, 2015 at 2:02 AM, Marko Rauhamaa wrote: > Mark Lawrence : > >> On 30/01/2015 06:16, Marko Rauhamaa wrote: >>> How about: >>> >>> == >>> try: >>> do_interesting_stuff() >>> except ValueError: >>> try: >>> log_it() >

Re: The Most Diabolical Python Antipattern

2015-01-30 Thread Ian Kelly
On Fri, Jan 30, 2015 at 3:00 AM, Marko Rauhamaa wrote: > Marko Rauhamaa : > Surprisingly this variant could raise an unexpected exception: == try: do_interesting_stuff() except ValueError: try:

Re: The Most Diabolical Python Antipattern

2015-01-30 Thread Ian Kelly
On Fri, Jan 30, 2015 at 8:30 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> The bare raise re-raises the most recent exception that is being >> handled. The "raise e" raises that exception specifically, which is >> not the most recent in the case of a secondary

Python tracker manual password reset

2015-01-30 Thread Ian Kelly
I just tried to use the password recovery tool for the Python tracker. I entered my personal email. It sent me the confirmation email with the password reset link, which I followed. It then reset my password and sent an email to a different address, an old work address that I no longer have, so I h

Re: how to parse sys.argv as dynamic parameters to another function?

2015-01-30 Thread Ian Kelly
On Fri, Jan 30, 2015 at 9:09 AM, Robert Chen wrote: > how to parse sys.argv as dynamic parameters to another function? > > > fun(sys.argv) > > in perl, this is very easy. please help. Do you mean that you want each item of sys.argv to be passed as a separate parameter to the function? If so, then

Re: The Most Diabolical Python Antipattern

2015-01-30 Thread Ian Kelly
On Fri, Jan 30, 2015 at 8:56 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> Like I suggested earlier, just don't catch the inner exception at all. >> The result will be both exceptions propagated, chained in the proper >> order. > > Depends on the situation. Lik

Re: Multiplexing 2 streams with asyncio

2015-01-30 Thread Ian Kelly
On Fri, Jan 30, 2015 at 11:45 AM, Paul Moore wrote: > 2. Because on Windows I'd have to use threads, whereas asyncio uses IO > completion ports behind the scenes (I think) which are probably a lot more > lightweight. I have no idea whether that's true, but note that add_reader() on Windows doe

Re: Python is DOOMED! Again!

2015-01-30 Thread Ian Kelly
On Fri, Jan 30, 2015 at 11:42 AM, Mario Figueiredo wrote: > To be clear, type declarations in Julia, Scala, C have the potential to > produce side-effects, can result in optimized code and can result in > compile time errors or warnings. They also affect runtime evaluation as > you could easily at

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Ian Kelly
On Sun, Feb 1, 2015 at 9:55 AM, Steven D'Aprano wrote: > Steven D'Aprano wrote: > >> len tries to call __len__ if it exists, and if not, it tries walking the >> iterable counting items. > > Hmmm, I may have mis-remembered that. Perhaps I'm thinking of Ruby. I think you just got it backward. iter

Re: Create dictionary based of x items per key from two lists

2015-02-01 Thread Ian Kelly
On Sat, Jan 31, 2015 at 7:38 PM, Jason Friedman wrote: >> I have two lists >> >> l1 = ["a","b","c","d","e","f","g","h","i","j"] >> l2 = ["aR","bR","cR"] >> >> l2 will always be smaller or equal to l1 >> >> numL1PerL2 = len(l1)/len(l2) >> >> I want to create a dictionary that has key from l1 and v

Re: Create dictionary based of x items per key from two lists

2015-02-01 Thread Ian Kelly
On Sun, Feb 1, 2015 at 11:49 AM, Mark Lawrence wrote: > On 01/02/2015 18:14, Grant Edwards wrote: >> A loop containing 1 line of code will execute in the same abount of >> time as that loop with 1 line of code and 99 blanks lines. >> >> The latter loop is running at 100 times as many lines/second

Re: __pycache__

2015-02-03 Thread Ian Kelly
On Mon, Feb 2, 2015 at 4:26 PM, Luke Lloyd wrote: > I am in school and there is a problem with my code: > > > > When I try to run my code in the python code in the python shell it waits > about 10 seconds then shows an error that says “IDLE’s subprocess didn’t > make connection. Either IDLE can’t

Re: __pycache__

2015-02-03 Thread Ian Kelly
On Mon, Feb 2, 2015 at 4:26 PM, Luke Lloyd wrote: > I am in school and there is a problem with my code: > > > > When I try to run my code in the python code in the python shell it waits > about 10 seconds then shows an error that says “IDLE’s subprocess didn’t > make connection. Either IDLE can’t

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Ian Kelly
On Tue, Feb 3, 2015 at 10:40 AM, Steven D'Aprano wrote: > AT LONG LAST THE LIGHT DAWNS! THE PENNY DROPS! Careful there, you're starting to sound like Ranting Rick. ;-) -- https://mail.python.org/mailman/listinfo/python-list

Re: basic generator question

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 6:23 AM, Neal Becker wrote: > class rpt: > def __init__ (self, value, rpt): > self.value = value; self.rpt = rpt > def __call__ (self): > for i in range (self.rpt): > yield self.value Note that this class is just reimplementing itertools.repeat. >>> list(

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 9:50 AM, Travis Griggs wrote: > I really like pymongo. And I really like Python. But one thing my fingers > really get tired of typing is > > someDoc[‘_’id’] > > This just does not roll of the fingers well. Too many “reach for modifier > keys” in a row. I would rather use

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 1:16 PM, Travis Griggs wrote: > Yes, that is clever. So if you wanted to minimize the amount of typing you > had to do at all of your pymongo API call sites, what strategy would you use > to keep that relatively terse? > > Is the following the right approach to take? > > c

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 1:16 PM, Travis Griggs wrote: > Yes, that is clever. So if you wanted to minimize the amount of typing you > had to do at all of your pymongo API call sites, what strategy would you use > to keep that relatively terse? > > Is the following the right approach to take? > > c

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 3:38 PM, Steven D'Aprano wrote: > Travis Griggs wrote: >> This just does not roll of the fingers well. Too many “reach for modifier >> keys” in a row. > > *One* modifier key in a row is too many? > > s o m e SHIFT D o c [ ' SHIFT _ i d ' ] I think the point was meant to be

Re: meaning of: line, =

2015-02-05 Thread Ian Kelly
On Thu, Feb 5, 2015 at 2:40 AM, Steven D'Aprano wrote: > Devin Jeanpierre wrote: > >> On Wed, Feb 4, 2015 at 1:18 PM, Chris Angelico wrote: >>> On Thu, Feb 5, 2015 at 4:36 AM, Peter Otten <__pete...@web.de> wrote: Another alternative is to put a list literal on the lefthand side: >>

Re: Monte Carlo probability calculation in Python

2015-02-05 Thread Ian Kelly
On Thu, Feb 5, 2015 at 12:25 PM, Paul Moore wrote: > On Thursday, 5 February 2015 16:57:07 UTC, Rob Gaddi wrote: >> You don't need the whole scipy stack, numpy will let you do everything >> you want. The trick to working in numpy is to parallelize your problem; >> you don't do a thing a thousan

Re: pymongo and attribute dictionaries

2015-02-06 Thread Ian Kelly
On Thu, Feb 5, 2015 at 6:27 AM, Anssi Saari wrote: > What I find surprising is that so many people cling so hard to their > localized keyboard layouts. I think none of those were created by > engineers and should be avoided by technical people. Or, in fact, > everyone. Even Microsoft seems to unde

Re: help with pypeg2?

2015-02-06 Thread Ian Kelly
On Fri, Feb 6, 2015 at 7:55 AM, Neal Becker wrote: > Trying out pypeg2. The below grammar is recursive. A 'Gen' is an ident > followed by parenthesized args. args is a csl of alphanum or Gen. > > The tests 'p' and 'p2' are fine, but 'p3' fails > SyntaxError: expecting u')' > > > from __future__

Re: Matplotlib import error

2015-02-06 Thread Ian Kelly
On Fri, Feb 6, 2015 at 11:49 AM, C Smith wrote: > On Fri, Feb 6, 2015 at 10:20 AM, Chris Angelico wrote: >> On Sat, Feb 7, 2015 at 3:34 AM, C Smith wrote: >>> ImportError: >>> dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so, >>> 2

Re: Python is DOOMED! Again!

2015-02-08 Thread Ian Kelly
On Sat, Feb 7, 2015 at 5:45 PM, Albert van der Horst wrote: > It is too bad `` -> '' as a token is now taken. > I wanted to propose to replace the ternary syntax > lambda .. : .. > by a regular operator > .. -> .. > then we could have > x -> x**2 > instead of > lambda x : x**2 Well, I don't th

Re: Python 3 and the requests library

2015-02-09 Thread Ian Kelly
On Mon, Feb 9, 2015 at 1:37 PM, Brian wrote: > Zach, > > Here is what I get on the Mac: > > $ python3 -c "import token;print(token.__file__)" > /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/token.py Are you running this from the same directory where you have your test scripts (i

Re: Python 3 and the requests library

2015-02-09 Thread Ian Kelly
On Mon, Feb 9, 2015 at 2:37 PM, Brian wrote: > Thank you, Ian and Zack! That was exactly the issue. Apparently, having a > token.py script (one of my first Python 2 scripts to get an authorization > token from a billing server) is OK for Python 2 but breaks Python 3. Local modules that have the

Re: __next__ and StopIteration

2015-02-09 Thread Ian Kelly
On Mon, Feb 9, 2015 at 4:30 PM, Steven D'Aprano wrote: > The way you write iterators is like this: > > > Method 1 (the hard way): > > - Give your class an __iter__ method which simply returns self: > > def __iter__(self): > return self > > - Give your class a __next__ method (`next` in

Re: __next__ and StopIteration

2015-02-10 Thread Ian Kelly
On Mon, Feb 9, 2015 at 5:59 PM, Chris Kaynor wrote: > On Mon, Feb 9, 2015 at 4:42 PM, Steven D'Aprano > wrote: >> so that's an excellent sign that doing so is best practice, but it should >> not be seen as *required*. After all, perhaps you have good reason for >> wanting your iterable class to o

Re: __next__ and StopIteration

2015-02-10 Thread Ian Kelly
On Tue, Feb 10, 2015 at 9:44 AM, Ethan Furman wrote: > On 02/09/2015 08:46 PM, Chris Angelico wrote: >> >> class Grid: >> blah blah >> >> def __iter__(self): >> for row in range(self._rows): >> for col in range(self._cols): >> if self._grid[row][col]: >>

Re: function inclusion problem

2015-02-10 Thread Ian Kelly
On Tue, Feb 10, 2015 at 4:38 PM, wrote: > I defined function Fatalln in "mydef.py" and it works fine if i call it from > "mydef.py", but when i try to call it from "test.py" in the same folder: > import mydef > ... > Fatalln "my test" > i have NameError: name 'Fatalln' is not defined > I also tr

Re: Floating point "g" format not stripping trailing zeros

2015-02-11 Thread Ian Kelly
On Wed, Feb 11, 2015 at 2:48 PM, Mark Lawrence wrote: > On 11/02/2015 20:02, Hrvoje Nikšić wrote: >> >> According to the documentation of the "g" floating-point format, >> trailing zeros should be stripped from the resulting string: >> >> """ >> General format. For a given precision p >= 1, this r

Re: Floating point "g" format not stripping trailing zeros

2015-02-11 Thread Ian Kelly
On Wed, Feb 11, 2015 at 3:19 PM, Ian Kelly wrote: > On Wed, Feb 11, 2015 at 2:48 PM, Mark Lawrence > wrote: >> On 11/02/2015 20:02, Hrvoje Nikšić wrote: >>> >>> According to the documentation of the "g" floating-point format, >>> trailing z

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-02-11 Thread Ian Kelly
On Wed, Feb 11, 2015 at 7:06 PM, Terry Reedy wrote: >> I can't see why the parser would understand more easily >> >> def f(x): >> return x**2 >> than >> >> f = x-> >> return x**2 > > > The parser parses both equally well. That is not the issue. The compiler could at some point recogniz

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-02-12 Thread Ian Kelly
On Wed, Feb 11, 2015 at 8:56 PM, Chris Angelico wrote: > On Thu, Feb 12, 2015 at 1:57 PM, Ian Kelly wrote: >> The reason I don't like this replacing def isn't because the name is >> necessarily lost. It's because the lack of the well-defined def >> statement

Re: Odd version scheme

2015-02-12 Thread Ian Kelly
On Thu, Feb 12, 2015 at 9:45 AM, Gisle Vanem wrote: > I tried using Interactive Python with a PyQt4 console: > "IPython.exe qtconsole" > > But got a > "ImportError: IPython requires PyQT4 >= 4.7, found 4.10.4" > > Looking at Ipython's check (in site-packages\IPython\external\qt.py): > if QtC

Re: Odd version scheme

2015-02-12 Thread Ian Kelly
On Thu, Feb 12, 2015 at 10:19 AM, Skip Montanaro wrote: > I believe this sort of lexicographical comparison wart is one of the reasons > the Python-dev gang decided that there would be no micro versions > 9. There > are too many similar assumptions about version numbers out in the real > world. I

Re: Odd version scheme

2015-02-12 Thread Ian Kelly
On Thu, Feb 12, 2015 at 11:58 AM, MRAB wrote: > On 2015-02-12 17:35, Ian Kelly wrote: >> >> On Thu, Feb 12, 2015 at 10:19 AM, Skip Montanaro >> wrote: >>> >>> I believe this sort of lexicographical comparison wart is one of the >>> reasons >&g

Re: Floating point "g" format not stripping trailing zeros

2015-02-12 Thread Ian Kelly
On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote: >> > from decimal import Decimal as D >> > x = D(1)/D(999) >> > '{:.15g}'.format(x) >> >> >> >> '0.00100100100100100' > [...] >> > I'd say it's a bug. P is 15, you've got 17 digits after the decimal place >> > and two of those are

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 2:26 AM, Hrvoje Nikšić wrote: > Ian Kelly writes: >> When you specify the a precision of 15 in your format string, you're >> telling it to take the first 15 of those. It doesn't care that the >> last couple of those are zeros, because as

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 7:02 AM, Grant Edwards wrote: > On 2015-02-12, Ian Kelly wrote: >> On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote: >> >>> {:.15g} is supposed to give 15 digits of precision, but with trailing >>> zeros removed. >> >> The

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 1:33 PM, Grant Edwards wrote: > On 2015-02-13, Ian Kelly wrote: >> On Fri, Feb 13, 2015 at 7:02 AM, Grant Edwards >> wrote: >>> On 2015-02-12, Ian Kelly wrote: >>>> On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote: >>>

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 2:22 PM, Grant Edwards wrote: > On 2015-02-13, Dave Angel wrote: >> On the other hand, the Decimal package has a way that the programmer >> can tell how many digits to use at each stage of the calculation. > > That's what surpised me. From TFM: > > https://docs.python.org

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 2:40 PM, Ian Kelly wrote: > On Fri, Feb 13, 2015 at 2:22 PM, Grant Edwards > wrote: >> On 2015-02-13, Dave Angel wrote: >>> On the other hand, the Decimal package has a way that the programmer >>> can tell how many digits to use at

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 4:05 PM, Mark Lawrence wrote: > I still think it's a bug as the 'p' being referred to in the OP's original > message is "The precision is a decimal number indicating how many digits > should be displayed after the decimal point for a floating point value > formatted with 'f

Re: ctypes.cdll.LoadLibrary() freezes when loading a .so that contains dlopen()

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 8:39 AM, Russell wrote: > I have a shared library, libfoo.so, that references another .so which isn't > linked but instead loaded at runtime with > myso=dlopen("/usr/local/lib/libbar.so", RTLD_NOW); when I try to load it with > ctypes, the call hangs and I have to ctl-c.

Re: Floating point "g" format not stripping trailing zeros

2015-02-14 Thread Ian Kelly
On Fri, Feb 13, 2015 at 6:22 PM, Mark Lawrence wrote: > On 14/02/2015 00:11, Ian Kelly wrote: >> >> On Fri, Feb 13, 2015 at 4:05 PM, Mark Lawrence >> wrote: >>> >>> I still think it's a bug as the 'p' being referred to in the OP's >

Re: Python implementations in JavaScript

2015-02-14 Thread Ian Kelly
On Fri, Feb 13, 2015 at 4:05 PM, Jonathan Hayward wrote: > > What is the relative maturity of different Python implementations in > JavaScript? Are any of the implementations ready to rely on? Brython is about two years old now. Skulpt has been around for at least four years. I don't use either

Re: Flagging classes as not intended for direct initialization

2015-02-16 Thread Ian Kelly
On Mon, Feb 16, 2015 at 3:55 AM, Mario Figueiredo wrote: > In article <54e14cfe$0$12997$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> Unless you have good reason not to, you should use super rather than >> directly call the superclass. >> >> https://rhettin

Re: Assigning a function to sys.excepthook doesn't work in WSGI

2015-02-18 Thread Ian Kelly
On Wed, Feb 18, 2015 at 8:08 AM, wrote: > I want to generate an html page with http response status '200 OK' in case of > an uncaught exception in my wsgi application, instead of web server's > standard '500 Internal Server Error' response for such case. To do so, I've > made the following sam

Re: What the Pythons docs means by "container" ?

2015-02-18 Thread Ian Kelly
On Wed, Feb 18, 2015 at 11:04 AM, MRAB wrote: > On 2015-02-18 02:14, candide wrote: >> >> Le mercredi 18 février 2015 01:50:16 UTC+1, Chris Angelico a écrit : >> >>> So, what's a container? It's a thing that you put other objects >>> into. >> >> >> I agree with this approach. The important point t

Re: Logging with Custom Levels not working

2015-02-18 Thread Ian Kelly
On Wed, Feb 18, 2015 at 6:49 AM, Didymus wrote: > def perror(self, message, *args, **kws): > """ Performance Error Message Level """ > # Yes, logger takes its '*args' as 'args'. > self._log(PERROR_NUM, message, args, **kws) > > logging.Logger.perror = perror I think you need to call s

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Ian Kelly
On Thu, Feb 19, 2015 at 8:45 AM, wrote: > On Wednesday, February 18, 2015 at 11:20:12 PM UTC+1, Dave Angel wrote: >> I'm not necessarily doubting it, just challenging you to provide a data >> sample that actually shows it. And of course, I'm not claiming that >> 7bit is in any way optimal. You

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Ian Kelly
On Thu, Feb 19, 2015 at 11:04 AM, Ian Kelly wrote: > There's also an optimization that can be added here if we wish to > inject a bit of cleverness. Notice that all values with more than one > group start with 11, never 10. We can borrow a trick from IEEE > floating point and m

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Ian Kelly
On Thu, Feb 19, 2015 at 11:24 AM, Dave Angel wrote: > Here's a couple of ranges of output, showing that the 7bit scheme does > better for values between 384 and 16379. > > 382 2 80fe --- 2 7e82 > 383 2 80ff --- 2 7f82 > 384 3 81 --- 2 0083 > 384 jan grew 3 81 > 385 3 810001 --- 2 0183 > 3

Re: Logging with Custom Levels not working

2015-02-20 Thread Ian Kelly
On Thu, Feb 19, 2015 at 11:16 AM, Didymus wrote: > On Wednesday, February 18, 2015 at 3:16:40 PM UTC-5, Ian wrote: >> > def perror(self, message, *args, **kws): >> > """ Performance Error Message Level """ >> > # Yes, logger takes its '*args' as 'args'. >> > self._log(PERROR_NUM, messa

Re: Python path on windows

2015-02-20 Thread Ian Kelly
On Feb 20, 2015 7:46 AM, "loial" wrote: > > On Linux we use > #!/usr/bin/env python > > At the start of scripts to ensure that the python executable used is the one defined in the PATH variable, rather than hardcoding a path to the python executable. > > What is the equivalent functionality in Win

Re: Python path on windows

2015-02-20 Thread Ian Kelly
On Fri, Feb 20, 2015 at 8:16 AM, loial wrote: > On Friday, February 20, 2015 at 2:54:26 PM UTC, Ian wrote: >> On Feb 20, 2015 7:46 AM, "loial" wrote: >> >> > >> >> > On Linux we use >> >> > #!/usr/bin/env python >> >> > >> >> > At the start of scripts to ensure that the python executable used is

Re: What the Pythons docs means by "container" ?

2015-02-20 Thread Ian Kelly
On Fri, Feb 20, 2015 at 4:37 AM, Rustom Mody wrote: > See https://www.python.org/dev/peps/pep-0246/ > > There Guido says "something much better is about to happen" > > Best as I know its not happened yet... Well, since that PEP was rejected we now have ABCs. Although PEP 3119 wasn't written until

Re: try pattern for database connection with the close method

2015-02-21 Thread Ian Kelly
On Sat, Feb 21, 2015 at 5:22 AM, Mark Lawrence wrote: > On 21/02/2015 02:42, Mario Figueiredo wrote: >> >> Hello all, >> >> I'm using the following pattern for db access that requires me to >> close the connection as soon as it is not needed: >> >> import sqlite3 as lite >> >> t

Re: try pattern for database connection with the close method

2015-02-21 Thread Ian Kelly
On Sat, Feb 21, 2015 at 8:27 AM, Peter Otten <__pete...@web.de> wrote: > Ian Kelly wrote: > >> On Sat, Feb 21, 2015 at 5:22 AM, Mark Lawrence >> wrote: >>> try: >>> with lite.connect('data.db') as db: >>> try: >>

Re: Design thought for callbacks

2015-02-21 Thread Ian Kelly
On Sat, Feb 21, 2015 at 1:57 PM, Grant Edwards wrote: > On 2015-02-21, Cem Karan wrote: >> >> On Feb 21, 2015, at 12:42 AM, Chris Angelico wrote: >> >>> On Sat, Feb 21, 2015 at 1:44 PM, Cem Karan wrote: In order to inform users that certain bits of state have changed, I require them

Re: Design thought for callbacks

2015-02-22 Thread Ian Kelly
On Sun, Feb 22, 2015 at 7:22 AM, Cem Karan wrote: > > On Feb 22, 2015, at 5:15 AM, Gregory Ewing > wrote: > >> Frank Millman wrote: >>> "In order to inform users that certain bits of state have changed, I >>> require them to register a callback with my code." >>> This sounds to me like a pub/su

Re: Best practice: Sharing object between different objects

2015-02-23 Thread Ian Kelly
On Mon, Feb 23, 2015 at 1:02 PM, wrote: > What's REALLY interesting is that this happens: > import myModule myModule.myInt > 1 myModule.myInt = 2 myModule.myInt > 2 del myModule import myModule myModule.myInt > 2 > > I would REALLY expect that deleting the modul

Re: new.py and having '.' in PYTHONPATH

2015-02-23 Thread Ian Kelly
On Mon, Feb 23, 2015 at 3:14 PM, Ethan Furman wrote: > On 02/23/2015 01:00 PM, Tobiah wrote: > >> Anyway, it raises the question as to whether having '.' in the >> PYTHONPATH is at all a sane thing to do. > > The current directory is added to sys.path /only/ for the interactive > interpreter. Wh

Re: Bug in timsort!?

2015-02-24 Thread Ian Kelly
On Tue, Feb 24, 2015 at 3:45 PM, Grant Edwards wrote: > On 2015-02-24, Roy Smith wrote: > >> http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/ > > I don't get it. > > 3.2 Corrected Python merge_collapse function > > merge_collapse(Me

Re: strip bug?

2015-02-24 Thread Ian Kelly
On Tue, Feb 24, 2015 at 4:05 PM, wrote: 'http://xthunder'.strip('http://') > 'xthunder' 'http://thunder'.strip('http://') > 'under' This removes all leading and trailing occurrences of the characters in the string 'http://', not the exact substring 'http://'. For that, use either

<    15   16   17   18   19   20   21   22   23   24   >