Re: Enumerating all 3-tuples

2018-03-09 Thread bartc
mber in the triple is the Plane number, then plane 1 looks like: 1,1,1 1,2,1 1,3,1 2,1,1 2,2,1 2,3,1 3,1,1 3,2,1 3,3,1 ... ... But whether that has an equivalent traversal path like the diagonals of the 2-D, I don't know. I'm just guessing.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Enumerating all 3-tuples

2018-03-10 Thread bartc
+) l1 l2 makes a list by pair-wise appending the elements of l1 and l2. What's the output? (And what's the input; how do you invoke pn, if that's how it's done?) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Enumerating all 3-tuples

2018-03-10 Thread bartc
On 10/03/2018 20:06, Ben Bacarisse wrote: bartc writes: [repost as original seems to have gone to email; my newsreader has somehow acquired a 'Reply' button where 'Followup' normally goes.] [I thought it was intended but my reply bounced.] On 10/03/2018 14:23, Ben B

Re: Thank you Python community!

2018-03-19 Thread bartc
x27;ve often wondered what the guys who invented C (around 1970) must have been smoking to have come up with some of those ideas. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Entering a very large number

2018-03-25 Thread bartc
a normal assignment. That conversion took 4 microseconds. Not significant if it's only done once. But it might be executed a million times. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Entering a very large number

2018-03-25 Thread bartc
On 25/03/2018 15:01, Christian Gollwitzer wrote: Am 25.03.18 um 14:32 schrieb bartc: Using CPython on my machine, doing a string to int conversion that specific number took 200 times as long as doing a normal assignment. That conversion took 4 microseconds. Not significant if it's only

Re: Entering a very large number

2018-03-25 Thread bartc
also do the conversion when the line is never executed!) Even if you write C = 288714823805077121267142959713039399197760945927972270092651602419743230379915273311632898314463922594197780311092934965557841894944174093380561511397421542416933972905423711002751042080134966731755152859226962916775325475058561019494042000399044321167766199496295392504526987193290703735640322737012784538991261203092448414947289768854060249767681220770716879381217098113222

Re: Entering a very large number

2018-03-25 Thread bartc
On 25/03/2018 16:47, Grant Edwards wrote: On 2018-03-25, bartc wrote: On 25/03/2018 02:47, Steven D'Aprano wrote: The Original Poster (OP) is concerned about saving, what, a tenth of a microsecond in total? Hardly seems worth the effort, especially if you're going to end up with

Re: Entering a very large number

2018-03-25 Thread bartc
On 26/03/2018 00:27, Richard Damon wrote: On 3/25/18 8:32 AM, bartc wrote: Using CPython on my machine, doing a string to int conversion that specific number took 200 times as long as doing a normal assignment. That conversion took 4 microseconds. Not significant if it's only done

Re: Entering a very large number

2018-03-26 Thread bartc
On 26/03/2018 10:34, Steven D'Aprano wrote: On Mon, 26 Mar 2018 02:37:44 +0100, bartc wrote: If I instead initialise C using 'C = int("288712...")', then timings increase as follows: Given that the original number given had 397 digits and has a bit length of 1

Re: Entering a very large number

2018-03-26 Thread bartc
On 26/03/2018 03:35, Richard Damon wrote: On 3/25/18 9:37 PM, bartc wrote: So the overhead /can/ be substantial, and /can/ be significant compared with doing bignum calculations. Of course, once initialised, C might be used a hundred times, then the overhead is less significant. But it is

Re: Entering a very large number

2018-03-26 Thread bartc
On 26/03/2018 13:30, Richard Damon wrote: On 3/26/18 6:31 AM, bartc wrote: The purpose was to establish how such int("...") conversions compare in overheads with actual arithmetic with the resulting numbers. Of course if this was done in C with a version that had builtin bignum

Re: Entering a very large number

2018-03-30 Thread bartc
On 26/03/2018 16:31, Chris Angelico wrote: On Mon, Mar 26, 2018 at 11:46 PM, bartc wrote: On 26/03/2018 13:30, Richard Damon wrote: On 3/26/18 6:31 AM, bartc wrote: The purpose was to establish how such int("...") conversions compare in overheads with actual arithmetic with the

