RE: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread avi.e.gross
sibly non-pythonic topic and go read another book or a few hundred so when it comes up again ... -Original Message- From: Python-list On Behalf Of Thomas Passin Sent: Saturday, March 4, 2023 5:04 PM To: python-list@python.org Subject: Re: Which more Pythonic - self.__class__ or type(self)

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread Weatherby,Gerard
Nope. No consensus. I’d use self.__class__ . Seems more explicit and direct to me. From: Python-list on behalf of Ian Pilcher Date: Thursday, March 2, 2023 at 4:17 PM To: python-list@python.org Subject: Which more Pythonic - self.__class__ or type(self)? *** Attention: This is an external

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread Thomas Passin
y, March 4, 2023 1:09 PM To: python-list@python.org Subject: Re: Which more Pythonic - self.__class__ or type(self)? On 3/4/2023 2:47 AM, Peter J. Holzer wrote: Even before Python existed there was the adage "a real programmer can write FORTRAN in any language", indicating that idiomatic

RE: RE: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread avi.e.gross
it becomes an exotic addition to Python in a way that loosely melds, or if it becomes the PYTHONIC way ... -Original Message- From: Alan Gauld Sent: Saturday, March 4, 2023 1:38 PM To: avi.e.gr...@gmail.com; python-list@python.org Subject: Re: RE: Which more Pythonic - self.__class__ or

RE: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread avi.e.gross
native language(s). I am sure some books along these lines have already been written! Who wants to collaborate? -Original Message- From: Python-list On Behalf Of dn via Python-list Sent: Saturday, March 4, 2023 1:26 PM To: python-list@python.org Subject: Re: Which more Pythonic - self

RE: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread avi.e.gross
and found an expanding language with way too many ways to do anything and can choose. But I claim that too is pythonic! -Original Message- From: Python-list On Behalf Of Thomas Passin Sent: Saturday, March 4, 2023 1:09 PM To: python-list@python.org Subject: Re: Which more Pythonic - self.__class

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread Peter J. Holzer
On 2023-03-04 12:38:22 -0500, avi.e.gr...@gmail.com wrote: > Of course each language has commonly used idioms as C with pointer > arithmetic and code like *p++=*q++ but my point is that although I live near > a seaway and from where C originated, I am not aware of words like "c-way" > or "scenic"

Re: RE: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread Alan Gauld
On 04/03/2023 17:38, avi.e.gr...@gmail.com wrote: > > Of course each language has commonly used idioms > That's the point, the correct term is probably "idiomatic" rather than "pythonic" but it is a defacto standard that idiomatic Python has become known as Pythonic. I don't think that's a

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread dn via Python-list
On 04/03/2023 20.47, Peter J. Holzer wrote: On 2023-03-03 13:51:11 -0500, avi.e.gr...@gmail.com wrote: ... No. Even before Python existed there was the adage "a real programmer can write FORTRAN in any language", indicating that idiomatic usage of a language is not governed by syntax and

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread Thomas Passin
On 3/4/2023 2:47 AM, Peter J. Holzer wrote: Even before Python existed there was the adage "a real programmer can write FORTRAN in any language", indicating that idiomatic usage of a language is not governed by syntax and library alone, but there is a cultural element: People writing code in a

RE: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread avi.e.gross
of seasoned python programmers which they would prefer, then sometimes there is a more pythonic solution by that definition. Give the same test to newbies who each came from a different language background and are just getting started, and I am not sure I care how they vote! I suggest that given a d

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread Peter J. Holzer
On 2023-03-03 13:51:11 -0500, avi.e.gr...@gmail.com wrote: > I do not buy into any concept about something being pythonic or not. > > Python has grown too vast and innovated quite a bit, but also borrowed from > others and vice versa. > > There generally is no universally pythonic way nor

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread Greg Ewing via Python-list
On 4/03/23 7:51 am, avi.e.gr...@gmail.com wrote: I leave you with the question of the day. Was Voldemort pythonic? Well, he was fluent in Parseltongue, which is not a good sign. I hope not, otherwise we'll have to rename Python to "The Language That Shall Not Be Named" and watch out for

