Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-14 Thread Steve D'Aprano
hat the average uneducated person believed in a flat earth. But we don't really know for sure. And there is more to the world than just Europe. In China, belief in a flat earth cosmology was virtually unchallenged until the 17th century. https://en.wikipedia.org/wiki/Flat_Earth -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-14 Thread Steve D'Aprano
entally dumped a trailer load of soil by the side of the road in Kanvas, and within a day some enterprising entrepreneur had set up a thriving roadside business offering mountain-climbing tours to the locals. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure en

Re: How could I implement a virtual method and override it in python?

2016-09-14 Thread Steve D'Aprano
e Foo method > would override the other one. It doesn't. Perhaps you are unclear about the difference between methods of a class and functions in modules? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-14 Thread Steve D'Aprano
nek/flat/flateart.htm (To answer my rhetorical question in the subject header: yes, apparently we can.) -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Expression can be simplified on list

2016-09-14 Thread Steve D'Aprano
d obvious. if obj: ... # implicitly calls obj.__bool__ or equivalent, by the bool protocol # versus if bool(obj): ... # implicitly calls obj.__bool__ or equivalent Apart from the extra six characters, I see no difference. What am I missing? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Playing an audio file, but not waiting for it to finish?

2016-09-15 Thread Steve D'Aprano
our main thread and the thread playing the sound. I guess you'll have to try it and see. If threading doesn't work for you, try the multiprocessing library instead. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https:/

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-15 Thread Steve D'Aprano
On Thu, 15 Sep 2016 11:45 pm, Grant Edwards wrote: > On 2016-09-15, Steve D'Aprano wrote: >> On Thu, 15 Sep 2016 06:19 am, breamore...@gmail.com wrote: >> >>> It is so blantantly obvious that the world is not flat I find this >>> discussion flabbergasti

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-15 Thread Steve D'Aprano
On Thu, 15 Sep 2016 04:02 pm, Random832 wrote: > On Wed, Sep 14, 2016, at 23:12, Steve D'Aprano wrote: >> Yes it does. Even an infinitely large flat plane has a horizon almost >> identical to the actual horizon. > > Your link actually doesn't support the latter cl

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-15 Thread Steve D'Aprano
On Fri, 16 Sep 2016 05:19 am, Random832 wrote: > On Thu, Sep 15, 2016, at 15:06, Steve D'Aprano wrote: >> No, the horizon would still be horizontal. It merely wouldn't *look* >> horizontal, an optical illusion. > > I guess that depends on your definition of w

Re: is it possible to adjust convex hull to draw blue line instead of green line?

2016-09-16 Thread Steve D'Aprano
things are undefined. My **guess** is that cv2.line() will take an argument to set the line colour. You should read the documentation for cv2.line(). Before asking any more questions, please read this: http://sscce.org/ -- Steve “Cheer up,” they said, “things could be worse.” So I che

Re: Where is the documentation for ','?

2016-09-16 Thread Steve D'Aprano
don't see in > which section ',' is documented. Could anybody let me know? Thanks. As well as the other suggestions you have been given, try "Sequence Unpacking". -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there something similar to `set -v` of bash in python

2016-09-16 Thread Steve D'Aprano
ere is no built-in command for this, but it would be an interesting project for an advanced user to write a pre-processor that inserts calls to print after every line. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://

Re: Is the content available in the html doc available in help()?

2016-09-17 Thread Steve D'Aprano
pydoc --help for details. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-17 Thread Steve D'Aprano
On Sun, 18 Sep 2016 07:19 am, Thomas 'PointedEars' Lahn wrote: > AFAIK, “ä”, “ö”, and “ü” are not accented characters in any natural > language, but characters of their own (umlauts). Are you saying that English is not a natural language? -- Steve “Cheer up,” they said,

Re: Functions Of Functions Returning Functions

2016-09-18 Thread Steve D'Aprano
efore it had classes. You're right about Python having functions first: steve@runes:~$ python0.9.1 >>> def f(): ... pass ... >>> class A: Parsing error: file , line 1: class A: ^ Unhandled exception: run-time error: syntax error However it only gained closures

