Re: Python Interview Questions

2012-07-10 Thread BartC
ir pet project instead of what they're being paid for? There's also the risk of mixing up software created at home, with that done at work, with all the intellectual property issues that might arise. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread BartC
mechanism without cluttering up the rest of code with extra variables. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-20 Thread BartC
never be enough material, even using multiple systems of exponents. (A few years ago the biggest number I'd heard of was Skewes' Number (something like 10^10^10^34), but even that is trivial to write using conventional exponents as I've just shown. Graham's Number is in a different

Re: simplified Python parsing question

2012-08-03 Thread BartC
enario, they are effectively 'blind' too. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: f python?

2012-04-08 Thread BartC
ket and be instantly understood on the other end. But they can't contains nulls! Null terminated strings have simplified all kids of text manipulation, lexical scanning, and data storage/communication code resulting in immeasurable savings over the years. They both have their uses. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: f python?

2012-04-10 Thread BartC
y management arrangements, such a length need not be stored at all. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie, homework help, please.

2012-04-21 Thread BartC
len(s))+" *"+hozmargin) newtext.append(hozmargin+"* "+" "*maxwidth+" *"+hozmargin) newtext.append(hozmargin+"*"*(maxwidth+4)+hozmargin) for i in range(vertinchlines): newtext.append("") for s in newtext: print (s) -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie, homework help, please.

2012-04-21 Thread BartC
ed like this (obviously you will need to obtain SHI from the input file): SHI=["First Name and Last","ENGR 109-X","Fall 2999","Format Example"] textTuple = border(SHI) for lines in textTuple: print (lines) The text handling is clunky (I had to learn the Python as I went along), but with these things you just want to get something working first, then you can tweak. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie, homework help, please.

2012-04-21 Thread BartC
* Please post the output you're getting that has too many asterisks. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie, homework help, please.

2012-04-21 Thread BartC
"someone" wrote in message news:9533449.630.1335042672358.JavaMail.geo-discussion-forums@ynmf4... On Saturday, April 21, 2012 3:44:49 PM UTC-5, BartC wrote: Hi, Bart: Thank you, your post is working now, maybe, I did something wrong, unfortunately, you are right, my setup for g

Re: auto increment

2011-03-04 Thread BartC
I agree. Out of curiosity, what resulting bugs? Probably things like i=(++i)+(--i), although more of being indeterminate than a bug. That assumes that ++i was intended for use in an expression, rather than just be a statement. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: having both dynamic and static variables

2011-03-04 Thread BartC
27;pythonic'; certainly it's a crude, if effective, way of getting extra performance). -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: having both dynamic and static variables

2011-03-09 Thread BartC
mes is '#define' and 'enum', while what it calls 'const' is really 'read-only variable'), and perhaps Python is another. But then, the dividing line between constants and 'variables' can get confused when the values involved are complex (strings and such), so might be understandable up to a point. -- bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Python CPU

2011-04-02 Thread BartC
CPU, and it would be interesting to see how well it works. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-05-01 Thread BartC
useful in practice. Yes, it generates lots of calls. About 22000 for fib(20), and 330 million for fib(40). That's why it's popular for benchmarks that measure performance of function calls. Using an iterative algorithm wouldn't work quite so well... -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: += and =+

2017-09-13 Thread bartc
see if i now changes. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-17 Thread bartc
js> print(21) Javascript I believe uses C-like syntax. C syntax is also fond of unnecessary punctuation, and its 'printf' requires a format string full of format codes. Even more of a nuisance. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-17 Thread bartc
ey would need to be given different names to make things easier. Then there wouldn't be any argument. No more cryptic and ugly syntax for printing to a file. Setting the argument separator is easy. Instead of an obscure and easy to miss trick to suppress the end of line, you use an obvious and self-explanatory keyword argument. movedata(a, b, action='copy', depth='shallow') Self-explanatory keyword arguments, tick; as simple as just writing: a = b probably not! -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-18 Thread bartc
nctuation characters, of which half are shifted (on my keyboard). /And/ you have to select a suitable format code. Suddenly, having to type: print (a) doesn't seem so bad. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-18 Thread bartc
till useful for print to be a little special. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-19 Thread bartc
t me and said proudly "$10.03 is your change." My bill in a store came to £3.20 (GBP3.20), so I handed over £10.20. I was given back £16.90 in change! It turned out the cashier had entered £20.10 as the amount tendered. It was sorted out in the end. Sometimes its easier not to be bot

