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 thin
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 Guido
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
https://docs.python.org/3/library/stdtypes.html
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 i
This is not a question or reply. Nor is it short. If not interested, feel free
to delete.
It is an observation based on recent experiences.
We have had quite a few messages that pointed out how some people approach
solving a problem using subconscious paradigms inherited from their past.
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 Gauld via Tutor wrote:
> >
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 onl
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.
>>
>> T
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 a
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:
> fmt="
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 something
> you can’t
> 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) pythonic to use the s
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 u
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:
> > format(datetime
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.
>
> > """Run if run as
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 generator
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 this
> the "right" way
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 rewrite
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()
...
>
> no
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 this
the "right" way to do it in python?
#!/usr/bin/env python3
"""Gene
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 now.
Ignore or replac
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.
>
>
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.
However, the following hasn;t always worked:
s=s
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:
class
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 o
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
I want to improve my Python coding skills but I'm not sure exactly what
to study next.
Right now I'm trying to use descriptors correctly and I'd like to k
On 27/01/12 06:44, Andre' Walker-Loud wrote:
... I have only had one programming class, and that was 15 years ago or so,
> ...so these are not issues I am aware of.
I often find myself joining strings (and have mostly used + to do it).
String addition is OK in some languages, or at least bet
On 27/01/2012 06:44, Andre' Walker-Loud wrote:
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*
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 i
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 wrote:
> spa...@gmail.com wrote:
>
>> Hello,
>>
>> My code is -
>>
>> l = len(m)
>> item = str(m[1])
>> for i i
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 an
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 anyone knows how to improve
"col speed" 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 "0"s where the blanks go.
b/ I create roworder (roworder = [[str(j)+str
Message: 6
Date: Tue, 28 Sep 2010 13:15:26 +0700
From: col speed
To: tutor@python.org
Subject: [Tutor] Pythonic nested lists
Message-ID:
Content-Type: text/plain; charset="iso-8859-1"
Hi all,
I've been trying to write a programme that solves sudoku problems for a
while n
Hi all,
I've been trying to write a programme that solves sudoku problems for a
while now. I'm getting close, but would like to ask a few questions about
the most pythonic way of doing some things.
I've decided to create nested lists (row order, column order and square
order) which correspond with
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'
On Fri, May 8, 2009 at 1:03 PM, 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
>
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
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 than 1 blank line
between paragr
"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
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.
> Wha
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.
Because the left and right delimiters a
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 /
"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
Hello,
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?
Thanks
_
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
> 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 E
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:
> inden
Hey all,
I would like to expand the "visual" representation of a tree
hierarchy, given below, where child-ness is defined by indentation,
and folder-ness is highlighted with a trailing '/'
Input (test.txt):
dir1/
file1
file2
1-1/
file3
file4
51 matches
Mail list logo