Re: Finding good documentation for gpiod

2023-09-03 Thread Barry via Python-list
E > On 3 Sep 2023, at 22:49, Chris Green via Python-list > wrote: > > Mostly I am managing to get things to work as I want but better > documentation of gpiod would be a great help. Ask the author? https://github.com/aswild/python-gpiod Maybe read the source code for hints? Barry -- https:/

Finding good documentation for gpiod

2023-09-03 Thread Chris Green via Python-list
ault values passed down to LineBulk.request()) is still supported for backward compatibility but is now deprecated when requesting single lines. Which is pretty good **except** that I can't find a proper description of the parameters anywhere, i.e. there's nowhere that e

ipaddress (was: Re: for a 'good python')

2023-04-21 Thread Simon Ward
On Thu, Apr 13, 2023 at 04:00:59PM +0100, Barry wrote: Ipaddress was developed outside of the std lib and later added i recall. I used it prior to it being in the standard library: https://pypi.org/project/ipaddr/ Simon -- A complex system that works is invariably found to have evolved from a

Re: for a 'good python'

2023-04-13 Thread Dennis Lee Bieber
On Thu, 13 Apr 2023 00:21:58 +0200, jak declaimed the following: >Thank you too. I had seen this library but I always try not to use >libraries outside the standard ones. Now I don't remember why I was >convinced that this wasn't part of it, perhaps because it was like that >at the time or becau

Re: for a 'good python'

2023-04-13 Thread jak
Dennis Lee Bieber ha scritto: On Thu, 13 Apr 2023 00:21:58 +0200, jak declaimed the following: Thank you too. I had seen this library but I always try not to use libraries outside the standard ones. Now I don't remember why I was convinced that this wasn't part of it, perhaps because it was l

Re: for a 'good python'

2023-04-13 Thread Barry
 > On 13 Apr 2023, at 00:19, jak wrote: > > Barry ha scritto: >>  >>>> On 12 Apr 2023, at 18:10, jak wrote: >>> Hi everyone, >>> some time ago I wrote a class to determine if an ipv4 address belonged >>> to a subnet. Seldom using pytho

Re: for a 'good python'

2023-04-13 Thread Lars Liedtke
ss to determine if an ipv4 address belonged to a subnet. Seldom using python I'm pretty sure it's not written in 'good python' nor too portable. Could you give me some advice to make it better? class calcip: def __init__(self, psubnet: str): ssubnet, scidr = psubnet.rep

Re: for a 'good python'

2023-04-12 Thread jak
Barry ha scritto:  On 12 Apr 2023, at 18:10, jak wrote: Hi everyone, some time ago I wrote a class to determine if an ipv4 address belonged to a subnet. Seldom using python I'm pretty sure it's not written in 'good python' nor too portable. Could you give me some advi

Re: for a 'good python'

2023-04-12 Thread Barry
 > On 12 Apr 2023, at 18:10, jak wrote: > Hi everyone, > some time ago I wrote a class to determine if an ipv4 address belonged > to a subnet. Seldom using python I'm pretty sure it's not written in > 'good python' nor too portable. Could you give

Re: for a 'good python'

2023-04-12 Thread jak
Stefan Ram ha scritto: jak writes: @property def subnet(self): return self.__to_str(self.__tsubnet) Maybe each of those attributes should be an object of a special class where your "__to_str" is "__str__"? E.g., # code in "calcip.__init__" self.tsubnet = ip_address_class.from_int(

for a 'good python'

2023-04-12 Thread jak
Hi everyone, some time ago I wrote a class to determine if an ipv4 address belonged to a subnet. Seldom using python I'm pretty sure it's not written in 'good python' nor too portable. Could you give me some advice to make it better? class calcip: def __init_

Re: Are these good ideas?

2022-11-14 Thread Axy via Python-list
;global variables" module acts exactly as a singleton class. Which is apparently a design pattern that some now believe is regrettable. Exactly. I dislike it too and always avoid. However, it could be a good starting point. Stepping directly into class-based approach would raise the same q

Re: Are these good ideas?