RE: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread avi.e.gross
you should not care about efficiency! LOL! I leave you with the question of the day. Was Voldemort pythonic? Avi -Original Message- From: Python-list On Behalf Of Alan Gauld Sent: Friday, March 3, 2023 4:43 AM To: python-list@python.org Subject: Re: Which more Pythonic - self.__class__

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread Ethan Furman
haven't found >>> anything that talks about which form is considered to be more Pythonic >>> in those situations where there's no functional difference. >> >> I think avoiding dunder methods is generally considered more Pythonic. Outside of writing dunder methods, I tend

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread Chris Angelico
which form is considered to be more Pythonic > > in those situations where there's no functional difference. > > I think avoiding dunder methods is generally considered more Pythonic. > > But in this specific case using isinstance() is almost always > the better option. Testing f

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread Alan Gauld
On 02/03/2023 20:54, Ian Pilcher wrote: > Seems like an FAQ, and I've found a few things on StackOverflow that > discuss the technical differences in edge cases, but I haven't found > anything that talks about which form is considered to be more Pythonic > in those situations w

RE: Which more Pythonic - self.__class__ or type(self)?

2023-03-02 Thread avi.e.gross
Subject: Re: Which more Pythonic - self.__class__ or type(self)? On 3/2/2023 5:53 PM, Greg Ewing via Python-list wrote: > On 3/03/23 9:54 am, Ian Pilcher wrote: >> I haven't found >> anything that talks about which form is considered to be more Pythonic >> in those situations where

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-02 Thread Thomas Passin
On 3/2/2023 5:53 PM, Greg Ewing via Python-list wrote: On 3/03/23 9:54 am, Ian Pilcher wrote: I haven't found anything that talks about which form is considered to be more Pythonic in those situations where there's no functional difference. In such cases I'd probably go for type(x), because

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-02 Thread Greg Ewing via Python-list
On 3/03/23 9:54 am, Ian Pilcher wrote: I haven't found anything that talks about which form is considered to be more Pythonic in those situations where there's no functional difference. In such cases I'd probably go for type(x), because it looks less ugly. x.__class__ *might* be slightly more

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-02 Thread Thomas Passin
On 3/2/2023 3:54 PM, Ian Pilcher wrote: Seems like an FAQ, and I've found a few things on StackOverflow that discuss the technical differences in edge cases, but I haven't found anything that talks about which form is considered to be more Pythonic in those situations where there's no functional

Which more Pythonic - self.__class__ or type(self)?

2023-03-02 Thread Ian Pilcher
Seems like an FAQ, and I've found a few things on StackOverflow that discuss the technical differences in edge cases, but I haven't found anything that talks about which form is considered to be more Pythonic in those situations where there's no functional difference. Is there any consensus

[issue42069] Make filecmp more pythonic

2020-10-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: In general, we don't accept patches like this: * It risks breaks (in fact the tests are failing. * We're not apply Black's quoting preferences to existing files. * We're not yet adding type annotations through out. * The PR introduces multiple new

[issue42069] Make filecmp more pythonic

2020-10-18 Thread Alex
Change by Alex : -- keywords: +patch pull_requests: +21712 stage: -> patch review pull_request: https://github.com/python/cpython/pull/22750 ___ Python tracker ___

[issue42069] Make filecmp more pythonic

2020-10-18 Thread Alex
New submission from Alex : Cleanup the filecmp file add typing and make it more pythonic -- components: Library (Lib) messages: 378877 nosy: alex.briskin priority: normal severity: normal status: open title: Make filecmp more pythonic versions: Python 3.9

[issue41077] Make Cookiejar a bit more pythonic

2020-06-22 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Hi Srinivas, as I said on the PR, cosmetic changes are usually not accepted. You can have a look at the other opened bug reports to find issues you can work on and at the Python Dev Guide (https://devguide.python.org/) for help to get started hacking Python!

[issue41077] Make Cookiejar a bit more pythonic

2020-06-22 Thread శ్రీనివాస్ రెడ్డి తాటిపర్తి
Change by Srinivas Reddy Thatiparthy(శ్రీనివాస్ రెడ్డి తాటిపర్తి) : -- resolution: -> wont fix stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue41077] Make Cookiejar a bit more pythonic