Re: how to automate java application in window using python

2016-09-18 Thread Steve D'Aprano
e, and a mouseclick event generated by software. They're ALL generated by software, and the application cannot tell them apart. (2) It works even if the application doesn't offer an OLE, COM or scripting interface. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered

Re: Serialising an 8x8x8 array of pygame sounds

2016-09-18 Thread Steve D'Aprano
jects)? Can you seralise *one* Sound object? If not, then you can't serialise an array of Sound objects either. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: get the sum of differences between integers in a list

2016-09-20 Thread Steve D'Aprano
First, work through the calculation by hand. How do you do it by hand, using pen and paper? Now write some code to do the same thing! Good luck! -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Idiomatic code validator?

2016-09-20 Thread Steve D'Aprano
Whether you agree with that opinion or not is up to you. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: list or dictionary

2016-09-20 Thread Steve D'Aprano
return key raise ValueError('not found') # Version 3: use a dict the way dicts are meant to be used hostnames = {1: 'hostname1', 2: 'hostname2', 842: 'hostname842'} def get_hostname(id): return hostnames[id] -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: automated comparison tool

2016-09-20 Thread Steve D'Aprano
e names for each host from all three directories, and compare the files. I leave the rest of the exercise to you, but remember the principle of Divide And Conquer. Divide the problem into smaller problems which are easy to solve, solve each small problem, and the big problem solves itself. --

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Steve D'Aprano
global count count += 1 return _iter(obj) assert list(tree) == sorted(data) print(count) # - cut - which prints 2, as expected: for each node, iter() gets called twice. So I don't understand where your O(N log N) behaviour is coming from. -- Steve “Ch

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 12:44 pm, Random832 wrote: > On Tue, Sep 20, 2016, at 22:34, Steve D'Aprano wrote: >> I'm afraid I don't understand this. This is a standard binary tree >> inorder traversal. Each node is visited once, and there are N nodes, >> so I make tha

Re: Data Types

2016-09-20 Thread Steve D'Aprano
. "Hi there" is a str (short for string). True is a bool (short for Boolean value, which is a technical term for special True/False values). Perhaps if you can ask a more clear question, I can give a more clear answer. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Steve D'Aprano
calling stack. You can re-write to_list as: def to_list(node): result = [] for value in node: # calls __iter__ method above result.append(node) return result One of us is badly missing something. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Steve D'Aprano
On Wed, 21 Sep 2016 12:47 pm, Chris Angelico wrote: > On Wed, Sep 21, 2016 at 12:34 PM, Steve D'Aprano > wrote: >> "since values from the leaves of the tree have to be yielded >> multiple times to the top of the tree" >> >> Each leaf is yield

Re: strings and ints consistency - isinstance

2016-09-21 Thread Steve D'Aprano
handle it: Look Before You Leap (an explicit test using if) Easier to Ask Forgiveness than Permission (try...except) https://docs.python.org/3/glossary.html#term-lbyl https://docs.python.org/3/glossary.html#term-eafp Use whichever is appropriate for the situation. There is no need to always use o

Re: automated comparison tool

2016-09-21 Thread Steve D'Aprano
u need to identify which "cryptography" module it relies on, and install it. Start by reading the paramiko documentation and especially look for "requirements" or "dependencies". -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough,

Re: get the sum of differences between integers in a list

2016-09-21 Thread Steve D'Aprano
On Thu, 22 Sep 2016 01:51 am, marco.naw...@colosso.nl wrote: > And here is a straightforward one without any helpers: Please don't do people's homework for them. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got wors

Re: Data Types

2016-09-21 Thread Steve D'Aprano
which is a bool, any more than we should think of 1+1 as being a different value to 2. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: strings and ints consistency - isinstance

2016-09-22 Thread Steve D'Aprano
will always print. > else: > print("Ok please ammend your entries") That can never occur, since both the if... clause and the elif... clause will always evaluate as True. So this is dead code. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Data Types

