Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-04 Thread Ian Kelly
On Mon, Mar 3, 2014 at 11:35 PM, Chris Angelico wrote: > In constant space, that will produce the sum of two infinite sequences > of digits. (And it's constant time, too, except when it gets a stream > of nines. Adding three thirds together will produce an infinite loop > as it waits to see if the

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-04 Thread Ian Kelly
On Tue, Mar 4, 2014 at 4:19 AM, Ian Kelly wrote: > def cf_sqrt(n): > """Yield the terms of the square root of n as a continued fraction.""" >m = 0 > d = 1 > a = a0 = floor_sqrt(n) > while True: > yield a >

Re: How to create an instance of a python class from C++

2014-03-04 Thread Ian Kelly
On Tue, Mar 4, 2014 at 5:14 PM, Bill wrote: > Hello: > > I can't figure out how to create an instance > of a python class from 'C++': > > ( I am relatively new to Python so excuse some of > the following. ) > > In a .py file I create an ABC and then specialize it: Why are you creating an ABC?

Re: Reference

2014-03-04 Thread Ian Kelly
On Tue, Mar 4, 2014 at 8:36 PM, Rustom Mody wrote: > * ... which summarizes my objection in this thread: Python's 'is' leaks the > machine abstraction. 'id' does it legitimately (somewhat), > 'is' does it illegitimately Well, since "if x == None" is buggy as a test for sentinel values, that means

Re: Tuples and immutability

2014-03-07 Thread Ian Kelly
On Fri, Mar 7, 2014 at 4:51 AM, Alister wrote: > I would think it would be better if the exception was thrown before the > assignment to the list took place > simply seeing that a modification action was being applied to a tupple > should be enough. > this would alert the programmer to the fact th

Re: Is their a command to view code?

2014-03-07 Thread Ian Kelly
On Fri, Mar 7, 2014 at 10:55 AM, NexusRAwesome1995 . wrote: > I am making a text based aventure game for my assignment and a friends test > run has somehow saved over the entire code file and now im using an earlier > version of the code. I have 0 idea if there is anyway to look at the code > usin

Re: Tuples and immutability

2014-03-07 Thread Ian Kelly
On Fri, Mar 7, 2014 at 7:17 PM, Gregory Ewing wrote: > Here's another idea: If the __iadd__ method returns the > same object, *and* the LHS doesn't have a __setitem__ > method, then do nothing instead of raising an exception. Maybe it doesn't have a __setitem__ because the object that was retriev

Re: Balanced trees (was: Re: Tuples and immutability)

2014-03-08 Thread Ian Kelly
On Sat, Mar 8, 2014 at 1:34 AM, Marko Rauhamaa wrote: > Speaking of which, are there plans to add a balanced tree to the > "batteries" of Python? Timers, cache aging and the like need it. I'm > using my own AVL tree implementation, but I'm wondering why Python > still doesn't have one. None curre

Re: Tuples and immutability

2014-03-08 Thread Ian Kelly
On Sat, Mar 8, 2014 at 5:40 PM, Gregory Ewing wrote: > Ian Kelly wrote: >> >> class LessThanFilter: >> >> def __init__(self, the_list): >> self._the_list = the_list >> >> def __getitem__(self, bound): >> return [x fo

Re: Tuples and immutability

2014-03-08 Thread Ian Kelly
On Sat, Mar 8, 2014 at 5:45 PM, Gregory Ewing wrote: > Ian Kelly wrote: > >> I already mentioned this earlier in the thread, but a balanced binary >> tree might implement += as node insertion and then return a different >> object if the balancing causes the root node to

Re: Tuples and immutability

2014-03-09 Thread Ian Kelly
On Sun, Mar 9, 2014 at 4:03 PM, Gregory Ewing wrote: > Ian Kelly wrote: >> >> In my view the second one is wrong. a += b should be understood as >> being equivalent to a = a + b, but with the *possible* and by no means >> guaranteed optimization that the operatio

Re: Balanced trees

2014-03-09 Thread Ian Kelly
On Sun, Mar 9, 2014 at 4:08 PM, Dan Stromberg wrote: > On Sun, Mar 9, 2014 at 2:43 PM, Marko Rauhamaa wrote: >> Dan Stromberg : >> >>> On Sun, Mar 9, 2014 at 2:32 PM, Marko Rauhamaa wrote: There is no O(1) hash table. >>> >>> http://stackoverflow.com/questions/2771368/can-hash-tables-really

Re: golang OO removal, benefits. over python?

2014-03-10 Thread Ian Kelly
On Sun, Mar 9, 2014 at 10:49 PM, flebber wrote: > I was wondering if a better programmer than I could explain if the removal of > OO features in golang really does offer an great benefit over python. > > An article I was reading ran through a brief overview of golang in respect of > OO features

Re: Tuples and immutability

2014-03-10 Thread Ian Kelly
On Sun, Mar 9, 2014 at 8:37 PM, Steven D'Aprano wrote: > On Sun, 09 Mar 2014 17:42:42 -0600, Ian Kelly wrote: > >> On Sun, Mar 9, 2014 at 4:03 PM, Gregory Ewing >> wrote: > >>> Note that it says "when possible", not "if the implementation fee

Re: Closure/method definition question for Python 2.7

2014-03-10 Thread Ian Kelly
On Mon, Mar 10, 2014 at 11:27 AM, Brunick, Gerard:(Constellation) wrote: > The following code: > > --- > class Test(object): > x = 10 > > def __init__(self): > self.y = x > > t = Test() > --- > > raises > > NameError: global name 'x' is not defined. > > in Python 2.7. I don't unde

Re: Balanced trees

2014-03-10 Thread Ian Kelly
On Mon, Mar 10, 2014 at 7:45 PM, Chris Angelico wrote: > On Tue, Mar 11, 2014 at 12:26 PM, Steven D'Aprano > wrote: >> In my experience, the average developer has an amazing talent for >> pessimising code when they think they are optimising it. > > I remember a number of incidents from personal e

Re: Tuples and immutability

2014-03-11 Thread Ian Kelly
On Mon, Mar 10, 2014 at 11:03 PM, Gregory Ewing wrote: > As far as observable effects are concerned, it's > quite clear: mutable objects can *always* be updated > in-place, and immutable objects can *never* be. Hm. Consider the circle-ellipse problem. Briefly, a circle is-an ellipse, so in an in

Re: which async framework?

2014-03-11 Thread Ian Kelly
On Tue, Mar 11, 2014 at 4:58 AM, Marko Rauhamaa wrote: > Sturla Molden : > >> I'd go for using iocp, epoll and kqueue/kevent directly. Why bother to >> learn a framework? You will find epoll and kqueue/kevent in the select >> module and iocp in pywin32. > > You beat me to it. > > However, I'm hopi

Re: golang OO removal, benefits. over python?

2014-03-11 Thread Ian Kelly
On Mon, Mar 10, 2014 at 2:38 AM, Marko Rauhamaa wrote: >> On the whole though I think that the language is not yet mature enough >> to be able to seriously compete with more established languages like >> Python or Java. > > Also, is there anything seriously lacking in Python, Java and C? > > I was

Re: Tuples and immutability

2014-03-11 Thread Ian Kelly
On Tue, Mar 11, 2014 at 10:46 AM, Steven D'Aprano wrote: >> There are a number of possible solutions. One possibility would be to >> copy the Circle as an Ellipse and return the new object instead of >> mutating it. Then you have the situation where, given a mutable object >> x that satisfies isi

Re: Tuples and immutability

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 12:28 AM, Steven D'Aprano wrote: > On Tue, 11 Mar 2014 23:25:19 -0400, Terry Reedy wrote: >> Nope, 'similar' is not 'equivalent'. Evaluating x twice instead of once >> and possibly allocating a new object versus not take extra time. In a >> statement like "x.y.z[3*n+m] += 1

Re: Tuples and immutability

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 3:39 AM, Antoon Pardon wrote: > The documentation is wrong at that point as the following code illustrates. Either way it still has to do a getitem and a setitem, but if you have a more nested structure then the extra getitems are not repeated. For example, using your log

Re: which async framework?

2014-03-12 Thread Ian Kelly
On Tue, Mar 11, 2014 at 5:38 PM, Chris Angelico wrote: > On Wed, Mar 12, 2014 at 10:18 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> What corner cases are there with threads that you don't have with >>> anything else? >> >> There are numerous. Here's one example: deadlocks due to two threa

Re: What does gc.get_objects() return?

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 3:44 PM, Chris Angelico wrote: > The concept is that the GC tracks (in that sense; everything in > CPython is refcounted, but that's not what these functions look at) > anything that could be a part of a reference cycle. That's all it > concerns itself with, so something th

Re: What does gc.get_objects() return?

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 4:35 PM, Ian Kelly wrote: >> So not all optimizations are done that could be done. > > Or is it? > >>>> a = 1,2,3 >>>> gc.is_tracked(a) > True >>>> gc.collect() > 0 >>>> gc.is_tracked(a) > False I gu

Re: DB API question - where is a stored procedure's return value?

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 3:44 PM, Skip Montanaro wrote: > What do other database adaptors do about stored procedure return > values? Does PEP 249 need revision? I can't speak generally, but in cx_Oracle you either execute a query like this: result = cursor.var(cx_Oracle.NUMBER) cursor.exe

Re: DB API question - where is a stored procedure's return value?

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 5:00 PM, Ian Kelly wrote: > result = cursor.var(cx_Oracle.NUMBER) > cursor.execute(":1 := test_proc()", [result]) > print(result.getvalue()) Sorry, that should properly be: result = cursor.var(cx_Oracle.NUMBER) cursor.execute(&qu

Re: Tuples and immutability

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 5:20 PM, Steven D'Aprano wrote: > On Tue, 11 Mar 2014 17:06:43 -0600, Ian Kelly wrote: > >> That's true but irrelevant to my point, which was to counter the >> assertion that mutable types can always be assumed to be able to perform >>

Re: Balanced trees

2014-03-13 Thread Ian Kelly
On Mon, Mar 10, 2014 at 11:34 AM, Marko Rauhamaa wrote: > The main thing is there are use cases where order is essential. That's > why I have had to implement the AVL tree in Python myself. No biggie, > but a C implementation would probably be much faster. Also, a standard > version would likely b

Re: Deep vs. shallow copy?

2014-03-13 Thread Ian Kelly
On Thu, Mar 13, 2014 at 5:55 PM, Chris Angelico wrote: > I'm going to troll for a moment and give you a function that has no > return value. > > def procedure(): > raise Exception >>> import dis >>> dis.dis(procedure) 2 0 LOAD_GLOBAL 0 (Exception) 3 RAIS

Re: pickle.dump (obj, conn)

2014-03-13 Thread Ian Kelly
On Thu, Mar 13, 2014 at 4:36 PM, Pedro Izecksohn wrote: > Shouldn't pickle.dump (obj, conn) raise an Exception if conn is a TCP > connection that was closed by the remote host? Can you be more specific about what you are doing, what you expect the result to be, and what the actual result is? h

Re: Thread._stop() behavior changed in Python 3.4

2014-03-17 Thread Ian Kelly
On Mon, Mar 17, 2014 at 11:40 AM, Chris Angelico wrote: > Antoine says that this doesn't even stop the thread > (I can't say; I've never used _stop(), for obvious reasons), so this > code was doubly broken. I was curious about that -- after all, Python's threads aren't truly concurrent, so perhap

Re: 'complex' function with string argument.

2014-03-17 Thread Ian Kelly
On Mon, Mar 17, 2014 at 12:15 PM, Marko Rauhamaa wrote: > Is "-2.0" a literal? > > What's the outcome of > >-2.0.__str__() No. The compiler will try to optimize it into a single constant if it can, but it has to be done in accordance with the order of operations. In that example, the __str_

Re: Thread._stop() behavior changed in Python 3.4

2014-03-17 Thread Ian Kelly
On Mar 17, 2014 12:53 PM, "Jurko Gospodnetić" wrote: > > Hi. > > > On 17.3.2014. 19:03, Ian Kelly wrote: >> >> So yes, despite the lack of true concurrency, a thread can continue to >> run after its _stop has been called. > > > Actuall

Re: Unexpected comparisons in dict lookup

2014-03-18 Thread Ian Kelly
On Tue, Mar 18, 2014 at 8:20 AM, Steven D'Aprano wrote: > I stumbled across this unexpected behaviour with Python 2.7 and 3.3. When > you look up a key in a dict, the key is sometimes compared against other > keys twice instead of just once. >From what I can see in the code, it adds a perturbatio

Re: 'complex' function with string argument.

2014-03-19 Thread Ian Kelly
On Wed, Mar 19, 2014 at 4:09 AM, Marko Rauhamaa wrote: > wxjmfa...@gmail.com: > >> Le mercredi 19 mars 2014 09:51:20 UTC+1, Marko Rauhamaa a écrit : >>> wxjmfa...@gmail.com: >>> complex(2, 1+1j) >>> > (1+1j) >>> >>> I find it neat, actually. >> > # tricky: yes, neat: no > complex(1+1j

Re: 'complex' function with string argument.

2014-03-19 Thread Ian Kelly
On Wed, Mar 19, 2014 at 5:04 AM, Skip Montanaro wrote: > On Wed, Mar 19, 2014 at 5:33 AM, Ian Kelly wrote: >> When is it ever useful though? > > About as often as int(0), float(0), or float(0.0) which all work as > expected, though probably don't turn up in a lot of code.

Re: 'complex' function with string argument.

2014-03-19 Thread Ian Kelly
On Wed, Mar 19, 2014 at 4:53 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Wed, Mar 19, 2014 at 4:09 AM, Marko Rauhamaa wrote: >>> So complex(a, b) is documented to produce a+bj when a and b are integers >>> or floats. What's more natural than saying it

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-21 Thread Ian Kelly
On Fri, Mar 21, 2014 at 3:09 PM, Rustom Mody wrote: > A 'for' introduces a scope: This is false. x = 42 for x in [1,2,3]: > ... print x > ... > 1 > 2 > 3 > > No sign of the 42 --v ie the outer x -- inside because of scope Try printing x again *after* the for loop: >>> x = 42 >>> fo

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-22 Thread Ian Kelly
On Fri, Mar 21, 2014 at 8:06 PM, Rustom Mody wrote: > Two: A comprehension variable is not bound but reassigned across the > comprehension. This problem remains in python3 and causes weird behavior when > lambdas are put in a comprehension Because Python as a language only has the concept of assi

Re: help with for loop----python 2.7.2

2014-03-22 Thread Ian Kelly
On Sat, Mar 22, 2014 at 5:21 AM, wrote: > I am trying to get all the element data from the rss below. > The only thing I am pulling is the first element. > I don't understand why the for loop does not go through the entire rss. > Here is my code [SNIP] > for item in soup.find_all('item'): >

Re: Python - Caeser Cipher Not Giving Right Output

2014-03-22 Thread Ian Kelly
On Mar 20, 2014 9:59 PM, "Dave Angel" wrote: > > dtran...@gmail.com Wrote in message: > > And I was wondering how I would add the partenthesis because I tried: > > > > return numtochar(c1 + c2 (%26)) and it gave me an error. > > Please help us to help you by actually showing the traceback. > Doe

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-22 Thread Ian Kelly
On Sat, Mar 22, 2014 at 6:32 PM, Rhodri James wrote: > On Sat, 22 Mar 2014 05:26:26 -, Rustom Mody > wrote: > >> Well almost... >> Except that the 'loop' I am talking of is one of >> def loop(): >> return [yield (lambda: x) for x in [1,2,3]] >> or >> return (yield (lambda: x) for x

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-22 Thread Ian Kelly
On Sat, Mar 22, 2014 at 9:16 PM, Rustom Mody wrote: > [I am not completely sure whether the following can be proved/is true] > > 1. One can change lambda's closure rules which would amount to > "significant complexity for relatively little gain" > > 2. One can change comprehension rules to not rea

Re: help with for loop----python 2.7.2

2014-03-23 Thread Ian Kelly
On Mar 23, 2014 11:31 AM, "tad na" wrote: > OK . second problem :) > I can print the date. not sure how to do this one.. Why not? What happens when you try? > try: > from urllib2 import urlopen > except ImportError: > from urllib.request import urlopen > import urllib2 > from bs4 import

Re: help with for loop----python 2.7.2

2014-03-23 Thread Ian Kelly
On Mar 23, 2014 3:56 PM, "tad na" wrote: > > This is the error I get with > 1. print data[x].pubDate.text > AttributeError: 'NoneType' object has no attribute 'text' > 2. print data[x].pubDate > It results in "None" So the problem is that it's not even finding the pubDate tag in the first

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Ian Kelly
On Mar 23, 2014 11:56 PM, "Mark H Harris" wrote: > > On 3/22/14 4:46 AM, Steven D'Aprano wrote: >> >> On Fri, 21 Mar 2014 23:51:38 -0500, Mark H Harris wrote: >> >>> Lambda is a problem, if only because it causes confusion. What's the >>> problem? Glad you asked. The constructs DO NOT work the wa

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Ian Kelly
On Mon, Mar 24, 2014 at 3:55 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> If lambda were going to be deprecated and removed then it already >> would have happened in Python 3, because Guido tried to do precisely >> that. I'm not sure what the reasons were for keepin

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Ian Kelly
On Mon, Mar 24, 2014 at 12:58 PM, Mark H Harris wrote: > That is what we mean by confusing. Or another really great example is this > thread. Somebody asks about a language feature and somebody else helpfully > answers the question by providing them with a similar lambda!! That is not in fact how

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Ian Kelly
On Mon, Mar 24, 2014 at 1:12 PM, Chris Angelico wrote: > Incidentally, I've often modified my loop counter, in C or REXX or any > other language. About the only situation where I actually miss it in > Python, though, is iterating over a list and mutating the list on the > way through; and even tha

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Ian Kelly
On Mon, Mar 24, 2014 at 3:43 PM, Mark H Harris wrote: > On 3/24/14 4:03 AM, Ian Kelly wrote: >> >> >> The difference does not really lie in the lambda construct per se but in >> the binding style of closures. Functional languages tend to go one way >> here; im

Re: unicode as valid naming symbols

2014-03-25 Thread Ian Kelly
On Tue, Mar 25, 2014 at 1:29 PM, Mark H Harris wrote: > On 3/25/14 2:24 PM, MRAB wrote: >> It's explained in PEP 3131. >> >> Basically, a name should to start with a letter (this has been extended >> to include Chinese characters, etc) or an underscore. >> >> λ is a classified as Lowercase_Letter.

Re: unicode as valid naming symbols

2014-03-26 Thread Ian Kelly
On Wed, Mar 26, 2014 at 2:52 AM, Antoon Pardon wrote: > On 26-03-14 03:56, MRAB wrote: >> Or as a root operator, e.g. 3 √ x (the cube root of x). >> > Personally I would think such an operator is too limited to include in a > programming language. > This kind of notation is only used with a const

Re: Dynamically reference variable in object

2014-03-26 Thread Ian Kelly
On Mar 26, 2014 5:48 AM, "Ben Collier" wrote: > > Sorry, subject was wrong. Please see below: > > On Wednesday, 26 March 2014 11:43:49 UTC, Ben Collier wrote: > > Hi all, > > I know that I can dynamically reference a variable with locals()["i"], for instance, but I'd like to know how to do this w

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-27 Thread Ian Kelly
On Tue, Mar 25, 2014 at 7:36 AM, Steven D'Aprano wrote: > Yes, Python could have changed the meaning of {} to mean the empty set. > But you know what? The empty set is not that important. Sets are not > fundamental to Python. Python didn't even have sets until 2.3, and at > first they were just a

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-27 Thread Ian Kelly
On Thu, Mar 27, 2014 at 1:32 AM, Ian Kelly wrote: > On Tue, Mar 25, 2014 at 7:36 AM, Steven D'Aprano > wrote: >> Yes, Python could have changed the meaning of {} to mean the empty set. >> But you know what? The empty set is not that important. Sets are not >> fundame

Re: unicode as valid naming symbols

2014-03-27 Thread Ian Kelly
On Thu, Mar 27, 2014 at 9:28 AM, Mark H Harris wrote: >> Do you think that the ability to write this would be an improvement? >> >> import ⌺ >> ⌚ = ⌺.╩░ >> ⑥ = 5*⌺.⋨⋩ >> ❹ = ⑥ - 1 >> ♅⚕⚛ = [⌺.✱✳**⌺.❇*❹{⠪|⌚.∣} for ⠪ in ⌺.⣚] >> ⌺.˘˜¨´՛՜(♅⚕⚛) > > >Steven, you're killing me here; argument by analo

Re: Keyboard standards

2014-03-29 Thread Ian Kelly
On Fri, Mar 28, 2014 at 11:40 PM, Mark H Harris wrote: > On 3/29/14 12:13 AM, Chris Angelico wrote: >> >> When I first met Windows keys, I just popped 'em off and left a gap. >> Worked fine. > > ha! see.. it popped you off too! :-)) I found it arrogant to the max to > place their stupid logo

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-30 Thread Ian Kelly
On Mar 30, 2014 9:26 AM, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > > On Sat, 29 Mar 2014 03:21:29 -0500, Mark H Harris wrote: > > from a computer historical standpoint too. I mean, think > > about it, computers have only existed since late 1940s and only in their > > modern

Re: unicode as valid naming symbols

2014-03-31 Thread Ian Kelly
On Mon, Mar 31, 2014 at 3:55 AM, Antoon Pardon wrote: > On 27-03-14 17:22, Ian Kelly wrote: >> On Thu, Mar 27, 2014 at 9:28 AM, Mark H Harris wrote: >>>> Do you think that the ability to write this would be an improvement? >>>> >>>> import ⌺ >>

Re: unicode as valid naming symbols

2014-03-31 Thread Ian Kelly
On Mon, Mar 31, 2014 at 12:02 PM, Tim Chase wrote: > On 2014-03-31 11:40, Ian Kelly wrote: >> There is nothing useful >> you can do with a name that is the U+1F4A9 character that you can't >> do just as easily with alphanumeric identifiers like pile_of_poo (or >

Re: unicode as valid naming symbols

2014-03-31 Thread Ian Kelly
On Mon, Mar 31, 2014 at 1:31 PM, Antoon Pardon wrote: > Op 31-03-14 19:40, Ian Kelly schreef: >> That was an exaggeration on my part. It wouldn't affect my job, as I >> wouldn't expect to ever actually have to maintain anything like the >> above. My greater

Re: Code style query: multiple assignments in if/elif tree

2014-03-31 Thread Ian Kelly
On Mon, Mar 31, 2014 at 11:01 PM, Chris Angelico wrote: > On Tue, Apr 1, 2014 at 3:26 PM, Steven D'Aprano wrote: >> The scenario you describe has (effectively) infinite rate-of-change-of- >> acceleration, often called "jerk". (A jerk is a rapid change in >> acceleration.) Human comfort is (within

Re: Code style query: multiple assignments in if/elif tree

2014-03-31 Thread Ian Kelly
On Mon, Mar 31, 2014 at 11:45 PM, Rustom Mody wrote: > On Tue, Apr 1, 2014 at 3:26 PM, Steven D'Aprano wrote: > >> Haskell has nifty pattern-matching syntax for this that looks quite close >> to the mathematical hybrid function syntax, but in Python, we're limited >> to explicitly using an if. If

Re: Code style query: multiple assignments in if/elif tree

2014-03-31 Thread Ian Kelly
On Tue, Apr 1, 2014 at 12:24 AM, David Hutto wrote: >> >> >> (1) v = u + at >> >> (2) s = 1/2(u + v)t >> >> (3) s = ut + 1/2(at^2) >> >> (4) v^2 = u^2 + 2as >> >> >> >> Only (1) and (3) are needed. >> > >> > Okay, what's u here? Heh. >> >> u is the initial velocity; v is the velocity after acceler

Re: Code style query: multiple assignments in if/elif tree

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 1:35 AM, Chris Angelico wrote: > On Tue, Apr 1, 2014 at 6:20 PM, Steven D'Aprano wrote: >> 177.2133 >> >> compared to 177.2652780002 calculated the rough way. That's not bad, >> only about 5cm off! Effectively, your rough calculation was accurate to >> one decim

Re: Code style query: multiple assignments in if/elif tree

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 2:18 AM, Ian Kelly wrote: > The reason the velocity is different after 2 seconds is because the > linear deceleration does not match the constraints of the problem. The > average deceleration for the first second is not 0.2 m/s, and the > average deceleration fo

Re: Code style query: multiple assignments in if/elif tree

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 1:59 AM, Ian Kelly wrote: > Given that, I have to question your figures: > >> 177.2133 > >> compared to 177.2652780002 calculated the rough way. That's not bad, >> only about 5cm off! Effectively, your rough calculation was

Re: Code style query: multiple assignments in if/elif tree

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 12:55 AM, Chris Angelico wrote: > On Tue, Apr 1, 2014 at 5:13 PM, Ian Kelly wrote: >> Then your computation is incorrect and will systematically >> underestimate the stopping distance. Assuming for simplicity that the >> acceleration actually increa

Re: unicode as valid naming symbols

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 2:19 AM, Antoon Pardon wrote: > On 01-04-14 02:47, Ian Kelly wrote: >> On Mon, Mar 31, 2014 at 1:31 PM, Antoon Pardon >> wrote: >>> Second of all I >>> think a good chosen symbolic name can be more readable than a >>> name in a

Re: unicode as valid naming symbols

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 3:32 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Tue, Apr 1, 2014 at 2:19 AM, Antoon Pardon >>> Which will give me the normal result. Maybe I missed it but I haven't >>> heard scheme being called an unreadable language. >> >

Re: unicode as valid naming symbols

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 7:44 AM, Chris Angelico wrote: > On Wed, Apr 2, 2014 at 12:33 AM, Ned Batchelder > wrote: >> Maybe I'm misunderstanding the discussion... It seems like we're talking >> about a hypothetical definition of identifiers based on Unicode character >> categories, but there's no

Re: Yet Another Switch-Case Syntax Proposal

2014-04-02 Thread Ian Kelly
On Wed, Apr 2, 2014 at 8:53 AM, Lucas Malor <3kywjyd...@snkmail.com> wrote: > Hi all. I would proposeto you all a switch-case syntax for Python. I already > read PEP 3103 and I'm not completely satisfied by any of the proposed > solutions. This is my proposal: A more suitable place to propose th

Re: Yet Another Switch-Case Syntax Proposal

2014-04-02 Thread Ian Kelly
On Wed, Apr 2, 2014 at 7:06 PM, Steven D'Aprano wrote: > If we're going to add "switch" and "case" keywords, how about we also add > "of"? Then we can write: > > switch x case of a, b, c: > # x equals one of a, b or c > case of d, e, f: > # x equals one of d, e or f > case in g, h, i: >

Re: Retrieve item deep in dict tree?

2014-04-03 Thread Ian Kelly
On Wed, Apr 2, 2014 at 10:15 PM, Rustom Mody wrote: > On Thursday, April 3, 2014 8:11:33 AM UTC+5:30, Rustom Mody wrote: >> On Wednesday, April 2, 2014 11:28:16 PM UTC+5:30, Roy Smith wrote: >> > I have a big hairy data structure which is a tree of nested dicts. I have >> > a sequence of strings

Re: Two Questions about Python on Windows

2014-04-03 Thread Ian Kelly
On Apr 3, 2014 11:12 AM, "Walter Hurry" wrote: > > Normally my Python development is done on FreeBSD and Linux. I know that on *ix I simply have to make foo.py executable (the shebang line is present, of course) to make it runnable. > > For my son's school assignment, I have to help him with Pytho

Re: Yet Another Switch-Case Syntax Proposal

2014-04-03 Thread Ian Kelly
On Thu, Apr 3, 2014 at 10:02 AM, Lucas Malor <3kywjyd...@snkmail.com> wrote: >> __contains__ is not part of the interface for iterables > > For what I know there's not an Iterable interface. For example List simply > extends Object. I hope that an ABC Iterable class will be introduced in a > futu

Re: Default mutable parameters in functions

2014-04-03 Thread Ian Kelly
On Thu, Apr 3, 2014 at 12:49 PM, wrote: > Now call it with a value: > foo([ 3 ]) > > as you might expect: > It's a parrot, not a cheese: [3] > > But now go back to no parameter in the call: > foo() > foo() > foo() > > It's a parrot, not a cheese: [46] > It's a parrot, not a cheese: [47] > It's a

Re: Two Questions about Python on Windows

2014-04-03 Thread Ian Kelly
On Thu, Apr 3, 2014 at 2:15 PM, Mark Lawrence wrote: > On 03/04/2014 18:54, Ian Kelly wrote: >> >> >> On Apr 3, 2014 11:12 AM, "Walter Hurry" > <mailto:walterhu...@gmail.com>> wrote: >> > >> > Normally my Python development is done

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 1:52 AM, Steven D'Aprano wrote: > py> from decimal import * > py> getcontext().prec = 16 > py> x = Decimal("0.77787516") > py> y = Decimal("0.77787518") > py> (x + y) / 2 > Decimal('0.77787515') > > "Guido, why can't Python do maths???" Well, you nee

Re: Yet Another Switch-Case Syntax Proposal

2014-04-04 Thread Ian Kelly
On Apr 4, 2014 3:51 AM, "Marko Rauhamaa" wrote: > > >>> switch day casein ("Monday", "Thursday", "Wednesday", "Tuesday", > >>> "Friday"): > >>> gotowork = True > >>> continue > >>> casein ("Monday", "Thursday", "Wednesday", "Tuesday", "Friday"): > >>> daytype = "ferial" > >>> casein

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 4:08 AM, Steven D'Aprano wrote: > On Fri, 04 Apr 2014 02:13:13 -0600, Ian Kelly wrote: > >> On Fri, Apr 4, 2014 at 1:52 AM, Steven D'Aprano >> wrote: >>> py> from decimal import * >>> py> getcontext().prec = 16 >>&

Re: Yet Another Switch-Case Syntax Proposal

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 10:44 AM, Marko Rauhamaa wrote: > Consider: > > switch local_sabbath():# bad > case (1, 2, 3) as sabbath: > ... I'm not overly fond of that either. That's why I liked the OP's choice to put the first case in the switch statement. > Now Python "fram

Re: Scoping rules for class definitions

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 12:37 PM, Rotwang wrote: > Hi all. I thought I had a pretty good grasp of Python's scoping rules, but > today I noticed something that I don't understand. Can anyone explain to me > why this happens? > x = 'global' def f1(): > x = 'local' > class C: >

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 2:58 PM, Mark H Harris wrote: > On 4/4/14 3:20 AM, Mark Lawrence wrote: >> >> On 04/04/2014 03:29, Mark H Harris wrote: >>> >>> >>> Now, about Python2. It has not died. It appears to be 'useful'. >>> {snip} >>> >> >> For a lot of people, if it ain't broke, don't fix it

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 10:10 PM, Mark H Harris wrote: > On 4/4/14 6:16 PM, Mark Lawrence wrote: >> >> Fear/panic of a fork, where did that come from? It's certainly the >> first I've ever heard of it. >> > > hi Mark, it came from Ian; or, my interpret

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 10:40 PM, Chris Angelico wrote: > On Sat, Apr 5, 2014 at 3:10 PM, Mark H Harris wrote: >> we don't want folks to be driven away from Cpython as a language, and we >> don't want them to fork the Cpython interpreter, so we'll take a very casual >> and methodically conservativ

Re: Yet Another Switch-Case Syntax Proposal

2014-04-06 Thread Ian Kelly
On Sun, Apr 6, 2014 at 11:49 AM, Lucas Malor <3kywjyd...@snkmail.com> wrote: > On 3 April 2014 20:12, Ian Kelly ian.g.kelly-at-gmail.com > |python-list@python.org| wrote: >> Use this instead [of continue]: > >> >> switch day case in ("Mon", "Tue&

Re: Keeping track of things with dictionaries

2014-04-08 Thread Ian Kelly
On Tue, Apr 8, 2014 at 1:14 AM, Frank Millman wrote: > > "Chris Angelico" wrote in message > news:captjjmqfbt2xx+bdfnhz0gagordkhtpbzrr29duwn36girz...@mail.gmail.com... >> On Tue, Apr 8, 2014 at 2:02 PM, Josh English >> wrote: >>> >>> Would dict.setdefault() solve this problem? Is there any advan

Re: Keeping track of things with dictionaries

2014-04-08 Thread Ian Kelly
On Tue, Apr 8, 2014 at 8:45 PM, alex23 wrote: > On 9/04/2014 12:33 PM, Chris Angelico wrote: >>> >>> Unfortunately I seem to be missing antidisestablishmentarianism, >>> because the longest words in my dict are only 24 characters, >>> excluding the '\n'. Should I ask for my money back? >> >> >> I

Re: Keeping track of things with dictionaries

2014-04-08 Thread Ian Kelly
On Tue, Apr 8, 2014 at 9:31 PM, Gene Heskett wrote: >> 'Pneumonoultramicroscopicsilicovolcanoconiosis' has them all beat. > > Source citation please? http://en.wikipedia.org/wiki/Pneumonoultramicroscopicsilicovolcanoconiosis http://www.oxforddictionaries.com/definition/english/pneumonoultramicros

Re: python obfuscate

2014-04-10 Thread Ian Kelly
On Thu, Apr 10, 2014 at 7:48 PM, Tobiah wrote: > On 4/10/2014 6:29 PM, Wesley wrote: >> Hi all, Does python has any good obfuscate? >> >> Currently our company wanna release one product developed by python >> to our customer. But dont's wanna others see the py code. >> >> I googled for a while but

Re: python obfuscate

2014-04-10 Thread Ian Kelly
On Thu, Apr 10, 2014 at 8:17 PM, Wesley wrote: > Umm, just wanna make all .py files not human readable. > > Or, maybe need a tool like zend in php. The only reliable way to prevent a customer from reverse-engineering your software is to not give them the software. For example, instead of giving

Re: Teaching python to non-programmers

2014-04-10 Thread Ian Kelly
On Thu, Apr 10, 2014 at 11:11 PM, Chris Angelico wrote: > On Fri, Apr 11, 2014 at 2:37 PM, Rustom Mody wrote: >> Right. Its true that when I was at a fairly large corporate, I was not told: >> "Please always top post!" >> >> What I was very gently and super politely told was: >> "Please dont dele

Re: python obfuscate

2014-04-11 Thread Ian Kelly
On Fri, Apr 11, 2014 at 3:17 AM, Sturla Molden wrote: > Ian Kelly wrote: > >> The only reliable way to prevent a customer from reverse-engineering >> your software is to not give them the software. > > Not really... On Fri, Apr 11, 2014 at 3:17 AM, Sturla Molden wr

Re: Teaching python to non-programmers

2014-04-14 Thread Ian Kelly
On Mon, Apr 14, 2014 at 12:13 AM, alex23 wrote: > http://www.ietf.org/rfc/rfc1855.txt > > If you are sending a reply to a message or a posting be sure you > summarize the original at the top of the message, or include just > enough text of the original to give a context. This will mak

Re: Martijn Faassen: The Call of Python 2.8

2014-04-14 Thread Ian Kelly
On Apr 14, 2014 11:46 AM, wrote: > > I will most probably backport two quite large applications > to Py27 ("scientific data processing apps"). These applications are already on Python 3? Why do you want them on Python 2? Even the people talking about a 2.8 are only seeing it as an upgrade path to

Re: Why Python 3?

2014-04-19 Thread Ian Kelly
On Sat, Apr 19, 2014 at 1:34 AM, Chris Angelico wrote: > That'll make Python 2.6/2.7 behave like Python 3.x in three ways: > firstly, "print" will be a function instead of a statement (and it's > more powerful than the statement form, as well as being more > flexible); secondly, quoted strings wil

Re: Why Python 3?

2014-04-19 Thread Ian Foote
a few other third party libraries we've wanted to use but can't, but we've been able to work around that. Regards, Ian F -BEGIN PGP SIGNATURE- Version: GnuPG v1 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJTUnMOAAoJEODsV4MF7PWzhEsH

Re: Why Python 3?

2014-04-19 Thread Ian Kelly
On Sat, Apr 19, 2014 at 3:37 AM, Chris Angelico wrote: > On Sat, Apr 19, 2014 at 7:25 PM, Ian Kelly wrote: >> The change from / denoting "classic >> division" to "true division" really only affects the case where both >> operands are integers, so far

<    19   20   21   22   23   24   25   26   27   28   >