Re: Change first occurrence of character x in a string - how?

2021-02-14 Thread Ned Batchelder
with_at = with_dots.replace(".", "@", 1) https://docs.python.org/3/library/stdtypes.html#str.replace --Ned. On Sunday, February 14, 2021 at 4:18:22 PM UTC-5, Chris Green wrote: > What's the easiest way to change the first occurrence of a specified > character in a string? > > E.g. I want to c

Re: New Python implementation

2021-02-13 Thread Ned Batchelder
On Saturday, February 13, 2021 at 7:19:58 PM UTC-5, Chris Angelico wrote: > On Sun, Feb 14, 2021 at 11:14 AM Mr Flibble > wrote: > > > > On 13/02/2021 23:30, Igor Korot wrote: > > > Hi, > > > But most importantly - what is the reason for this ? > > > I mean - what problems the actual python

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

2018-06-08 Thread Ned Batchelder
On 6/8/18 2:34 AM, Thomas Jollans wrote: On 07/06/18 22:36, Peter Pearson wrote: X-Copyright: (C) Copyright 2018 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change

Re: Learning Python

2018-06-05 Thread Ned Batchelder
On 6/5/18 12:51 PM, T Berger wrote: Can someone learn Python through a book such as Head Start Python? Would an online course from MIT or google be better? This is really a question about your own learning style.  It is possible to learn from a book.  Not too long ago, that was one of the onl

Re: Sorting NaNs

2018-06-02 Thread Ned Batchelder
On 6/2/18 6:16 PM, Richard Damon wrote: On 6/2/18 4:51 PM, Ben Bacarisse wrote: 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

Re: Fwd: QUERY

2018-06-02 Thread Ned Batchelder
On 6/2/18 9:08 AM, S Srihari wrote: To: python-list@python.org I AM UNABLE TO INSTALL PYTHON. KINDLY HELP ME. Put yourself in our shoes: how can we help you with so little information?  We don't know what operating system you are on, we don't know what you have tried, we don't know what has

Re: convert a string to a variable

2018-05-25 Thread Ned Batchelder
On 5/25/18 9:52 AM, brucegoodst...@gmail.com wrote: On Friday, May 25, 2018 at 8:06:31 AM UTC-4, Ned Batchelder wrote: On 5/24/18 6:54 PM, bruceg113...@gmail.com wrote: I am trying to convert a string to a variable. I got cases 1 & 2 to work, but not cases 3 & 4. The print statement

Re: convert a string to a variable

2018-05-25 Thread Ned Batchelder
On 5/24/18 6:54 PM, bruceg113...@gmail.com wrote: I am trying to convert a string to a variable. I got cases 1 & 2 to work, but not cases 3 & 4. The print statement in cases 3 & 4 reports the following: builtins.AttributeError: type object 'animal' has no attribute 'tiger' I am stuck

Re: List replication operator

2018-05-24 Thread Ned Batchelder
On 5/24/18 2:17 PM, Steven D'Aprano wrote: Python has a sequence replication operator: py> [1, 2]*3 [1, 2, 1, 2, 1, 2] Unfortunately, it is prone to a common "gotcha": py> x = [[]]*5 # make a multi-dimensional list py> x [[], [], [], [], []] py> x[0].append(1) py> x [[1], [1], [1], [1], [1]]

Re: Usenet Gateway

2018-05-23 Thread Ned Batchelder
On 5/23/18 12:03 PM, Gene Heskett wrote: On Wednesday 23 May 2018 11:20:34 Abdur-Rahmaan Janhangeer wrote: can someone explain to me why the mailing list (spam free) is not used by everybody? Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Brain damaged by facebook, AOL, M$, Google

Re: "Data blocks" syntax specification draft

2018-05-21 Thread Ned Batchelder
On 5/21/18 9:42 PM, Mikhail V wrote: On Mon, May 21, 2018 at 2:14 PM, Ned Batchelder wrote: On 5/19/18 10:58 PM, Mikhail V wrote: I have made up a printable PDF with the current version of the syntax suggestion. https://github.com/Mikhail22/Documents/blob/master/data-blocks-v01.pdf After

Re: "Data blocks" syntax specification draft

2018-05-21 Thread Ned Batchelder
On 5/19/18 10:58 PM, Mikhail V wrote: I have made up a printable PDF with the current version of the syntax suggestion. https://github.com/Mikhail22/Documents/blob/master/data-blocks-v01.pdf After some of your comments I've made some further re-considerations, e.g. element separation should be

Re: what does := means simply?

2018-05-18 Thread Ned Batchelder
On 5/18/18 7:09 AM, 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 Python source code. But you will quickly run into problems because you will often