2016-09-22 Thread Steve D'Aprano
se and 1 (or sometimes -1) for true. In the early days, Python was the same. See https://www.python.org/dev/peps/pep-0285/ for more details. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Any ReST aware editors?

2016-09-22 Thread Steve D'Aprano
ery thirty seconds or so.) Anybody know anything like that? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: strings and ints consistency - isinstance

2016-09-22 Thread Steve D'Aprano
On Thu, 22 Sep 2016 11:40 pm, Sayth Renshaw wrote: > True it failed, just actually happy to get it to fail or pass successfully > on int input. But it doesn't. It raises ValueError no matter what you enter. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered u

Re: How to import all things defined the files in a module directory in __init__.py?

2016-09-24 Thread Steve D'Aprano
ule before I split it into submodules purely on the basis of size. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-25 Thread Steve D'Aprano
thor says: "One of my clients gets address data from Europe, but most of their systems cannot handle Latin-1 characters. With all due respect to the umlaut, scharfes s, cedilla, and all the other fine accented characters of Europe, all I needed to do was to prepare addresses for a shippin

Re: Nested for loops and print statements

2016-09-26 Thread Steve D'Aprano
f you picked one (spaces) or the other (tabs) and ONLY used that. Other wise you will just confuse yourself. But you won't confuse the interpreter. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to make a copy of chained dicts effectively and nicely?

2016-09-27 Thread Steve D'Aprano
#x27;s only three dicts: new_dict = d1.copy() new_dict.update(d2, **d3) Or if you prefer: new_dict = dict(d1) # same as copying new_dict.update(d2, **d3) -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/

How to reduce the DRY violation in this code

2016-09-27 Thread Steve D'Aprano
t value in from_strings - change the conversion function from float to int in from_strings Not to mention that each parameter is named seven times. How can I improve this code to reduce the number of times I have to repeat myself? -- Steve “Cheer up,” they said, “things could be worse.

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Steve D'Aprano
rship testing. The union of A and B is the set of all elements in A plus those in B; the intersection of A and B is the set of all elements in both A and B. > but membership inclusion checks are definitely up there among primary > purposes of sets.) I can't think of a set operation (apa

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
chain of function calls. > > Procedural programming under another name... Only in the sense that procedural programming is unstructured programming under another name. What is a procedure call but a disguised GOSUB, and what is GOSUB but a pair of GOTOs? -- Steve “Cheer up,” they said,

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
On Wed, 28 Sep 2016 11:05 pm, Jussi Piitulainen wrote: > Steve D'Aprano writes: > >> On Wed, 28 Sep 2016 08:03 pm, Lawrence D’Oliveiro wrote: >> >>> On Wednesday, September 28, 2016 at 9:53:05 PM UTC+13, Gregory Ewing >>> wrote: >>>> Es

Re: Syncing up iterators with gaps

2016-09-28 Thread Steve D'Aprano
es x", "tres y", "tres z"] 4: ["cuatro", ("iv", "extra beta")] 5: ["five", ("v", "extra gamma")] and then you can extract the separate columns from each value. You might find it easier to have *all* the iterators yield (key, tuple) pairs, where data1 and data2 yield a 1-tuple and data3 yields a 2-tuple. If you look on ActiveState, I'm pretty sure you will find a recipe from Raymond Hettinger for a merge sort or heap sort or something along those lines, which you can probably adapt for an arbitrary number of inputs. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
as "pure > function" and "function" in other contexts? Honestly Chris, what's hard to understand about this? Monads are burritos. http://blog.plover.com/prog/burritos.html -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, thi

Re: Syncing up iterators with gaps

2016-09-28 Thread Steve D'Aprano
ge(data1, data2, data3), keyfunc): for x in stuff: DISPATCH[id](key, *x) you can do: for key, (process, stuff) in groupby(merge(data1, data2, data3), keyfunc): for x in stuff: process(key, *x) -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and s

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steve D'Aprano
t; idioms" vs "languages with no functional programming support". Python > is squarely in the second camp, with features like list > comprehensions, map/reduce, etc, but never forcing you to use them. List comps, map/reduce etc are the highest profile and least useful parts of functional programming. The most useful is learning to avoid depending on mutable state in your functions' environment, i.e. global variables, instance attributes, etc. List comps etc are just a means to an end. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Expression can be simplified on list

