Re: _sitebuiltins?

2017-09-25 Thread Steve D'Aprano
foo.__module__ will be 'spam'. But that's not a promise. It just means that the foo function happened to have been created inside the foo.py or foo.so file (or foo.dll on Windows?) but that isn't always the case. -- 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

Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Steve D'Aprano
uot;) (using Python syntax for simplicity) and somebody tries to tell me that the value of x is anything but a Parrot instance named "Polly", I have no time for that sort of nonsense. They might as well tell me that I'm typing this response on an elephant. > Can't we just

calling __del__ [was Re: [Tutor] beginning to code]

2017-09-25 Thread Steve D'Aprano
uldn't call dunder ("Double UNDERscore") methods directly unless you know what you're doing. You should consider them for Python's use only, unless explicitly told differently. Calling __del__ directly is *especially* fraught with problems. It does not delete the object. It just run

Reductionism gone mad [was Re: Call by binding]

2017-09-25 Thread Steve D'Aprano
here are trees, only self-organising collections of molecules; - or physicists denying that there are molecules, only quarks and electrons. But apparently reductionism is alive and well in computing. -- 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: Calling methods without objects?

2017-09-25 Thread Steve D'Aprano
nd methods no longer use the wrapper, and just return the function object itself. The wrapper can be found in the types module: from types import MethodType -- 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: Printing a Chunk Of Words

2017-09-25 Thread Steve D'Aprano
here's no built-in command in Python to do so, and to be honest, I'm not sure how to do it. -- 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: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Steve D'Aprano
e clear about it when you do. > Software gets complicated because it involves multiple levels of > abstraction layered on top of each other.  We might as well be arguing > like this: > > A: "The gas pedal makes the car go" > > B: "Nonsense! The g

Aliasing [was Re: [Tutor] beginning to code]

2017-09-26 Thread Steve D'Aprano
On Tue, 26 Sep 2017 03:26 am, Antoon Pardon wrote: >>> I'm not sure that Steve knows how it works. When he denies that the >>> assignment is an alias operation in Python that casts an important doubt. >> >> I can assure you that Steve knows how it works. A

Re: Parentheses (as after "print")

2017-09-26 Thread Steve D'Aprano
On Wed, 27 Sep 2017 06:00 am, Stefan Ram wrote: > Python could have taken the indentation of the > next line to tell that this is supposed to be > a function definition and not a function call. "Do What I Mean" (DWIM) programming is a terrible idea. -- Steve “Cheer up,”

Re: Boolean Expressions

2017-09-26 Thread Steve D'Aprano
est describes as "equals": False equals False gives True False equals True gives False True equals False gives False True equals True gives True -- 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: Aliasing [was Re: [Tutor] beginning to code]

2017-09-26 Thread Steve D'Aprano
On Wed, 27 Sep 2017 02:03 am, Stefan Ram wrote: > Steve D'Aprano writes: >>On Tue, 26 Sep 2017 03:26 am, Antoon Pardon wrote: >>>at that moment, but it still needed correction. If the assignment is >>>an alias operator then after the statements >>Her

Re: Spacing conventions

2017-09-27 Thread Steve D'Aprano
potential trouble in (really-long) real-world code. How so? Besides, if your code is "really long", you probably should factorise it into smaller, meaningful chunks. -- 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: Beginners and experts (Batchelder blog post)

2017-09-28 Thread Steve D'Aprano
is done and working correctly, and move on to the next project. *wink* -- 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: Spacing conventions

2017-09-28 Thread Steve D'Aprano
wouldn't say "Oh, the code crashed on line 587. I'll do a quick search for the closest break statement and start working from there." What do you do? -- 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

Textwrap doesn't honour NO-BREAK SPACE

2017-09-28 Thread Steve D'Aprano
etur adipiscing elit ZZZ ZZZ sed do euismod tempor incididunt ut labore et dolore magna aliqua. I'm pretty sure this is a bug. -- 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: Textwrap doesn't honour NO-BREAK SPACE

