Re: Usenet vs. Mailing-list

2023-01-29 Thread Ben Bacarisse
Igor Berger writes: > On Saturday, January 28, 2023 at 10:02:57 PM UTC-5, Ben Bacarisse wrote: >> Jon Ribbens writes: >> >> > On 2023-01-29, Ben Bacarisse wrote: >> >> "Peter J. Holzer" writes: >> >> >> >

Re: Usenet vs. Mailing-list

2023-01-28 Thread Ben Bacarisse
Jon Ribbens writes: > On 2023-01-29, Ben Bacarisse wrote: >> "Peter J. Holzer" writes: >> >>> On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: >>>> mutt...@dastardlyhq.com writes: >>>> >>>> > Hi >&g

Re: Usenet vs. Mailing-list

2023-01-28 Thread Ben Bacarisse
"Peter J. Holzer" writes: > On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: >> mutt...@dastardlyhq.com writes: >> >> > Hi >> >> It looks like you posted this question via Usenet. comp.lang.python is >> essentially dead as a Usenet group

Re: evaluation question

2023-01-27 Thread Ben Bacarisse
mutt...@dastardlyhq.com writes: > Hi It looks like you posted this question via Usenet. comp.lang.python is essentially dead as a Usenet group. It exists, and gets NNTP versions of mail sent to the mailing list, but nothing posted to the group via NNTP get send on the mailing list. I prefer

Re: bool and int

2023-01-26 Thread Ben Bacarisse
Chris Angelico writes: > On Thu, 26 Jan 2023 at 08:19, Dino wrote: >> >> On 1/23/2023 11:22 PM, Dino wrote: >> > >>> b = True >> > >>> isinstance(b,bool) >> > True >> > >>> isinstance(b,int) >> > True >> > >>> >> >> ok, I read everything you guys wrote. Everyone's got their reasons >>

Re: Local variable definition in Python list comprehension

2022-09-01 Thread Ben Bacarisse
James Tsai writes: > I find it very useful if I am allowed to define new local variables in > a list comprehension. For example, I wish to have something like > [(x, y) for x in range(10) for y := x ** 2 if x + y < 80], or > [(x, y) for x in range(10) with y := x ** 2 if x + y < 80]. > > For now

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Ben Bacarisse
Grant Edwards writes: > On 2021-11-20, Ben Bacarisse wrote: > >> You seem to be agreeing with me. It's the floating point part that is >> the issue, not the base itself. > > No, it's the base. Floating point can't represent 3/10 _because_ it's > base 2 floating point

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Ben Bacarisse
Chris Angelico writes: > On Sat, Nov 20, 2021 at 3:41 PM Ben Bacarisse wrote: >> >> Chris Angelico writes: >> >> > On Sat, Nov 20, 2021 at 12:43 PM Ben Bacarisse >> > wrote: >> >> >> >> Chris Angelico writes: >> >

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Ben Bacarisse
Chris Angelico writes: > On Sat, Nov 20, 2021 at 12:43 PM Ben Bacarisse wrote: >> >> Chris Angelico writes: >> >> > On Sat, Nov 20, 2021 at 9:07 AM Ben Bacarisse wrote: >> >> >> >> Chris Angelico writes: >> >> >> >&g

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Ben Bacarisse
Chris Angelico writes: > On Sat, Nov 20, 2021 at 9:07 AM Ben Bacarisse wrote: >> >> Chris Angelico writes: >> >> > On Sat, Nov 20, 2021 at 5:08 AM ast wrote: >> >> >> >>> 0.3 + 0.3 + 0.3 == 0.9 >> >> False >> > >

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Ben Bacarisse
Chris Angelico writes: > On Sat, Nov 20, 2021 at 5:08 AM ast wrote: >> >>> 0.3 + 0.3 + 0.3 == 0.9 >> False > > That's because 0.3 is not 3/10. It's not because floats are > "unreliable" or "inaccurate". It's because the ones you're entering > are not what you think they are. > > When will

Re: Help with gaussian filter from scipy

2021-07-07 Thread Ben Bacarisse
Arak Rachael writes: > On Wednesday, 7 July 2021 at 12:47:40 UTC+2, Arak Rachael wrote: >> On Wednesday, 7 July 2021 at 12:41:44 UTC+2, Ben Bacarisse wrote: >> > Arak Rachael writes: >> > >> > > this time I am stuck on gaussian_filter scipy returns none

Re: Help with gaussian filter from scipy