Re: why does list's .remove() does not return an object?

2018-05-17 Thread Ned Batchelder
On 5/17/18 12:28 PM, Dan Strohl via Python-list wrote: On 2018-05-17 11:26 AM, Abdur-Rahmaan Janhangeer wrote: I don't understand what this would return? x? You already have x. Is it meant to make a copy? x has been mutated, so I don't understand the benefit of making a copy of the 1-less x. C

Re: why does list's .remove() does not return an object?

2018-05-17 Thread Ned Batchelder
On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer wrote: x = [0,1] x.remove(0) new_list = x instead i want in one go x = [0,1] new_list = x.remove(0) # here a way for it to return the modified list by adding a .return() maybe ? There isn't a way to do that in one line.  I often find myself splitt

Re: why does list's .remove() does not return an object?

2018-05-17 Thread Ned Batchelder
-Ned. (PS: bottom-posting (adding your response below the text you are responding to) will make the conversation easier to follow...) ps. list is was demo illustrative var Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ On Thu, 17 May 2018, 07:01 Ned Batchelder, <mailto:n...@nedb

Re: why does list's .remove() does not return an object?

2018-05-16 Thread Ned Batchelder
On 5/16/18 10:41 PM, Abdur-Rahmaan Janhangeer wrote: why is x = list.remove(elem) not return the list? Methods in Python usually do one of two things: 1) mutate the object and return None; or 2) leave the object alone and return a new object.  This helps make it clear which methods mutate and

Re: object types, mutable or not?

2018-05-16 Thread Ned Batchelder
On 5/16/18 10:06 AM, Steven D'Aprano wrote: On Wed, 16 May 2018 09:23:02 -0400, Ned Batchelder wrote: I've also experimented with different ways to better say "everything is an object".  One possibility is, "any right-hand side of an assignment is an object,"

Re: object types, mutable or not?

2018-05-16 Thread Ned Batchelder
On 5/16/18 3:17 AM, Steven D'Aprano wrote: On Wed, 16 May 2018 17:03:22 +1000, Ben Finney wrote: So, no, I think the more useful – and less problematic – framing is that every object *has* a value, and mutable objects may change to a different value while remaining the same object. What's an o

Re: Problem/bug with class definition inside function definition

2018-05-08 Thread Ned Batchelder
On 5/8/18 3:55 AM, Alexey Muranov wrote: Sorry, i was confused.  I would say that this mostly works as expected, though the difference between    x = 42    class C:    x = x  # Works and    def f2(a):    class D:    a = a  # Does not work <    return D is still surpr

Re: syntax error (?) on ubuntu

2018-05-03 Thread Ned Batchelder
On 5/3/18 9:11 AM, Joel Goldstick wrote: On Thu, May 3, 2018 at 9:06 AM, joseph pareti wrote: $ python tf_simple.py /anaconda/envs/py35/lib/python3.5/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. I

Re: The perils of multiple Pythons

2018-04-30 Thread Ned Batchelder
On 4/30/18 1:15 PM, Chris Angelico wrote: https://xkcd.com/1987/ So take-away is: On a Mac, just use Homebrew. (Cue the angry hordes telling me how wrong I am.) My take-away (though not really, since I held this view before this morning): pick a way and stick to it. --Ned. -- https://

Re: Issue with python365.chm on window 7

2018-04-24 Thread Ned Batchelder
On 4/24/18 2:10 AM, Bob Martin wrote: Senior Software Engineer? Seriously? What is the point of this comment?  We can be more respectful than this. --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: Compression of random binary data

2018-04-12 Thread Ned Batchelder
On 4/11/18 9:29 PM, cuddlycave...@gmail.com wrote: I’m replying to your post on January 28th Nice carefully chosen non random numbers Steven D'Aprano. Was just doing what you asked, but you don’t remember 😂😂😂 Best practice is to include a quote of the thing you are replying to.  It makes it m

Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-26 Thread Ned Batchelder
On 3/26/18 7:10 PM, Python wrote: Humans are already good enough at making mistakes that they require no additional encouragement, such as what is provided by allowing such syntactical horrors. Agreed. And that's why we must respect and follow the code styling wisdom which has been passed down b

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Ned Batchelder
On 3/23/18 12:39 PM, Malcolm Greene wrote: Perhaps it doesn't need to be said, but just to be sure: don't use eval if you don't trust the people writing the configuration file. They can do nearly unlimited damage to your environment.  They are writing code that you are running. Of course! Sc

Re: Python 3.6: How to expand f-string literals read from a file vs inline statement

