On 20/11/2018 22:35, Steven D'Aprano wrote:
> On Tue, Nov 20, 2018 at 08:22:01PM +, Alan Gauld via Tutor wrote:
>
>> I think that's a very deliberate feature of Python going back
>> to its original purpose of being a teaching language that
>> can be used beyond the classroom.
>
> I don't
On Tue, Nov 20, 2018 at 08:22:01PM +, Alan Gauld via Tutor wrote:
> I think that's a very deliberate feature of Python going back
> to its original purpose of being a teaching language that
> can be used beyond the classroom.
I don't think that is correct -- everything I've read is that
On 20/11/2018 18:08, Avi Gross wrote:
We have two completely separate ways to format strings that end up with fairly
similar functionality. Actually, there is an implicit third way
You could argue five ways :-)
1. C printf style formatting
On 20/11/2018 18:08, Avi Gross wrote:
> ... So there isn’t really ONE pythonic way for many things.
That's true and, I think, inevitable for anything developed
in the open source world. If you compare it to a language
entirely controlled by a single mind - like Oberon or Eiffel
say - then there
Op 2 apr. 2018 15:31 schreef Steven D'Aprano :
>
> On Mon, Apr 02, 2018 at 06:49:52AM -0600, Mats Wichmann wrote:
> > On 04/02/2018 02:56 AM, Alan Gauld via Tutor wrote:
> > > On 02/04/18 04:19, Steven D'Aprano wrote:
> > >> On Sun, Apr 01, 2018 at 10:58:51PM +0100, Alan
On Mon, Apr 02, 2018 at 04:28:10PM +0200, Peter Otten wrote:
> > They look like string constants, but they're actually a hidden call to
> > eval().
>
> But because you cannot f-ify a string variable (without an additional eval()
> call) you aren't tempted to feed them user-provided data.
If
On 04/02/2018 08:28 AM, Peter Otten wrote:
> Steven D'Aprano wrote:
>
>> On Mon, Apr 02, 2018 at 06:49:52AM -0600, Mats Wichmann wrote:
>
>>> so since we're all learning things here, how would this play out with
>>> the new f-strings?
>>
>> I don't think f-strings are even a bit Pythonic.
>>
>>
Steven D'Aprano wrote:
> On Mon, Apr 02, 2018 at 06:49:52AM -0600, Mats Wichmann wrote:
>> so since we're all learning things here, how would this play out with
>> the new f-strings?
>
> I don't think f-strings are even a bit Pythonic.
>
> They look like string constants, but they're actually
On Mon, Apr 02, 2018 at 06:49:52AM -0600, Mats Wichmann wrote:
> On 04/02/2018 02:56 AM, Alan Gauld via Tutor wrote:
> > On 02/04/18 04:19, Steven D'Aprano wrote:
> >> On Sun, Apr 01, 2018 at 10:58:51PM +0100, Alan Gauld via Tutor wrote:
> >>> On01/04/18 20:20, Albert-Jan Roskam wrote:
>
On Mon, Apr 2, 2018 at 9:01 AM, David Rock wrote:
> It’s just as (if not more) pythonic to use the standard libraries. It’s very
> common in a professional environment to not have access to outside (i.e.,
> internet) resources. I wouldn’t venture into Pypi unless there’s
> On Mar 30, 2018, at 04:15, George Fischhof wrote:
>
> 2.)
> argparse
>
> it is good, but you can write more Pythonic code using click
> https://pypi.python.org/pypi/click/
> it is also Pythonic to use / know the Python ecosystem (the packages)
It’s just as (if not more)
On 04/02/2018 02:56 AM, Alan Gauld via Tutor wrote:
> On 02/04/18 04:19, Steven D'Aprano wrote:
>> On Sun, Apr 01, 2018 at 10:58:51PM +0100, Alan Gauld via Tutor wrote:
>>> On01/04/18 20:20, Albert-Jan Roskam wrote:
fmt="%Y-%m-%d %H:%M\n"
f.write(now.strftime(fmt))
Lately I've been
On 02/04/18 04:19, Steven D'Aprano wrote:
> On Sun, Apr 01, 2018 at 10:58:51PM +0100, Alan Gauld via Tutor wrote:
>> On01/04/18 20:20, Albert-Jan Roskam wrote:
>>> fmt="%Y-%m-%d %H:%M\n"
>>> f.write(now.strftime(fmt))
>>> Lately I've been using format(), which uses __format__, because I find it
On Sun, Apr 01, 2018 at 10:58:51PM +0100, Alan Gauld via Tutor wrote:
> On01/04/18 20:20, Albert-Jan Roskam wrote:
> > fmt="%Y-%m-%d %H:%M\n"
> > f.write(now.strftime(fmt))
> > Lately I've been using format(), which uses __format__, because I find it
> > slightly more readable:
> >
On01/04/18 20:20, Albert-Jan Roskam wrote:
> fmt="%Y-%m-%d %H:%M\n"
> f.write(now.strftime(fmt))
> Lately I've been using format(), which uses __format__, because I find it
> slightly more readable:
> format(datetime.now(), "%Y-%m-%d %H:%M")
Interesting,
I didn't know that format() recognised the
On Mar 30, 2018 10:39, Alan Gauld via Tutor wrote:
>
> On 30/03/18 03:48, Pat Martin wrote:
>
> > the "right" way to do it in python?
>
> More or less, a couple of comments below...
>
> > def Main():
>
> Python function names begin with a lowercase letter by convention.
>
> >
Thank you all for the ideas and comments, it is appreciated.
I have some refactoring to do now.
On Fri, Mar 30, 2018 at 2:22 AM, Peter Otten <__pete...@web.de> wrote:
> Pat Martin wrote:
>
> > I have written the following program. It generates a template for Pelican
> > web site static
2018-03-30 4:48 GMT+02:00 Pat Martin :
> Hello all,
>
> I have written the following program. It generates a template for Pelican
> web site static generator. It works just fine, it generates the template
> and then I put the info in it to customize. But I was wondering, is
Pat Martin wrote:
> I have written the following program. It generates a template for Pelican
> web site static generator. It works just fine, it generates the template
> and then I put the info in it to customize. But I was wondering, is this
> the "right" way to do it in python?
You may
On 30/03/18 03:48, Pat Martin wrote:
> the "right" way to do it in python?
More or less, a couple of comments below...
> def Main():
Python function names begin with a lowercase letter by convention.
> """Run if run as a program."""
> parser = argparse.ArgumentParser()
...
>
>
On Mon, Jul 31, 2017 at 3:39 PM, bruce wrote:
>
> So, is there a quick/dirty approach I can use to simply strip out the
> "non-ascii" chars. I know, this might not be the "best/pythonic" way,
> and that it might result in loss of some data/chars, but I can live
> with it for
On 07/31/2017 09:39 AM, bruce wrote:
> Hi guys.
>
> Testing getting data from a number of different US based/targeted
> websites. So the input data source for the most part, will be "ascii".
> I'm getting a few "weird" chars every now and then asn as fas as I can
> tell, they should be utf-8.
>
On 28/04/15 10:55, Sage Hack wrote:
I'm looking for somebody willing to review parts of this code
https://github.com/SageHack/cloud-buster and let me know what is not
Pythonic :P
https://github.com/SageHack/cloud-buster/tree/master/bust/descriptor
The thing that jumps out to me is your use
On 28/04/15 10:55, Sage Hack wrote:
I'm looking for somebody willing to review parts of this code
https://github.com/SageHack/cloud-buster and let me know what is not
Pythonic :P
https://github.com/SageHack/cloud-buster/tree/master/bust/descriptor
Another point re the PageTitle class:
spa...@gmail.com wrote:
Hello,
My code is -
l = len(m)
item = str(m[1])
for i in range(2,l):
item = item + - + str(m[i])
This code is part of a bigger function. It works fine. But I am not happy
with the way I have written it. I think there is a better (Pythonic) way to
rewrite it.
If
Hello Steven,
Thanks a lot for the detailed answer. I will implement your suggestions.
Really appreciate it.
Thanks and Regards,
Sumod
On Fri, Jan 27, 2012 at 4:34 AM, Steven D'Aprano st...@pearwood.infowrote:
spa...@gmail.com wrote:
Hello,
My code is -
l = len(m)
item = str(m[1])
for
Hi Steven,
(5) When assembling strings from substrings, never use repeated concatenation
using + as that can be EXTREMELY slow. Use str.join to build the string in
one assignment, instead of multiple assignments.
Your code shown above is *very* inefficient and will be PAINFULLY slow if m
col speed ajarnco...@gmail.com wrote
HI again, I realise that I should have included more information in
the
above e-mail. Here goes:
a/ I have a 9*9 nested list called rows, which contains the given
numbers
in a sudoku puzzle - with 0s where the blanks go.
b/ I create roworder (roworder
Le Fri, 08 May 2009 13:03:47 -0400,
pyt...@bdurham.com s'exprima ainsi:
[...]
Approaches:
1. split text to list of lines that get stripped then:
a. walk this list building a new list of lines that track and
ignore extra blank lines
-OR-
b. re-join lines and replace '\n\n\n' wth' \n\n' until
pyt...@bdurham.com wrote:
Note: Following cross-posted to python-list where it got queued due to
suspicious subject line.
I'm looking for suggestions on technique (not necessarily code) about
the most pythonic way to normalize vertical whitespace in blocks of
text so that there is never more
On Fri, May 8, 2009 at 1:03 PM, pyt...@bdurham.com wrote:
Note: Following cross-posted to python-list where it got queued due to
suspicious subject line.
I'm looking for suggestions on technique (not necessarily code) about the
most pythonic way to normalize vertical whitespace in blocks of
Malcolm Greene wrote:
Suggestions on the best way to extract delimited substrings strings from
a larger string?
Background: I have a long multi-line string with expressions delimited
with '(' and ')' markers. I would like to extract these substrings and
process them in a loop.
What
Malcolm Greene [EMAIL PROTECTED] wrote in
Background: I have a long multi-line string with expressions
delimited
with '(' and ')' markers. I would like to extract these substrings
and
process them in a loop.
I know how to do this task with regular expressions, but I'm always
cautious
Allen Fowler [EMAIL PROTECTED] wrote
I have a block of code buried deep in a module
that I expect to fail periodically.
(Calls to other machines over slow network, and such.)
Generally, though, trying it a second / third will work.
Is there clean way to write this on Python?
There
On Friday 26 October 2007 03:17:47 pm Alan Gauld wrote:
Allen Fowler [EMAIL PROTECTED] wrote
I have a block of code buried deep in a module
that I expect to fail periodically.
(Calls to other machines over slow network, and such.)
Generally, though, trying it a second / third will
stv wrote:
I considered several brute-force solutions, but I persevered and came
to, what I think, is a more Pythonic solution. What do you think?
Looks pretty sweet to me :-)
import string
def expand_tree(filetree):
indent = '\t'
stack = []
for f in filetree:
indents =
The list comp is fine but I don't think you need it
at all, since you strip() the string before you
add it to stack.
Ahh yes. I used the rstrip() in development, printing intermediary
output to stdout, so I could see what my input file-to-list looked
like (and it looked ugly with all those
On 3/21/06, stv [EMAIL PROTECTED] wrote:
import string
def expand_tree(filetree):
indent = '\t'
stack = []
for f in filetree:
indents = f.count(indent)
while len(stack) indents: stack.pop()
stack.append(f.strip())
yield string.join(stack,'')
if not
38 matches
Mail list logo