2016-09-29 Thread Steve D'Aprano
e of the iterator: def gen(): if random.random() < 0.5: yield 1 it = gen() Is it exhausted or not? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: how to automate java application in window using python

2016-09-29 Thread Steve D'Aprano
On Fri, 30 Sep 2016 05:18 am, Lawrence D’Oliveiro wrote: > On Thursday, September 29, 2016 at 11:46:59 PM UTC+13, Ned Batchelder > wrote: >> This is just getting rude. Let's please drop it. > > Do you have anything substantive to contribute? Infinitely more than you

Re: Expression can be simplified on list

2016-09-29 Thread Steve D'Aprano
type (including a union of multiple types) which has at least one falsey value. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: unintuitive for-loop behavior

2016-09-30 Thread Steve D'Aprano
AL. I'm not aware of any sensible language that does anything like this. No, wait a minute, I tell a lie, I recall Chris Angelico mentioning that one of his favourite languages, Pike or REXX, does it. I forget which. -- Steve “Cheer up,” they said, “things could be worse.” So I

Re: unintuitive for-loop behavior

2016-09-30 Thread Steve D'Aprano
or even unavoidable, decisions. [1] "When I design my killer language, the identifiers `foo` and `bar` will be reserved words, never used, and not even mentioned in the reference manual. Any program using one will simply dump core without comment. Multitudes will rejoice." - Tim

Re: unintuitive for-loop behavior

2016-09-30 Thread Steve D'Aprano
ed. With 'for', especially one > inside a list-comp, often you just need some throwaway index variable > without worrying if it will clash with an existing local. > > But it's not useful enough I think to bother changing now. Or even when > the language was designed. Indeed

Re: unintuitive for-loop behavior

2016-09-30 Thread Steve D'Aprano
On Sat, 1 Oct 2016 10:46 am, Gregory Ewing wrote: > Steve D'Aprano wrote: >> Giving for-loops their own namespace is a grossly unintuitive and a very >> weird thing to do. >> >> It would be terribly inconvenient and surprising for if...else blocks to >> b

Re: unintuitive for-loop behavior

2016-10-01 Thread Steve D'Aprano
indings in a namespace rather than fixed addresses, there is no difference between updating an existing binding and creating a new one. In a language like Python, the only distinction we can make between name bindings is, which namespace is the binding in? In other words, what is the current block of code's scope? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: unintuitive for-loop behavior

2016-10-01 Thread Steve D'Aprano
{ printf("%d:", i); i = 0; } } Solution: don't do that. [1] Apparently useful error messages are one of those things C programmers eschew, like type safety, memory safety, and correctness. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: generator no iter - how do I call it from another function

2016-10-01 Thread Steve D'Aprano
, then cut your code down to the smallest possible amount that shows the problem: http://sscce.org/ and I'll read it again. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Copying a compiled Python from one system to another

2016-10-01 Thread Steve D'Aprano
main development machine, but as a temporary measure, I thought I could compile 3.6 on this VM, then copy the python binary to my usual desktop machine. What sort of challenges am I likely to find? Both machines are Linux, but different distros. -- Steve “Cheer up,” they said, “things could be

Re: unintuitive for-loop behavior

2016-10-01 Thread Steve D'Aprano
he explanatory mechanisms of why/whither/what etc should > at best be secondary 5. is workaroundable with a [... for newvar in [rhs]] >Possible and clunky I don't know what this means. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Copying a compiled Python from one system to another

2016-10-01 Thread Steve D'Aprano
. Does gcc support static linking? Even if I end up with a much bigger binary, at least I know it will have everything it needs to run and I won't have to deal with DLL hell. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: unintuitive for-loop behavior