Re: Entering a very large number

2018-03-30 Thread bartc
On 27/03/2018 04:49, Richard Damon wrote: On 3/26/18 8:46 AM, bartc wrote: Hence my testing with CPython 3.6, rather than on something like PyPy which can give results that are meaningless. Because, for example, real code doesn't repeatedly execute the same pointless fragment millio

Re: How to fill in a dictionary with key and value from a string?

2018-03-31 Thread bartc
C', 'a':'A', 't':'T'}, then the loop might look like this: D = {} for c in S: D[c] = c.upper() print (D) Output: {'c': 'C', 'a': 'A', 't': 'T'} But, how to fill in the valu

Re: Python Developer Survey: Python 3 usage overtakes Python 2 usage

2018-03-31 Thread bartc
3G/4G). But a temporary WiFi link (eg. a free one at McDonald's) can be useful to download extra free apps then they can be used off-line. Of source it might not be very popular without access to social media if that's the main purpose of the device. -- bartc -- https://mail.python.or

Re: check if bytes is all nulls

2018-04-01 Thread bartc
Or one that is all zeros but with a sparse smattering of non-zeros? If not very, then just check the bytes one by one. If non-zero, you will know as soon as you see the first non-zero byte, possibly the first one. def allzeros(a): for x in a: if x: return 0 return 1 --

Re: # of Months between two dates

2018-04-06 Thread bartc
ime and to dates. (10-day weeks? I don't think so.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Can't install Python

2018-04-21 Thread bartc
executable program or a batch file. The process failed to start (invalid command?). (1 = I do not know what to do ... Thanks in advance Try clicking the Start button and typing python.exe into the search box. (Unless this is Windows 10, then try right-clicking Start and choose Search.)

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread bartc
le )) { printf( "found at %d\n", offset -( int )strlen( needle )); }} for( int i = l; i; --i )o[ i ]= o[ i - 1 ]; o[ 0 ]= 0; goto next; out: fclose( haystack ); } end: ; } Did you say that you teach programming? -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Issue with python365.chm on window 7

2018-04-24 Thread bartc
riendly to say the least for a HELP file of all things to just flatly not work like without a word of explanation (or even This file is blocked; do you want to unblock it?) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Minmax tictactoe :c Cannot understand why this does not work