2017-09-28 Thread Steve D'Aprano
ed, or actual) is "this" in your comment. I wonder if the behaviour is platform specific? On Linux, I've tried Python 2.7 (after adjusting for a Unicode string rather than byte string), 3.3 and 3.5 and it breaks on the NO-BREAK SPACE on all three. -- Steve “Cheer up,” the

Re: Beginners and experts (Batchelder blog post)

2017-09-29 Thread Steve D'Aprano
s are bad.) I still haven't gotten over hearing about a bug in the Internet Explorer routines for handling WMF files, which lead to being unable to copy and paste plain text in any application. [2] The place I worked had a cuddly penguin toy called Mr Snuggles, and the programmers would go and explain the problem to him. It never[3] failed. [3] Well, hardly ever. -- 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: Textwrap doesn't honour NO-BREAK SPACE

2017-09-29 Thread Steve D'Aprano
On Fri, 29 Sep 2017 07:11 pm, Wolfgang Maier wrote: > On 29.09.2017 11:05, Wolfgang Maier wrote: >> On 29.09.2017 07:25, Steve D'Aprano wrote: >>> I'm pretty sure this is a bug. >>> >> >> Yes, it is a bug, but a known one: https://bugs.python.org

Re: Beginners and experts (Batchelder blog post)

2017-09-29 Thread Steve D'Aprano
On Fri, 29 Sep 2017 08:34 pm, D'Arcy Cain wrote: > On 09/29/2017 03:15 AM, Steve D'Aprano wrote: >> "Carefully-designed experiments" -- yeah, that is so totally how the coders >> I've worked with operate *wink* >> >> I think that&#x

Redirecting stdio streams with a context manager

2017-09-29 Thread Steve D'Aprano
__ save f1 in instance2._old_targets set sys.stdout = f2 # second call __exit__ restore sys.stdout = f1 # first call __exit__ restore sys.stdout = __stdout__ I'm not seeing why _old_targets is a list. Can anyone explain? -- Steve “Cheer up,” they said, “things could be worse.” So I

Re: Spacing conventions

2017-09-29 Thread Steve D'Aprano
On Fri, 29 Sep 2017 03:01 pm, Chris Angelico wrote: > On Fri, Sep 29, 2017 at 2:38 PM, Steve D'Aprano > wrote: >> On Thu, 28 Sep 2017 03:56 pm, Bill wrote: >> >>> I worked in maintenance programming. You got the hand you were dealt! >>> And you weren&#

Re: newb question about @property

2017-09-30 Thread Steve D'Aprano
@property def diameter(self): return 2*self.radius @property def area(self): return pi*self.radius**2 @property def circumference(self): return pi*self.diameter -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure en

Re: newb question about @property

2017-09-30 Thread Steve D'Aprano
criptors*. Properties are just one kind of descriptor, as are methods. But I'm intentionally not talking about the gory details of descriptors. Feel free to ask if you care, but honestly, you don't need to care unless you are writing your own descriptor class. -- 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: newb question about @property

2017-10-01 Thread Steve D'Aprano
eferences for descriptors which you think are good, I would > be interested. The definitive explanation of descriptors is here: https://docs.python.org/3/howto/descriptor.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: on a very slow function

2017-10-01 Thread Steve D'Aprano
ur algorithm is better than speeding up your code. > change it to > > last = (last**2 + c) % N > return next Better: last = (pow(last, 2, N) + (2 % N)) % N will almost certainly be faster for large values of last. -- Steve “Cheer up,” they said, “things could be wo

Re: on a very slow function

2017-10-01 Thread Steve D'Aprano
of digits or more. I just tried it with: last = 123456789012345**85 which has over 1000 digits, comparing: (last**2 + 17) % 95 versus: (pow(last, 2, 95) + (17 % 95)) % 95 and the second form is about ten times faster. But for smaller values of last, I agree, the first form