2021-07-07 Thread Ben Bacarisse
Arak Rachael writes: > this time I am stuck on gaussian_filter scipy returns none instead of some > valid gaussian filtered image, can someone help me please. > > Here is the full code: > https://www.dropbox.com/s/18ylpiwmhlu5n62/test_filter_xdog.ipynb?dl=0 It might help to link to the code

Re: neonumeric - C++ arbitrary precision arithmetic library

2021-03-06 Thread Ben Bacarisse
Mr Flibble writes: >> Someone who says that he is capable of writing a compiler that >> translates every language has megalomania. No one can do this. > > Just because you can't make one it doesn't follow that nobody else > can. True, but lots of very knowledgeable people have tried and failed.

Re: New Python implementation

2021-02-16 Thread Ben Bacarisse
"Avi Gross" writes: > Thanks for sharing. I took a look and he does have a few schemas for Ada and > C from TWO YEARS ago. Nothing about the infinite number of other languages > he plans on supporting, let alone Python. And what he has is likely not > enough to do what he claims he can do easily

Re: Mr. Flibble

2021-02-15 Thread Ben Bacarisse
Ethan Furman writes: > On 2/15/21 2:02 PM, Grant Edwards wrote: >> On 2021-02-15, Ben Bacarisse wrote: >> >>> You said you used Usenet (and your reply here was via Usenet). >>> Usenet posts to comp.lang.python don't go to the mailing list (the >>> &

Re: Mr. Flibble

2021-02-15 Thread Ben Bacarisse
Mr Flibble writes: > On 15/02/2021 18:09, Ethan Furman wrote: >> Thank you to those who pointed out this individual to the >> moderators. As Mr. Flibble accurately noted, he is not on the mailing >> list -- so his posts won't be here either. > > ORLY? You said you used Usenet (and your reply

Re: sqlite3 cannot detect the version of compiled sqlite version at some point in runtime.