2016-10-01 Thread Steve D'Aprano
On Sat, 1 Oct 2016 09:33 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: > >> # create a new binding >> x: address 1234 > [ box contains 999 ] >> x: address 5678 > [ a different box, containing 888 ] > > In the context of CPython and nes

Re: unintuitive for-loop behavior

2016-10-01 Thread Steve D'Aprano
prehension-ified If your students think in terms of map, then fine, but I think it would confuse more people than it would help. Your mileage may vary. There are certainly a number of ways to get the desired behaviour. If you prefer to work with map, go right ahead. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Copying a compiled Python from one system to another

2016-10-01 Thread Steve D'Aprano
On Sun, 2 Oct 2016 09:31 am, Paul Rubin wrote: > Steve D'Aprano writes: >> However I do have access to another machine (actually a VM) which can >> compile Python 3.6. It's not practical for me to use it as a my main >> development machine, but as a tempo

Re: announcing fython

2016-10-01 Thread Steve D'Aprano
y the same way, neither by value nor by reference. http://import-that.dreamwidth.org/1130.html -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: unintuitive for-loop behavior

2016-10-01 Thread Steve D'Aprano
ing. tabulate() has a single scope, fabulate() has multiple scopes because it has inner functions that take i as argument, making them local to the inner functions. Um, yeah, of course they are different. They're different because you've written them differently. What's your point? As far

Re: Copying a compiled Python from one system to another

2016-10-01 Thread Steve D'Aprano
On Sun, 2 Oct 2016 12:30 am, Zachary Ware wrote: > On Oct 1, 2016 06:25, "Steve D'Aprano" wrote: >> >> Long story short: I have no working systems capable of compiling the > latest >> Python 3.6, and no time to upgrade my usual machines to something which

Re: Copying a compiled Python from one system to another

2016-10-01 Thread Steve D'Aprano
o build CPython 3.6, and the most recent any of my systems support is 4.4. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: unintuitive for-loop behavior

2016-10-01 Thread Steve D'Aprano
On Sun, 2 Oct 2016 11:44 am, Gregory Ewing wrote: > Steve D'Aprano wrote: >> When you say: >> >> x = 0 >> x = 1 >> >> inside a function, and the interpreter does the name binding twice, >> there's no way of telling whether it write

Re: unintuitive for-loop behavior

2016-10-02 Thread Steve D'Aprano
On Sun, 2 Oct 2016 04:06 pm, Chris Angelico wrote: > On Sun, Oct 2, 2016 at 3:19 PM, Steve D'Aprano > wrote: >> In IronPython, you could have the following occur in a function locals, >> just as it could happen CPython for globals: >> >> - delete the nam

Re: unintuitive for-loop behavior

2016-10-02 Thread Steve D'Aprano
t we're in a rather murky part of Python's behaviour here, one where a clean name lookup model has been most definitely put aside in favour of speed, but it isn't quite clear whether this is defined language behaviour, reference behaviour that all implementations are require

Re: unintuitive for-loop behavior

2016-10-02 Thread Steve D'Aprano
had introduced it was an explanation like: "Here is a proof of concept that shows that Python could give for loops their own scope. If this Python code [nested for-loops] were translated mechanically by the compiler [nested while loops with iterators] then each loop would have their own scope."

Re: Copying a compiled Python from one system to another

2016-10-03 Thread Steve D'Aprano
On Sun, 2 Oct 2016 04:45 pm, Paul Rubin wrote: > Steve D'Aprano writes: >> Yes, this. You need gcc 4.8 or better to build CPython 3.6, and the most >> recent any of my systems support is 4.4. > > Building gcc takes a while but it's reasonably simple. Just start i

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Steve D'Aprano
rfaces* go, I'd like to see the research that proves that babies don't intuitively know how to suckle from a nipple. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Assignment versus binding [was Re: unintuitive for-loop behavior]

2016-10-03 Thread Steve D'Aprano
On Mon, 3 Oct 2016 04:15 pm, Jussi Piitulainen wrote: > Steve D'Aprano writes: >> Why shouldn't people say that binding and assignment are the same >> thing in Python? What's the difference? > > Outside Python, (lambda x : f(x)) is said to "bind" x.