2018-03-23 Thread Ned Batchelder
On 3/23/18 4:30 AM, Malcolm Greene wrote: Looking for advice on how to expand f-string literal strings whose values I'm reading from a configuration file vs hard coding into my script as statements. I'm using f-strings as a very simple template language. I'm currently using the following techniqu

Re: [OT] Re: Thank you Python community!

2018-03-20 Thread Ned Batchelder
On 3/20/18 12:08 PM, Rick Johnson wrote: On Tuesday, March 20, 2018 at 7:03:11 AM UTC-5, Adriaan Renting wrote: (on the subject of the opioid epidemic) The [OT] in the subject line is right: let's not get off on a political tangent. --Ned. -- https://mail.python.org/mailman/listinfo/python-

Re: Style Q: Instance variables defined outside of __init__

2018-03-19 Thread Ned Batchelder
On 3/19/18 1:04 PM, Irv Kalb wrote: I am building some classes for use in future curriculum. I am using PyCharm for my development. On the right hand edge of the PyCharm editor window, you get some little bars indicating warnings or errors in your code. I like this feature and try to clean

Re: List slicing on Python 2.7

2018-03-15 Thread Ned Batchelder
On 3/15/18 12:35 PM, Peter Otten wrote: Ned Batchelder wrote: On 3/15/18 9:57 AM, Vlastimil Brom wrote: 2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski : I have a custom class (a lazy list-like container) that needs to support slicing. The __getitem__ checks if index is of slice type, and does a

Re: List slicing on Python 2.7

2018-03-15 Thread Ned Batchelder
On 3/15/18 9:57 AM, Vlastimil Brom wrote: 2018-03-15 12:54 GMT+01:00 Arkadiusz Bulski : I have a custom class (a lazy list-like container) that needs to support slicing. The __getitem__ checks if index is of slice type, and does a list comprehension over individual integer indexes. The code work

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-04 Thread Ned Batchelder
On 3/4/18 5:25 PM, Ooomzay wrote: On Sunday, 4 March 2018 14:37:30 UTC, Ned Batchelder wrote: Are you including cyclic references in your assertion that CPython behaves as you want? Yes. Because the only behaviour required for RAII is to detect and debug such cycles in order to eliminate

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-04 Thread Ned Batchelder
On 3/4/18 9:11 AM, Ooomzay wrote: I am well aware of what it will mean for interpreters. For some interpreters it will have zero impact (e.g. CPython) ... There's no point continuing this if you are just going to insist on falsehoods like this.  CPython doesn't currently do what you want, but

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-04 Thread Ned Batchelder
On 3/4/18 7:37 AM, Ooomzay wrote: On Sunday, 4 March 2018 04:23:07 UTC, Steven D'Aprano wrote: [...] [This PEP] imposes enormous burdens on the maintainers of at least five interpreters (CPython, Stackless, Jython, IronPython, PyPy) all of which will need to be re-written to have RAII semantics

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-04 Thread Ned Batchelder
On 3/4/18 8:26 AM, Ooomzay wrote: On Sunday, 4 March 2018 03:16:31 UTC, Paul Rubin wrote: Chris Angelico writes: Yep, cool. Now do that with all of your smart pointers being on the heap too. You are not allowed to use ANY stack objects. ANY. Got it? That's both overconstraining and not even

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-03 Thread Ned Batchelder
On 2/28/18 6:53 PM, ooom...@gmail.com wrote: On Wednesday, February 28, 2018 at 11:45:24 PM UTC, ooo...@gmail.com wrote: On Wednesday, February 28, 2018 at 11:02:17 PM UTC, Chris Angelico wrote: On Thu, Mar 1, 2018 at 9:51 AM, ooomzay wrote: [snip] Taking a really simple situation: class Foo:

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-03 Thread Ned Batchelder
On 3/2/18 10:36 AM, Paul Moore wrote: Or (real Python): def fn(): for i in range(1): with open(f"file{i}.txt", "w") as f: f.write("Some text") How would you write this in your RAII style - without leaving 10,000 file descriptors open until the end

Re: Functions unnecessarily called in Python/pylifecycle.c:_Py_InitializeCore() ?

2018-03-01 Thread Ned Batchelder
On 3/1/18 7:40 AM, Thomas Nyberg wrote: On 03/01/2018 12:46 PM, bartc wrote: If they're only called once, then it probably doesn't matter too much in terms of harming performance. Oh yeah there's no way this has any affect on performance. A smart compiler might even be able optimize the call aw

Re: Detection of ultrasonic side channels in mobile devices with Python?