2022-11-14 Thread Dan Stromberg
On Mon, Nov 14, 2022 at 11:33 AM Axy via Python-list wrote: > On 14/11/2022 17:14, Stephen Tucker wrote: > > Hi, > > > > I have two related issues I'd like comments on. > > > > Issue 1 - Global Values > > Your "global variables" module acts exactly as a singleton class. > Which is apparently a d

Re: Are these good ideas?

2022-11-14 Thread Thomas Passin
On 11/14/2022 5:36 PM, Barry wrote: On 14 Nov 2022, at 22:06, Thomas Passin wrote: For parameter passing like your #2, I have packaged them into a dictionary and passed that around. It was easy enough, and worked well. I used to use a dict but having been burnt with issues now create a

Re: Are these good ideas?

2022-11-14 Thread Barry
> On 14 Nov 2022, at 22:49, Chris Angelico wrote: > > On Tue, 15 Nov 2022 at 09:38, Barry wrote: >> >> >> On 14 Nov 2022, at 22:06, Thomas Passin wrote: >>> >>> For parameter passing like your #2, I have packaged them into a dictionary >>> and passed that around. It was easy enou

Re: Are these good ideas?

2022-11-14 Thread Chris Angelico
On Tue, 15 Nov 2022 at 09:38, Barry wrote: > > > > > On 14 Nov 2022, at 22:06, Thomas Passin wrote: > > > > For parameter passing like your #2, I have packaged them into a dictionary > > and passed that around. It was easy enough, and worked well. > > > I used to use a dict but having been bur

Re: Are these good ideas?

2022-11-14 Thread Barry
> On 14 Nov 2022, at 22:06, Thomas Passin wrote: > > For parameter passing like your #2, I have packaged them into a dictionary > and passed that around. It was easy enough, and worked well. > I used to use a dict but having been burnt with issues now create a class. With a class you can a

Re: Are these good ideas?

2022-11-14 Thread Thomas Passin
For parameter passing like your #2, I have packaged them into a dictionary and passed that around. It was easy enough, and worked well. The only potential problem is in documenting the key/value pairs the dictionary is supposed to contain. You had better make sure it's made clear somewhere,

Re: Are these good ideas?

2022-11-14 Thread Axy via Python-list
On 14/11/2022 17:14, Stephen Tucker wrote: Hi, I have two related issues I'd like comments on. Issue 1 - Global Values Your "global variables" module acts exactly as a singleton class. Funny, you could (and maybe you do) write in your functions import global_vars_module as self as the fir

Re: Are these good ideas?

2022-11-14 Thread Weatherby,Gerard
: first : int second: str etc. I use context specific names, not “first” et. al. From: Python-list on behalf of Stephen Tucker Date: Monday, November 14, 2022 at 12:16 PM To: Python Subject: Are these good ideas? *** Attention: This is an external email. Use caution responding

Re: Are these good ideas?

2022-11-14 Thread Karsten Hilbert
Am Mon, Nov 14, 2022 at 05:14:05PM + schrieb Stephen Tucker: > Issue 2 - Passed Parameters > > I am now facing another situation where I am wanting to pass 6 or 7 > parameters down through several layers of logic (function A calling > function B calling ... ) and for results to be passed back.

Re: Are these good ideas?

2022-11-14 Thread Paul Bryan
Seems like this is a use case for context managers and/or context variables: https://docs.python.org/3/library/contextlib.html https://docs.python.org/3/library/contextvars.html On Mon, 2022-11-14 at 17:14 +, Stephen Tucker wrote: > Hi, > > I have two related issues I'd like comments on. >

Are these good ideas?

2022-11-14 Thread Stephen Tucker
Hi, I have two related issues I'd like comments on. Issue 1 - Global Values Some years ago, I had a situation where (a) I could supply low-level functions that carry out tasks, (b) I needed those functions to communicate with each other, but (c) I had no access to the module that invoked my func

Re: any author you find very good has written a book on Python?

2022-09-09 Thread Fulian Wang
Python is an appropriate computer language for kids and teenagers. A very good book for beginners: Invent Your Own computer games with Python Author: Al Sweigart It's free online, but it's worth to have one. Get Outlook for iOS<https://aka.ms/o0ukef> _

Re: any author you find very good has written a book on Python?