Re: Assignment versus binding

2016-10-04 Thread Steve D'Aprano
understand what distinction you are trying to make. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Assignment versus binding

2016-10-04 Thread Steve D'Aprano
seconds, then print 2. Is that right? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Assignment versus binding

2016-10-04 Thread Steve D'Aprano
On Wed, 5 Oct 2016 06:10 am, Marko Rauhamaa wrote: > Steve D'Aprano : > >> On Tue, 4 Oct 2016 11:27 pm, Ben Bacarisse wrote: >> >>> Haskell defines let (it's version of multiple mutually recursive >>> bindings) in terms of the least fix point of a

Re: Assignment versus binding

2016-10-04 Thread Steve D'Aprano
On Wed, 5 Oct 2016 04:12 am, Rustom Mody wrote: > On Tuesday, October 4, 2016 at 10:06:00 PM UTC+5:30, Steve D'Aprano wrote: >> On Tue, 4 Oct 2016 09:32 pm, Rustom Mody wrote: >> >> > Are not the contents of the scope and the shape of the scope different >>

Re: static, class and instance methods

2016-10-06 Thread Steve D'Aprano
methods are decorated too > > @staticmethod > def funct3(a, b): > ... > > The 1st argument is not supposed to be automatically filled > So what the decorator used for ? > Just to distinguish funct3 from an instance method ? Correct. -- Steve “Cheer up,” they said, “t

Re: static, class and instance methods (Reposting On Python-List Prohibited)

2016-10-06 Thread Steve D'Aprano
om ? It doesn't. The descriptor protocol only gets called by classes, so when you call a function directly, the special __get__ method isn't used. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Copying a compiled Python from one system to another

2016-10-06 Thread Steve D'Aprano
On Fri, 7 Oct 2016 01:36 am, Ned Deily wrote: > On 2016-10-02 00:25, Steve D'Aprano wrote: >> On Sun, 2 Oct 2016 01:58 pm, Chris Angelico wrote: >>> Hmm, I've possibly missed something here, which may indicate a >>> problem. Why can't your existing machi

Re: User Interface Suggestions? (newbie)

2016-10-06 Thread Steve D'Aprano
etc) > then that would be useful to know too. (And how does curses manage it?!) I believe that curses uses a large database of terminal types and associated escape sequences. So when you start it up, it determines what terminal type you have (that's black magic itself) and then works out w

Re: BeautifulSoup help !!

2016-10-06 Thread Steve D'Aprano
bed." P.S. Desolate.Soul.Me, you might be taken a bit more seriously if you give a name, or at least a moniker or nick-name which is easier for others to refer to you by. It doesn't have to be your birthname, or legal name. What do your friends and workmates call you? I don't know Be

Re: BeautifulSoup help !!

2016-10-06 Thread Steve D'Aprano
. [3] Quite possibly the stupidest thing that has come out of academia since post-modernism. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: A newbie doubt on methods/functions calling

2016-10-06 Thread Steve D'Aprano
be to write your own pre-processor, which will parse your source code, and translate it from your language to valid Python. That's a lot of work for very little value -- I recommend you just learn the Python syntax rather than trying to force it to be something it is not. -- Steve “Cheer up,

Re: static, class and instance methods

2016-10-07 Thread Steve D'Aprano
.. py> hasattr(f.__get__, '__get__') False So what kind of thing is f.__get__? f itself is a function, which looks like this: py> f but f.__get__ is something different: py> f.__get__ "Method-wrapper" is an undocumented internal implementation detail. It isn'

Re: Doubled backslashes in Windows paths

2016-10-07 Thread Steve D'Aprano
spaces in them. The os.path and os functions do not need you to escape the file name with quotes to handle spaces. It is very likely that if you call out to another Windows program using the os.system() call you will need to worry about escaping the spaces, but otherwise, you don't need the

Re: default argument value is mutable

2016-10-07 Thread Steve D'Aprano
gt; example() 3081877100 [] py> example() 3081877100 [1] py> example() 3081877100 [1, 1] py> example() 3081877100 [1, 1, 1] -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: default argument value is mutable

2016-10-07 Thread Steve D'Aprano
*is* a standard idiom. > That is if you care about anyone reading your code ;) Here's another example of a mutable default argument: https://www.python.org/doc/essays/graphs/ Although it isn't actually being mutated. Nevertheless, if it is good enough for Guido, then it should be