Re: newb question about @property

2017-10-02 Thread Steve D'Aprano
On Mon, 2 Oct 2017 05:34 pm, Marko Rauhamaa wrote: > I must say, though, I have yet to run into a need for descriptors. You've never called a method? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.py

Re: on a very slow function

2017-10-02 Thread Steve D'Aprano
ts represent thirty-eight thousand one hundred more duotrigintillions. A trifling number, much smaller than a googolplex. -- 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: newb question about @property

2017-10-02 Thread Steve D'Aprano
a gun to your head and forcing you to use @contextmanager. Its a convenience, nothing more. You can still write your own __enter__ and __exit__ methods if you prefer. -- 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: style: single and multiple lines

2017-10-02 Thread Steve D'Aprano
ances. Semi-colon separated statements are a convenience of use at the command line and REPL. -- 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: newb question about @property

2017-10-02 Thread Steve D'Aprano
On Tue, 3 Oct 2017 06:32 am, Bill wrote: > Steve D'Aprano wrote: >> Circle didn't use any setters, but I could have let you set the >> diameter, which in >> turn would set the radius: >> >> circle.radius = 2 >> assert circle.diameter == 4 >&

Re: INSTRUCTOR SOLUTIONS MANUAL Linear Systems And Signals 2nd ED by B P Lathi

2017-10-02 Thread Steve D'Aprano
are to hijack people's computers to send their spam, and you want to trust them and buy from them? -- 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: newb question about @property

2017-10-03 Thread Steve D'Aprano
duction of the @ syntactic sugar would have a big impact on the way people think about Python code. http://www.artima.com/weblogs/viewpost.jsp?thread=240808 Feel free to read his post before trying the problems I set. -- 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: newb question about @property

2017-10-03 Thread Steve D'Aprano
On Tue, 3 Oct 2017 10:01 pm, Lele Gaifax wrote: > Steve D'Aprano writes: > >> (9) [ADVANCED] Modify the decorator from (8) to take an argument specifying >> the path to a file, and use the logging module to log the details to that >> file instead of printing

Re: The "loop and a half"

2017-10-03 Thread Steve D'Aprano
On Wed, 4 Oct 2017 04:45 am, Rhodri James wrote: > On 03/10/17 18:29, Stefan Ram wrote: >>Is this the best way to write a "loop and a half" in Python? > > Define "best". I'd start with "define loop and a half". -- Steve “Cheer up,” t

Re: optional int- and float arguments

2017-10-03 Thread Steve D'Aprano
On Wed, 4 Oct 2017 03:18 am, Stefan Ram wrote: > »int« and »float« seem to behave quite similar: > > |>>> int( x = 8 ) > |8 > |>>> float( x = 8.0 ) > |8.0 I expect that these functions taking a *named* parameter "x" is an accident that should

Re: The "loop and a half"

2017-10-03 Thread Steve D'Aprano
On Wed, 4 Oct 2017 09:08 am, Stefan Ram wrote: > Steve D'Aprano writes: >>On Wed, 4 Oct 2017 04:45 am, Rhodri James wrote: >>>On 03/10/17 18:29, Stefan Ram wrote: >>>>Is this the best way to write a "loop and a half" in Python? >>>D

Re: optional int- and float arguments

2017-10-03 Thread Steve D'Aprano
On Wed, 4 Oct 2017 12:17 pm, Stefan Ram wrote: > |>>> str(object='abc') > |'abc' That's probably also a bug. -- 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: The "loop and a half"

2017-10-03 Thread Steve D'Aprano
sd whn u run ot n hav shrtg of vwel wth nt nuff 4 vrybdy. -- 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: on a very slow function