2022-09-07 Thread Tim Daneliuk via Python-list
On 9/5/22 21:22, Meredith Montgomery wrote: I never read a book on Python. I'm looking for a good one now. I just searched the web for names such as Charles Petzold, but it looks like he never wrote a book on Python. I also searched for Peter Seibel, but he also never did. I also tri

Re: any author you find very good has written a book on Python?

2022-09-07 Thread TheSeeker
On Monday, September 5, 2022 at 9:23:04 PM UTC-5, Meredith Montgomery wrote: > I never read a book on Python. I'm looking for a good one now. I just > searched the web for names such as Charles Petzold, but it looks like he > never wrote a book on Python. I also searched for Peter

Re: any author you find very good has written a book on Python?

2022-09-07 Thread Meredith Montgomery
jkn writes: > On Tuesday, September 6, 2022 at 4:36:38 PM UTC+1, Meredith Montgomery wrote: >> Paul Rubin writes: >> >> > Meredith Montgomery writes: >> >> So that's my request --- any author you find very good has written a >> >> book

Re: any author you find very good has written a book on Python?

2022-09-06 Thread Dennis Lee Bieber
On Mon, 05 Sep 2022 23:22:34 -0300, Meredith Montgomery declaimed the following: >I never read a book on Python. I'm looking for a good one now. I just >searched the web for names such as Charles Petzold, but it looks like he So far as I know, Petzold is a Windows Int

Re: any author you find very good has written a book on Python?