Re: SyntaxError: multiple statements found while compiling a single statement

2016-10-07 Thread Steve D'Aprano
n File "", line 1 a=1 ^ SyntaxError: multiple statements found while compiling a single statement Notice how the compiler shows the offending line and puts a caret ^ at the end? Unless you show us what code actually causes this error message, I don't think it is poss

Re: SyntaxError: multiple statements found while compiling a single statement

2016-10-08 Thread Steve D'Aprano
ther copy and paste one line at a time, or you can use the File > Open menu command to open a complete script. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Steve D'Aprano
t of things, including globals(), map(), named exceptions, "" strings ('' is okay), exponentiation, and more. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Steve D'Aprano
On Sun, 9 Oct 2016 05:45 am, Random832 wrote: > On Sat, Oct 8, 2016, at 07:29, Steve D'Aprano wrote: >> The oldest version I have access to is the *extremely* primitive 0.9. Not >> surprisingly, it doesn't have xrange -- but it lacks a lot of things, >> in

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Steve D'Aprano
ception: type error: illegal argument type for built-in operation Stack backtrace (innermost last): File "", line 1 >>> d['1'] = 2 >>> print d {'1': 2} There are functions (def) but not lambda, but no `class` statement. Primitive days indeed. And yet already usable. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: SyntaxError: multiple statements found while compiling a single statement

2016-10-08 Thread Steve D'Aprano
t; error: > Traceback (most recent call last): > File "", line 1, in > while not done: > NameError: name 'done' is not defined Right. That's because 'done' is not defined. Why don't you try my suggestion of saving the code into a .py fi

Re: SyntaxError: multiple statements found while compiling a single statement

2016-10-08 Thread Steve D'Aprano
lse >>>> pygame = True Why have you defined pygame = True? Is that what the code on the website does? My guess is that you are supposed to say: import pygame Why don't you try my suggestion of saving the code into a .py file, then using the File > Open command to open it?

Re: Function to take the minimum of 3 numbers

2016-10-10 Thread Steve D'Aprano
;= c means a <= b and b <= c which is False for a = 1, b = 3 and c = 2. > Using consistent operators is not required but is easier to read and less > confusing. Indeed. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Deviding N(1, 2, 3, .., N) part from numeric list as summation of each values(don't sorted) has highest as possible.

2016-10-10 Thread Steve D'Aprano
t; N=3 part. I do not understand, what do you mean "dividing N=3 part"? Could you do this? [10,20,30,40,110,50,18,32,5] split into three lists: [10,20,30,40,110,50,18], [32], [5] Or these three lists: [10], [20,30,40,110,50,18], [32,5] Or these three lists: [10,20,30], [40,110

Re: Python Shell in Russian exists/possible??

2016-10-11 Thread Steve D'Aprano
://www.chinesepython.org/english/english.html or at least was very serious a few years ago. Unfortunately I don't know if it is still maintained. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to process syntax errors

2016-10-11 Thread Steve D'Aprano
ns calling" from last week. I believe that he hasn't given up on the hope to avoid writing parentheses and just use spaces, even though we've already explained that is ambiguous: func a b c # is that func(a, b, c) or func(a(b, c)) or func(a, b(c)) or ... ? I don't believe t

Re: Python code is compiled before execution

2016-10-11 Thread Steve D'Aprano
On Wed, 12 Oct 2016 12:19 am, BartC wrote: > Python is not really suited for AOT native-code compilation. You might be right, but the author of Nuitka disagrees. http://nuitka.net/ Nice to see that there's a new release, only a week or so ago! -- Steve “Cheer up,” they said,

<    4   5   6   7   8   9   10   11   12   13   >