2020-06-22 Thread శ్రీనివాస్ రెడ్డి తాటిపర్తి
Srinivas Reddy Thatiparthy(శ్రీనివాస్ రెడ్డి తాటిపర్తి) added the comment: I am not sure this PR will be accepted. If you are a core dev, and thinks this is not Okay, please feel free close this issue. -- keywords: +patch message_count: 1.0 -> 2.0 pull_requests: +20226 stage: ->

[issue41077] Make Cookiejar a bit more pythonic

2020-06-22 Thread శ్రీనివాస్ రెడ్డి తాటిపర్తి
New submission from Srinivas Reddy Thatiparthy(శ్రీనివాస్ రెడ్డి తాటిపర్తి) : Title says it all. -- messages: 372087 nosy: thatiparthy priority: normal severity: normal status: open title: Make Cookiejar a bit more pythonic ___ Python tracker

Re: more pythonic way

2019-02-16 Thread Grant Edwards
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

Re: more pythonic way

2019-02-16 Thread Barry
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

Re: more pythonic way

2019-02-11 Thread Jimmy Girardet
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_mo

Re: more pythonic way

2019-02-11 Thread Peter Otten
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: >

Re: more pythonic way

2019-02-11 Thread Peter Otten
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.da

Re: more pythonic way

2019-02-11 Thread Sivan Grünberg
, etc. > > > -Original Message- > From: Python-list [mailto:python-list-bounces+david.raymond= > tomtom@python.org] On Behalf Of Felix Lazaro Carbonell > Sent: Monday, February 11, 2019 2:30 PM > To: python-list@python.org > Subject: more pythonic way > &

Re: more pythonic way

2019-02-11 Thread Terry Reedy
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

RE: more pythonic way

2019-02-11 Thread David Raymond
or overrides, etc. -Original Message- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of Felix Lazaro Carbonell Sent: Monday, February 11, 2019 2:30 PM To: python-list@python.org Subject: more pythonic way Hello to everyone: Could you please tell me

RE: more pythonic way

2019-02-11 Thread Felix Lazaro Carbonell
-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

RE: more pythonic way

2019-02-11 Thread Felix Lazaro Carbonell
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. --

Re: more pythonic way

2019-02-11 Thread Grant Edwards
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: > &

more pythonic way

2019-02-11 Thread Felix Lazaro Carbonell
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: month

[issue32829] Lib/ be more pythonic

2018-03-17 Thread R. David Murray
R. David Murray added the comment: The risk of introducing a bug is higher than the minimal benefit of making the changes. Thus we do not typically accept changes like this. We'll clean up such code when we touching it for other reasons. -- nosy:

[issue32829] Lib/ be more pythonic

2018-03-05 Thread Дилян Палаузов
Дилян Палаузов added the comment: The variables got_it in distutils/command/sdist and quote in email/_header_value_parser can be skipped making the code shorter and faster. -- ___ Python tracker

[issue32829] Lib/ be more pythonic

2018-02-16 Thread Terry J. Reedy
Terry J. Reedy added the comment: Dilyan, please explain what you believe the problems to be and how the patch solves it. These seem to be 3 separate issues. Do not change idlelib.config. config_main.def contain 'default = True' or 'default = False' and that is what the

[issue32829] Lib/ be more pythonic

2018-02-12 Thread Christian Heimes
Christian Heimes added the comment: We generally don't accept patches on bugs.python.org. Please open a pull request on github, see https://devguide.python.org/#contributing -- nosy: +christian.heimes ___ Python tracker

[issue32829] Lib/ be more pythonic