2018-02-28 Thread Ned Batchelder
On 2/28/18 7:01 PM, Etienne Robillard wrote:  What do rats find rewarding in play fighting? This is well outside the topics for this list. --Ned. Le 2018-02-28 à 18:29, Chris Angelico a écrit : On Thu, Mar 1, 2018 at 10:23 AM, Steven D'Aprano wrote: I'd go further... what gave you the i

Re: Detection of ultrasonic side channels in mobile devices with Python?

2018-02-28 Thread Ned Batchelder
On 2/28/18 4:13 PM, Etienne Robillard wrote: I want to know why this question is being silently ignored by this group. If no one has any information about your topic, then no one will say anything.  Python on Android is very specialized as it is, and I have no idea what ultrasonic side channe

Re: Questions about `locals` builtin

2018-02-27 Thread Ned Batchelder
On 2/27/18 3:52 AM, Kirill Balunov wrote: a. Is this restriction for locals desirable in the implementation of CPython in Python 3? b. Or is it the result of temporary fixes for Python 2? My understanding is that the behavior of locals() is determined mostly by what is convenient for the imp

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

2018-02-26 Thread Ned Batchelder
On 2/26/18 10:09 AM, Chris Angelico wrote: On Tue, Feb 27, 2018 at 2:02 AM, bartc wrote: On 26/02/2018 14:04, bartc wrote: On 26/02/2018 13:42, Ned Batchelder wrote: Well, once you notice that the Python code had N=1e5, and the C code had N=1e9 :) If you want to experiment, with N

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

2018-02-26 Thread Ned Batchelder
On 2/26/18 7:13 AM, bartc wrote: On 26/02/2018 11:40, Chris Angelico wrote: On Mon, Feb 26, 2018 at 10:13 PM, bartc wrote: Below is the first draft of a Python port of a program to do with random numbers. (Ported from my language, which in turned ported it from a C program by George Marsaglia

Re: How to only get \n for newline without the single quotes?

2018-02-24 Thread Ned Batchelder
On 2/24/18 2:08 PM, Peng Yu wrote: On Sat, Feb 24, 2018 at 12:45 PM, Wildman via Python-list wrote: On Sat, 24 Feb 2018 11:41:32 -0600, Peng Yu wrote: I would like to just get the escaped string without the single quotes. Is there a way to do so? Thanks. x='\n' print repr(x) '\n' Python 3

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

2018-02-23 Thread Ned Batchelder
On 2/23/18 3:02 PM, bartc wrote: On 23/02/2018 19:47, Chris Angelico wrote: On Sat, Feb 24, 2018 at 6:25 AM, bartc wrote: The difference between Python and another dynamic language might be a magnitude, yet you say it doesn't matter. Thanks, that makes me feel much better about my own work!

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

2018-02-22 Thread Ned Batchelder
On 2/22/18 11:00 AM, bartc wrote: On 22/02/2018 12:03, bartc wrote: On the fib(20) test, it suggests using this to get a 30,000 times speed-up: BTW while doing my tests, I found you could redefine the same function with no error: def fred(): pass def fred(): pass def fred():

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-20 Thread Ned Batchelder
On 2/20/18 5:47 AM, Antoon Pardon wrote: On 19-02-18 16:18, Ned Batchelder wrote: On 2/19/18 9:54 AM, Steven D'Aprano wrote: On Mon, 19 Feb 2018 13:28:26 +, Paul Moore wrote: [1] The most basic question, which people making such claims often can't answer, is "Do you mean

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Ned Batchelder
On 2/19/18 1:01 PM, Paul Moore wrote: On 19 February 2018 at 17:11, Ned Batchelder wrote: On 2/19/18 10:39 AM, Paul Moore wrote: I'm curious - How would you explain Python's "variables" to someone who knows how C variables work, in a way that ensures they don't car

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Ned Batchelder
On 2/19/18 10:39 AM, Paul Moore wrote: On 19 February 2018 at 15:18, Ned Batchelder wrote: On 2/19/18 9:54 AM, Steven D'Aprano wrote: On Mon, 19 Feb 2018 13:28:26 +, Paul Moore wrote: [1] The most basic question, which people making such claims often can't answer, is "D

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Ned Batchelder
On 2/19/18 9:54 AM, Steven D'Aprano wrote: On Mon, 19 Feb 2018 13:28:26 +, Paul Moore wrote: [1] The most basic question, which people making such claims often can't answer, is "Do you mean that values are strongly typed, or that names are? Or did you mean that variables are, because if so

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-18 Thread Ned Batchelder
On 2/18/18 6:57 AM, bartc wrote: On 18/02/2018 11:45, Ned Batchelder wrote: Let's not go down this path yet again. We've heard it all before. Bart: stop it.  Everyone else: stop it. :) Well, this was a rare instance of someone admitting that a simple and smaller codebase has b

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-18 Thread Ned Batchelder
On 2/18/18 6:33 AM, bartc wrote: On 18/02/2018 01:39, Chris Angelico wrote: On Sun, Feb 18, 2018 at 12:31 PM, bartc wrote: On 18/02/2018 00:45, Chris Angelico wrote: On Sun, Feb 18, 2018 at 11:13 AM, bartc wrote: It's text, but it is an intermediate or "object" file. It's not doing poin

