On 2019-02-16, Barry wrote:
> On 11 Feb 2019, at 20:00, Felix Lazaro Carbonell wrote:
>
>>> The most pythonic way is to do this:
>>>
>>> def find_monthly_expenses(month=datetime.date.today().month,
>> year=datetime.date.today().year):
>>>...
>
> This has subtle bugs.
> The default is calcul
On 11 Feb 2019, at 20:00, Felix Lazaro Carbonell wrote:
>> The most pythonic way is to do this:
>>
>> def find_monthly_expenses(month=datetime.date.today().month,
> year=datetime.date.today().year):
>>...
This has subtle bugs.
The default is calculated at import time and not at function
The first one is used very often. Less verbose
Le 11 févr. 2019 à 20:41, à 20:41, Felix Lazaro Carbonell
a écrit:
>
>
>Hello to everyone:
>
>Could you please tell me wich way of writing this method is more
>pythonic:
>
>
>
>..
>
>def find_monthly_expenses(month=None, year=None):
>
>
Felix Lazaro Carbonell wrote:
> Hello to everyone:
> Could you please tell me wich way of writing this method is more pythonic:
> def find_monthly_expenses(month=None, year=None):
>
> month = month or datetime.date.today()
> Or it should better be:
> if not month:
>
Grant Edwards wrote:
> On 2019-02-11, Felix Lazaro Carbonell wrote:
>
>> Could you please tell me wich way of writing this method is more
>> pythonic:
>>
>> def find_monthly_expenses(month=None, year=None):
>> month = month or datetime.date.today()
>>
>> Or it should better be:
>>
>>
+1 with David Raymond, it's nice to use condensed style when it leaves
things readable and logic. But if in doubt:
"Explicit is better than implicit.
Simple is better than complex." :)
-Sivan
On Mon, Feb 11, 2019 at 10:19 PM David Raymond
wrote:
> My non-expert vote is for
>
> if month is None
On 2/11/2019 2:46 PM, Felix Lazaro Carbonell wrote:
def find_monthly_expenses(month=None, year=None):
month = month or datetime.date.today().month
Or it should better be:
if not month:
month = datetime.date.today().month
As a 20+ year veteran, I would be
My non-expert vote is for
if month is None:
month = datetime.date.today().month
Because you're checking for your default value, not whether the boolean version
of what they did give you is True or False. It's explicit, it's not reliant on
any __bool__() function implementations or overrides
-Mensaje original-
De: Python-list [mailto:python-list-bounces+felix=epepm.cupet...@python.org]
En nombre de Grant Edwards
Enviado el: lunes, 11 de febrero de 2019 02:46 p.m.
Para: python-list@python.org
Asunto: Re: more pythonic way
On 2019-02-11, Felix Lazaro Carbonell wrote
Sorry I meant
..
def find_monthly_expenses(month=None, year=None):
month = month or datetime.date.today().month
..
Or it should better be:
...
if not month:
month = datetime.date.today().month
..
Cheers,
Felix.
--
https://mail.python.org/mailman
On 2019-02-11, Felix Lazaro Carbonell wrote:
> Could you please tell me wich way of writing this method is more pythonic:
>
> def find_monthly_expenses(month=None, year=None):
> month = month or datetime.date.today()
>
> Or it should better be:
>
> if not month:
>
Shubham Tomar writes:
> Lets say I have a function poker(hands) that takes a list of hands and
> returns the highest ranking hand, and another function hand_rank(hand)
> that takes hand and return its rank.
To make it clearer, I think you mean something like this::
def hand_rank(hand):
On Tue, Aug 19, 2014 at 10:09 AM, Shubham Tomar
wrote:
> Lets say I have a function poker(hands) that takes a list of hands and
> returns the highest ranking hand, and another function hand_rank(hand) that
> takes hand and return its rank. As in Poker
> http://www.pokerstars.com/poker/games/rules
On Feb 29, 5:57 pm, Alan Isaac <[EMAIL PROTECTED]> wrote:
> Paul McGuire wrote:
> > In general, whenever you have:
> > someNewList = []
> > for smthg in someSequence:
> > if condition(smthg):
> > someNewList.append( elementDerivedFrom(smthg) )
> > replace it with:
> >
Paul McGuire wrote:
> In general, whenever you have:
> someNewList = []
> for smthg in someSequence:
> if condition(smthg):
> someNewList.append( elementDerivedFrom(smthg) )
> replace it with:
> someNewList = [ elementDerivedFrom(smthg)
>
On Feb 28, 8:58 am, Temoto <[EMAIL PROTECTED]> wrote:
> On 28 ÆÅ×, 15:42, Paul McGuire <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On Feb 28, 5:40 am, Temoto <[EMAIL PROTECTED]> wrote:
>
> > > Hello.
>
> > > There is a Django application, i need to place all its data into
> > > Access mdb file and sen
On 28 фев, 15:42, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Feb 28, 5:40 am, Temoto <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello.
>
> > There is a Django application, i need to place all its data into
> > Access mdb file and send it to user.
> > It seems to me that params filling for statement cou
On Feb 28, 5:40 am, Temoto <[EMAIL PROTECTED]> wrote:
> Hello.
>
> There is a Django application, i need to place all its data into
> Access mdb file and send it to user.
> It seems to me that params filling for statement could be expressed in
> a more beautiful way.
> Since i'm very new to Python,
On Feb 28, 4:48 am, 7stud <[EMAIL PROTECTED]> wrote:
>
> It's my understanding that the way you insert arguments into queries
> has to be done in a db specific way.
>
Rather:
It's my understanding that the way you insert arguments into queries
*should* be done in a db specific way.
--
http:/
On Feb 28, 4:40 am, Temoto <[EMAIL PROTECTED]> wrote:
> Hello.
>
> There is a Django application, i need to place all its data into
> Access mdb file and send it to user.
> It seems to me that params filling for statement could be expressed in
> a more beautiful way.
> Since i'm very new to Python,
On 11/06/2006 1:26 PM, [EMAIL PROTECTED] wrote:
> Thanks for the critique.
>
> John Machin wrote:
>> On 10/06/2006 7:00 AM, [EMAIL PROTECTED] wrote:
[snip]
>>> def sort(self,myList):
>>> for gap in self.gapSeq:
>>> for i in range(1,gap+1):
>>> self.gapInsert
Thanks for the critique.
John Machin wrote:
> On 10/06/2006 7:00 AM, [EMAIL PROTECTED] wrote:
> > Disclaimer - I recognize this is not a practical exercise. There are
> > many implementations around that would do the job better, more
> > efficiently (Meaning in C) or whatever.
> >
> > I caught so
On 10/06/2006 7:00 AM, [EMAIL PROTECTED] wrote:
> Disclaimer - I recognize this is not a practical exercise. There are
> many implementations around that would do the job better, more
> efficiently (Meaning in C) or whatever.
>
> I caught some thread about sorting and started thinking about shell
Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
>
> > An aside - can anyone tell me where the use += and -= is documented?
>
> http://docs.python.org/ref/augassign.html
> http://pyref.infogami.com/assignments
>
>
Thanks!!!
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> An aside - can anyone tell me where the use += and -= is documented?
http://docs.python.org/ref/augassign.html
http://pyref.infogami.com/assignments
--
http://mail.python.org/mailman/listinfo/python-list
[Pythor]
Sure, I tested it.
===
I don't think that word means what you think it means :-)
[Pythor]
On the other hand, I'm not
having any trouble producing a whole circle, while you seem to think
I'm only producing half a circle. The code that limits itself to a 5x5
box is only expected to produce
John Machin wrote:
> [Michael Tobis]
> Also, with this code, you are using radius for the dimensions of the
> enclosing box, as well as the radius of the circle, so it's guaranteed
> to not to actually produce a whole circle. Recall what python does with
> negative indices!
>
> [Pythor]
> I'm not s
Pythor wrote:
> I wrote the following code for a personal project. I need a function
> that will plot a filled circle in a two dimensional array. I found
> Bresenham's algorithm, and produced this code. Please tell me there's
> a better way to do this.
>
> import numpy
>
> def circle(field=Non
[Michael Tobis]
Also, with this code, you are using radius for the dimensions of the
enclosing box, as well as the radius of the circle, so it's guaranteed
to not to actually produce a whole circle. Recall what python does with
negative indices!
[Pythor]
I'm not sure what you mean here. It produc
It's also possible to write microprocessor assembly language in any
other language.
The following code generates the OP's list of points with nothing more
complicated than integer addition/subtraction inside the loop. It also
does the right thing if the radius is not an integer, and avoids the
OP's
Fredrik Lundh wrote:
> "Pythor" wrote:
>
> > > You aren't getting any benefit from numpy or python here. Are you
> > > aiming for speed or legibility?
> > >
> > Speed will be a necessity, eventually. I was just really aiming for
> > something that works, and that I am capable of writing.
>
> any
"Pythor" wrote:
> > You aren't getting any benefit from numpy or python here. Are you
> > aiming for speed or legibility?
> >
> Speed will be a necessity, eventually. I was just really aiming for
> something that works, and that I am capable of writing.
any special reason you cannot use an exis
Steven D'Aprano wrote:
> No, "minimum number of space characters" means "you don't use enough
> spaces", not "your variable names are too short" *wink*
>
Hmm. Guess I can't read too well.
> Within a single line, a good guideline is to leave a single space on
> either side of pluses and minuses (
Michael Tobis wrote:
> Proving yet again that it's possible to write Fortran in any language.
>
Ouch...
> You aren't getting any benefit from numpy or python here. Are you
> aiming for speed or legibility?
>
Speed will be a necessity, eventually. I was just really aiming for
something that work
On Sat, 08 Apr 2006 21:17:32 -0700, Pythor wrote:
>> (3) legibility: there's no prize for the script with the absolutely
>> minimum number of space characters :-)
> True. I assume your saying I should make cx,cy,dx, and dy better
> names. I probably will. Up to now I was just playing around wit
Proving yet again that it's possible to write Fortran in any language.
You aren't getting any benefit from numpy or python here. Are you
aiming for speed or legibility?
Also, with this code, you are using radius for the dimensions of the
enclosing box, as well as the radius of the circle, so it'
Em Sáb, 2006-04-08 às 21:17 -0700, Pythor escreveu:
> John Machin wrote:
> > (3) legibility: there's no prize for the script with the absolutely
> > minimum number of space characters :-)
> True. I assume your saying I should make cx,cy,dx, and dy better
> names. I probably will. Up to now I was
John Machin wrote:
> OTTOMH, in a rush to go out: never mind Pythonic, following apply to
> any language:
> (1) accuracy: (a) sue me if I'm wrong, but I think you need range(dx+1)
> so that the dx pixel is filled in
Hmm. I think you're right. Thanks.
> (b) a few more digits after 0.71
> might be
OTTOMH, in a rush to go out: never mind Pythonic, following apply to
any language:
(1) accuracy: (a) sue me if I'm wrong, but I think you need range(dx+1)
so that the dx pixel is filled in (b) a few more digits after 0.71
might be useful
(2) efficiency: seems that range(dy, dx+1) would save some we
39 matches
Mail list logo