Re: Old Man Yells At Cloud

2017-09-19 Thread bartc
>>file, args` hack; - it can't be mocked, shadowed, monkey-patched or replaced for testing; - and you can't even write help(print) in the interactive interpreter because its a syntax error. Can't you get around all those with things like sys.stdout.write?

Re: Old Man Yells At Cloud

2017-09-19 Thread bartc
ces. The increase would actually be just over 2.1% (a £100 ex-VAT price increases from £117.50 to £120.00). Etc. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] beginning to code

2017-09-21 Thread bartc
of view of "intuitiveness".   It's much easier to tell what's going on, at a glance, in a C++ program. You're being serious, aren't you? -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] beginning to code

2017-09-22 Thread bartc
amp;a,value): a = value set(x,100) Here the type of x is irrelevant anyway. It doesn't even need to be initialised to anything first (that might violate something in Python, I don't know what). -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] beginning to code

2017-09-22 Thread bartc
given: A = [10,20,30] B = ["X","Y","Z"] and wanting to swap A[0] and B[2]. Although these being list elements, they /could/ be exchanged via a function: def swapelems(a,i,b,j): a[i],b[j]=b[j],a[i] swapelems(A,0,B,2) Just not using a general-purpose swap function. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] beginning to code

2017-09-22 Thread bartc
x.y, provided the term is mutable. (To make it work would require a new reference type. And extra versions of the byte-codes or whatever is used to evaluate terms such as: a, a[i], x.y that evaluate a reference rather than the value. So LOADFASTREF as well as LOADFAST) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-24 Thread bartc
his is why you can't change A in the caller as there is no way to get from X's box to A's box. And the strings to the object are one-way. In the case of fn(A+2), a new object is created (with value '3', or an existing '3' might be used), a new string is att

Re: Beginners and experts (Batchelder blog post)

2017-09-28 Thread bartc
ng (and fun, a lot of it), and the second is the usual lot of tools and technologies that programmers seems to have to know about these days (and not so much fun). -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Beginners and experts (Batchelder blog post)

2017-09-28 Thread bartc
On 28/09/2017 12:31, Steve D'Aprano wrote: On Thu, 28 Sep 2017 09:12 pm, bartc wrote: And I have little interest in most of this lot (my eyes glaze over just reading some of these): > - how to use operating systems You've never used a system call? Written to a file? Mo

Re: I'd like to use "semantic indentation"

2017-09-30 Thread bartc
def fn(*a): pass fn( country( 'USA' ), state( 'Alabama' ), town( 'Abbeville' ), town( 'Addison' ), state( 'Arizona' ), town( 'Apache Junction' ), town( 'Avondale' ), town( 'Benson

Re: on a very slow function

2017-10-02 Thread bartc
takes time. If it recalculates 'last' once for each of those couple of dozen printed lines, that I doubt accessing a few MB of memory is the issue. More doing such a big calculation. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: on a very slow function

2017-10-02 Thread bartc
On 02/10/2017 14:54, Peter Otten wrote: bartc wrote: On 02/10/2017 08:41, Peter Otten wrote: Daniel Bastos wrote: def make_sequence_non_recursive(N, x0 = 2, c = -1): "What's wrong with this function? It's very slow." last = x0 def sequence(): nonl

Re: newb question about @property

2017-10-03 Thread bartc
ss such code) still count as programming? It seems to me the equivalent of an advanced driving course teaching you how to customise your car rather than involving any actual driving. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: newb question about @property

2017-10-04 Thread bartc
On 04/10/2017 06:32, Steve D'Aprano wrote: On Wed, 4 Oct 2017 02:00 am, bartc wrote: Does all this advanced stuff (which I don't understand and which doesn't look very appealing either; hopefully I will never come across such code) still count as programming? I could not have

Re: The "loop and a half"

2017-10-04 Thread bartc
and-a-half. My proposed while-do has a less chaotic structure. It wouldn't preclude 'break' from still being used, but there would be less need. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-04 Thread bartc
ode wonder what it means." Exactly the same could be said of pretty much any of the advanced features that /have/ been added. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-04 Thread bartc
ns I counted at least half a dozen different ideas for implementing what the OP really wanted to do, which was expressed using C-like syntax. None of which were as obvious. And that C-like one worked because it could use an assignment within a while-condition. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: newb question about @property

2017-10-04 Thread bartc
On 04/10/2017 14:41, Ian Kelly wrote: On Wed, Oct 4, 2017 at 5:07 AM, bartc wrote: For that matter, I don't think Python has such a feature either. So that you write for example: const C = 123345 and then whenever C appears within the code, it's implemented as: LOAD_CON

Re: The "loop and a half"

2017-10-04 Thread bartc
ile by line or by byte won't work. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: newb question about @property

2017-10-04 Thread bartc
p := point(10,20) println p # (10.,20.) println p.bytes# 16 It's not Pythonic, but it is pretty handy (I know Python can also do structs like this but it appeared to be quite a slog last time I looked.) I guess my kind of coding is somewhat less esoteric than the kind of thing I typically see in Python here. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-05 Thread bartc
print ("You typed:", buffer) # process(buffer) print ("Bye") This is a loop-and-a-half. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-05 Thread bartc
On 05/10/2017 12:09, Chris Angelico wrote: On Thu, Oct 5, 2017 at 9:56 PM, bartc wrote: This doesn't make sense. For interactive use, you wouldn't bother testing for eof, as you'd be testing the eof status of the keyboard. You mean the way heaps and heaps of Unix programs w

Re: newb question about @property

2017-10-05 Thread bartc
On 05/10/2017 12:29, Gregory Ewing wrote: bartc wrote: Result? You can't just look at my 'any' class and see what fields it uses. You can't even just look at the static source code. You have to run the program to find out. And it might be different each time. You can

Re: The "loop and a half"

2017-10-05 Thread bartc
On 05/10/2017 18:01, Chris Angelico wrote: On Thu, Oct 5, 2017 at 10:26 PM, bartc wrote: On 05/10/2017 12:09, Chris Angelico wrote: On Thu, Oct 5, 2017 at 9:56 PM, bartc wrote: This doesn't make sense. For interactive use, you wouldn't bother testing for eof, as you'd be

Re: why does memory consumption keep growing?

2017-10-05 Thread bartc
ely too (temporarily of course). Other replies suggest that deleting the import [name] doesn't affect any data it contains. So might as well move it to the top where it belongs. del mystuff import mystuff mystuff.some_more_expensive_stuff( x ) You'll have to comment

Re: The "loop and a half"

2017-10-05 Thread bartc
On 05/10/2017 23:42, Gregory Ewing wrote: bartc wrote: It can be done with an in-band end-of-data code, Then you need some way of escaping that in-band code, in case it happens to equal some of the data you want to sort. It needn't be a big deal. You can do this (you have to in Pyth

Re: why does memory consumption keep growing?

2017-10-05 Thread bartc
rogram will only run on the programmer's machine and not a million consumer machines who would also need to fork out for extra memory. Their salaries may not stretch as far.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-06 Thread bartc
t hundreds of dialogue lines scrolling up the screen while it's doing so. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-06 Thread bartc
On 06/10/2017 12:04, Rhodri James wrote: On 05/10/17 19:45, bartc wrote: Yes, I tried typing 'sort' in Linux, where it apparently hangs (same on Windows actually). The reason: because it might have killed someone to have added a message saying what you are expected to type and how

Re: The "loop and a half"

2017-10-06 Thread bartc
On 06/10/2017 12:51, Chris Angelico wrote: On Fri, Oct 6, 2017 at 10:41 PM, bartc wrote: > What you REALLY mean is that you can't see the point of an interactive > sort command. It doesn't fit into your workflow. And that's fine. It's > not something you'

Re: The "loop and a half"

2017-10-06 Thread bartc
On 06/10/2017 12:45, Chris Angelico wrote: On Fri, Oct 6, 2017 at 9:32 PM, bartc wrote: (And properly, by being given the same of an actual file rather than using crude redirection.) Why do you call redirection "crude"? Do you not understand the value of generic solutions that wor

Re: newb question about @property

2017-10-06 Thread bartc
On 05/10/2017 14:13, Steve D'Aprano wrote: On Thu, 5 Oct 2017 10:51 pm, bartc wrote: Am I allowed to say that it all seems a bit of a mess? You may or may not be pleased to learn that there's a push to create a "record like" or "struct like" datatype for

Re: The "loop and a half"

2017-10-06 Thread bartc
On 06/10/2017 14:11, Peter J. Holzer wrote: On 2017-10-06 12:38, bartc wrote: On 06/10/2017 12:51, Chris Angelico wrote: What you REALLY mean is that you can't see the point of an interactive sort command. It doesn't fit into your workflow. And that's fine. It's not some

Re: The "loop and a half"

2017-10-06 Thread bartc
On 06/10/2017 14:35, Paul Moore wrote: On 6 October 2017 at 13:56, bartc wrote: If you don't like the word 'crude', try 'lazy'. Take this example of the gcc C compiler: > gcc -E program.c This preprocesses the code and shows the result. Typical programs will hav

Re: The "loop and a half"

2017-10-06 Thread bartc
On 06/10/2017 15:55, Chris Angelico wrote: On Fri, Oct 6, 2017 at 11:38 PM, bartc wrote: Have you ever worked on a slow remote session where a GUI is completely impracticable (or maybe even unavailable), and redrawing the screen is too expensive to do all the time? You absolutely have to

Re: The "loop and a half"

2017-10-06 Thread bartc
On 06/10/2017 18:42, Chris Angelico wrote: On Sat, Oct 7, 2017 at 4:13 AM, bartc wrote: So what's the excuse for an unresponsive text display in 2017? Got it. You assume that a system is a coherent computer with its peripherals, rather than being a networked collection of computers, a

Re: The "loop and a half"

2017-10-06 Thread bartc
On 06/10/2017 18:55, Marko Rauhamaa wrote: bartc : The internal utilities used within an operating system, primarily intended for file or redirected i/o with no live interaction, should be distinct from those designed to be used directly with a live user. Or is it against the rules of Unix to

Re: The "loop and a half"

2017-10-06 Thread bartc
On 06/10/2017 20:38, Grant Edwards wrote: On 2017-10-06, bartc wrote: For sort, there is no real need. You use a text editor to create your data. Then use existing file-based sort. I sort streams on stdin far more often than I sort named files. So what's been established is that 

Re: The "loop and a half"

2017-10-06 Thread bartc
On 06/10/2017 20:21, Chris Angelico wrote: On Sat, Oct 7, 2017 at 5:51 AM, bartc wrote: If you're stuck, whip out a tablet computer or smartphone (they should still function without connectivity) and use a preloaded text editor. Or just compose and then save an email. Even the sim

Re: The "loop and a half"

2017-10-06 Thread bartc
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 would cheerfully and unapologetically take their designers, disguise them as a lettuce, and stake them out t

Re: The "loop and a half"

2017-10-06 Thread bartc
On 07/10/2017 01:14, Ben Bacarisse wrote: bartc writes: On 06/10/2017 14:35, Paul Moore wrote: On 6 October 2017 at 13:56, bartc wrote: If you don't like the word 'crude', try 'lazy'. Take this example of the gcc C compiler: > gcc -E program.c This preproc

Re: The "loop and a half"

2017-10-07 Thread bartc
On 07/10/2017 02:46, Steve D'Aprano wrote: On Sat, 7 Oct 2017 06:18 am, bartc wrote: For sort, there is no real need. You use a text editor to create your data. Then use existing file-based sort. What you mean is, *you* see no need for sorting interactively, or sorting as part of a pip

Re: The "loop and a half"

2017-10-07 Thread bartc
with the next page. I think I did a 350-page manual like that. With pictures. My current language doesn't link its 'print' to graphic displays or images.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-07 Thread bartc
On 07/10/2017 09:35, Steve D'Aprano wrote: On Sat, 7 Oct 2017 11:05 am, bartc wrote: Um, that actually follows what interactive Python does. What is "that" to which you refer? If you mean, "what I, Bart C, suggested, namely having the program exit on a blank line"

Re: The "loop and a half"

2017-10-07 Thread bartc
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" mode; R to Read from a file (at last an actual mnemonic command!) enter a fil

Re: The "loop and a half"

2017-10-07 Thread bartc
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 interface for a heavy-weight task like that. With 33000 lines of text, I absolutely would save

Re: The "loop and a half"

2017-10-07 Thread bartc
On 07/10/2017 15:45, Grant Edwards wrote: On 2017-10-07, bartc wrote: Interactive Python requires quit() or exit(), complete with parentheses. Nonsense. On Unix you can just press ctrl-D (or whatever you have configured as eof) at the command prompt. On windows, it's Ctrl-Z . Steve

Re: The "loop and a half"

2017-10-07 Thread bartc
On 07/10/2017 17:28, Steve D'Aprano wrote: On Sun, 8 Oct 2017 01:15 am, bartc wrote: You do remember this was about using programs /like/ sort as a model for writing true interactive scrolling text apps? I don't remember any such thing. I remember you *claiming* that, but if anyon

Re: The "loop and a half"

2017-10-08 Thread bartc
On 08/10/2017 10:12, Steve D'Aprano wrote: On Sun, 8 Oct 2017 02:06 am, bartc wrote: Thousands of Python programmers on Windows successfully learned to use Ctrl-Z ENTER back in the days of Python 1.5, before quit/exit were added as a convenience for beginners, and many of them probably

Re: The "loop and a half"

2017-10-08 Thread bartc
On 07/10/2017 15:40, Steve D'Aprano wrote: On Sat, 7 Oct 2017 11:54 pm, bartc wrote: So my programs that use Escape on Windows needed to use Escape Escape on Linux to get around that. Or you could just follow the expected Unix interface instead of inventing your own. Your job is to

Re: The "loop and a half"

2017-10-08 Thread bartc
ain, runs on either OS. And I believe each file works with any C compiler. (Actually, I just found it had a dependency on a Windows time function; I've removed that temporarily for this upload.) See the pattern here? Simplicity not complexity. Consideration for others by making

Re: The "loop and a half"

2017-10-08 Thread bartc
On 08/10/2017 13:05, Chris Angelico wrote: On Sun, Oct 8, 2017 at 10:46 PM, bartc wrote: Just look at any interactive page on the web, they all work differently. People are used to it. And it allows innovation. Maybe it's just that you're not old enough to have worked with te

Re: The "loop and a half"

2017-10-08 Thread bartc
On 08/10/2017 17:13, Chris Angelico wrote: On Mon, Oct 9, 2017 at 2:01 AM, bartc wrote: However as graphics became more mainstream then yes I did adopt some commonly expected styles (menubars for example). As for Alt-F4, if that generates a WM_CLOSE message for example, then I would be obliged

Re: The "loop and a half"

2017-10-08 Thread bartc
On 08/10/2017 19:10, Chris Angelico wrote: On Mon, Oct 9, 2017 at 3:50 AM, bartc wrote: You assume that since *you* have never needed to produce one lower-case letter in a block of upper-case, that "probably no one else has", and then you make it impossible to do that in your edit

Re: The "loop and a half"

2017-10-09 Thread bartc
r that means - ended up being used to mark the end of text files, I don't know.] -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-09 Thread bartc
hey're offloaded to a library. And in your example, which I don't really understand, it seems more like the headache of the application. (Where a language allows elements of a program to be disseminated across a network, that's rather different, and an advanced feature that only so

Re: on = style

2017-10-09 Thread bartc
yellow= 201 but it's not hard. Although it might not be worth doing until a program is finished. Compare to: red = 1 green = 2 blue = 3 turquoise = 4 yellow = 201 -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-10 Thread bartc
On 09/10/2017 01:37, boB Stepp wrote: On Sun, Oct 8, 2017 at 5:36 AM, bartc wrote: And Bart, when large numbers of technical experts in their fields have spent many hours/months/years, yea, even several decades, developing these software systems, why do you think that you, all by yourself

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

2017-10-11 Thread bartc
ere, but what's the type?) Not so convenient. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2017-10-11 Thread bartc
On 11/10/2017 15:52, breamore...@gmail.com wrote: On Wednesday, October 11, 2017 at 3:14:51 PM UTC+1, bartc wrote: On 11/10/2017 14:16, Marko Rauhamaa wrote: Python and C don't try to protect you. In return, you get syntactic convenience that probably enhances the quality of your pro

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

2017-10-11 Thread bartc
On 11/10/2017 15:36, Chris Angelico wrote: On Thu, Oct 12, 2017 at 1:14 AM, bartc wrote: Python, maybe. C syntax isn't as painful as C++ but I still have a lot of trouble with it. (Eg. the variable declaration 'char(*(*x[3])())[5]'. The name of the variable can be found lurk

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

2017-10-11 Thread bartc
On 11/10/2017 17:16, Jonathan Cast wrote: On Wed, 2017-10-11 at 15:14 +0100, bartc wrote: On 11/10/2017 14:16, Marko Rauhamaa wrote: Python and C don't try to protect you. In return, you get syntactic convenience that probably enhances the quality of your programs. Python, maybe. C s

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

2017-10-11 Thread bartc
the cast is 'pointer to pointer to function returning pointer to int64'. The line includes two dereferences (^^) which /I think/ account for two of the "*" in the C version. Which * are dereferences, and which are part of the type, or indeed whether only one * is the dereference, I have absolutely no idea. Great language...) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2017-10-11 Thread bartc
tigate a problem in one language that doesn't exist in the other. Surely it's better to have neither the cryptic type nor the typedef. Everything would be much cleaner. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2017-10-11 Thread bartc
# (blank) error, divide string by string .1e10 1e5 # 1.00 ten twenty # error, divide string by string For throwaway programs, or for testing, or for trusted input, this is perfectly reasonable. For perfect error checking, you need to do a bit more work on either ver

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

2017-10-11 Thread bartc
On 11/10/2017 23:03, Gregory Ewing wrote: bartc wrote:     tokenrec * (*)[] > the original source and that type is written like this:     ref [] ref tokenrec The idiomatic way to write that type in C would be    tokenrec ** The original has an extra pointer so idiomatic C might

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

2017-10-12 Thread bartc
t syntax can be; you write what you have to write, then get on with the rest of the coding. Oh, and it's also very easy to read. It's a mystery to me actually; there is zero cost to devising, implementing and using the most helpful syntax, and actually there are real benefits. So why u

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

2017-10-12 Thread bartc
ead-only, but with any even slightly complex type, it won't work (the head of a linked list for example, where the node elements need to be writeable). It gives a false sense of security. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2017-10-12 Thread bartc
On 12/10/2017 11:39, Stefan Ram wrote: bartc writes: (1) Define named constants; except (in C) they can't be used like constant expressions, you can take their addresses, and accidentally or maliciously change their values. When I think of »const«, I do not think of ROM. »const«

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

2017-10-12 Thread bartc
an element is a pointer, nothing stops you writing to what the pointer points to, unless that has a const target too. And then you've going to have problems doing normal updates. This constness just insinuates itself everywhere. -- bartc -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2017-10-13 Thread bartc
is written to multiple times at runtime. It can't go into actual read-only memory like a ROM. And it might have trouble going into a memory page with read-only attributes. 'const' tries to do too many things, most of them poorly, although it does a very good job at adding clutter. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2017-10-13 Thread bartc
to it will cause a crash. On my home-made system, they just did nothing. Much more graceful. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2017-10-13 Thread bartc
On 13/10/2017 14:16, Chris Angelico wrote: On Sat, Oct 14, 2017 at 12:00 AM, bartc wrote: Even if data is actually in write-protected memory, attempts to write to it will cause a crash. On my home-made system, they just did nothing. Much more graceful. The novice thinks his job is to stop

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

2017-10-13 Thread bartc
plies that same algorithm? We mustn't forget the person writing the code, who may have a certain type in mind for X, but their (I nearly said 'his') analysis may not match the compiler's. Annotations can be useful. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2017-10-13 Thread bartc
On 13/10/2017 15:59, Julien Salort wrote: Le 12/10/2017 à 17:57, bartc a écrit : With a const struct, you are stopped from directly modifying elements, but if an element is a pointer, nothing stops you writing to what the pointer points to, unless that has a const target too. And then you&#x

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

2017-10-13 Thread bartc
, why can't a scheme like that work now? BTW, when you're developing a new bit of hardware or software, and you're not part of team, then the user-base is normally just yourself. Nothing wrong with that, but you seem to like belittling people with such comments. What was th

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

2017-10-13 Thread bartc
hey would be accessed as: i.spam So this would be a const attribute. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: An endless loop

2017-10-15 Thread bartc
). That looks to be a repeat-N-times loop. There isn't a dedicated statement for that, the closest Python feature would be 'for i in range(n)' with i a dummy loop variable. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: An endless loop

2017-10-15 Thread bartc
On 15/10/2017 12:20, Chris Angelico wrote: On Sun, Oct 15, 2017 at 9:15 PM, bartc wrote: I assume you're talking about the while-loop (because on my machine, it hangs just using 'from turtle...' or 'import turtle'). (Machine was screwed up I think, as I had to rest

  1   2   3   4   5   6   7   8   9   10   >