Re: Python GIL vs CAS

2018-02-15 Thread Ned Batchelder
On 2/15/18 9:35 AM, Chris Angelico wrote: On Thu, Feb 15, 2018 at 2:40 PM, Oleg Korsak wrote: Hi. While hearing about GIL every time... is there any real reason why CAS doesn't help to solve this problem? https://en.wikipedia.org/wiki/Compare-and-swap Because the GIL is not a problem. It's a

Re: Django-hotsauce 1.0 commercial edition looking for beta testers!

2018-02-13 Thread Ned Batchelder
On 2/13/18 6:41 PM, Etienne Robillard wrote: Hello everyone, Django-hotsauce 1.0 commercial edition (LTS) is now available for preorder :) Checkout: https://www.livestore.ca/product/django-hotsauce/ I'm also looking for expert Django and Python programmers to test and review the design and

Re: PyPy support breaking CPython compatibility?

2018-01-31 Thread Ned Batchelder
On 1/30/18 3:58 PM, Etienne Robillard wrote: Hi Ned, Le 2018-01-30 à 15:14, Ned Batchelder a écrit : I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 thing as Chris mentions.) Please take a look at the changesets: https://bitbucket.org/tkadm30/libsche

Re: PyPy support breaking CPython compatibility?

2018-01-30 Thread Ned Batchelder
On 1/30/18 4:08 PM, Chris Angelico wrote: On Wed, Jan 31, 2018 at 7:58 AM, Etienne Robillard wrote: Hi Ned, Le 2018-01-30 à 15:14, Ned Batchelder a écrit : I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 thing as Chris mentions.) Please take a look at the

Re: PyPy support breaking CPython compatibility?