2022-09-06 Thread Thomas Passin
On 9/6/2022 5:10 PM, jkn wrote: On Tuesday, September 6, 2022 at 9:06:31 PM UTC+1, Thomas Passin wrote: Mark Pilgram's "Dive Into Python" was good. Now he's updated it for Python 3: like, about ten years ago? (I think Mark Pilgrim dropped off the 'net many years ag

RE: any author you find very good has written a book on Python?

2022-09-06 Thread avi.e.gross
n-list On Behalf Of Meredith Montgomery Sent: Monday, September 5, 2022 10:23 PM To: python-list@python.org Subject: any author you find very good has written a book on Python? I never read a book on Python. I'm looking for a good one now. I just searched the web for names such as Charles P

Re: any author you find very good has written a book on Python?

2022-09-06 Thread jkn
On Tuesday, September 6, 2022 at 9:06:31 PM UTC+1, Thomas Passin wrote: > Mark Pilgram's "Dive Into Python" was good. Now he's updated it for > Python 3: like, about ten years ago? (I think Mark Pilgrim dropped off the 'net many years ago...) > https://divei

Re: any author you find very good has written a book on Python?

2022-09-06 Thread jkn
On Tuesday, September 6, 2022 at 4:36:38 PM UTC+1, Meredith Montgomery wrote: > Paul Rubin writes: > > > Meredith Montgomery writes: > >> So that's my request --- any author you find very good has written a > >> book on Python? > > > > The one

Re: any author you find very good has written a book on Python?

2022-09-06 Thread Peter J. Holzer
On 2022-09-05 23:22:34 -0300, Meredith Montgomery wrote: > I never read a book on Python. I'm looking for a good one now. I just > searched the web for names such as Charles Petzold, but it looks like he > never wrote a book on Python. I also searched for Peter Seibel, but he &g

Re: any author you find very good has written a book on Python?

2022-09-06 Thread Louis Krupp
On 9/5/2022 8:22 PM, Meredith Montgomery wrote: I never read a book on Python. I'm looking for a good one now. I just searched the web for names such as Charles Petzold, but it looks like he never wrote a book on Python. I also searched for Peter Seibel, but he also never did. I also

Re: any author you find very good has written a book on Python?

2022-09-06 Thread Thomas Passin
Mark Pilgram's "Dive Into Python" was good. Now he's updated it for Python 3: https://diveintopython3.net On 9/6/2022 11:36 AM, Meredith Montgomery wrote: Paul Rubin writes: Meredith Montgomery writes: So that's my request --- any author you find very good has

Re: any author you find very good has written a book on Python?

2022-09-06 Thread Meredith Montgomery
Paul Rubin writes: > Meredith Montgomery writes: >> So that's my request --- any author you find very good has written a >> book on Python? > > The ones by David Beazley are great. Same with his non-book writings > about Python. See: http://dabeaz.com/ Distilled

any author you find very good has written a book on Python?

2022-09-06 Thread Meredith Montgomery
I never read a book on Python. I'm looking for a good one now. I just searched the web for names such as Charles Petzold, but it looks like he never wrote a book on Python. I also searched for Peter Seibel, but he also never did. I also tried to search for Richard Heathfield. (I took a

Anyone has good understanding of how model base agents work in 2D array? --AIMA repository

2019-10-06 Thread krishna singh
Hi, I have started learning artificial intelligence and currently going through AIMA repository https://github.com/aimacode/aima-python but I am stucked at model base reflex agent implementation in the 2D environment. Does anyone have a good understanding of how model base agents work in 2D

Re: OT: Using a fake Gmail address is probably not a good idea

2019-09-16 Thread Max Zettlmeißl via Python-list
On Mon, Sep 16, 2019 at 1:56 PM Skip Montanaro wrote: > Mails for someone here who goes by the handle "ast" with a fake > address of n...@gmail.com keep landing in my Gmail spam folder. I > suspect the same is true for all people subscribed to python-list who > use Gmail. Gmail (correctly, I think

OT: Using a fake Gmail address is probably not a good idea

2019-09-16 Thread Skip Montanaro
(I would have sent this off-list, but for obvious reasons I couldn't.) Mails for someone here who goes by the handle "ast" with a fake address of n...@gmail.com keep landing in my Gmail spam folder. I suspect the same is true for all people subscribed to python-list who use Gmail. Gmail (correctly

Re: Good editor for python

2018-11-11 Thread tommy yama
did not trigger an editor war. I don't know how familiar > you > > are > > with emacs. The answer depends alot on your preference and future work. > > Emacs > > and vi have been around for a long time for good reasons. > > > > If you prefer an extensible a

Re: Good editor for python

2018-11-11 Thread Andrew Z
er depends alot on your preference and future work. > Emacs > and vi have been around for a long time for good reasons. > > If you prefer an extensible and futureproof editor, I can wholeheartedly > recommend emacs or vi. I went from a happy emacs user to an even happier > spacemacs user

Re: Good editor for python

2018-11-11 Thread Brian J. Oney via Python-list
Hi Olivier I am glad you did not trigger an editor war. I don't know how familiar you are with emacs. The answer depends alot on your preference and future work. Emacs and vi have been around for a long time for good reasons. If you prefer an extensible and futureproof editor,

Re: Good editor for python

2018-11-11 Thread Spencer Graves
  People rave about Jupyter Notebooks, which reportedly allow you to mix narrative with code describing what you are doing and why.   I primarily program in R, and RMarkdown Documents in RStudio allow me to mix narrative with R and Python code.  I explain what I'm doing and why, then

Re: Good editor for python

2018-11-11 Thread Andrew Z
If you do scripts - emacs/vi is the way to go. If you need something more (like creating libraries, classes) go with pycharm. It is a professionally made IDE. Over past 2 years ive been trying to "downgrade" myself to something with less belts and whistles, but come back to it all the time. On

Re: Good editor for python

2018-11-11 Thread Thomas Jollans
ext is a fantastic, powerful and (fairly) fast editor (proprietary, shareware, 80 USD) with good support for Python with a number of packages (plugins), chief among them "Anaconda", which gives you linting and autocompletion. Visual Studio Code (open source, from Microsoft) is younger

Re: Good editor for python

2018-11-11 Thread Daniele Forghieri
Il 11/11/2018 10:14, Olive ha scritto: I am not a professional programmer but I use Python regularly for custom scripts (and plot with matplotlib). I have just learned VBA for Excel: what I found amazing was their editor: it is able to suggest on the spot all the methods an object support and

Good editor for python

2018-11-11 Thread Olive
I am not a professional programmer but I use Python regularly for custom scripts (and plot with matplotlib). I have just learned VBA for Excel: what I found amazing was their editor: it is able to suggest on the spot all the methods an object support and there is a well-integrated debugger. I wo

Re: Good reason not to obfuscate URLs (was: Fishing from PyPI ?)

2018-08-14 Thread Ian Kelly
On Tue, Aug 14, 2018 at 1:41 PM Peter J. Holzer wrote: > > On 2018-08-08 05:18:21 +, Gilmeh Serda wrote: > > And if you read email in blasted HTML, chances are they also have an > > image that they serve to you on their "beautiful" page you receive, an > > image whose link which may or may not

Re: Good reason not to obfuscate URLs (was: Fishing from PyPI ?)

2018-08-14 Thread Peter J. Holzer
On 2018-08-08 05:18:21 +, Gilmeh Serda wrote: > And if you read email in blasted HTML, chances are they also have an > image that they serve to you on their "beautiful" page you receive, an > image whose link which may or may not be equally personalized, and more > often than not has its ori

Good reason not to obfuscate URLs (was: Fishing from PyPI ?)

2018-08-06 Thread Ben Finney
are obfuscated deliberately. What we can say for certain, is that following those links allows parties unknown, to track the fact you've followed that link, before you ever get to PyPI. You are right to be concerned. This is one good reason why I argue that link obfuscation like this is bad pr

Re: OFF-TOPIC Good sig [was Re: What is the "Unpacking Arguments List" rule?]

2018-06-13 Thread Ian Kelly
On Wed, Jun 13, 2018 at 10:10 AM Steven D'Aprano wrote: > > On Wed, 13 Jun 2018 12:43:12 +, Alister via Python-list wrote: > > > I have a theory that it's impossible to prove anything, but I can't > > prove it. > > Heh, that reminds me of Stephen Pinker's comment from "Enlightenment Now": > >

OFF-TOPIC Good sig [was Re: What is the "Unpacking Arguments List" rule?]

2018-06-13 Thread Steven D'Aprano
On Wed, 13 Jun 2018 12:43:12 +, Alister via Python-list wrote: > I have a theory that it's impossible to prove anything, but I can't > prove it. Heh, that reminds me of Stephen Pinker's comment from "Enlightenment Now": "one cannot reason that there's no such thing as reason" but on the oth

Re: Is there are good DRY fix for this painful design pattern?

2018-03-01 Thread Jugurtha Hadjar
On 03/01/2018 10:34 AM, Gregory Ewing wrote: After this thread, the term "docstring" is never going to mean quite the same thing to me again. I still feel that the following is quite readable: <---> import inspect def snatch(func):     def snatched(self, *arg

Re: Is there are good DRY fix for this painful design pattern?

2018-03-01 Thread Gregory Ewing
After this thread, the term "docstring" is never going to mean quite the same thing to me again. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there are good DRY fix for this painful design pattern?

2018-02-27 Thread Tim Chase
ful is None: > bashful = self.bashful > # and so on > > > There's a lot of tedious boilerplate repetition in this, and to add > insult to injury the class is still under active development with > an unstable API, so every time I change one of the p

Re: Is there are good DRY fix for this painful design pattern?

2018-02-27 Thread Jugurtha Hadjar
one of the parameters, or add a new one, I have to change it in over a dozen places. Is there a good fix for this to reduce the amount of boilerplate? Thanks, def snatchit(func):     def snatched(self, *args, **kwargs):     frame = inspect.signature(func)     for name in frame.

Re: Is there are good DRY fix for this painful design pattern?

2018-02-27 Thread Kirill Balunov
Of course you can do the same without annotations, but with the introduction of private attribute while your API it is under active development: from functools import wraps def validate(func): @wraps(func) def _wrap(self, *args, **kwargs): variables = self._vars # Here kw

Re: Is there are good DRY fix for this painful design pattern?

2018-02-27 Thread Kirill Balunov
This validation can be also done with the use of annotations, while I find it super awful, I put this for one more example: from functools import wraps def validate(func): @wraps(func) def _wrap(self, *args, **kwargs): variables = func.__annotations__.keys() kwargs.update(z

Re: Is there are good DRY fix for this painful design pattern?

2018-02-27 Thread Wolfgang Maier
None, the defaults are taken from the instance attributes. Others have pointed out good solutions already, in particular, combining inspect and decorators or encapsulating the parameters in an object. Alternatively, you could reconsider your class design. Although I can't tell from yo

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Ben Finney
Steven D'Aprano writes: > Interesting, I'll certainly have a good read of that, thanks. But I > fear I mislead you: you seem to have understood that either all the > parameters are None, or none of them are, whereas what I meant was > that they can vary independently of eac

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Steven D'Aprano
s that naturally go together. > > Replace them with an object. > > https://refactoring.com/catalog/introduceParameterObject.html> Interesting, I'll certainly have a good read of that, thanks. But I fear I mislead you: you seem to have understood that either all the pa

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Steven D'Aprano
On Mon, 26 Feb 2018 16:23:39 -0800, Rick Johnson wrote: > On Monday, February 26, 2018 at 5:44:18 PM UTC-6, MRAB wrote: [...] >> Before using or'd-logic, you need to know whether the value could be >> falsey, e.g. 0. > > True. However. Steven failed to provide any info that might help us > determ

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Steven D'Aprano
On Mon, 26 Feb 2018 17:39:43 +0100, Peter Otten wrote: [...] > I have not yet looked into dataclasses. Don't they handle the __init__() > part? Anyway, here's my attempt to make spam() less spammy: I'm not too concerned about __init__, it's only one method :-) > $ cat attrs_to_args_decorator.p

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Rick Johnson
On Monday, February 26, 2018 at 5:44:18 PM UTC-6, MRAB wrote: [...] > Before using or'd-logic, you need to know whether the value > could be falsey, e.g. 0. True. However. Steven failed to provide any info that might help us determine the types of these parameters, and as such, i was forced to tak

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread MRAB
On 2018-02-26 21:12, Rick Johnson wrote: On Monday, February 26, 2018 at 8:44:14 AM UTC-6, Steven D'Aprano wrote: I have a class with a large number of parameters (about ten) assigned in `__init__`. The class then has a number of methods which accept *optional* arguments with the same names as t

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Ben Finney
Steven D'Aprano writes: > I have a class with a large number of parameters (about ten) assigned > in `__init__`. The class then has a number of methods which accept > *optional* arguments with the same names as the > constructor/initialiser parameters. If those arguments are None, the > defaults

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 2:37 PM, Ian Kelly wrote: > On Mon, Feb 26, 2018 at 1:09 PM, wrote: >> def foo(self, *args, **kwargs): >> assert len(args) == 0 > > Better: > > def foo(self, **kwargs): > >> So, use the inspect module to detect the valid arguments >> from the class initializer

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 1:09 PM, wrote: > def foo(self, *args, **kwargs): > assert len(args) == 0 Better: def foo(self, **kwargs): > So, use the inspect module to detect the valid arguments > from the class initializer. Then use **kwargs in every > class method. It would be nice if

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Rick Johnson
On Monday, February 26, 2018 at 8:44:14 AM UTC-6, Steven D'Aprano wrote: > I have a class with a large number of parameters (about > ten) assigned in `__init__`. The class then has a number of > methods which accept *optional* arguments with the same > names as the constructor/initialiser parameter

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread marco . nawijn
and so on > > > There's a lot of tedious boilerplate repetition in this, and to add > insult to injury the class is still under active development with an > unstable API, so every time I change one of the parameters, or add a new > one, I have to change it in over a doz

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 8:06 AM, Chris Angelico wrote: > On Tue, Feb 27, 2018 at 1:41 AM, Steven D'Aprano > wrote: >> I have a class with a large number of parameters (about ten) assigned in >> `__init__`. The class then has a number of methods which accept >> *optional* arguments with the same n

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Peter Otten
boilerplate repetition in this, and to add > insult to injury the class is still under active development with an > unstable API, so every time I change one of the parameters, or add a new > one, I have to change it in over a dozen places. > > Is there a good fix for this to reduc

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Rob Gaddi
stable API, so every time I change one of the parameters, or add a new one, I have to change it in over a dozen places. Is there a good fix for this to reduce the amount of boilerplate? You could use dicts?  Untested code: class Foo:     def __init__(self, **kwds):     self.defaults = kwds

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Rhodri James
one of the parameters, or add a new one, I have to change it in over a dozen places. Is there a good fix for this to reduce the amount of boilerplate? You could use dicts? Untested code: class Foo: def __init__(self, **kwds): self.defaults = kwds def spam(self, **kwds):

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Antoon Pardon
On 26-02-18 15:41, Steven D'Aprano wrote: > I have a class with a large number of parameters (about ten) assigned in > `__init__`. The class then has a number of methods which accept > *optional* arguments with the same names as the constructor/initialiser > parameters. If those arguments are No

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Vincent Vande Vyvre
one of the parameters, or add a new one, I have to change it in over a dozen places. Is there a good fix for this to reduce the amount of boilerplate? Thanks, Maybe something like this:     def config(self, **kwargs):     for key, value in kwargs.items():     if value i

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 1:41 AM, Steven D'Aprano wrote: > I have a class with a large number of parameters (about ten) assigned in > `__init__`. The class then has a number of methods which accept > *optional* arguments with the same names as the constructor/initialiser > parameters. If those argu

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Antoon Pardon
On 26-02-18 15:41, Steven D'Aprano wrote: > I have a class with a large number of parameters (about ten) assigned in > `__init__`. The class then has a number of methods which accept > *optional* arguments with the same names as the constructor/initialiser > parameters. If those arguments are No

Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Steven D'Aprano
dozen places. Is there a good fix for this to reduce the amount of boilerplate? Thanks, -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: Any good explanations on pd.merge(df,df2, on=['Code', 'Region'])

2017-11-08 Thread William Ayd
Assuming df and df2 are dataframes you are essentially doing a SQL-like join of the two objects where the records within match on both the Code and Region columns Sent from my iPhone -- https://mail.python.org/mailman/listinfo/python-list

Re: Any good explanations on pd.merge(df,df2, on=['Code', 'Region'])

2017-11-08 Thread Paul Moore
On 8 November 2017 at 11:15, Karsten Hilbert wrote: > On Wed, Nov 08, 2017 at 09:26:04AM +, David Shi via Python-list wrote: > >> I am trying to gain a clear understanding on pd.merge(df,df2, on=['Code', >> 'Region']). >> Can anyone assist? > > ncq@hermes:~$ python > Python 2

Re: Any good explanations on pd.merge(df,df2, on=['Code', 'Region'])

2017-11-08 Thread Karsten Hilbert
On Wed, Nov 08, 2017 at 09:26:04AM +, David Shi via Python-list wrote: > I am trying to gain a clear understanding on pd.merge(df,df2, on=['Code', > 'Region']). > Can anyone assist? ncq@hermes:~$ python Python 2.7.14 (default, Sep 17 2017, 18:50:44) [GCC 7.2.0] on li

Any good explanations on pd.merge(df,df2, on=['Code', 'Region'])

2017-11-08 Thread David Shi via Python-list
I am trying to gain a clear understanding on pd.merge(df,df2, on=['Code', 'Region']). Can anyone assist? Regards, David -- https://mail.python.org/mailman/listinfo/python-list

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-06 Thread Anssi Saari
Leam Hall writes: > Folks on IRC have suggested using virtualenv to test code under > different python versions. Sadly, I've not found a virtualenv tutorial > I understand. Anyone have a link to a good one? I recently used http://www.simononsoftware.com/virtualenv-tutorial-part-2/

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Christopher Reimer
On Oct 4, 2017, at 3:49 AM, Leam Hall wrote: > > Folks on IRC have suggested using virtualenv to test code under different > python versions. Sadly, I've not found a virtualenv tutorial I understand. > Anyone have a link to a good one? > > The next step will be to figu

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Paul Moore
irtualenv tutorial >> > I understand. Anyone have a link to a good one? >> >> The Python Packaging Authority has a guide >> https://packaging.python.org/tutorials/installing- >> packages/#creating-virtual-environments> >> which seems good to me. >&g

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread leam hall
On Wed, Oct 4, 2017 at 7:15 AM, Ben Finney wrote: > Leam Hall writes: > > > Folks on IRC have suggested using virtualenv to test code under > > different python versions. Sadly, I've not found a virtualenv tutorial > > I understand. Anyone have a link to a good

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Ben Finney
Leam Hall writes: > Folks on IRC have suggested using virtualenv to test code under > different python versions. Sadly, I've not found a virtualenv tutorial > I understand. Anyone have a link to a good one? The Python Packaging Authority has a guide https://packaging.python

Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Leam Hall
Folks on IRC have suggested using virtualenv to test code under different python versions. Sadly, I've not found a virtualenv tutorial I understand. Anyone have a link to a good one? The next step will be to figure out how to package a project; a good tutorial URL would be appreciated on

Re: A good way to unpack a matrix

2017-09-13 Thread Sean DiZazzo
On Wednesday, September 13, 2017 at 7:53:25 PM UTC-7, Andrew Zyman wrote: > hello, > is there a better approach to populating a function in this situation? > > res = self.DB.getPrice(): # returns array of 3x2 always. symbol_id, > symbol, price. > > var1 = self.AFunction(symbols=res[0][2] + '.'

A good way to unpack a matrix

2017-09-13 Thread Andrew Zyman
hello, is there a better approach to populating a function in this situation? res = self.DB.getPrice(): # returns array of 3x2 always. symbol_id, symbol, price. var1 = self.AFunction(symbols=res[0][2] + '.' + res[1][2], conid1= self.Contracts[res[0][0]].conId, conid2=self.Contracts[res[1][0]]

Re: A Good Tutorial on Python Decorators

2017-06-28 Thread Marko Rauhamaa
ies, das [Turing] uns geschaffen, soll uns niemand vertreiben können. https://en.wikipedia.org/wiki/Cantor%27s_paradise> > The Internet is fundamentally broken and hostile, and we're addicted > to it. The Internet has taken us to the next level. Let's hope G

Re: A Good Tutorial on Python Decorators

2017-06-28 Thread D'Arcy Cain
On 06/28/17 17:59, Steve D'Aprano wrote: On Thu, 29 Jun 2017 01:56 am, Peter Pearson wrote: (Blushing) Thanks. Life is getting difficult for us JavaScript paranoids. Its not paranoia if they're really out to get you. https://www.cnet.com/news/javascript-opens-doors-to-browser-based-attacks/

Re: A Good Tutorial on Python Decorators

2017-06-28 Thread Steve D'Aprano
On Thu, 29 Jun 2017 01:56 am, Peter Pearson wrote: > (Blushing) Thanks. Life is getting difficult for us JavaScript paranoids. Its not paranoia if they're really out to get you. https://www.cnet.com/news/javascript-opens-doors-to-browser-based-attacks/ https://www.proofpoint.com/us/corporate-b

Re: A Good Tutorial on Python Decorators

2017-06-28 Thread Peter Pearson
On Tue, 27 Jun 2017 16:43:38 +, Andre Müller wrote: > Peter Pearson schrieb am Di., 27. Juni 2017 um > 18:35 Uhr: > >> On Tue, 27 Jun 2017 15:10:53 + (UTC), Saurabh Chaturvedi wrote: >> > https://opensource.google.com/projects/py-decorators-tutorial >> >> "No Results found." >> > Activate

Re: A Good Tutorial on Python Decorators

2017-06-27 Thread Paul Barry
Me doing the decorator thing (from a web dev point-of-view) at PyCon Ireland 2015: https://www.youtube.com/watch?v=My2UpCaN7rE and here's a link to the PDF of my talk's material: http://paulbarry.itcarlow.ie/pyconie2015/decorators.pdf Paul. On 27 June 2017 at 17:43, Andre Müller wrote: >

Re: A Good Tutorial on Python Decorators

2017-06-27 Thread Andre Müller
Activate JavaScript, then you can see the content. I had the same problem. Peter Pearson schrieb am Di., 27. Juni 2017 um 18:35 Uhr: > On Tue, 27 Jun 2017 15:10:53 + (UTC), Saurabh Chaturvedi wrote: > > https://opensource.google.com/projects/py-decorators-tutorial > > "No Results found." > >

Re: A Good Tutorial on Python Decorators

2017-06-27 Thread Peter Pearson
On Tue, 27 Jun 2017 15:10:53 + (UTC), Saurabh Chaturvedi wrote: > https://opensource.google.com/projects/py-decorators-tutorial "No Results found." -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list

A Good Tutorial on Python Decorators

2017-06-27 Thread Saurabh Chaturvedi
https://opensource.google.com/projects/py-decorators-tutorial -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   8   9   10   >