2018-04-25 Thread bartc
n't help.) Is an empty movimientos allowed at this point or not? Is auxb==0 a legal index here or not? (Tip: I used these lines in the input loop to simply testing rather than having to type them in (as 2 and 2) each time: fila = 1 columna = 1 ) -- bartc -- https://mail.python.

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-09 Thread bartc
't however allow augmented assignments in expressions, as it's not that useful, and it would be too much (and I could never get the precedences right). But normal assignment is handy.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-10 Thread bartc
On 10/05/2018 09:09, Marko Rauhamaa wrote: bartc : On 09/05/2018 06:44, Steven D'Aprano wrote: But by the time 1.4 came around, Guido had settled on a clean separation between statements and expressions as part of Python's design. That separation has gradually weakened over

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread bartc
syntax that doesn't need to be backwards compatible. That changed in Python 3. If you slim the start of PEP 3127, you'll learn the new notation. What, 0O100 instead of 0100? Yeah that's a big improvement... Fortunately octal doesn't get used much. -- Bartc -- https://mai

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread bartc
On 10/05/2018 18:03, Ian Kelly wrote: On Thu, May 10, 2018 at 10:36 AM, bartc wrote: What, 0O100 instead of 0100? Yeah that's a big improvement... Fortunately octal doesn't get used much. The PEP discusses this: """ Proposed syntaxes included things like arbitrar

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread bartc
On 10/05/2018 19:51, Chris Angelico wrote: On Fri, May 11, 2018 at 4:31 AM, bartc wrote: 2x100 (4) Binary 3x100 (9) Ternary 4x100 (16) Quaternary 5x100 (25) etc 6x100 (36) 7x100 (49) 8x100 (64) Octal 9x100 (81) ... (Not implemented 11x to 15x

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread bartc
miles 31424 miles 2629 miles This is Wrong, and would have been just as obviously wrong in 1989. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread bartc
of three bits, or were divided up on 3-bit boundaries. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-11 Thread bartc
On 11/05/2018 01:11, Chris Angelico wrote: On Fri, May 11, 2018 at 8:43 AM, bartc wrote: This is Wrong, and would have been just as obviously wrong in 1989. Having spent many years programming in C and working on Unix, I strongly disagree. Using C is apt to give you a rather warped view of

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-11 Thread bartc
On 10/05/2018 21:18, bartc wrote: On 10/05/2018 19:51, Chris Angelico wrote: On Fri, May 11, 2018 at 4:31 AM, bartc wrote:    2x100  (4)   Binary    3x100  (9)   Ternary    4x100  (16)  Quaternary    5x100  (25)  etc    6x100  (36)    7x100  (49)    8x100  (64)  Octal    9x100  (81

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-11 Thread bartc
On 11/05/2018 14:24, Chris Angelico wrote: On Fri, May 11, 2018 at 9:09 PM, bartc wrote: when 101'11010'000'B then ... Try /that/ in hex /or/ octal.) I've no idea what this is supposed to mean, or why you have groups of three, five, and three. Looks like a pos

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-12 Thread bartc
On 12/05/2018 05:29, Steven D'Aprano wrote: On Fri, 11 May 2018 16:56:09 +0100, bartc wrote: 0100, if not intended as octal, is an undetectable error in C and Python 2. How fortunate then that Python 2 is history (soon to be ancient history) and people can use Python 3 where that err

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-15 Thread bartc
nyway, as it would be an error in Python) because usually both = and == are plausible in an expression. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-15 Thread bartc
can augmented assignments (+= and so on). -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-16 Thread bartc
On 16/05/2018 16:09, Ian Kelly wrote: On Tue, May 15, 2018, 6:36 PM bartc wrote: On 16/05/2018 01:04, Steven D'Aprano wrote: I'm not a C coder, but I think that specific example would be immune to the bug we are discussing, since (I think) you can't chain assignments i

Re: what does := means simply?

2018-05-17 Thread bartc
because it assumes left-to-right evaluation order of the arguments. Even if Python guarantees that, it might be a problem if the code is ever ported anywhere else. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: what does := means simply?

2018-05-17 Thread bartc
On 17/05/2018 14:32, Steven D'Aprano wrote: On Thu, 17 May 2018 12:58:43 +0100, bartc wrote: On 17/05/2018 04:54, Steven D'Aprano wrote: On Thu, 17 May 2018 05:33:38 +0400, Abdur-Rahmaan Janhangeer wrote: what does := proposes to do? A simple example (not necessarily a GOOD ex

Re: what does := means simply?

2018-05-17 Thread bartc
On 17/05/2018 15:03, Chris Angelico wrote: On Thu, May 17, 2018 at 9:58 PM, bartc wrote: On 17/05/2018 04:54, Steven D'Aprano wrote: On Thu, 17 May 2018 05:33:38 +0400, Abdur-Rahmaan Janhangeer wrote: what does := proposes to do? A simple example (not necessarily a GOOD example,

Re: what does := means simply?

2018-05-17 Thread bartc
On 17/05/2018 18:19, Steven D'Aprano wrote: On Thu, 17 May 2018 15:50:17 +0100, bartc wrote: Of course, full-on Python code is pretty much impossible to port anywhere else anyway. *rolls eyes* Any pair of languages will have code that is hard to port from one to the other without ju

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 02:45, Steven D'Aprano wrote: On Fri, 18 May 2018 02:17:39 +0100, bartc wrote: Normally you'd use the source code as a start point. In the case of Python, that means Python source code. But you will quickly run into problems because you will often see 'import lib

Re: syntax oddities

2018-05-18 Thread bartc
On 17/05/2018 23:49, Chris Angelico wrote: On Fri, May 18, 2018 at 8:44 AM, Paul wrote: I've been using email for thirty years, including thousands of group emails at many tech companies, and no one has ever suggested, let alone insisted on, bottom posting. If someone's late to a thread they

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 13:29, Steven D'Aprano wrote: On Fri, 18 May 2018 12:09:02 +0100, bartc wrote: On 18/05/2018 02:45, Steven D'Aprano wrote: On Fri, 18 May 2018 02:17:39 +0100, bartc wrote: Normally you'd use the source code as a start point. In the case of Python, that means Pyt

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 15:47, Chris Angelico wrote: On Sat, May 19, 2018 at 12:37 AM, bartc wrote: Have a look at some of the implementations here (to test some Mandelbrot benchmark): https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/mandelbrot.html The three Python examples all

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 18:27, bartc wrote: (BTW here's a port of that benchmark based on the Lua code:   https://pastebin.com/raw/ivDaKudX And here's the payoff: I was able to use this version to port it to Python. One which works better the the originals, as they wrote output to

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 19:36, Chris Angelico wrote: On Sat, May 19, 2018 at 3:27 AM, bartc wrote: Once again, you're confusing *porting* with *emulating*. This is the point. Those libraries are specific to Python and cannot be ported. And very often they don't just provide general su

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 20:15, Alexandre Brault wrote: On 2018-05-18 02:48 PM, bartc wrote: Note this version doesn't use any imports at all. Except your version doesn't read its parameter from the command line args and doesn't output to standard output, which all of the others do.

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 19:57, Chris Angelico wrote: On Sat, May 19, 2018 at 4:48 AM, bartc wrote: The translation was straightforward, EXCEPT that I wasted an hour trying to figure out to write /a single byte/ to a file. The following eventually worked, using a binary file as a text one had Unicode

Re: what does := means simply?

2018-05-18 Thread bartc
On 19/05/2018 01:00, Chris Angelico wrote: On Sat, May 19, 2018 at 7:53 AM, bartc wrote: I've worked with text files for 40 years. Now Python is telling me I've been doing it wrong all that time! Look at the original code I posted from which this Python was based. That creates a fil

Re: what does := means simply?

2018-05-18 Thread bartc
On 19/05/2018 01:42, Dennis Lee Bieber wrote: On Fri, 18 May 2018 22:53:06 +0100, bartc declaimed the following: I've worked with text files for 40 years. Now Python is telling me I've been doing it wrong all that time! Look at the original code I posted from which this Python

Re: what does := means simply?

2018-05-18 Thread bartc
typo.) The .ppm (really .pbm) file which was the subject of this sub-thread has its header defined using ASCII. I don't think an EBCDIC 'P4' etc will work. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: what does := means simply?

2018-05-19 Thread bartc
On 19/05/2018 02:26, Chris Angelico wrote: On Sat, May 19, 2018 at 11:10 AM, bartc wrote: The .ppm (really .pbm) file which was the subject of this sub-thread has its header defined using ASCII. I don't think an EBCDIC 'P4' etc will work. "Defined using ASCII" i

Re: what does := means simply?

2018-05-19 Thread bartc
On 19/05/2018 12:38, Chris Angelico wrote: On Sat, May 19, 2018 at 8:33 PM, bartc wrote: But then you are acknowledging the file is, in fact, ASCII. Cool! So what happens if you acknowledge that a file is ASCII, and then it starts with a byte value of E3 ? It depends. If this is a .ppm

Re: what does := means simply?

2018-05-19 Thread bartc
On 19/05/2018 12:33, Peter J. Holzer wrote: On 2018-05-19 11:33:26 +0100, bartc wrote: Not you understand why some of us don't bother with 'text mode' files. "Not" or "Now"? Now. Yesterday you claimed that you worked with them for 40 years. Text f

Re: what does := means simply?

2018-05-19 Thread bartc
On 19/05/2018 20:47, Dennis Lee Bieber wrote: On Sat, 19 May 2018 13:28:41 +0100, bartc declaimed the following: Out of interest, how would Python handle the headers for binary file formats P4, P5, P6? I'd have a go but I don't want to waste half the day trying to get past th

Re: what does := means simply?

2018-05-19 Thread bartc
On 20/05/2018 01:39, Dennis Lee Bieber wrote: On Sat, 19 May 2018 23:14:08 +0100, bartc declaimed the following: The comments and examples here: https://en.wikipedia.org/wiki/Netpbm_format, and all actual ppm files I've come across, suggest the 3 parts of the header (2 parts for P1/P4

Re: what does := means simply?

2018-05-20 Thread bartc
On 20/05/2018 02:58, Dennis Lee Bieber wrote: On Sun, 20 May 2018 02:13:01 +0100, bartc declaimed the following: I think if you are going to be generating ppm, then the best choice of format, for the widest acceptance, is to separate the header groups with a newline. (As I mentioned my

Re: what does := means simply?

2018-05-20 Thread bartc
On 20/05/2018 10:19, Peter J. Holzer wrote: On 2018-05-19 13:43:14 +0100, bartc wrote: Text files, yes. Not 'text mode' which is something inflicted on us by the C library. I very much enjoy the fact that the programming languages I've used to process text files in the las

Re: what does := means simply?

2018-05-20 Thread bartc
On 20/05/2018 16:37, Dennis Lee Bieber wrote: On Sun, 20 May 2018 12:38:59 +0100, bartc declaimed the Just for giggles, I decided to write the start of a PPM reader (it only handles P6 binary, doesn't have the code for the other styles, and doesn't incorporate PPM writer

Re: "Data blocks" syntax specification draft

2018-05-21 Thread bartc
to print boarding passes via PDF; I doubt airlines wanted to alienate Linux users). -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: "Data blocks" syntax specification draft

2018-05-21 Thread bartc
is: data = { but you need: date = \ /// Or do you also allow: date = /// with data following on the next line? -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: "Data blocks" syntax specification draft

2018-05-22 Thread bartc
On 22/05/2018 03:49, Mikhail V wrote: On Mon, May 21, 2018 at 3:48 PM, bartc wrote: But I have to say it looks pretty terrible, and I can't see that it buys much over normal syntax. # t # t 11 22 33 Is this example complete? Presumably it means ((11,22,33),). Yo

Re: "Data blocks" syntax specification draft

2018-05-22 Thread bartc
On 22/05/2018 15:25, Chris Angelico wrote: On Tue, May 22, 2018 at 8:25 PM, bartc wrote: Note that Python tuples don't always need a start symbol: a = 10,20,30 assigns a tuple to a. The tuple has nothing to do with the parentheses, except for the special case of the empty tuple.

Re: "Data blocks" syntax specification draft

2018-05-22 Thread bartc
ight either. Asterisk is just an overloaded token but you will what it's for as soon as it's encountered. Comma seems to be used only as a separator. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
On 23/05/2018 07:47, Steven D'Aprano wrote: On Tue, 22 May 2018 18:51:30 +0100, bartc wrote: On 22/05/2018 15:25, Chris Angelico wrote: [...] The tuple has nothing to do with the parentheses, except for the special case of the empty tuple. It's the comma. No? Take these: a =

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
lenty), none of them are tied to anything to do with tuples. Actually 'tuple' doesn't appear at all. 'dict' does, presumably because a dict-constructor is different syntactically in requiring key:value pairs. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
On 23/05/2018 14:11, Steven D'Aprano wrote: On Wed, 23 May 2018 11:10:33 +0100, bartc wrote: (x,) Tuple of one item Incorrect. Yet again, you have failed to do enough testing. No special form is required. Only a comma: py> x = 1, py> type(x) It isn't enough to test exampl

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
ssion comprises, then you will run into problems. Try adding two tuples: 1, 2, 3 + 4, 5, 6 This in fact gives you 1,2,7,5,6 rather than 5,7,9. (I don't know if tuples can actually be added like this, but the point is clear.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
On 23/05/2018 22:51, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index Not for that trivial task. But you can create your own: def upb(x): return len(x)-1 # '

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
ot the last value itself which would be 'i'. And actually, the subject line seems to confirm that. In that case, using a '-1' index won't work. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
On 24/05/2018 01:46, bartc wrote: On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, Use -1, which is the

Re: how to get INDEX count, or last number of Index

2018-05-24 Thread bartc
On 24/05/2018 03:37, Terry Reedy wrote: On 5/23/2018 8:46 PM, bartc wrote: On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know

Re: Raw string statement (proposal)

2018-05-25 Thread bartc
). As for a better proposal, I'm inclined not to make it part of the language at all, but to make it an editor feature: insert a block of arbitrary text, and give a command to turn it into a string literal. With perhaps another command to take a string literal within a program and view it

Re: why do I get syntax error on if : break

2018-05-25 Thread bartc
On 25/05/2018 11:08, asa32s...@gmail.com wrote: On Thursday, May 24, 2018 at 10:12:46 PM UTC-4, asa3...@gmail.com wrote: here is the code, i keep getting an error, "break outside loop". if it is false just exit function def d(idx): if type(idx) != int: break d('k') thanks...

Re: List replication operator

2018-05-25 Thread bartc
plement ** too, and that is harder. For this specific example, it can just be: def dupllist(x,n): return [x[0].copy() for _ in range(n)] -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: List replication operator

2018-05-25 Thread bartc
On 25/05/2018 13:36, bartc wrote: Of course you have to implement dupllist(), but you'd have to implement ** too, and that is harder. For this specific example, it can just be: def dupllist(x,n):     return [x[0].copy() for _ in range(n)] On 25/05/2018 03:25, Steven D'Aprano wr

Re: List replication operator

2018-05-25 Thread bartc
On 25/05/2018 13:46, Chris Angelico wrote: On Fri, May 25, 2018 at 10:36 PM, bartc wrote: On 24/05/2018 19:17, Steven D'Aprano wrote: But what do people think about proposing a new list replication with copy operator? [[]]**5 would return a new list consisting of five shallow c

Re: List replication operator

2018-05-25 Thread bartc
On 25/05/2018 16:27, Chris Angelico wrote: On Fri, May 25, 2018 at 10:58 PM, bartc wrote: I'm in general not in favour of piling in special symbols into a language just to solve some obscure or rare problem. As I went on to demonstrate, function-like syntax (or even actual functions) cou

Re: List replication operator

2018-05-25 Thread bartc
On 25/05/2018 16:40, Steven D'Aprano wrote: On Fri, 25 May 2018 22:46:37 +1000, Chris Angelico wrote: We've already had a suggestion for [[]]@5 and that should deal with that issue. Steven is proposing "multiply by copying" as an alternative to "multiply by referencing", so an alternative multi

Re: List replication operator

2018-05-25 Thread bartc
On 25/05/2018 17:11, Alexandre Brault wrote: On 2018-05-25 11:40 AM, bartc wrote: On 25/05/2018 16:27, Chris Angelico wrote: You're way WAY too late to debate the matrix multiplication operator. /The/ matrix multiplication operator? In which language? And what was wrong with &quo

Re: List replication operator

2018-05-25 Thread bartc
)) print (len(x[0])) print (len(x[0][0])) Gives output of 4, 3, 2 rather than 2, 3, 4. Which means that x[0][0][3] is a bounds error. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-29 Thread BartC
f-else that appears in an expression, but it has function-call. But why stop there? Anyway this is all hypothetical, in case anyone thinks I'm pushing for a change in the language. I thought such a language was cool in the 1980s, but now will settle for a more conservative one even if it's not so elegant. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with python code

2016-03-29 Thread BartC
e option 0 for some of these, and that might help solve the indexing problem.) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Calculate Bill

2016-03-30 Thread BartC
)) showmenu(pizzas) option = 3-1# vegetarian (3 on displayed menu is 2 in list) quantity = 2 print ("You chose",quantity,"of",pizzas[option][descr]) print ("Total is",pizzas[option][cost]*quantity) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-30 Thread BartC
. Never thought of how Python sounds when spoken. Among other things, it becomes case insensitive... -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread BartC
r, that's harder to do. Someone else will have to help.) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread BartC
On 02/04/2016 23:16, Ned Batchelder wrote: On Saturday, April 2, 2016 at 6:09:13 PM UTC-4, BartC wrote: On 02/04/2016 22:59, Loop.IO wrote: Hey So I built a keylogger using python as a test, got the code from the tutorial online, I want to improve on it to make it more automated, but the

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-02 Thread BartC
lained how before, just use: name='C:\\Documents\\PythonCoding\\launch2.bat' if that's the file name you need. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-03 Thread BartC
On 03/04/2016 15:41, Loop.IO wrote: On Sunday, April 3, 2016 at 1:12:23 AM UTC+1, BartC wrote: On 02/04/2016 23:31, Loop.IO wrote: Oh i see, so the code prompts for a name.. so i'm more lost than i thought, what do I need to change to make it just create the file with the chosen

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-03 Thread BartC
On 03/04/2016 16:25, Rustom Mody wrote: On Sunday, April 3, 2016 at 8:41:49 PM UTC+5:30, BartC wrote: You can create the path manually outside of Python. Or look up the docs to find out how to do that. A quick google suggested using os.makedirs (to create multiple nested paths at the same

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-03 Thread BartC
On 03/04/2016 20:36, Loop.IO wrote: On Sunday, April 3, 2016 at 8:32:06 PM UTC+1, Loop.IO wrote: The issue is that it hangs, there is no error. its like it pauses until i press enter, ill try what you've posted one momen Ok the Bartc code gives me an error. This is confusing! I

Re: [beginner] What's wrong?

2016-04-04 Thread BartC
to reply to a post, which sends to the group. Other options on the dropdown box below the Followup button are Reply and Reply All. Clicking Reply (on your post) starts an email to you, while Reply All starts an email to you and to the group. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Promoting Python

2016-04-05 Thread BartC
ays of the time No If that code is BBC basic then it would print the word Colour followed by the numbers 1 - 15 For x in range (1,16): print "Colour %s"%x You forgot the COLOUR statement. Presumably each line is in a different text colour. -- Bartc -- https://mail.python.

Re: Promoting Python

2016-04-06 Thread BartC
in Python, but I would start by googling 'python basic graphics' or some such phrase. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Promoting Python

2016-04-06 Thread BartC
On 06/04/2016 12:38, Ned Batchelder wrote: On Wednesday, April 6, 2016 at 7:06:28 AM UTC-4, BartC wrote: On 05/04/2016 06:48, Gordon( Hotmail ) wrote: The problem I am finding is most of the sites claiming to help understand Python devote far too much space bragging about the wonders of

Re: Promoting Python

2016-04-06 Thread BartC
On 06/04/2016 12:46, Marko Rauhamaa wrote: BartC : It'll cope with ordinary coding as well, although such programs seem to be frowned upon here; they are not 'Pythonic'. I wonder what is left of Python after your list of exclusions. There are plenty of features that /I/ con

Re: Promoting Python

2016-04-06 Thread BartC
On 06/04/2016 15:20, Mark Lawrence wrote: On 06/04/2016 14:54, BartC wrote: Please state why you're still here if Python is such a poorly designed language that it doesn't fit your needs. I was replying to the OP who was being put off the language. The vast majority have to cho

Re: Promoting Python

2016-04-06 Thread BartC
On 06/04/2016 21:38, Mark Lawrence wrote: No it didn't, it was quite clear from the beginning that he knew squat, and since then he's admitted that he knows squat. About Python. I see. According to you: (1) To have an opinion about a language, you have to know everything in it 100%, inside

Re: one-element tuples

2016-04-11 Thread BartC
he comma, but when going from c to b, you remove only "20". But this can be fixed if tuples are written like this: a = 10 # int b = 10,# tuple c = 10,20, # tuple d = 10,20,30, # tuple Now, you remove "30," then "20,". No exception. Of course this doesn't help you parsing typical input which uses commas as separators, not terminators! -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Guido sees the light: PEP 8 updated

2016-04-16 Thread BartC
ed into multiple columns. (But I think 80 columns is a bit limited. Maybe 100 or 132.) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

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