2021-01-20 Thread Ben Bacarisse
panfei writes: > 4. Test sqlite3 > Python 3.9.1 (default, Jan 20 2021, 14:32:50) > [GCC 10.2.0] on linux > Type "help", "copyright", "credits" or "license" for more information. import sqlite3 conn = sqlite3.connect(':memory:') conn.create_function('f', 2, lambda *args: None,

Re: Find word by given characters

2020-11-03 Thread Ben Bacarisse
Bischoop writes: > Let me clarify what I want to do: > We all know Scrabble game. > there's a file with Dictionary containing word in each line, the idea is > to input some letters for example mentioned earlier: att, the script > supposed to find all words in which letters: 'a','t','t' occur and

Re: musings on static variables

2020-09-16 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > This C program use a local /static/ variable. > > main.c > > #include > > int f( void ) > { static int i = 0; > return i++; } > > int main( void ) > { printf( "%d\n", f() ); > printf( "%d\n", f() ); > printf( "%d\n", f() ); } > >

Re: Didn't understand the output of the following Python 3 code with reduce function?

2020-08-28 Thread Ben Bacarisse
Shivlal Sharma writes: > I have seen this code on one of competative programming site but I > didn't get it, Why output is 9? > > from functools import * > > def ADDS(a,b): > return a+1 > nums = [1, 2, 3, 4, 5, 6, 7, 8, 9] > add = reduce(ADDS, nums) > print(add) > > output: 9 Hint:

Re: Behaviour of os.path.join

2020-05-27 Thread Ben Bacarisse
Roel Schroeven writes: > Ben Bacarisse schreef op 27/05/2020 om 17:53: >> There is well-known (*nix) software that relies on a/b/c/ meaning >> something different to a/b/c but I don't know anyone who thinks this is >> a good idea. It causes no end of confusion. > > r

Re: Behaviour of os.path.join

2020-05-27 Thread Ben Bacarisse
BlindAnagram writes: > On 27/05/2020 16:53, Ben Bacarisse wrote: >> As it should. Relying on a trailing \ having the right effect is >> brittle to say the least. > > In my case less brittle than leaving it out. Brittle does not mean broken. I know you can fix it by mak

Re: Behaviour of os.path.join

2020-05-27 Thread Ben Bacarisse
BlindAnagram writes: > On 27/05/2020 13:30, Ben Bacarisse wrote: >> BlindAnagram writes: >> >>> The issue that I raised here was whether the behaviour of os.path.join() >>> in treating the Windows directory separator '\\' as an absolute path >>> sh

Re: Behaviour of os.path.join

2020-05-27 Thread Ben Bacarisse
BlindAnagram writes: > The issue that I raised here was whether the behaviour of os.path.join() > in treating the Windows directory separator '\\' as an absolute path > should be considered a bug. You think it should be considered to be a relative path? The only meaning that would give you

Re: Behaviour of os.path.join

2020-05-26 Thread Ben Bacarisse
BlindAnagram writes: > I came across an issue that I am wondering whether I should report as an > issue. If I have a directory, say: > > base='C:\\Documents' > > and I use os.path.join() as follows: > > join(base, '..\\..\\', 'build', '') It rather defeats the purpose of os.sep if you

Re: ÿ in Unicode

2020-03-07 Thread Ben Bacarisse
moi writes: > Le samedi 7 mars 2020 16:41:10 UTC+1, R.Wieser a écrit : >> Moi, >> >> > Fortunately, UTF-8 has not been created the Python devs. >> >> And there we go again, making vague statements/accusations - without >> /anything/ to back it up ofcourse >> >> Kiddo, you have posted a

Re: ÿ in Unicode

2020-03-06 Thread Ben Bacarisse
moi writes: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ÄCcrit : >> moi writes: >> >> >>>> 'Ä¿'.encode('utf-8') >> > b'\xc3\xbf' >> >>>> 'Ä¿'.encode('utf-16-le') >> > b'\xff\x00' >> >>>> 'Ä¿'

Re: ÿ in Unicode

2020-03-06 Thread Ben Bacarisse
moi writes: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a écrit : >> moi writes: >> >> >>>> 'ÿ'.encode('utf-8') >> > b'\xc3\xbf' >> >>>> 'ÿ'.encode('utf-16-le') >> > b'\xff\x00' >> >>>> 'ÿ'

Re: ÿ in Unicode

2020-03-06 Thread Ben Bacarisse
moi writes: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a écrit : >> moi writes: >> >> >>>> 'ÿ'.encode('utf-8') >> > b'\xc3\xbf' >> >>>> 'ÿ'.encode('utf-16-le') >> > b'\xff\x00' >> >>>> 'ÿ'.

Re: ÿ in Unicode

2020-03-05 Thread Ben Bacarisse
moi writes: 'ÿ'.encode('utf-8') > b'\xc3\xbf' 'ÿ'.encode('utf-16-le') > b'\xff\x00' 'ÿ'.encode('utf-32-le') > b'\xff\x00\x00\x00' That all looks as expected. Is there something about the output that puzzles you? Did you have a question? -- Ben. --

Re: Extract all words between two keywords in .txt file (Python)

2019-12-12 Thread Ben Bacarisse
A S writes: > On Thursday, 12 December 2019 02:28:09 UTC+8, Ben Bacarisse wrote: >> A S writes: >> >> > I would like to extract all words within specific keywords in a .txt >> > file. For the keywords, there is a starting keyword of "PROC SQL;&quo

Re: Extract all words between two keywords in .txt file (Python)

2019-12-11 Thread Ben Bacarisse
A S writes: > I would like to extract all words within specific keywords in a .txt > file. For the keywords, there is a starting keyword of "PROC SQL;" (I > need this to be case insensitive) and the ending keyword could be > either "RUN;", "quit;" or "QUIT;". This is my sample .txt file. > >

Re: How to convert the following IDL program lines to equivalent Python program lines?

2019-11-28 Thread Ben Bacarisse
Madhavan Bomidi writes: > I have the following IDL program lines. I want to write equivalent > Python program lines. Can anyone suggest me equivalent Pythons program > lines? > > # --- 1 --- # > How to handle the format in IDL to Python? > > IDL program line:

Re: join and split with empty delimiter

2019-07-18 Thread Ben Bacarisse
Danilo Coccia writes: > Il 18/07/2019 12:27, Ben Bacarisse ha scritto: >> Irv Kalb writes: >> >>> I have always thought that split and join are opposite functions. For >>> example, you can use a comma as a delimiter: >>> >>>>>> m

Re: join and split with empty delimiter

2019-07-18 Thread Ben Bacarisse
Irv Kalb writes: > I have always thought that split and join are opposite functions. For > example, you can use a comma as a delimiter: > myList = ['a', 'b', 'c', 'd', 'e'] myString = ','.join(myList) print(myString) > a,b,c,d,e > myList = myString.split(',')

Re: repr = expression representation?

2019-05-17 Thread Ben Bacarisse
Christian Gollwitzer writes: > Am 17.05.19 um 06:13 schrieb Stefan Ram: However, look at this >> >> |>>> print( str( print )) >> | >> >> |>>> print( repr( print )) >> | >> >>. While it is nice that »str( print )« gives some useful >>information, I would expect »repr( print )« to give

Re: Testing the data type of a value

2019-05-12 Thread Ben Bacarisse
binoythomas1...@gmail.com writes: > When I run the following code, I get the following output: print(type(5)) > class 'int' > > Next, I try to compare the data-type of 5 with the earlier output, I > get no output: if type(5) == "": > print("Integer") > > Why isn't this working?

Re: Help? How do i solve this problem with Python List Concept

2019-05-11 Thread Ben Bacarisse
Donald Tripdarlinq writes: > In the traditional Yoruba tribal Set-Up in Nigeria,West Africa the > tradition of inheritance is very important. Now, The relative position > of a child in the family counts when the issue of inheritance is > considered. > > Question: Now a farmer with 10 children

Re: Is this a "gotcha" in Python?

2019-04-20 Thread Ben Bacarisse
Gilmeh Serda writes: > On Fri, 19 Apr 2019 21:01:05 +, Stefan Ram wrote: > >> Has this ever been a problem for someone? > > Only for programmers who come here from other languages and expect Python > to behave in the same manner as their favorite language, so they try and > argue that

Re: Function to determine list max without itertools

2019-04-19 Thread Ben Bacarisse
Sayth Renshaw writes: >> Now, what happens when the code is tested with various (different) sets >> of test-data? >> (remember the last question from my previous msg!?) >> > It fails on any list entry that isn't a float or an int, giving a TypeError. > >> Once you are happy with the various

Re: Design a function that finds all positive numbers

2019-04-09 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Ben Bacarisse writes: >>Ranjith Bantu writes: >>>can I solve any problems like this by learning python? >>You need to learn how to solve problems as well as learning Python -- > > I do not separate "solv

Re: Design a function that finds all positive numbers

2019-04-09 Thread Ben Bacarisse
Ranjith Bantu writes: > A numeric array of length 'N' is given. you need to design a function > that finds all positive numbers in the array that have their opposites > in it swell. give the approach for solving the optimal average or best > case performance. answer will be your obsolute. >

Re: New rules for scope in a function?

2019-02-18 Thread Ben Bacarisse
"Steve" writes: > OK, I wrote: > > x = "A" > print("x = " + x) > > def f(y): > print("x= " + x + " y= "+ y) > > f(x) > > and it worked, inspite of what I was seeing in my own program. > How quick I am to blame Python. (: > When I isolate my function that stumped me, I will post it.

Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ben Bacarisse
Grant Edwards writes: > On 2019-02-07, Ben Bacarisse wrote: >> Ian Clark writes: >> >>> This is my whack at it, I can't wait to hear about it being the wrong big o >>> notation! >>> >>> numbers=[] >>> >>> while len(n

Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ben Bacarisse
Bart writes: > On 07/02/2019 20:45, Ben Bacarisse wrote: >> Ian Clark writes: >> >>> This is my whack at it, I can't wait to hear about it being the wrong big o >>> notation! >>> >>> numbers=[] >>> >>> while len(numbers) <

Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ben Bacarisse
Ian Clark writes: > This is my whack at it, I can't wait to hear about it being the wrong big o > notation! > > numbers=[] > > while len(numbers) < 10: > try: > chip = int(input('please enter an integer: ')) > except ValueError: > print('that is not a number, try again')

Re: Bringing Order to programming

2019-01-31 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > source = \ > 'Python is an easy to learn, powerful programming language. It has' + \ > ' efficient high-level data structures and a simple but effective' + \ > ' approach to object-oriented programming. Python's elegant syntax' + \ You have an

Re: graded randomness

2018-12-28 Thread Ben Bacarisse
Abdur-Rahmaan Janhangeer writes: > let us say that i have a box of 5 balls, > > green balls - 2 with probability 2/5 > red balls 2 - with probability 2/5 > blue balls 1 - with probability 1/5 > > how to program the selection so that the random choices reflect the > probabilities? >>> import

Re: random choice from dictionary

2018-12-23 Thread Ben Bacarisse
"Avi Gross" writes: > The following is a function that iterates over the dictionary one key at a > time and when it reaches a random one, it returns the key without further > evaluation. On the average, it takes N/2 iterations for N keys. Asking to > make a list(data) may be efficient in terms

Re: multiple JSON documents in one file, change proposal

2018-12-01 Thread Ben Bacarisse
Marko Rauhamaa writes: > Chris Angelico : > >> On Sat, Dec 1, 2018 at 10:16 PM Marko Rauhamaa wrote: >>> and the framing format is HTTP. I will need to type something like this: >>> >>>POST / HTTP/1.1^M >>>Host: localhost^M >>>Content-type: application/json^M >>>Content-length:

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Ben Bacarisse
srinivasan writes: > Even after changing as per the below > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" > or: > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' > or: > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" > > Still my output is: > */dev/mmcblk1p1: LABEL="efi"

Re: snakify issues

2018-10-13 Thread Ben Bacarisse
bob gailer writes: > 5:50 AM Dec 8, 2016 a post was made to this list - subject "Snakify - > free introductory Python online course with exercises" > > Recently I was engaged by a student seeking help with some of the > exercises. I found a number of issues at the snakify web site. Thus > began

Re: Writing bytes to stdout reverses the bytes

2018-08-19 Thread Ben Bacarisse
Grant Edwards writes: > On 2018-08-20, Steven D'Aprano wrote: >> On Mon, 20 Aug 2018 00:31:35 +, Steven D'Aprano wrote: >> >>> When I write bytes to stdout, why are they reversed? >> >> Answer: they aren't, use hexdump -C. > > One might think that dumping out bytes in the correct order

Re: coding style - where to declare variables

2018-07-23 Thread Ben Bacarisse
Mark Lawrence writes: > On 22/07/18 14:51, Abdur-Rahmaan Janhangeer wrote: >> except local vars >> >> Abdur-Rahmaan Janhangeer >> https://github.com/Abdur-rahmaanJ >> Mauritius >> > > Python doesn't have variables, it has names. I think we should cut beginners (and probably everyone) some slack

Re: [OT] Bit twiddling homework

2018-07-20 Thread Ben Bacarisse
Brian Oney writes: > On Fri, 2018-07-20 at 06:37 +, Steven D'Aprano wrote: >> On Fri, 20 Jul 2018 08:25:04 +0200, Brian Oney via Python-list wrote: >> >> > PS: Can I twiddle bits in Python? >> >> Yes. >> >> These operators work on ints: >> >> bitwise AND: & >> bitwise OR: | >>

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Ben Bacarisse
Just word on quoting... codewiz...@gmail.com writes: > On Thursday, July 12, 2018 at 5:45:52 AM UTC-4, Ben Bacarisse wrote: >> >> [snip] You cut everything I wrote. What you left is what I quoted from the Python documentation. In fairness to the authors you should pr

Re: variable scope in try ... EXCEPT block.

2018-07-12 Thread Ben Bacarisse
aleiphoenix writes: > suppose following code running with Python-3.4.8 and Python-3.6.5 > > > # -*- coding: utf-8 -*- > > > def hello(): > err = None > print('0: {}'.format(locals())) > try: > b = 2 > print('1: {}'.format(locals())) > raise ValueError() >

Re: Static variables [was Re: syntax difference]

2018-06-26 Thread Ben Bacarisse
To: Bart From: "Ben Bacarisse" To: Bart From: Ben Bacarisse Bart writes: > On 23/06/2018 23:25, Ben Bacarisse wrote: >> Bart writes: >> >>> On 23/06/2018 21:13, Chris Angelico wrote: >>>> On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: >

Re: Static variables [was Re: syntax difference]

2018-06-26 Thread Ben Bacarisse
To: Bart From: "Ben Bacarisse" To: Bart From: Ben Bacarisse Bart writes: > On 23/06/2018 21:13, Chris Angelico wrote: >> On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: > >>> (At what point would that happen anyway; if you do this: > >>

Re: translating foreign data

2018-06-26 Thread Ben Bacarisse
To: Steven D'Aprano From: "Ben Bacarisse" To: Steven D'Aprano From: Ben Bacarisse Steven D'Aprano writes: > On Fri, 22 Jun 2018 11:14:59 +0100, Ben Bacarisse wrote: > >>>> The code page remark is curious. Will some "code pages" have digits >&g

Re: Static variables [was Re: syntax difference]

2018-06-25 Thread Ben Bacarisse
To: Bart From: Ben Bacarisse Bart writes: > On 23/06/2018 23:25, Ben Bacarisse wrote: >> Bart writes: >> >>> On 23/06/2018 21:13, Chris Angelico wrote: >>>> On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: >>> >>>>> (At what p

Re: Static variables [was Re: syntax difference]

2018-06-25 Thread Ben Bacarisse
To: Bart From: Ben Bacarisse Bart writes: > On 23/06/2018 21:13, Chris Angelico wrote: >> On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: > >>> (At what point would that happen anyway; if you do this: > >> NONE of your examples are taking copies of the fu

Re: translating foreign data

2018-06-24 Thread Ben Bacarisse
To: Steven D'Aprano From: Ben Bacarisse Steven D'Aprano writes: > On Fri, 22 Jun 2018 11:14:59 +0100, Ben Bacarisse wrote: > >>>> The code page remark is curious. Will some "code pages" have digits >>>> that are not ASCII digits? >>> >>

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Ben Bacarisse
Bart writes: > On 23/06/2018 23:25, Ben Bacarisse wrote: >> Bart writes: >> >>> On 23/06/2018 21:13, Chris Angelico wrote: >>>> On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: >>> >>>>> (At what point would that happen anyway; if y

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Ben Bacarisse
Bart writes: > On 23/06/2018 21:13, Chris Angelico wrote: >> On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: > >>> (At what point would that happen anyway; if you do this: > >> NONE of your examples are taking copies of the function. They all are >> making REFERENCES to the same function. That is

Re: translating foreign data

2018-06-22 Thread Ben Bacarisse
Steven D'Aprano writes: > On Fri, 22 Jun 2018 11:14:59 +0100, Ben Bacarisse wrote: > >>>> The code page remark is curious. Will some "code pages" have digits >>>> that are not ASCII digits? >>> >>> Good question. I have no idea. >>

Re: translating foreign data

2018-06-22 Thread Ben Bacarisse
Ethan Furman writes: > On 06/21/2018 01:20 PM, Ben Bacarisse wrote: >> You say in a followup that you don't need to worry about digit grouping >> marks (like thousands separators) so I'm not sure what the problem is. >> Can't you just replace ',' with '.' a proceed a

Re: translating foreign data

2018-06-21 Thread Ben Bacarisse
Ethan Furman writes: > I need to translate numeric data in a string format into a binary > format. I know there are at least two different methods of > representing parts less that 1, such as "10.5" and "10,5". The data > is encoded using code pages, and can vary depending on the file being >

Re: syntax difference

2018-06-18 Thread Ben Bacarisse
Bart writes: > On 18/06/2018 11:45, Chris Angelico wrote: >> On Mon, Jun 18, 2018 at 8:33 PM, Bart wrote: > > >>> You're right in that neither task is that trivial. >>> >>> I can remove comments by writing a tokeniser which scans Python source and >>> re-outputs tokens one at a time. Such a

Re: syntax difference

2018-06-16 Thread Ben Bacarisse
Cameron Simpson writes: > ... In Python 3 we have "format strings", which let you write: > > name = "Sharon" > age = 35 > print(f"The person named {name|r} is {age} years old.") You meant {name!r} I think there. -- Ben. -- https://mail.python.org/mailman/listinfo/python-list

Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Ben Bacarisse
Jon Ribbens writes: > I'd suggest that since the processes he's purporting to disallow are > entirely standard and automated and he knows full well they exist and > that there is no mechanism by which they could be affected by his > notice, the notice has little effect. The Copyright notice is

Re: Sorting NaNs

2018-06-02 Thread Ben Bacarisse
Paul Rubin writes: > Steven D'Aprano writes: >> it too will mess up sorting in unpredictable ways. So don't do that. > > Hmm. GHCi 7.4.2: > > Prelude> let x = 0.0 / 0.0 > Prelude> x > NaN > Prelude> x==x > False > Prelude> :m Data.List > Prelude Data.List> sort

Re: Pink Floyd: is there anybody in here?

2018-05-30 Thread Ben Bacarisse
Steven D'Aprano writes: > On Wed, 30 May 2018 21:53:05 +0100, Ben Bacarisse wrote: > >> Rob Gaddi writes: >> >>> On 05/30/2018 09:34 AM, Paul Rubin wrote: >>>> I think Usenet posts are no longer getting forwarded to the mailing >>>> list, b

Re: Pink Floyd: is there anybody in here?

2018-05-30 Thread Ben Bacarisse
Rob Gaddi writes: > On 05/30/2018 09:34 AM, Paul Rubin wrote: >> I think Usenet posts are no longer getting forwarded to the mailing >> list, but now I wonder if this is getting out at all, even to usenet. >> >> Does anyone see it? > > Can't speak for the mailing list, but this came out to

Re: List replication operator

2018-05-25 Thread Ben Bacarisse
Steven D'Aprano writes: > On Thu, 24 May 2018 16:05:32 -0700, Paul wrote: > >> How would one make a multi-dimensional list now, with truly-separate sub >> lists? Is there just no way to do it with the replication operator? > > Correct. Let's say you want to

Re: best way to remove leading zeros from a tuple like string

2018-05-20 Thread Ben Bacarisse
<pre>"Michael F. Stemper" <michael.stem...@gmail.com> writes: > On 2018-05-20 16:19, Ben Bacarisse wrote: >> bruceg113...@gmail.com writes: >> >>> Lets say I have the following tuple like string. >>>(128, 020, 008, 255) >>>

Re: best way to remove leading zeros from a tuple like string

2018-05-20 Thread Ben Bacarisse
bruceg113...@gmail.com writes:

> Lets say I have the following tuple like string.
>   (128, 020, 008, 255)
>
> What is the best way to to remove leading zeroes and end up with the 
> following.
>   (128, 20, 8, 255)-- I do not care about spaces

You could use a regexp:

  import re
  

Re: syntax oddities

2018-05-18 Thread Ben Bacarisse
bartc writes: > 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

Re: object types, mutable or not?

2018-05-17 Thread Ben Bacarisse
Anders Wegge Keller writes: > På Wed, 16 May 2018 14:48:27 +0100 > Paul Moore skrev: > >> C++ called that an "rvalue". And then went on to define things that >> could go on the left hand side of an assignment as "lvalues". And now >> we have two confusing

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

2018-05-11 Thread Ben Bacarisse
bartc writes: > On 11/05/2018 01:25, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> Octal makes a lot of sense in the right contexts. >> >> I think octal is a historical relic from a time when people weren't yet >> comfortable with hexadecimal. > > It's a

Re: try-except syntax

2018-04-05 Thread Ben Bacarisse
ElChino writes: > I'm trying to simplify a try-except construct. E.g. how come > this: > try: > _x, pathname, _y = imp.find_module (mod, mod_path) > return ("%s" % pathname) > except ImportError: > pass > except RuntimeError: > pass > return ("") > >

Re: Why is the use of an undefined name not a syntax error?

2018-04-01 Thread Ben Bacarisse
David Foster writes: > My understanding is that the Python interpreter already has enough > information when bytecode-compiling a .py file to determine which > names correspond to local variables in functions. That suggests it has > enough information to identify all valid

Re: Curious case of UnboundLocalError

2018-03-30 Thread Ben Bacarisse
Johannes Bauer <dfnsonfsdu...@gmx.de> writes: > On 30.03.2018 13:13, Ben Bacarisse wrote: > >>> import collections >>> >>> class Test(object): >>> def __init__(self): >>> z = { >>> "y&quo

Re: Curious case of UnboundLocalError

2018-03-30 Thread Ben Bacarisse
Johannes Bauer writes: > I stumbled about something that I cannot quite explain while doing some > stupid naming of variables in my code, in particular using "collections" > as an identifier. However, what results is strange. I've created a > minimal example. Consider this:

Re: Enumerating all 3-tuples (Posting On Python-List Prohibited)

2018-03-15 Thread Ben Bacarisse
Lawrence D’Oliveiro <lawrenced...@gmail.com> writes: > On Thursday, March 15, 2018 at 2:56:24 PM UTC+13, Ben Bacarisse wrote: >> >> Lawrence D’Oliveiro writes: >> >>> On Wednesday, March 14, 2018 at 2:18:24 PM UTC+13, Ben Bacarisse wrote:

Re: Enumerating all 3-tuples (Posting On Python-List Prohibited)

2018-03-14 Thread Ben Bacarisse
Lawrence D’Oliveiro <lawrenced...@gmail.com> writes: > On Wednesday, March 14, 2018 at 2:18:24 PM UTC+13, Ben Bacarisse wrote: >> Lawrence D’Oliveiro writes: >> >> The original problem -- triples of natural numbers -- is >> not particularly hard, but the genera

Re: Enumerating all 3-tuples (Posting On Python-List Prohibited)

2018-03-13 Thread Ben Bacarisse
Lawrence D’Oliveiro <lawrenced...@gmail.com> writes: > On Tuesday, March 13, 2018 at 1:58:48 PM UTC+13, Ben Bacarisse wrote: >> Of course you can always generate n-tuples of N and then map these to >> n-tuples of the intended sequence but that seems inelegant. > >

Re: Enumerating all 3-tuples (Posting On Python-List Prohibited)

2018-03-12 Thread Ben Bacarisse
Lawrence D’Oliveiro <lawrenced...@gmail.com> writes: > On Sunday, March 11, 2018 at 2:40:16 PM UTC+13, Ben Bacarisse wrote: >> It would be nice to avoid relying on any value-based ordering. > > I don’t see why. The set of elements has to have the same cardinality > as th

Re: Enumerating all 3-tuples (Posting On Python-List Prohibited)

2018-03-10 Thread Ben Bacarisse
Lawrence D’Oliveiro <lawrenced...@gmail.com> writes: > On Sunday, March 11, 2018 at 3:24:05 AM UTC+13, Ben Bacarisse wrote: >> Unfortunately my Python is not up to using iterators well enough to >> avoid a "maximum recursion depth exceeded" error. > >

Re: Enumerating all 3-tuples

2018-03-10 Thread Ben Bacarisse
bartc <b...@freeuk.com> writes: > On 10/03/2018 20:06, Ben Bacarisse wrote: >>> On 10/03/2018 14:23, Ben Bacarisse wrote: >>>> Off topic: I knocked up this Haskell version as a proof-of-concept: >>>> >>>> import Data.List >>>>

Re: Enumerating all 3-tuples

2018-03-10 Thread Ben Bacarisse
bartc <b...@freeuk.com> 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 Bacarisse wrote: >> B

Re: Enumerating all 3-tuples

2018-03-10 Thread Ben Bacarisse
Sorry for following up to myself again... Ben Bacarisse <ben.use...@bsb.me.uk> writes: >> ... But I think that is an easier way (no code yet though!) unless >> you are set on one particular enumeration: consider the triple as a pair >> one element of which runs over the

Re: Enumerating all 3-tuples

2018-03-10 Thread Ben Bacarisse
Ben Bacarisse <ben.use...@bsb.me.uk> writes: > Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> writes: > >> I am trying to enumerate all the three-tuples (x, y, z) where each of x, >> y, z can range from 1 to ∞ (infinity). > ... But I think that is

Re: Enumerating all 3-tuples

2018-03-09 Thread Ben Bacarisse
Steven D'Aprano writes: > I am trying to enumerate all the three-tuples (x, y, z) where each of x, > y, z can range from 1 to ∞ (infinity). > > This is clearly unhelpful: > > for x in itertools.count(1): > for y in itertools.count(1): > for z in

Re: How to make Python run as fast (or faster) than Julia

2018-02-27 Thread Ben Bacarisse
Christian Gollwitzer writes: > George Marsaglia is a researcher who invented a couple of PRNGs which > are both simple (one of the first was called KISS) yet surprisingly > good. s/is/was/ Sadly, he died a few years ago (2011). -- Ben. --

Re: How to make Python run as fast (or faster) than Julia

2018-02-26 Thread Ben Bacarisse
bartc writes: > A C version is given below. (One I may have messed around with, which > I'm not sure works properly. For an original, google for Marsaglia and > KISS64 or SUPRKISS64.) The version I know uses unsigned integers. Did you change then to signed? For a Python

Re: How to make Python run as fast (or faster) than Julia

2018-02-23 Thread Ben Bacarisse
Steven D'Aprano writes: > On Fri, 23 Feb 2018 00:26:33 +, bartc wrote: > >> The point of the article was Julia vs. Python. You can't make Python >> faster by switching to a faster algorithm; you have to use the same one >> on both. > > No, the point of

Re: could use some help with this problem! (Posting On Python-List Prohibited)

2018-02-20 Thread Ben Bacarisse
Lawrence D’Oliveiro <lawrenced...@gmail.com> writes: > On Wednesday, February 21, 2018 at 3:10:25 AM UTC+13, Ben Bacarisse wrote: >> You almost never /have/ to use nested loops. Has the course got this >> far without introducing the idea of a function? > > If you ar

Re: could use some help with this problem! I've been working on it for days but cant seem to get it right !

2018-02-20 Thread Ben Bacarisse
Marc Cohen writes: > USING PYTHON 2: Why is that? > Write a program to play this game. This may seem tricky, so break it > down into parts. Like many programs, we have to use nested loops (one > loop inside another). In the outermost loop, we want to keep playing > until

  1   2   3   >