2018-02-12 Thread Дилян Палаузов
ut it is ignored. """ -- components: Build messages: 312040 nosy: dilyan.palauzov priority: normal severity: normal status: open title: Lib/ be more pythonic type: performance versions: Python 3.8 ___ Python tracker <rep...@bugs.python.org>

Re: What is more Pythonic: subclass or adding functionality to base class?

2018-02-11 Thread Paul Moore
On 11 February 2018 at 12:55, D'Arcy Cain <da...@vybenetworks.com> wrote: > On 02/11/18 06:30, Victor Porton wrote: >> What is more pythonic? >> >> 1. Create its subclass PredicateParserWithError and add the additional field >> on_error to this class. >> >

Re: What is more Pythonic: subclass or adding functionality to base class?

2018-02-11 Thread D'Arcy Cain
On 02/11/18 06:30, Victor Porton wrote: > What is more pythonic? > > 1. Create its subclass PredicateParserWithError and add the additional field > on_error to this class. > > 2. Add on_error field to the base class, setting it to None by default, if > the class's user doe

What is more Pythonic: subclass or adding functionality to base class?

2018-02-11 Thread Victor Porton
e objects of this class. What is more pythonic? 1. Create its subclass PredicateParserWithError and add the additional field on_error to this class. 2. Add on_error field to the base class, setting it to None by default, if the class's user does not need this field. -- Victor Porton - htt

Re: More Pythonic implementation

2014-08-19 Thread Chris Kaynor
://www.pokerstars.com/poker/games/rules/hand-rankings/. Which of the following is better and more Pythonic ? Your two code segments will do different things. def poker(hands): return max(hands, key=hand_rank) In this case, the hand_rank function will take a single hand, and return its rank value

Re: More Pythonic implementation

2014-08-19 Thread Ben Finney
hand_rank(hand): Determine the rank of the poker hand. rank = int(some_complex_computation(hand)) return rank In other words, I'm assuming ‘hand_rank’ returns an integer. Which of the following is better and more Pythonic ? Only one of them does anything useful

ANN: Twiggy 0.2, a more Pythonic logger

2010-06-03 Thread Pete
Hiya- I'm pleased to announce the initial public release of Twiggy, a more Pythonic logger. It was conceived at Pycon, at the prodding of Jesse Noller. It features: * a clean, powerful syntax for logging using method chaining * loose coupling between log targets and emitters * glue

Re: Can someone please make it more pythonic or better?

2010-04-19 Thread J Kenneth King
the Car class) user-input = tests.testfile.Cacr.test_stop and I'm doing it this the following way and I really think there has to be more readable, more pythonic and more possibly short way to do it import unittest import sys import inspect def get_test_names(full_name,module): name

Can someone please make it more pythonic or better?

2010-04-17 Thread Oltmans
and I'm doing it this the following way and I really think there has to be more readable, more pythonic and more possibly short way to do it import unittest import sys import inspect def get_test_names(full_name,module): name = full_name.split('.') loader = unittest.TestLoader() if len(name

Re: Which is more pythonic?

2009-12-04 Thread Bruno Desthuilliers
Filip Gruszczyński a écrit : I have just written a very small snippet of code and started thinking, which version would be more pythonic. Basically, I am adding a list of string to combo box in qt. So, the most obvious way is: for choice in self.__choices: choicesBox.addItem(choice

Re: Which is more pythonic?

2009-12-04 Thread nn
On Dec 3, 10:41 am, Filip Gruszczyński grusz...@gmail.com wrote: I have just written a very small snippet of code and started thinking, which version would be more pythonic. Basically, I am adding a list of string to combo box in qt. So, the most obvious way is: for choice in self.__choices

Which is more pythonic?

2009-12-03 Thread Filip Gruszczyński
I have just written a very small snippet of code and started thinking, which version would be more pythonic. Basically, I am adding a list of string to combo box in qt. So, the most obvious way is: for choice in self.__choices: choicesBox.addItem(choice) But I could also do: map(self

Re: Which is more pythonic?

2009-12-03 Thread Rhodri James
On Thu, 03 Dec 2009 15:41:56 -, Filip Gruszczyński grusz...@gmail.com wrote: I have just written a very small snippet of code and started thinking, which version would be more pythonic. Basically, I am adding a list of string to combo box in qt. So, the most obvious way is: for choice

Re: Which is more pythonic?

2009-12-03 Thread MRAB
Filip Gruszczyński wrote: I have just written a very small snippet of code and started thinking, which version would be more pythonic. Basically, I am adding a list of string to combo box in qt. So, the most obvious way is: for choice in self.__choices: choicesBox.addItem(choice) But I

Re: Which is more pythonic?

2009-12-03 Thread Lie Ryan
On 12/4/2009 11:44 AM, Rhodri James wrote: map(self.__choices, choicesBox.addItem) or [choicesBox.addItem(choice) for choice in self.__choices] Aside from being pythonic or non-pythonic, using map or list comprehension with a method with side-effect is not the intention of functional

Re: Which is more pythonic?

2009-12-03 Thread Edward A. Falk
In article mailman.1375.1259885328.2873.python-l...@python.org, Filip GruszczyÅ ski grusz...@gmail.com wrote: for choice in self.__choices: choicesBox.addItem(choice) This is the easiest to read. I'm guessing that this is not inner-loop stuff that needs to be optimized, so you should

Re: Could this expression parser be more 'Pythonic'?

2009-05-07 Thread Amr
Hi John, Thanks for the tips, I will check them out. --Amr -- http://mail.python.org/mailman/listinfo/python-list

Could this expression parser be more 'Pythonic'?

2009-05-06 Thread Amr
Hello all, I've been spending the last few weeks learning Python, and I've just started to use it to write a simple BASIC compiler. I'm writing a mathematical expression parser and wrote a function that would take a string and split it into high level tokens. The code can be found at

Re: Could this expression parser be more 'Pythonic'?

2009-05-06 Thread John Machin
On May 7, 9:23 am, Amr amrbek...@gmail.com wrote: Hello all, I've been spending the last few weeks learning Python, and I've just started to use it to write a simple BASIC compiler. I'm writing a mathematical expression parser and wrote a function that would take a string and split it into

Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread John Posner
Dennis Lee Bieber presented a code snippet with two consecutive statements that made me think, I'd code this differently. So just for fun ... is Dennis's original statement or my _alt statement more idiomatically Pythonic? Are there even more Pythonic alternative codings? mrkrs = [b for b

Re: Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread bieffe62
more Pythonic alternative codings?    mrkrs = [b for b in block      if b 127        or b in [ \r, \n, \t ]       ]    mrkrs_alt1 = filter(lambda b: b 127 or b in [ \r, \n, \t ], block)    mrkrs_alt2 = filter(lambda b: b 127 or b in list(\r\n\t), block) Never tested my 'pythonicity

RE: Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread John Posner
   mrkrs_alt2 = filter(lambda b: b 127 or b in list(\r\n\t), block) Never tested my 'pythonicity', but I would do: def test(b) : b 127 or b in r\r\n\t Oops! Clearly, b in \r\n\t is preferable to ... b in list(\r\n\t) You do *not* want to use a raw string here:

Re: Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread John Machin
more Pythonic alternative codings?    mrkrs = [b for b in block      if b 127        or b in [ \r, \n, \t ]       ] I'd worry about correct before Pythonic ... see my responses to Dennis in the original thread.    mrkrs_alt1 = filter(lambda b: b 127 or b in [ \r, \n, \t ], block

Re: Which is more Pythonic?

2009-04-01 Thread Terry Reedy
Pythonic? Are there even more Pythonic alternative codings? mrkrs = [b for b in block if b 127 or b in [ \r, \n, \t ] ] I'd worry about correct before Pythonic ... see my responses to Dennis in the original thread. mrkrs_alt1 = filter(lambda b: b 127 or b in [ \r, \n, \t

A more pythonic way of writting

2008-12-05 Thread eric
Hi, I've got this two pieces of code that works together, and fine def testit(): for vals in [[imask==mask for mask in [1j for j in range(6)] ] for i in range(16)]: print vals, '-', flag(*vals) def flag(IGNORECASE=False, LOCALE=False, MULTILINE=False, DOTALL=False, UNICODE=False,

Re: A more pythonic way of writting

2008-12-05 Thread Mark Tolonen
eric [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] def flag(IGNORECASE=False, LOCALE=False, MULTILINE=False, DOTALL=False, UNICODE=False, VERBOSE=False): vals = [IGNORECASE, LOCALE, MULTILINE, DOTALL, UNICODE, VERBOSE] filtered = map( lambda m:m[1],filter( lambda m: m[0],

Re: A more pythonic way of writting

2008-12-05 Thread Gerard flanagan
eric wrote: Hi, I've got this two pieces of code that works together, and fine def testit(): for vals in [[imask==mask for mask in [1j for j in range(6)] ] for i in range(16)]: print vals, '-', flag(*vals) def flag(IGNORECASE=False, LOCALE=False, MULTILINE=False, DOTALL=False,

Re: A more pythonic way of writting

2008-12-05 Thread eric
On Dec 5, 3:44 pm, Mark Tolonen [EMAIL PROTECTED] wrote: eric [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] def flag(IGNORECASE=False, LOCALE=False, MULTILINE=False, DOTALL=False, UNICODE=False, VERBOSE=False):    vals = [IGNORECASE, LOCALE, MULTILINE, DOTALL, UNICODE,

Re: A more pythonic way of writting

2008-12-05 Thread Steven D'Aprano
On Fri, 05 Dec 2008 07:44:21 -0800, eric wrote: I like to believe that the less the 'debug pointer' stands in the python code, the fastest the code is (or is potentially) What's a debug pointer? Pre-mature optimization is the root of evil in programming. Unless you have actually *measured*

Re: A more pythonic way of writting

2008-12-05 Thread eric
On Dec 6, 12:19 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Fri, 05 Dec 2008 07:44:21 -0800, eric wrote: I like to believe that the less the 'debug pointer' stands in the python code, the fastest the code is (or is potentially) What's a debug pointer? Pre-mature

Wanted: something more Pythonic than _winreg.

2008-10-10 Thread Jonathan Fine
Hello I'm using the _winreg module to change Windows registry settings, but its rather low level, and I'd prefer to be working with something more Pythonic. Does anyone have any recommendations? Jonathan -- http://mail.python.org/mailman/listinfo/python-list

Re: Wanted: something more Pythonic than _winreg.

2008-10-10 Thread Christian Heimes
Jonathan Fine wrote: Hello I'm using the _winreg module to change Windows registry settings, but its rather low level, and I'd prefer to be working with something more Pythonic. Does anyone have any recommendations? Yeah, please implement a nice wrapper and submit a patch

Re: Wanted: something more Pythonic than _winreg.

2008-10-10 Thread Mike Driscoll
On Oct 10, 9:44 am, Jonathan Fine [EMAIL PROTECTED] wrote: Hello I'm using the _winreg module to change Windows registry settings, but its rather low level, and I'd prefer to be working with something more Pythonic. Does anyone have any recommendations? Jonathan I've used YARW before

Re: Making Variable Text Output More Pythonic?

2008-05-16 Thread Arnaud Delobelle
afrobeard [EMAIL PROTECTED] writes: Arnaud's code wont work if self.opt1 is None, an empty list, an empty tuple, False, etc, because all these evaluate to false. They wont print the internal state of these variables. [Just an informational notice, this may be the behavior you expect] ??? My

Re: Making Variable Text Output More Pythonic?

2008-05-16 Thread I-T
A thousand apologies for my ignorance. I'll try not to get names mixed up again in the future. On May 16, 8:42 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote: afrobeard [EMAIL PROTECTED] writes: Arnaud's code wont work if self.opt1 is None, an empty list, an empty tuple, False, etc, because

Making Variable Text Output More Pythonic?

2008-05-15 Thread Casey McGinty
Hi, I have some classes that print variable outputs depending on their internal state, like so: def __str__(self): out = [] if self.opt1: out += ['option 1 is %s' % self.opt1'] if self.opt2: out += ['option 2 is %s' % self.opt2'] return '\n'.join(out) Is there any way

Making Variable Text Output More Pythonic?

2008-05-15 Thread Casey
Hi, I have some classes that print variable outputs depending on their internal state, like so: def __str__(self): out = [] if self.opt1: out += ['option 1 is %s' % self.opt1'] if self.opt2: out += ['option 2 is %s' % self.opt2'] return '\n'.join(out) Is there any way

Re: Making Variable Text Output More Pythonic?

2008-05-15 Thread Arnaud Delobelle
Casey [EMAIL PROTECTED] writes: Hi, I have some classes that print variable outputs depending on their internal state, like so: def __str__(self): out = [] if self.opt1: out += ['option 1 is %s' % self.opt1'] if self.opt2: out += ['option 2 is %s' % self.opt2']

Re: Making Variable Text Output More Pythonic?

2008-05-15 Thread afrobeard
Arnaud's code wont work if self.opt1 is None, an empty list, an empty tuple, False, etc, because all these evaluate to false. They wont print the internal state of these variables. [Just an informational notice, this may be the behavior you expect] Secondly, I'm not sure if you know the variable

ANN: Porcupine 0.5 is released. More Pythonic, more productive.

2008-05-04 Thread t . koutsovassilis
Porcupine Web Application Server is a Python based framework that provides front-to-back revolutionary technologies for building modern Web2.0 applications. This release is a major breakthrough for Porcupine. The two main new concepts introduced on the server side are the services and the web

Re: more pythonic

2008-02-29 Thread Alan Isaac
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) for

Re: more pythonic

2008-02-29 Thread Paul McGuire
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:     someNewList =

more pythonic

2008-02-28 Thread Temoto
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, i don't feel that, though. Could you tell your opinion on that

Re: more pythonic

2008-02-28 Thread 7stud
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, i don't

Re: more pythonic

2008-02-28 Thread 7stud
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.   --

Re: more pythonic

2008-02-28 Thread Paul McGuire
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, i don't

Re: more pythonic

2008-02-28 Thread Temoto
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 could be expressed

Re: more pythonic

2008-02-28 Thread Paul McGuire
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 send it to user. It

Re: Which is more pythonic?

2008-01-25 Thread Paul Hankin
[EMAIL PROTECTED] wrote: I have a goal function that returns the fitness of a given solution. I need to wrap that function with a class or a function to keep track of the best solution I encounter. Which of the following would best serve my purpose and be the most pythonic? You could write a

Which is more pythonic?

2008-01-24 Thread [EMAIL PROTECTED]
I have a goal function that returns the fitness of a given solution. I need to wrap that function with a class or a function to keep track of the best solution I encounter. Which of the following would best serve my purpose and be the most pythonic? class Goal: def __init__(self, goal):

Re: Which is more pythonic?

2008-01-24 Thread Travis Jensen
Well, regardless of being pythonic or not, the first is far more understandable and therefore more maintainable. Objects were invented to handle holding state; using a function to hold state is, in my opinion, doing a language-based cheat. :) tj On Jan 24, 2008, at 10:14 PM, [EMAIL

Re: Which is more pythonic?

2008-01-24 Thread Paddy
On Jan 25, 5:14 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have a goal function that returns the fitness of a given solution. I need to wrap that function with a class or a function to keep track of the best solution I encounter. Which of the following would best serve my purpose and be

Re: Hex editor display - can this be more pythonic?

2007-07-30 Thread Marc 'BlackJack' Rintsch
On Sun, 29 Jul 2007 18:27:25 -0700, CC wrote: Marc 'BlackJack' Rintsch wrote: I'd use `string.printable` and remove the invisible characters like '\n' or '\t'. What is `string.printable` ? There is no printable method to strings, though I had hoped there would be. I don't yet know how

Re: Hex editor display - can this be more pythonic?

2007-07-30 Thread Neil Cerutti
On 2007-07-30, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Sun, 29 Jul 2007 18:30:22 -0700, CC [EMAIL PROTECTED] declaimed the following in comp.lang.python: Yeah, with this I'm not that concerned about Windows. Though, can WinXP still load the ansi.sys driver? I'm actually not

Hex editor display - can this be more pythonic?

2007-07-29 Thread CC
want it. But which is more pythonic? The next step consists of printing out the ASCII printable characters. I have devised the following silliness: printable = ' [EMAIL PROTECTED]8*9(0)aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\ `~-_=+\\|[{]};:\',./?' for c in ln: if c

  1   2   >