2018-01-30 Thread Ned Batchelder
On 1/30/18 2:35 PM, Etienne Robillard wrote: Hi, I managed to patch Schevo and Durus to run under PyPy 5.9. However, I'm afraid the changes is breaking Python 2.7 compatibility. I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 thing as Chris mentions.) I'm not sure how I

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-27 Thread Ned Batchelder
On 1/27/18 3:15 PM, Jason Qian via Python-list wrote: HI I am a string that contains \r\n\t [Ljava.lang.Object; does not exist*\r\n\t*at com.livecluster.core.tasklet I would like it print as : [Ljava.lang.Object; does not exist tat com.livecluster.core.tasklet It looks like

Re: exec and traceback

2018-01-25 Thread Ned Batchelder
On 1/22/18 3:22 AM, ken...@gameofy.com wrote: I'm using exec() to run a (multi-line) string of python code. If an exception occurs, I get a traceback containing a stack frame for the string. I've labeled the code object with a "file name" so I can identify it easily, and when I debug, I find

Re: python to C code generator

2018-01-23 Thread Ned Batchelder
On 1/23/18 8:48 AM, kushal bhattacharya wrote: On Tuesday, January 23, 2018 at 7:05:02 PM UTC+5:30, bartc wrote: On 23/01/2018 13:23, kushal bhattacharya wrote: On Wednesday, January 17, 2018 at 4:34:23 PM UTC+5:30, kushal bhattacharya wrote: Hi, Is there any python framework or any tool as

Re: exec and traceback

2018-01-22 Thread Ned Batchelder
On 1/22/18 3:22 AM, ken...@gameofy.com wrote: (BTW, I've written a simple secure eval()) You have accurately guessed our interest!  Would you mind starting a new thread to show us your simple secure eval? --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: Speeding up the implementation of Stochastic Gradient Ascent in Python

2018-01-17 Thread Ned Batchelder
On 1/17/18 2:45 PM, Chris Angelico wrote: On Thu, Jan 18, 2018 at 6:28 AM, Ned Batchelder wrote: You'll have to replace random.choice() with random.choice(list(...)), since you can't random.choice from a set. Side point: why can't you? You can random.sample from a set, bu

Re: Speeding up the implementation of Stochastic Gradient Ascent in Python

2018-01-17 Thread Ned Batchelder
On 1/17/18 9:29 AM, leutrim.kal...@gmail.com wrote: Hello everyone, I am implementing a time-dependent Recommender System which applies BPR (Bayesian Personalized Ranking), where Stochastic Gradient Ascent is used to learn the parameters of the model. Such that, one iteration involves sampling

Re: documentation on read.encode

2018-01-16 Thread Ned Batchelder
On 1/16/18 2:19 PM, Larry Martell wrote: On Tue, Jan 16, 2018 at 12:00 PM, Larry Martell wrote: Looking for 2.7 docs on read.encode - googling did not turn up anything. Specifically, looking for the supported options for base64, and how to specify them, e.g. Base64.NO_WRAP So I just realized

Re: Where is the usage of (list comprehension) documented?

2018-01-15 Thread Ned Batchelder
On 1/14/18 9:57 PM, Dan Stromberg wrote: On Sun, Jan 14, 2018 at 3:01 PM, Peng Yu wrote: Hi, I see the following usage of list comprehension can generate a generator. Does anybody know where this is documented? Thanks. Here's the (a?) generator expression PEP: https://www.python.org/dev/peps/

Re: Simple graphic library for beginners

2018-01-11 Thread Ned Batchelder
On 1/11/18 8:21 PM, bartc wrote: On 11/01/2018 23:23, Chris Angelico wrote: On Fri, Jan 12, 2018 at 10:11 AM, bartc wrote: I'm almost ready to plonk you, but I think there is still SOME value in your posts. But please, stop denigrating what you don't understand. And please try to see thing

Re: Simple graphic library for beginners

2018-01-11 Thread Ned Batchelder
On 1/11/18 10:23 AM, Chris Angelico wrote: On Fri, Jan 12, 2018 at 12:38 AM, bartc wrote: On 11/01/2018 05:16, Michael Torrie wrote: On 01/10/2018 01:13 PM, bartc wrote: Yes the link didn't have the simple examples I hoped for. How's this: - import pygame import

Re: Copy-on-write friendly Python garbage collection (Posting On Python-List Prohibited)

2018-01-01 Thread Ned Batchelder
On 1/1/18 1:49 PM, Niles Rogoff wrote: On Mon, 01 Jan 2018 10:42:58 -0800, breamoreboy wrote: On Monday, January 1, 2018 at 10:14:59 AM UTC, wxjm...@gmail.com wrote: Le lundi 1 janvier 2018 08:35:53 UTC+1, Lawrence D’Oliveiro a écrit : On Monday, January 1, 2018 at 7:52:48 AM UTC+13, Paul Rub

Re: you shortened it, but you broke it too... ;-)

2018-01-01 Thread Ned Batchelder
On 12/31/17 8:15 PM, Wu Xi wrote: def neighbours(point): x,y = point yield x + 1 , y yield x - 1 , y yield x , y + 1 yield x , y - 1 #this is proof that life can emerge inside of computers and cellular automatons, yield x + 1 , y + 1

Re: Python goto

2017-12-28 Thread Ned Batchelder
On 12/28/17 6:43 AM, jorge.conr...@cptec.inpe.br wrote: Hi, I would like to know if there is a goto command or something similar that I can use in Python. Python does not have a goto statement. You have to use structured statements: for, while, try/except, yield, return, etc. If you sh

Re: What is wrong with this regex for matching emails?

2017-12-17 Thread Ned Batchelder
On 12/17/17 10:29 AM, Peng Yu wrote: Hi, I would like to extract "a...@efg.hij.xyz". But it only shows ".hij". Does anybody see what is wrong with it? Thanks. $ cat main.py #!/usr/bin/env python # vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8: import re email_re

Re: Automated distribution building tools to support SpamBayes

2017-12-15 Thread Ned Batchelder
On 12/15/17 2:03 PM, Skip Montanaro wrote: SpamBayes (http://www.spambayes.org/) has languished for quite awhile, in part because nobody is around who can put together a Windows installer. Unfortunately, most users are on Windows and have to work around problems caused by the march of time and co

Re: f-string

2017-12-08 Thread Ned Batchelder
On 12/5/17 7:16 PM, Steve D'Aprano wrote: > compile('f"{spam} {eggs}"', '', 'single') $ python3.6 Python 3.6.3 (default, Octâ 4 2017, 06:03:25) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin Type "help", "copyright", "credits" or "license" for more information.

Re: How to use a regexp here

2017-12-08 Thread Ned Batchelder
On 12/4/17 9:13 AM, Rick Johnson wrote: > Perhaps it's not politically correct for me to say this, but > i've never been one who cared much about political > correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's message.â His messages are famous for their outra

Re: How to use a regexp here

2017-12-08 Thread Ned Batchelder
On 12/4/17 4:36 AM, Cecil Westerhof wrote: > I have a script that was running perfectly for some time. It uses: > array = [elem for elem in output if 'CPU_TEMP' in elem] > > But because output has changed, I have to check for CPU_TEMP at the > beginning of the line. What would be the best way

Re: why won't slicing lists raise IndexError?

2017-12-08 Thread Ned Batchelder
On 12/7/17 9:02 PM, Python wrote: Can you please explain to me Really, you just have to ignore him. --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ned Batchelder
On 12/7/17 2:41 PM, Ethan Furman wrote: On 12/07/2017 11:23 AM, Ned Batchelder wrote: On 12/7/17 1:28 PM, Ethan Furman wrote: --> identity('spam', 'eggs', 7) ('spam', 'eggs', 7) I don't see why this last case should hold.  Why does the functi

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ned Batchelder
On 12/7/17 1:28 PM, Ethan Furman wrote: The simple answer is No, and all the answers agree on that point. It does beg the question of what an identity function is, though. My contention is that an identity function is a do-nothing function that simply returns what it was given: --> identity(

Re: why won't slicing lists raise IndexError?

2017-12-06 Thread Ned Batchelder
After a certain point, the only thing you can do with a troll is ignore them. --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: f-string

2017-12-05 Thread Ned Batchelder
On 12/5/17 7:16 PM, Steve D'Aprano wrote: compile('f"{spam} {eggs}"', '', 'single') $ python3.6 Python 3.6.3 (default, Oct  4 2017, 06:03:25) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin Type "help", "copyright", "credits" or "license" for more information.

Re: why won't slicing lists raise IndexError?

2017-12-05 Thread Ned Batchelder
On 12/4/17 10:41 PM, Rick Johnson wrote: I think we've demonstrated the slicing semantics well. Indeed. And i never questioned this aspect. I merely wanted to inform the lurkers that the else-clause was handling a non-action, and therefore, could be omitted. Your original statement sounded lik

Re: why won't slicing lists raise IndexError?

2017-12-04 Thread Ned Batchelder
On 12/4/17 9:31 PM, Rick Johnson wrote: On Monday, December 4, 2017 at 7:47:20 PM UTC-6, Ned Batchelder wrote: [...] Here are details filled in: $ python3.6 Python 3.6.3 (default, Oct 4 2017, 06:03:25) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin

Re: why won't slicing lists raise IndexError?

2017-12-04 Thread Ned Batchelder
On 12/4/17 8:03 PM, Rick Johnson wrote: On Monday, December 4, 2017 at 6:13:19 PM UTC-6, Chris Angelico wrote: [...] Ahhh, I see how it is. You didn't run the code, ergo you don't understand it. Makes perfect sense. :) Being that Terry didn't offer any declarations or defintions for his

Re: How to use a regexp here

2017-12-04 Thread Ned Batchelder
On 12/4/17 9:13 AM, Rick Johnson wrote: Perhaps it's not politically correct for me to say this, but i've never been one who cared much about political correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's message.  His messages are famous for their outrageo

Re: How to use a regexp here

2017-12-04 Thread Ned Batchelder
On 12/4/17 4:36 AM, Cecil Westerhof wrote: I have a script that was running perfectly for some time. It uses: array = [elem for elem in output if 'CPU_TEMP' in elem] But because output has changed, I have to check for CPU_TEMP at the beginning of the line. What would be the best way to impl

Re: connect four (game)

2017-11-27 Thread nospam . Ned Batchelder
On 11/27/17 1:57 PM, bartc wrote: > On 27/11/2017 17:41, Chris Angelico wrote: >> On Tue, Nov 28, 2017 at 2:14 AM, bartc wrote: >>> JPEG uses lossy compression. The resulting recovered data is an >>> approximation of the original. >> >> Ah but it is a perfect representation of the JPEG stream. Any

Re: I have framework on python with pyunit, facing below issue while

2017-11-27 Thread nospam . Ned Batchelder
On 11/27/17 8:13 AM, jaya.bir...@gmail.com wrote: > Please let me know anyone aware about the issue > > > Traceback (most recent call last): > File "testrunner.py", line 447, in > testrunner_obj.main() > File "testrunner.py", line 433, in main > self.result() > File "testrunner.py", line 310, in r

Re: While, If, Count Statements

2017-11-27 Thread nospam . Ned Batchelder
On 11/27/17 7:54 AM, Cai Gengyang wrote: > Input : > > count = 0 > > if count < 5: >print "Hello, I am an if statement and count is", count > > while count < 10: >print "Hello, I am a while and count is", count >count += 1 > > Output : > > Hello, I am an if statement and count is 0 > He

Re: connect four (game)

2017-11-27 Thread Ned Batchelder
On 11/27/17 1:57 PM, bartc wrote: On 27/11/2017 17:41, Chris Angelico wrote: On Tue, Nov 28, 2017 at 2:14 AM, bartc wrote: JPEG uses lossy compression. The resulting recovered data is an approximation of the original. Ah but it is a perfect representation of the JPEG stream. Any given compre

Re: While, If, Count Statements

2017-11-27 Thread Ned Batchelder
On 11/27/17 7:54 AM, Cai Gengyang wrote: Input : count = 0 if count < 5: print "Hello, I am an if statement and count is", count while count < 10: print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is 0 Hello, I am a while and c

Re: I have framework on python with pyunit, facing below issue while executing test case

2017-11-27 Thread Ned Batchelder
On 11/27/17 8:13 AM, jaya.bir...@gmail.com wrote: Please let me know anyone aware about the issue Traceback (most recent call last): File "testrunner.py", line 447, in testrunner_obj.main() File "testrunner.py", line 433, in main self.result() File "testrunner.py", line 310, in result result =

Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-26 Thread nospam . nospam . Ned Batchelder
On 11/25/17 5:05 PM, wojtek.m...@gmail.com wrote: > Hi, my goal is to obtain an interpreter that internally > uses UCS-2. Such a simple code should print 65535: > >import sys >print sys.maxunicode > > This is enabled in Windows, but I want the same in Linux. > What options have I pass to th

Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-26 Thread nospam . Ned Batchelder
On 11/25/17 5:05 PM, wojtek.m...@gmail.com wrote: > Hi, my goal is to obtain an interpreter that internally > uses UCS-2. Such a simple code should print 65535: > >import sys >print sys.maxunicode > > This is enabled in Windows, but I want the same in Linux. > What options have I pass to th

Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-25 Thread Ned Batchelder
On 11/25/17 5:05 PM, wojtek.m...@gmail.com wrote: Hi, my goal is to obtain an interpreter that internally uses UCS-2. Such a simple code should print 65535: import sys print sys.maxunicode This is enabled in Windows, but I want the same in Linux. What options have I pass to the configure

Re: Benefits of unicode identifiers (was: Allow additional separator in identifiers)

2017-11-24 Thread Ned Batchelder
On 11/24/17 5:26 PM, Richard Damon wrote: Have you tried using U+2010 (HYPHEN) ‐. It is in the class XID_CONTINUE (in fact it is in XID_START) so should be available. U+2010 isn't allowed in Python 3 identifiers. The rules for identifiers are here: https://docs.python.org/3/reference/lexical

Re: How to Generate dynamic HTML Report using Python

2017-11-21 Thread Ned Batchelder
On 11/20/17 9:50 AM, Stefan Ram wrote: Ned Batchelder writes: Also, why set headers that prevent the Python-List mailing list from archiving your messages? I am posting to a Usenet newsgroup. I am not aware of any "Python-List mailing list". I am posting specifically to

Re: How to Generate dynamic HTML Report using Python

2017-11-19 Thread Ned Batchelder
On 11/19/17 8:40 PM, Stefan Ram wrote: mradul dhakad writes: I am new to python . I am trying to generate Dynamic HTML report using Pyhton based on number of rows selected from query .Do any one can suggest some thing for it. main.py import sqlite3 conn = sqlite3.connect( ':memory:' ) c =

Re: Should constants be introduced to Python?

2017-11-16 Thread Ned Batchelder
On 11/16/17 1:16 AM, Saeed Baig wrote: Hey guys I am thinking of perhaps writing a PEP to introduce constants to Python. Something along the lines of Swift’s “let” syntax (e.g. “let pi = 3.14”). Since I’m sort of new to this, I just wanted to ask: - Has a PEP for this already been written? If

Re: from xx import yy

2017-11-12 Thread Ned Batchelder
On 11/12/17 9:17 PM, bvdp wrote: I'm having a conceptual mind-fart today. I just modified a bunch of code to use "from xx import variable" when variable is a global in xx.py. But, when I change/read 'variable' it doesn't appear to change. I've written a bit of code to show the problem: mod1.p

Re: How to modify this from Python 2.x to v3.4?

2017-11-11 Thread Ned Batchelder
On 11/11/17 6:56 AM, jf...@ms4.hinet.net wrote: I learned python start from using v3.4 and never has any v2.x experience. There is a Pypi project "ctypesgen" I like to use, but it seems is for v2.x. (un)Fortunately I found one of its branch on github which announced is for Python3, but strangel

  1   2   3   4   5   6   7   8   9   >