Re: RFC: Proposal: Deterministic Object Destruction

2018-03-03 Thread Gregory Ewing
ooom...@gmail.com wrote: Well he was not telling you the whole story: RAII works just as well with heap objects using smart pointers (unique_ptr and friends) which are a closer analogy to python object references. By that definition, *all* resource management in Python is based on RAII[1]. The

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Gregory Ewing
Paul Rubin wrote: Richard Damon writes: a class to define member functions like __ref__ and __unref__ (or perhaps some other name) that if defined, would be called every time a name was bound or unbound to an object? That sounds horrendous and wouldn't handle the case of a list element creat

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Gregory Ewing
Steven D'Aprano wrote: Not just the class __dict__. You would have to do a full search of the MRO looking for any superclass which defines such methods. That could be reduced a lot by making it a type slot. But it would still increase the overhead of every refcount change by at least a factor o

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Gregory Ewing
Richard Damon wrote: The idea was to have a way to mark that certain classes/objects request that they are reference counted so they get the __del__ called as soon as the last reference goes away, without needing to require that overhead for all objects in all implementations. That could be

Re: "built-in" callables?

2018-03-05 Thread Gregory Ewing
Stefan Ram wrote: . So, what does "built-in" in the sense of »isbuiltin« actually mean? It means "implemented in C". Yes, this is confusing. The term "built-in" is used in two different ways, and you just have to disambiguate them from context. -- Greg -- https://mail.python.org/mailman/

Re: What's the best way to minimize the need of run time checks?

2016-08-09 Thread Gregory Ewing
Juan Pablo Romero Méndez wrote: This is interesting. You are Ok having runtime errors? You're going to have runtime errors in any case, whether they come from code you've put there yourself to check types, or from somewhere deeper down. The only difference is that checks you make yourself *mi

Re: ctypes And The WACAH Principle

2016-08-09 Thread Gregory Ewing
Lawrence D’Oliveiro wrote: When using array objects from code written in C or C++ (the only way to effectively make use of this information), it makes more sense to use the buffer interface supported by array objects. Ah, I wish... I had a look at the documentation for the buffer interface and

Re: ctypes And The WACAH Principle

2016-08-10 Thread Gregory Ewing
Lawrence D’Oliveiro wrote: It will let you create non-leaky wrappers ... Why would I want to do that? You mentioned that ctypes wrappers are leaky, which I assumed was meant as a criticism. But if you *like* your wrappers to be leaky, by all means go for it. :-) -- Greg -- https://mail.pyth

Re: Make sure you removed all debugging print statements error

2016-08-10 Thread Gregory Ewing
Chris Angelico wrote: I suppose you could put down Kelvin as a last name and either Baron or Lord as a first name, but that'd just be cheating... Or put NULL as the first name and have fun watching the database break. http://www.wired.com/2015/11/null/ Or perhaps even profit: http://www.dail

Re: What's the best way to minimize the need of run time checks?