2017-10-03 Thread Steve D'Aprano
Modding the result of the > exponentiation might be useful for performance, but if c is expected > to be small then it may be pointless to mod that as well. > > py> ((2**75) % 12 + 7) % 12 # Still correct. > 3 Its been years since I've had to tackle modulo arithmetic, but the

Re: newb question about @property

2017-10-03 Thread Steve D'Aprano
ot in your little corner of the programming world, but there's an entire world out there. -- 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 best to initialize in unit tests?

2017-10-04 Thread Steve D'Aprano
ve to define some sort of super_initialize() function for your tests > which guarantees that your initialize function is called precisely > once? No. > This all seems rather messy. Indeed. And now you know why importing a module/package should be sufficient to initialise it

Re: Multithreaded compression/decompression library with python bindings?

2017-10-04 Thread Steve D'Aprano
much to ask (I haven't found anything myself after all), > if anyone here happens to have any experience using similar C++ (or > possibly C) libraries I am certainly open for any recommendations. :) > > Thanks in advance! > Thomas -- Steve “Cheer up,” they said, “things cou

Constants [was Re: newb question about @property]

2017-10-04 Thread Steve D'Aprano
time I accidentally reassigned to something intended as a constant. Nevertheless, constants are a safety net I would appreciate. [1] By which I mean names which can only be bound once, but not rebound. This is not about mutability, it is about whether or not the name can be rebound. -- Steve “Cheer

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
hers who have to read/maintain their > code wonder what it means." > > Exactly the same could be said of pretty much any of the advanced > features that have been added. People can say any old rubbish they like, and frequently do. -- Steve “Cheer up,” they said, “things co

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Wed, 4 Oct 2017 09:35 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>For-each loops are MUCH easier to understand, and should be taught first. > > I prefer a bottom-up approach. I prefer an effective approach that starts with the simplest concepts first, not the most

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
roduced to help with the while loop. This > boolean variable > is the condition that gets you out of the while loop and the first time > through it must > be set to get your code to execute the while loop at least one." I've been programming in Python for twenty years, and I do

Re: How best to initialize in unit tests?

2017-10-04 Thread Steve D'Aprano
at with unittest; doing so in doctest requires a bit more nuance and care, but is still possible. If this doesn't solve your problem, I'm afraid I don't understand your problem. -- 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: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 02:56 am, Paul Moore wrote: > On 4 October 2017 at 16:35, Steve D'Aprano > wrote: >> I've been programming in Python for twenty years, and I don't think I have >> ever once read from a file using a while loop. > > Twenty years isn&

Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Steve D'Aprano
alfway through the second course for students in the major, > not the sort of thing I would teach to this particular audience this early. > > But yes, we can use yield, and iter(), and itertools to do both of these > examples very clearly with a for loop (and without an explicit break &

Re: newb question about @property

2017-10-04 Thread Steve D'Aprano
n. It is a language wart and a trap for the beginner, or even the experienced coder. Use Python 3, where it is fixed. -- 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: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 09:42 am, Stefan Ram wrote: > Steve D'Aprano writes: >>>So, "bottom-up" in this case means: iterators should be >>>taught before for-loops. >>Why? > > The syntax for is (from memory): > > for in : >

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
ivalent high-level socket interface, like for files, so we can simply write something like: with Socket(spam) as mysock: for block in mysock(blocksize): ... I haven't done enough [read: any] socket programming to tell how useful and practical this is, but it seems like an obviou

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
rit. But you don't need to know the slightest thing about iterators in order to learn how to iterate over lists, strings, tuples, dicts etc. In fact, iterators are merely a subset of a more fundamental "kind" of object, iterables: anything which can be iterated over. -- Steve “C

Re: Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 01:21 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>At various stages of education, we teach many lies-to-children, including: > > Many of those lies can be perfectly true in some sense. Well of course, that's the whole point of them being &q

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 01:36 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>If you were teaching people to drive a car, would you insist on teaching >>them how to pull out and rebuild the engine before sitting them in the >>drivers seat? > > If I would have t

Re: Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Steve D'Aprano
sitron particles. In actual annihilation events, there is (as far as I know) generally a single real photon produced, with momentum equal to the sum of the momentum vectors of the original electron and positron. That moves away from the point of production at the speed of light. -- Steve “Che

OT aggression [was Re: Lies in education [was Re: The "loop and a half"]]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 02:54 pm, Chris Angelico wrote: > On Thu, Oct 5, 2017 at 2:22 PM, Steve D'Aprano > wrote: [...] >> In the East, while Japan did take the first overtly military action against >> the US, the US had (in some sense) first engaged in hostile behavi

Re: Constants [was Re: newb question about @property]

2017-10-04 Thread Steve D'Aprano
earn. When I first learned Python, they caused me trouble, and I'm sure they will cause any beginner to programming trouble. Adding constants to the language won't change that. Besides, if we had constants: const foo = 1234 then we could have: from demo import const foo -- 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

OT I before E [was Re: Lies in education [was Re: The "loop and a half"]]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 02:54 pm, Chris Angelico wrote: > On Thu, Oct 5, 2017 at 2:22 PM, Steve D'Aprano > wrote: >> It is, I think, an example of a stupid English language folklore that >> people repeat unthinkingly, even though the counter-examples are obvious >> and co

Re: newb question about @property

2017-10-04 Thread Steve D'Aprano
o, think rather of Terry Pratchett. +1 for mentioning Sir PTerry! And an extra bonus for it actually being relevant :-) -- 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: Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 03:54 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>In actual annihilation events, there is (as far as I know) >>generally a single real photon produced > > »There are only a very limited set of possibilities for > the final st

Re: newb question about @property

2017-10-05 Thread Steve D'Aprano
hand which will fill in the boilerplate for you: - an appropriate initialiser __init__ - a good-looking __repr__ - equality, inequality, and rich comparison operators; - an optional __hash__ method. https://www.python.org/dev/peps/pep-0557/ -- Steve “Cheer up,” they said, “things could be

Re: How to determine lowest version of Python 3 to run?

2017-10-05 Thread Steve D'Aprano
t* release, rather than the latest. If it works with (say) 3.5.0, then you should be safe to claim it works for all 3.5. But if it works for 3.5.4, say, you aren't *quite* so safe to make the same claim. -- 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

Pedagogical style [was Re: The "loop and a half"]

2017-10-05 Thread Steve D'Aprano
to concrete geometric terms, showing physical shapes divided into quarters, she could instantly tell that 1/4 plus 1/4 must be 1/2. As I said, anecdotes are not data, but when research claims to show that apples fall upwards in contradiction to anecdotal evidence that they fall downwards, we would be wise to be cautious before accepting the research as fact. -- 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: type and object

2017-10-05 Thread Steve D'Aprano
ts of Python, but don't worry about it. In practice, you almost never need to care about it. -- 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: why does memory consumption keep growing?

2017-10-05 Thread Steve D'Aprano
gh, and they'll need to buy another 16GB plus more downtime and more installation costs. Memory leaks expand to fill the available memory. -- 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: The "loop and a half"

2017-10-05 Thread Steve D'Aprano
nd line tool. But the OS is what it is, and the culture has a certain level of commandline machismo, so that's unlikely to change. -- 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: why does memory consumption keep growing?

2017-10-05 Thread Steve D'Aprano
ing; (2) rather than `del x`, try `x[:] = []`; (3) then if memory consumption stops increasing that may be evidence of a leak, and provide a reasonable work around until the leak can be fixed. But in a well-behaved program, you shouldn't need to manually delete x at all. -- Steve “Ch

Re: why does memory consumption keep growing?

2017-10-06 Thread Steve D'Aprano
On Fri, 6 Oct 2017 04:51 pm, Chris Angelico wrote: > On Fri, Oct 6, 2017 at 4:14 PM, Gregory Ewing > wrote: >> Steve D'Aprano wrote: >>> >>> Plus the downtime and labour needed to install the memory, if the computer >>> will even take it. >> >

Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-06 Thread Steve D'Aprano
a bit weird about using the magic constant 0 here. Is that guaranteed to be stdin on all platforms? Or should I be using sys.stdin.fileno()? -- 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: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-06 Thread Steve D'Aprano
n (possibly blocking, waiting for input). Is that right? But aren't there circumstances where fileno 0 isn't attached to a terminal, and writing a prompt would be inappropriate? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got wors

Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-06 Thread Steve D'Aprano
hen every time I'm on a different computer or running as a different user, I'd end up with the annoying default single column 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

Re: The "loop and a half"

2017-10-06 Thread Steve D'Aprano
Actually two: your OS's version of EOF (Ctrl-D on Unix-like systems, Ctrl-Z ENTER on Windows), plus at least one of the usual exit/quit/bye named commands. (Localised into whatever natural language you are using for the prompts.) -- Steve “Cheer up,” they said, “things could be worse.” So I

Re: The "loop and a half"

2017-10-06 Thread Steve D'Aprano
uot;treelang", whatever the hell that is. -- 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: callable values (was: Introducing the "for" loop)

2017-10-06 Thread Steve D'Aprano
't know whether German makes a practice of taking arbitrary verbs and adjectives and turning them into nouns, but English does, and so a callable object is just called a "callable". -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things go

Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-06 Thread Steve D'Aprano
bly including a kool new design that uses light grey text on an ever so slightly lighter grey background) and deleting any useful functionality that the lead developer personally doesn't use, because "nobody uses that". https://www.jwz.org/doc/cadt.html -- Steve “Cheer up,” the