2016-08-10 Thread Gregory Ewing
Dennis Lee Bieber wrote: Stray gamma rays flipping bits in memory (though a bit harder to do, considering the firmware was in some hard-wired mess of core, I think the RAM was core too, so pretty much immune to gamma rays as well (at least at any intensity that wouldn't instantly kill the crew)

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Gregory Ewing
Steven D'Aprano wrote: To be honest, I don't remember. It was so-called "Lightspeed Pascal", later renamed "Think Pascal", and especially after that experience I mostly used it for experimenting with Hypertalk XCMDs and XFNCs, which were much simpler as they weren't stand-alone GUI applications.

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread Gregory Ewing
Terry Reedy wrote: What the *current* version removed from an earlier version is that there was a clear community consensus against the condition-in-the-middle syntax Guido proposed The way I remember it, condition-in-the-middle was first suggested by others, and Guido expressed dislike for it

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread Gregory Ewing
Terry Reedy wrote: One of the ironies (or puzzles) of Guido's choice is that he once condemned Perl's 'value if cond' as wretched. I don't think that's the same thing. Perl allows 'statement if cond' as an alternative way of writing "if (cond) statement'. Nobody has ever seriously considered al

Re: type lookuperror

2016-08-18 Thread Gregory Ewing
Chris Angelico wrote: You can't get a program to program itself. That's called the Singularity [1], and depending on your point of view, it's either still in the future, or fundamentally impossible. Quite likely it's provably impossible. A computer that can program itself for anything you might

Re: type lookuperror

2016-08-18 Thread Gregory Ewing
Chris Angelico wrote: If you're specifying them formally, you're probably coding them. Any form sufficiently well-defined for a program to analyze is basically code already. Yes, I think that once a specification language crosses a certain threshold of complexity, it becomes just as difficult t

Re: PEP 492: isn't the "await" redundant?

2016-08-26 Thread Gregory Ewing
Marko Rauhamaa wrote: How about making *every* function *always* and async, unconditionally? That way *every* function would be an async and every function call would be an await. 1. Many people regard it as a feature that you can see where potential suspension points are. 2. Doing this would

Re: [OT] Altair

2016-09-01 Thread Gregory Ewing
Christopher Reimer wrote: The first time I came across a paper tape reader when I visited the university as a teenager in 1984. A CNC machine read the paper tape to drill six holes in a piece of metal. I think that would have just been called NC (Numerical Control). CNC (Computer Numerical Con

Re: [OT] Altair

2016-09-01 Thread Gregory Ewing
Grant Edwards wrote: The file containing the list of coordinates generated by a CAD program for holes in a circuit board is still often referred to as a "drill tape". Yep, and we talk about "core" memory, use a "tape archive" program to produce compressed files, and have "drives" with no movin

Re: What's the best way to minimize the need of run time checks?

2016-09-01 Thread Gregory Ewing
Chris Angelico wrote: You might have won the 100m dash, except that we couldn't verify your velocity of locomotion without a... run time check. Badumtish. All is not lost. You just need to devise a type system capable of proving that his time is faster than any other runner in all possible rac

Re: The Joys Of Data-Driven Programming

2016-09-01 Thread Gregory Ewing
Paul Moore wrote: Is there any "make replacement" out there that focuses more on named sets of actions (maybe with prerequisite/successor type interdependencies), and less on building file dependency graphs? Possibly Gradle might qualify. I only have a hazy understanding of it (basically just w

Re: *args and **kwargs

2016-09-02 Thread Gregory Ewing
Ben Finney wrote: in the definition of the function, parameters are neither positional nor keyword. In Python 3 that's not quite true -- it's possible to define "keyword only" parameters that can't be passed positionally. However, it's true that any of the "ordinary" parameters (ones that aren

Re: manually sorting images?

2016-09-04 Thread Gregory Ewing
Quivis wrote: 2. You want to sort them according to red houses, blue houses, green trees, yellow trees (that's autumn leaves), cats, dogs, children, elderly people, But... but... what if you have a picture of a child playing with a dog that's chasing an elderly cat up a yellow tree in front of

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Gregory Ewing
Larry Hudson wrote: If you continue to read this forum, you will quickly learn to ignore "Pointy-Ears". He rarely has anything worth while to post, and his unique fetish about Real Names shows him to be a hypocrite as well. To be fair, it's likely that Thomas Lahn is his real name, and he's n

Re: Why doesn't my finaliser run here?

2016-09-04 Thread Gregory Ewing
Chris Angelico wrote: There's a reference here somewhere, though. My suspicion is it's in sys.exc_info / sys.last_traceback, It's sys.last_traceback: >>> e = Eggs() instance created successfully ('self definitely exists:', <__main__.Eggs object at 0x2b6670>) Traceback (most recent call last):

Re: [Python-ideas] Inconsistencies

2016-09-13 Thread Gregory Ewing
Marko Rauhamaa wrote: It has been prophesied that God will eventually write a Version 2 of the universe which will have most of the known glitches in Version 1 fixed. Well, He did release a Religion 2.0 and sent His son to install it, but some users resisted the upgrade and crucified him before

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

2016-09-15 Thread Gregory Ewing
Dennis Lee Bieber wrote: And then there is Pratchett's Discworld... which is both flat and round (just not spherical) And it has a horizon -- if you go far enough you fall off the edge. -- Greg -- 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-15 Thread Gregory Ewing
Marko Rauhamaa wrote: It is actually quite interesting how the brain forms an accurate idea of a straight line and, say, a circle. Whenever you get a new pair of glasses, the brain needs a recalibration and manages to do it within a week. I had an interesting experience in that area a few years

Re: how to automate java application in window using python

2016-09-17 Thread Gregory Ewing
Lawrence D’Oliveiro wrote: On Friday, September 16, 2016 at 10:22:34 PM UTC+12, Christian Gollwitzer wrote: "How do I automate a Java application using Python?" Which is really a meaningless question. “Automation” is what computer programs do. It's not meaningless. The term "automation" is

Re: Cython taking more time than regular Python

2016-09-20 Thread Gregory Ewing
Christian Gollwitzer wrote: However, I'm not convinced it did succeed here. An evaluation of the Gauß formula would run in a few *nanoseconds* on any moddern machine. It may take a microsecond to call a functino from Python. a hundred microseconds means that the loop does run. Obviously the c

Re: Cython taking more time than regular Python

2016-09-21 Thread Gregory Ewing
Lawrence D’Oliveiro wrote: Don’t forget “functino”. :) ... is that the gauge boson for the function field? Or is that a “functon”? One of them might be spin-½ ... A functino would be the supersymmetric partner of a bosonic function. For a fermionic function, its partner would be a sfunction.

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Gregory Ewing
eryk sun wrote: Actually in a Unix terminal the cursor can also be at the end of a line, but a bug in Python requires pressing Ctrl+D twice in that case. I wouldn't call that a bug, rather it's a consequence of what Ctrl-D does. It doesn't really mean EOF, it means to send whatever the terminal

Re: strings and ints consistency - isinstance

2016-09-22 Thread Gregory Ewing
On Wednesday, September 21, 2016 at 11:41:42 PM UTC-4, Sayth Renshaw wrote: answer = input("\t >> ") if isinstance(int(answer), int) is True: raise ValueError("Ints aren't valid input") You seem to be trying to check that the user hasn't entered an integer. But that's a backwards way of loo

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Gregory Ewing
eryk sun wrote: if we see a read that returns less than the buffer size but doesn't end on a newline, then for a terminal, and only a terminal, I think we can infer Ctrl+D was typed and handle it as EOF. I don't think it would be wise to rely on that. There is no promise that any given read() c

Re: Nested for loops and print statements

2016-09-26 Thread Gregory Ewing
Cai Gengyang wrote: I'll still be asking for help here. Please help out a newbie. We're trying to help, but we need to know more about the environment you're using to enter your code. What operating system are you using? How are you running the interactive interpreter? Are you using IDLE, or

Re: Nested for loops and print statements

2016-09-27 Thread Gregory Ewing
Cai Gengyang wrote: How are you running the interactive interpreter? Are you using IDLE, or are you running Python in a command window? --- IDLE I don't normally use IDLE on MacOSX, so I had to try it to find out. I think I know what your problem is now. When you type a line into IDLE ending w

Getting IDLE to use correct Tcl/Tk on MacOSX 10.6?

2016-09-27 Thread Gregory Ewing
I don't normally use IDLE, but I had occasion to use it on MacOSX 10.6 to answer someone's question, and of course it didn't work properly due to Apple's broken Tcl/Tk. I followed the advice to install ActiveState Tcl 8.5.18.0, but my Python still wants to use Apple's Tcl. How do I persuade Pyth

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

2016-09-27 Thread Gregory Ewing
Lawrence D’Oliveiro wrote: On Wednesday, September 28, 2016 at 3:35:58 AM UTC+13, Peter Otten wrote: is Python actually a "functional language"? Yes . No, not according to what the term "functional language" usually

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

2016-09-27 Thread Gregory Ewing
Peng Yu wrote: On Tue, Sep 27, 2016 at 10:01 AM, Chris Angelico wrote: """In some languages, the variable bindings contained in a closure behave just like any other variables. Alas, in python they are read-only.""" This is not true, at least as of Python 3. So in Python 2, this is true? P

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

2016-09-28 Thread Gregory Ewing
Chris Angelico wrote: wrote: * No side effects (new variable bindings may be created, but existing ones cannot be changed; no mutable data structures). If that's adhered to 100%, the language is useless for any operation that cannot be handled as a "result at end of calculation" function.

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Gregory Ewing
dieter wrote: dl l writes: When I debug in C++, I see the reference count of a PyObject is 1. >> How can I find out where is referencing this object? Likely, it is the reference, you are holding: Unless you've just Py_DECREFed it, expecting it to go away, and the recfcount is still 1, in

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Gregory Ewing
Chris Angelico wrote: If you've Py_DECREFed it and then peek into its internals, you're aiming a gun at your foot. That's true. A safer way would be to look at the refcount *before* decreffing and verify that it's what you expect. -- Greg -- 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 Gregory Ewing
Paul Moore wrote: What "allows side effects" in languages like Haskell is the fact that the runtime behaviour of the language is not defined as "calculating the value of the main function" but rather as "making the process that the main functon defines as an abstract monad actually happen". Tha

Re: unintuitive for-loop behavior

2016-09-29 Thread Gregory Ewing
namenobodywa...@gmail.com wrote: > can anyone help to reconcile me to this semantics? Not really. Most people agree that it's not desirable behaviour, but we've ended up here due to a convoluted history, and there doesn't seem to be a good way to fix it without breaking a lot of existing code. C

Re: unintuitive for-loop behavior

2016-09-30 Thread Gregory Ewing
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 be separate namespaces: There's an important difference between a for-loop and an if-statement that's relev

Re: unintuitive for-loop behavior

2016-09-30 Thread Gregory Ewing
Steve D'Aprano wrote: What happens if it is *not* a misfeature? Gotchas are not always misfeatures -- sometimes gotchas are gotchas because people's expectations are simply wrong, and pandering to their confused expectations does not actually help them. I haven't made up my mind about *this* spe

Re: unintuitive for-loop behavior

2016-10-01 Thread Gregory Ewing
Random832 wrote: > for a in collection: > b = some_calculation_of(a) > final b: do_something_with(lambda: ... b ...) I would prefer something like for a in collection: let b = some_calculation_of(a): do_something_with(lambda: ... b ...) -- Greg -- https://mail.python.org/ma

Re: unintuitive for-loop behavior

2016-10-01 Thread Gregory Ewing
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 nested functions, replace "box" with "cell". When I said "creating a new binding" I meant that the name x refers to

Re: unintuitive for-loop behavior

2016-10-01 Thread Gregory Ewing
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 writes to the same cell each time or not. Yes, there is: ... x = 0 ... f1 = lambda: x ... x = 1 ... f2 = lambda: x ... print(f

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

2016-10-01 Thread Gregory Ewing
Sayth Renshaw wrote: def dataAttr(roots): """Get the root object and iter items.""" with open("output/first2.csv", 'w', newline='') as csvf: race_writer = csv.writer(csvf, delimiter=',') for meet in roots.iter("meeting"): The value of roots you're passing in here is a ge

Re: Lawrence D'Oliveiro

2016-10-01 Thread Gregory Ewing
On Fri, 30 Sep 2016 23:29:41 -0700, Paul Rubin declaimed the following: That's the weird Italian spam that the newsgroup has been getting for a while. I've been wondering for a while if anyone knows what the story is, i.e. why it's on comp.lang.python but not on other newsgroups that I've noti

Re: unintuitive for-loop behavior

2016-10-03 Thread Gregory Ewing
Steve D'Aprano wrote: No it doesn't mean that at all. The result you see is compatible with *both* the "update existing slot" behaviour and "create a new slot" behavior. We're getting sidetracked talking about slots here. It's not really relevant. The point is that there is only *one* binding f

Re: unintuitive for-loop behavior

2016-10-03 Thread Gregory Ewing
Chris Angelico wrote: The only way to prove that something is a new binding is to demonstrate that, when this binding is removed, a previous one becomes visible. Or capture them both with closures and show that each closure sees a different version of the binding. -- Greg -- https://mail.pytho

Re: unintuitive for-loop behavior

2016-10-03 Thread Gregory Ewing
Steve D'Aprano wrote: x = str = 1 assert x == 1 and str == 1 del x, str assert str # succeeds assert x # NameError x = str = 2 # create new bindings, or update existing ones? Is it our conclusion that therefore Python creates a new binding for str but not for x? Or that the evidence for x is

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

2016-10-03 Thread Gregory Ewing
Rustom Mody wrote: My new car goes in reverse when I put it in first gear but only on full-moon nights with the tank on reserve when the left light is blinking OT aside: When I went to take my current car (a manual) for a test drive, I had to stop and ask the dealer how to put it into reverse.

Re: Create a map for data to flow through

2016-10-03 Thread Gregory Ewing
Sayth Renshaw wrote: Is there a standard library feature that allows you to define a declarative map or statement that defines the data and its objects to be parsed and output format? Not really. Just wondering as for loops are good but when i end up 3-4 for loops deep and want multiple match

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

2016-10-03 Thread Gregory Ewing
BartC wrote: On 03/10/2016 12:53, Marko Rauhamaa wrote: Well, it could be worse. This layout is pretty traditional: 1 3 5 | | | +--+--+ | | | 2 4 R Yes, you get a funny grinding sound when attempting to change from 5th to '6th' at 70mph/110kph. Fortunately it doe

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

2016-10-03 Thread Gregory Ewing
On Mon, 3 Oct 2016 10:57:27 -0700 (PDT), sohcahto...@gmail.com declaimed the following: > My car is similar, but the R is actually to the left of 1. It looks like this: R 1 3 5 +-+-+-+ 2 4 6 Mine is actually like that too, but it feels like you're doing the same thing in both cases -- push l

Re: Assignment versus binding

2016-10-04 Thread Gregory Ewing
Steve D'Aprano wrote: And (shamelessly using Python syntax) if I have a function: def spam(x): print(x) print(x+1) > > spam(time.sleep(60) or 1) You can't write that in Haskell, because Haskell's equivalent of print() is not a function (or at least it's not a function that ever return

Re: Assignment versus binding

2016-10-04 Thread Gregory Ewing
Chris Angelico wrote: So what happens if you have a monad "print to the console" in place of Steve's time.sleep example? Will you get one execution of it or two? Again, you wouldn't be able to write it that way in Haskell. The things you *would* be able to write would all have the property tha

Re: Assignment versus binding

2016-10-04 Thread Gregory Ewing
Chris Angelico wrote: Seriously though... this ties in with the other issues about *purely* functional languages being rather impractical, and the purity generally being sullied some by things like monads (which I still don't understand, despite the explanations in another thread). If you'd lik

Re: Assignment versus binding

2016-10-05 Thread Gregory Ewing
Chris Angelico wrote: How do you handle variadic functions? All functions in Haskell take exactly one argument, so there isn't really any such thing as a variadic function. The argument can be a list, however, so you can get the same effect. -- Greg -- https://mail.python.org/mailman/listinfo/

Re: Assignment versus binding

2016-10-05 Thread Gregory Ewing
Chris Angelico wrote: So how do you handle something that, by its nature, has BOTH side effects and a return value? A Pascal purist would probably say that you should make it a procedure, and use var parameters to pass back any results. In the case of something like the unix write() call, this

Re: Assignment versus binding

2016-10-05 Thread Gregory Ewing
BartC wrote: This is exactly why I persist with my own language implementations. My current one is only 1/5000th the size but standard libraries are included!) You might like to try a different Haskell implementation, such as Hugs: https://wiki.haskell.org/Hugs According to the web page, it c

Re: Assignment versus binding

2016-10-05 Thread Gregory Ewing
Chris Angelico wrote: Hence my query about how variadic functions and automatic currying work - how does it know whether to curry or run? Calling it "automatic" was probably a bad choice of words. I don't mean to imply that Haskell goes around currying things behind your back when you don't wan

Re: I am comfused about the name behavior of Python in recursion

2016-10-05 Thread Gregory Ewing
38016226...@gmail.com wrote: def rec(a): a+=1 if a<10: rec(a) print(a) rec(0) gives me 101 normally.Why it works? Because of the stack memory management? Yes. There isn't just one 'a' here, there's a different one each time rec is called. Thank yo

Re: Assignment versus binding

2016-10-06 Thread Gregory Ewing
Chris Angelico wrote: There's one other consideration. With Python functions, you often want to run a function for its side effects and ignore its return value. You can't just ignore a return value in Haskell. The return value is always going *somewhere*. If you leave off an argument, the resul

Re: Assignment versus binding

2016-10-06 Thread Gregory Ewing
Rustom Mody wrote: It is fair to say that Haskell's variadic function support is poorer than C's [Collecting into a list fails for different types If you want an arbitrary number of args of unrelated types, you would need to define a wrapper type that can encapsulate all the ones you're interes

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

2016-10-06 Thread Gregory Ewing
Lawrence D’Oliveiro wrote: Every function is already a descriptor. Which you can see with a simple experiment: >>> def f(self): ... print("self =", self) ... >>> g = f.__get__(17, None) >>> g >>> g() self = 17 -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Assignment versus binding

2016-10-06 Thread Gregory Ewing
Paul Rubin wrote: It's useful to write some Python things in monadic style, but monads make the most sense as type operators, which don't map onto Python that well. There probably isn't much point in using the monadic style in Python, since the main reason for it is to express stateful proces

Re: Assignment versus binding

2016-10-06 Thread Gregory Ewing
Ben Bacarisse wrote: import Control.Concurrent spam io = do x <- io; print x; print (x+1) main = spam (do threadDelay (2*10^6); return 1) It matches the Python in that the delay happens once. To get the behaviour being hinted at (two delays) you need to re-bind the I

Re: Question on multiple Python users in one application

2016-10-07 Thread Gregory Ewing
Loren Wilton wrote: I've read that Python supports 'threads', and I'd assumed (maybe incorrectly) that these were somewhat separate environments that could be operating concurrently (modulo the GC lock). Not really. Python threads are just a thin wrapper around OS threads, and don't provide an

Re: Question on multiple Python users in one application

2016-10-07 Thread Gregory Ewing
Loren Wilton wrote: One concern I have is if two users both "import widget". Are they now sharing the widget namespace? I suspect they are, and that is probably undesirable. Yes, they will be, unless you use sub-interpreters. I've just been looking at the current docs for sub-interpreters, and

Re: Question on multiple Python users in one application

2016-10-07 Thread Gregory Ewing
Dennis Lee Bieber wrote: What is it... A Burroughs mainframe running a version of FORTH? The Burroughs architecture is a stack architecture, so the machine code looks like a version of Forth in some ways. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Question on multiple Python users in one application

2016-10-07 Thread Gregory Ewing
Dennis Lee Bieber wrote: normally the main file of a Python program is still the plain text, It doesn't have to be, though -- you can do 'python somefile.pyc' and it will happily run it. and imported modules are retrieved from the file system as (if found) PYC pre-compiled, otherwise the text

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

2016-10-08 Thread Gregory Ewing
Cai Gengyang wrote: Somehow it still doesnt work --- it keeps giving the syntaxerror, inconsistent use of tabs and indentation message EVEN though i use only the enter and space buttons and never touched the tab button a single time. There was another thread about this a short time ago. It turn

Python-based monads essay (Re: Assignment versus binding)

2016-10-09 Thread Gregory Ewing
Here's the first part of the essay I said I'd write about monads: http://www.cosc.canterbury.ac.nz/greg.ewing/essays/monads/DemystifyingMonads.html Hope it's useful, Greg -- 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-09 Thread Gregory Ewing
Chris Angelico wrote: Fascinating! What about: except sys.intern('type error') ? Or does interning of strings not exist yet :) Even if it was, I don't think there was any guarantee that the "official" strings representing those exceptions would be interned. You were supposed to use the provide

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-09 Thread Gregory Ewing
Paul Rubin wrote: [h|t] should say h:t . Thanks, corrected. (You can probably tell I'm not a regular Haskell user. Not sure where I got [h|t] from -- maybe I was thinking of Prolog?) -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-09 Thread Gregory Ewing
Paul Rubin wrote: Gregory Ewing writes: http://www.cosc.canterbury.ac.nz/greg.ewing/essays/monads/DemystifyingMonads.html https://byorgey.wordpress.com/2009/01/12/abstraction-intuition-and-the-monad-tutorial-fallacy/ Well, at least I refrained from saying that monads are like burritos! I

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-09 Thread Gregory Ewing
Paul Rubin wrote: Well, at least I refrained from saying that monads are like burritos! But they are! See: http://blog.plover.com/prog/burritos.html Oh, undoubtedly. I just don't think it helps understand how burritos are used in prog... er, that is, how monads... well, you know what I mean.

Re: Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread Gregory Ewing
Dennis Lee Bieber wrote: VMS documentation set was around 60 linear inches (two 30" shelves) of 3-ring binders. Amiga RKMs were five volumes with the main documentation in fine print -- two "pages" side-by-side on a landscape page. Apparently if you're writing software for the US Air Fo

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-11 Thread Gregory Ewing
Anuradha Laxminarayan wrote: seq f g h = f (\s1 -> g h s1) better be written as seq f g x = f (\s1 -> g x s1) because naming conventions imply that h is function. Well, for the subset of monads I'm talking about, it always is a function -- it's the continuation to be run after f and g. -- G

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-11 Thread Gregory Ewing
Paul Rubin wrote: Also if this operation is what it looks like, it's usually called "bind". seq is something else entirely. Ah, I hadn't realised there was already a function in Haskell called seq -- sorry about that! I don't really want to call the Python version 'bind', because it seems a b

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-12 Thread Gregory Ewing
Steven D'Aprano wrote: "the implementation is free to use in-place mutations of the state object – ... without letting anyone know that the implementation has given up any functional purity." If it's impossible to tell that functional purity has been given up, then in what sense has it been gi

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-13 Thread Gregory Ewing
Steve D'Aprano wrote: The way you can usually tell your functional language has given up purity in favour of mutating implementations is that your code actually runs with non-toy amounts of data :-) Hmmm. Your argument here seems to be: "Everyone knows that functional languages are impractical,

Python-based monads essay part 2

2016-10-13 Thread Gregory Ewing
A bit more on SMFs, and then some I/O. http://www.cosc.canterbury.ac.nz/greg.ewing/essays/monads/DemystifyingMonads2.html -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-13 Thread Gregory Ewing
Marko Rauhamaa wrote: This suggests even the promoters of functional programming intuitively prefer imperative programming, but that's ok as long as it's all functional under the hood. You make it sound like functional programmers like functional programming because it gives them a warm fuzzy f

Re: Python-based monads essay part 2

2016-10-18 Thread Gregory Ewing
Chris Angelico wrote: You can take your original set-builder monad and turn it into genuinely functional code; show me that you can do the same with I/O. Otherwise, what you're really saying is "we can cheat until we can do I/O", not "we can do I/O in a functional way". I don't think I'm saying

Re: Python-based monads essay part 2

2016-10-20 Thread Gregory Ewing
Chris Angelico wrote: Okay. Now let's suppose that, instead of "73" in the first step, you have "ask the user for an integer". Are you allowed to eliminate this prompt, since the result of it cannot possibly affect anything? That's an excellent question. The answer is no, you're not allowed to

Re: Python-based monads essay part 2

2016-10-20 Thread Gregory Ewing
Marko Rauhamaa wrote: def main(): try: guard_it() except ValueError: # I'm having none of it! resume "CarryOn!" The problem is, how can the file f unclose itself when work resumes? The same thing could happen in Scheme, though. Re-enteri

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-27 Thread Gregory Ewing
BartC wrote: "There's a room in your house with no door to it; how do I get in?" "There's no need for a door because no one ever uses that room! But you can get in through the chimney - if you /have/ to." It's not like that. The room *does* have a door, it's just that it's in different places

Re: Recursive generator in Python 3.5

2016-10-31 Thread Gregory Ewing
tpqnn...@gmail.com wrote: def fg(args): if not args: yield "" return for i in args[0]: for tmp in fg(args[1:]): yield i + tmp return The final return is redundant, since there is an implicit return at the end, just like an ordinary function. The other one is just perfor

Re: if iter(iterator) is iterator

2016-11-13 Thread Gregory Ewing
Antoon Pardon wrote: def bar(iterator): if iter(iterator) is iterator: ... That's a way of finding out whether you can safely iterate over something more than once. If the object is already an iterator, applying iter() to it will return the same object, and iterating over it will c

Re: Making stl files with python for 3d printing

2016-11-13 Thread Gregory Ewing
Poul Riis wrote: However, when sending the .stl file produced to a 3D-printer the vase comes out as a filled solid - no room for water and flowers! My guess is that you have a problem with the orientation of your faces. The inner surface needs to have its triangles oriented so that their "outsi

Re: Best way to go about embedding python

2016-11-13 Thread Gregory Ewing
Michael Torrie wrote: And such bindings may need to be two-way. For example in Python code you may want to instantiate some new instance of game object, and you'll need to make sure that the wrapper code will create the appropriate in-game object. Another thing that can be tricky about this is

Re: Error in webscraping problem

2016-11-17 Thread Gregory Ewing
stanleydasilv...@gmail.com wrote: I am trying to solve the following problem. Two numbers appear on a website. The user has to enter the gcd (greatest common divisor) and hit the submit button. The catch is that the time limit is far too slow for any human processes -- it must be fully automate

Re: Extra base class in hierarchy

2016-11-19 Thread Gregory Ewing
Ian Kelly wrote: Is it better to introduce an extra base class? That's one possibility. An advantage would be that it would be easier to add methods in the future that apply to UsualTreeNodes but not FinalTreeNodes. Another possibility would be to just rename the classes. Instead of FinalTreeN

Re: Is this pythonic?

2016-11-23 Thread Gregory Ewing
Frank Millman wrote: For the time being I will use 'print(await obj.__str__())', as this is a good compromise. It seems more like a very *bad* compromise to me. I can't see how this gains you anything over just doing print(await obj.getvalue()), and you lose the ability to do anything that cal

Re: The Case Against Python 3

2016-11-25 Thread Gregory Ewing
Chris Angelico wrote: but brace-formatting lets you reorder the parameters, so it has flexibility that can be important for i18n. Actually, Python's version of %-formatting lets you reorder the parameters as well. The brace syntax for this is easier to read and write, though, so probably better

Re: The Case Against Python 3

2016-11-28 Thread Gregory Ewing
Steve D'Aprano wrote: I daresay you are right that a sufficiently clever adversary may have found an exploit. But there's no sign that anyone actually did find an exploit, until f-strings made exploiting this trivial. The person who wrote the bug report found at least one way of exploiting it t

<    1   2   3   4   5   6   7   8   9   10   >