Re: The "loop and a half"

2017-10-06 Thread Steve D'Aprano
. The sorts of games your students write use stdin to get input from the user, but they don't -- or at least, shouldn't -- merely dump the user at a bare screen with no prompt and no explanation of what they're supposed to do. -- 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: The "loop and a half"

2017-10-06 Thread Steve D'Aprano
ary file; - hit backspace to send it to the trash (27 steps). Yes, I can certainly see why you prefer that second work-flow to the first. Its so much more inefficient than memorising "Ctrl-D for EOF". I forget... it is "work harder, not smarter"? Being inefficient is a

Re: The "loop and a half"

2017-10-06 Thread Steve D'Aprano
en really useful. -- 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: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
On Sat, 7 Oct 2017 11:05 am, bartc wrote: > On 07/10/2017 00:43, Steve D'Aprano wrote: >> On Sat, 7 Oct 2017 12:24 am, bartc wrote: >> >>> print ("Enter blank expression to quit.") >> >> >> I *despise* programs that do that, and woul

Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-07 Thread Steve D'Aprano
he'd see the defaults, not Fred's settings, and could run source george to get his own settings. (Obviously Fred and George would have to create the "fred" and "george" config files first.) I don't know if Windows shells have something like bash's `source

Re: Introducing the "for" loop

2017-10-07 Thread Steve D'Aprano
this last sense (an instance of FunctionType) which people are thinking of when they state that range is not a function. -- 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: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
that. > Even though that method is not user-friendly True enough. `sort` is not designed to be a end-user application, although it can be used by the end-user. > and hardly anyone ever uses it in that mode. Translation: "I don't use it in that mode". > So that same unfr

Re: Warnings (was Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"])

2017-10-07 Thread Steve D'Aprano
e free to disable the warnings. Personally, I think Python gets it right: by default, warnings are only printed once each. Instead of getting a million WARNING: 32x32 icon missing, using 16x16 icon you only see it once. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up,

Re: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
standard keyboard shortcuts Ctrl-KW Ctrl-KY Ctrl-KR is better than memorising Ctrl-D which works across thousands of applications? Good for you. You probably would love Emacs, except other people use it, and therefore you will hate it. [...] > However, how hard would it for the editor to do its own sorting? Yes, it is a mystery to me why so few editors include a "sort lines" function. -- 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: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
he Mac software, making it essentially unusable. -- 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: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
On Sun, 8 Oct 2017 12:49 am, bartc wrote: > On 07/10/2017 14:19, Steve D'Aprano wrote: >> On Sat, 7 Oct 2017 11:06 pm, bartc wrote: > >> Ctrl-K to enter "operate on selected text" mode; >> Y to Delete >> Ctrl-K to enter "operate on selected text&

Re: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
On Sun, 8 Oct 2017 01:15 am, bartc wrote: > On 07/10/2017 14:19, Steve D'Aprano wrote: >> On Sat, 7 Oct 2017 11:06 pm, bartc wrote: > >>> So I have to copy 33,000 lines from a document, >> >> Don't be daft. Nobody says that stdin is a sufficient int

Re: Introducing the "for" loop

2017-10-07 Thread Steve D'Aprano
are values but classes are not (e.g. Java), then classes should be considered distinct from functions. As always, it depends on what you mean by function. -- 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: The "loop and a half"

2017-10-08 Thread Steve D'Aprano
u have >> configured as eof) at the command prompt. On windows, it's Ctrl-Z >> . > > Steve spoke about the 'usual quit/exit/bye' commands. As well as Ctrl-D, EOF, which is a standard way to exit most Unix programs. (Or as close as anything in Unix comes to a stan

Re: on = style

2017-10-09 Thread Steve D'Aprano
eptions (*ALL* of which are some form of in-line data table, and even then only rarely) any programmer who worries about lining up assignments on different lines like this is just engaged in a time-wasting exercise to make themselves look busy while actually taking it easy. It is a pure avoidance activity. -- 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: Lies in education [was Re: The "loop and a half"]

2017-10-09 Thread Steve D'Aprano
C, I don't think many people believe that it is a well-designed language. But even if it were the best language in the world, and Stroustrup the greatest language designer in the history of computing, what makes you think that he knows anything about teaching? -- Steve “Cheer up,” they said, “thi

Re: Is there a way to globally set the print function separator?

2017-10-10 Thread Steve D'Aprano
n objects which exist at the same time. If you delete an object, so the garbage collector reclaims its memory and reuses it, it is possible that the ID number may be reused as well.) -- 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: about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-10 Thread Steve D'Aprano
rying to attach attributes to arbitrary objects like None or "Hello World"? But certainly if you get something like UnicodeDecodeError or ImportError from trying to set an attribute, that's a bug in o.__setattr__ that needs fixing. -- Steve “Cheer up,” they said, “things could

Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Steve D'Aprano
ly the same between C and C++. Even two different C compilers could return different values. > Then we have syntactic problems: [...] I don't believe that anyone meant to imply that C++ is an exact superset of C. I know I didn't, although I acknowledge that my terminology was lazy. C+

Re: Looping [was Re: Python and the need for speed]

2017-10-11 Thread Steve D'Aprano
ns: > |You can use exception handling as a technique of last resort > |to handle unexpected events for which the normal control > |structures let you down. Even more ironically, exception handling is most similar to a COMEFROM, which was invented as a joke. -- 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: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Steve D'Aprano
On Thu, 12 Oct 2017 04:41 pm, Grant Edwards wrote: >> Even two >> different C compilers could return different values. > > Nope. If sizeof char is not 1, then it's not C. Today I Learned. Thank you to everyone who corrected me, even the person who said I was not

Re: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Steve D'Aprano
veloper's productivity. > [...] If I had to write a > high performance application these days I would reach > for C. -- 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: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Steve D'Aprano
1 byte = 32 bits? I don't suppose you remember the name of the machine do you? > Writing protocol code that dealt with the outside world via a serial > port was _painful_. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. --

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