On 3/10/2023 11:15 PM, aapost wrote:
On 3/10/23 22:16, Thomas Passin wrote:
[...]
The additional note in the above is, when taking the def route above,
the thing you would have to consider is what scope is the dictionary pids?
Do you need to submit it to the lambda and subsequently the functi
On 3/10/23 22:16, Thomas Passin wrote:
On 3/10/2023 7:07 PM, aapost wrote:
which does start to break down readability due to line length, as
there isn't really an indention rule set for something uncommonly used.
but some renaming makes the pattern clearer
pids.update({"messages" :subprocess.
t;1", "-f", f"/var/log/{target}"]
pids.update({target: subprocess.Popen(cmd)}) if not \
pids[target] else None
I might be missing something, but how is that more understandable and
less error prone than any of the following:
The main point is that there can be an ea
On 2023-03-10 at 22:16:05 -0500,
Thomas Passin wrote:
> I'd make the pattern in this example even more understandable and less
> error-prone:
>
> def update_pids(target):
> cmd = ["tail", "-n", "1", "-f", f"/var/log/{target}"]
> pids.update({target: subprocess.Popen(cmd)}) if not \
>
On 3/10/2023 7:07 PM, aapost wrote:
which does start to break down readability due to line length, as there
isn't really an indention rule set for something uncommonly used.
but some renaming makes the pattern clearer
pids.update({"messages" :subprocess.Popen(["cmd1"])}) if not
pids["messages
should be killed, and how do you kill the right one? With the function,
you can get those details under control, but I hate to think what might
happen to the lambda expression.
Yes, of course, there can be times when the lambda expression is
somewhat easy to understand and the side effects
On 3/10/23 18:46, aapost wrote:
main.pids.update({"messages" :subprocess.Popen(["tail", "-n",
"1", "-f", "/var/log/messages"])}),
main.pids.update({"syslog" :subprocess.Popen(["tail", "-n",
"1", "-f", "/var/log/syslog"])}),
main.pids.update({"kern" :subprocess.Popen([
On 09Mar2023 17:55, aapost wrote:
On 3/9/23 16:37, Cameron Simpson wrote:
Just a note that some code formatters use a trailing comma on the last
element to make the commas fold points. Both yapf (my preference) and
black let you write a line like (and, indeed, flatten if short
enough):
On 3/9/23 16:37, Cameron Simpson wrote:
On 09Mar2023 09:06, Alan Gauld wrote:
Just a note that some code formatters use a trailing comma on the last
element to make the commas fold points. Both yapf (my preference) and
black let you write a line like (and, indeed, flatten if short enough):
On 3/9/23 04:06, Alan Gauld wrote:
Thank you for the feedback, I appreciate the comments.
To add a little extra, there is actually a reason I lean toward overuse
of .config() for a lot of things even though they could be sent to the
constructor (other than that w["attribute"]= doesn't work
ived {x}') or x*x
I'm not sure why lambda functions shouldn't have side effects. They
can be used for anything, as long as it's a single expression (which
can, of course, be composed of other expressions).
> The Python Reference on readthedocs.io also has a tk example
On 09Mar2023 09:06, Alan Gauld wrote:
Also layout is all important here. It could get very messy to read if
indentation isn't clear. You only have to look at some Javascript code
with function definitions as arguments to functions to see how clunky
that can be.
Just a note that some code forma
;), ...maybe more..., expr)[-1]
to embed some debug tracing in a lambda defined expression.
Cheers,
Cameron Simpson
--
https://mail.python.org/mailman/listinfo/python-list
killed, and how do you kill the right one? With the function,
you can get those details under control, but I hate to think what might
happen to the lambda expression.
Yes, of course, there can be times when the lambda expression is
somewhat easy to understand and the side effects are harmless.
On 3/9/23 00:13, Thomas Passin wrote:
lol.. 'us'..
So.. to give an example from your own code:
but_play = Tk.Button(_frame, text='Play', width = BUTTONWIDTH + 1, pady
= PADY, command=lambda x=plotmgr:play_macro(x), bg = BUTTON_BG, font =
NEWFONT)
Can be written as:
b = Tk.Button(master=
t;,command=e)
or
b = tk.Button(master=main, text="Enable",command=lambda:
[e.config(state="normal") for e in (e1, e2, e3)])
From: Python-list on
behalf of aapost
Date: Wednesday, March 8, 2023 at 5:15 PM
To: python-list@python.org
Subject: Lambda returning tuple question,
On 08/03/2023 21:56, aapost wrote:
> When making a UI there are a lot of binding/trace operations that need
> to occur that lead to a lot of annoying 1 use function definitions. I
> don't really see lambda use like below.
Lambdas are very common in GUI callbacks but I admit I've never seen
tuple
on config_b_and_entries()
that I suggested is not meant to be the target of a lambda expression
that is the argument of b.config(). It is meant to be called *instead*
of b.config(command = lambda.). I can't see any benefit of trying
to force this coordination of states by using an obs
On 3/8/23 16:56, aapost wrote:
Thomas > Cameron
def set_entries_enabled_state(enabled = True):
state = 'normal' if enabled else 'disabled'
for e in (e1, e2, e3):
e.config(state=state)
def config_b_and_entries(enabled = True):
state = 'normal' if enabled else 'disabled'
On 08Mar2023 16:56, aapost wrote:
When making a UI there are a lot of binding/trace operations that need
to occur that lead to a lot of annoying 1 use function definitions. I
don't really see lambda use like below.
Giving 2 working lambda examples using a returned tuple to accomplish
multipl
On 3/8/2023 4:56 PM, aapost wrote:
b = tk.Button(master=main, text="Enable")
b.config(
command=lambda: (
e1.config(state="normal"),
e2.config(state="normal"),
e3.config(state="normal")
)
)
It's hard to understand what you are trying to do here. I don't
rem
When making a UI there are a lot of binding/trace operations that need
to occur that lead to a lot of annoying 1 use function definitions. I
don't really see lambda use like below.
Giving 2 working lambda examples using a returned tuple to accomplish
multiple expressions - what sort of gotchas
On Thu, Mar 2, 2023 at 9:56 PM Alan Bawden wrote:
>
> jose isaias cabrera writes:
>
>On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote:
>
>This re is a bit different than the one I am used. So, I am trying to match
>everything after 'pn=':
>
>import re
>s = "pm=jose pn=2017"
ject manager. pn=project name. I needed search()
rather than match().
>
> >>> s = "pn=jose pn=2017"
> ...
> >>> s0 = r0.match(s)
> >>> s0
>
>
>
>
> -Original Message-
> From: Python-list On
> Behalf Of jose isaias cab
On Thu, Mar 2, 2023 at 8:30 PM Cameron Simpson wrote:
>
> On 02Mar2023 20:06, jose isaias cabrera wrote:
> >This re is a bit different than the one I am used. So, I am trying to
> >match
> >everything after 'pn=':
> >
> >import re
> >s = "pm=jose pn=2017"
> >m0 = r"pn=(.+)"
> >r0 = re.compile(m0)
jose isaias cabrera writes:
On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote:
This re is a bit different than the one I am used. So, I am trying to match
everything after 'pn=':
import re
s = "pm=jose pn=2017"
m0 = r"pn=(.+)"
r0 = re.compile(m0)
s0 = r0.match(s)
>>
On 02Mar2023 20:06, jose isaias cabrera wrote:
This re is a bit different than the one I am used. So, I am trying to
match
everything after 'pn=':
import re
s = "pm=jose pn=2017"
m0 = r"pn=(.+)"
r0 = re.compile(m0)
s0 = r0.match(s)
`match()` matches at the start of the string. You want r0.se
;> s0
-Original Message-
From: Python-list On
Behalf Of jose isaias cabrera
Sent: Thursday, March 2, 2023 8:07 PM
To: Mats Wichmann
Cc: python-list@python.org
Subject: Re: Regular Expression bug?
On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote:
>
> On 3/2/23 12:28
On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote:
>
> On 3/2/23 12:28, Chris Angelico wrote:
> > On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera
wrote:
> >>
> >> Greetings.
> >>
> >> For the RegExp Gurus, consider the following python3 code:
> >>
> >> import re
> >> s = "pn=align upgrade sd=2
On
Behalf Of jose isaias cabrera
Sent: Thursday, March 2, 2023 2:23 PM
To: python-list@python.org
Subject: Regular Expression bug?
Greetings.
For the RegExp Gurus, consider the following python3 code:
import re
s = "pn=align upgrade sd=2023-02-"
ro = re.compile(r"pn=(.+) &
n upgrade sd=2023-02-"
> > ro = re.compile(r"pn=(.+) ")
> > r0=ro.match(s)
> > >>> print(r0.group(1))
> > align upgrade
> >
> >
> > This is wrong. It should be 'align' because the group only goes up-to
> > the space. Thought
On 3/2/23 12:28, Chris Angelico wrote:
On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera wrote:
Greetings.
For the RegExp Gurus, consider the following python3 code:
import re
s = "pn=align upgrade sd=2023-02-"
ro = re.compile(r"pn=(.+) ")
r0=ro.match(s)
print(r0.group(1))
align upgrade
T
)
> align upgrade
>
>
> This is wrong. It should be 'align' because the group only goes up-to
> the space. Thoughts? Thanks.
The bug is in your regular expression; the plus modifier is greedy.
If you want to match up to the first space, then you'll need somethin
On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera wrote:
>
> Greetings.
>
> For the RegExp Gurus, consider the following python3 code:
>
> import re
> s = "pn=align upgrade sd=2023-02-"
> ro = re.compile(r"pn=(.+) ")
> r0=ro.match(s)
> >>> print(r0.group(1))
> align upgrade
>
>
> This is wrong. I
Greetings.
For the RegExp Gurus, consider the following python3 code:
import re
s = "pn=align upgrade sd=2023-02-"
ro = re.compile(r"pn=(.+) ")
r0=ro.match(s)
>>> print(r0.group(1))
align upgrade
This is wrong. It should be 'align' because the group only goes up-to
the space. Thoughts? Thanks.
e, but by its reference. All checks therefore refence
only the last variable.
Yep, that is the nature of closures. (Side point: This isn't actually
a generator expression, it's a list comprehension; current versions of
Python treat them broadly the same way, but there was previously a
diffe
he lambda
> not by its value, but by its reference. All checks therefore refence
> only the last variable.
>
Yep, that is the nature of closures. (Side point: This isn't actually
a generator expression, it's a list comprehension; current versions of
Python treat them broadly the
it outputs:
Check for bar
False
Check for bar
False
I.e., the iteration variable "z" somehow gets bound inside the lambda
not by its value, but by its reference. All checks therefore refence
only the last variable.
This totally blew my mind. I can understand why it's happening, but is
e
only the last variable.
This totally blew my mind. I can understand why it's happening, but is
this the behavior we would expect? And how can I create lambdas inside a
generator expression and tell the expression to use the *value* and not
pass the "z" variable by reference?
Cheers,
Joe
--
https://mail.python.org/mailman/listinfo/python-list
> Check for bar
> False
> Check for bar
> False
>
> I.e., the iteration variable "z" somehow gets bound inside the lambda
> not by its value, but by its reference. All checks therefore refence
> only the last variable.
>
> This totally blew my mind. I ca
(*) Question
How can I, in a single line, write a statement followed by an
expression? For example, if /d/ is a dicionary, how can I write
d["key"] = value # and somehow making this line end up with d
(*) Where does the question come from?
>From the following experi
Meredith Montgomery writes:
How can I execute a statement followed by a value in a single line?
def roberry_via_reduce(rs):
return my_reduce(rs, lambda d, r: ``increment and return d'', {})
The grammar or Python is deliberately designed so that the body of a
lambda express
ansari.aafaq1...@gmail.com wrote:
> Lets say i have a expression:
> flowrate=(veloctiy*area)
> i can find the flowrate with this expression
> but if i dont wanna change the expression and want to find the velocity by
> giving it value of area and flowrate ,how do i do this in p
On 5/21/20 5:56 AM, ansari.aafaq1...@gmail.com wrote:
> Lets say i have a expression:
> flowrate=(veloctiy*area)
> i can find the flowrate with this expression
> but if i dont wanna change the expression and want to find the velocity by
> giving it value of area and flowrate ,how
Lets say i have a expression:
flowrate=(veloctiy*area)
i can find the flowrate with this expression
but if i dont wanna change the expression and want to find the velocity by
giving it value of area and flowrate ,how do i do this in python?
is there any library or package or module for this
On Wed, Apr 22, 2020 at 6:12 AM Barry Scott wrote:
>
>
>
> > On 20 Apr 2020, at 10:29, Veek M wrote:
> >
> > On Mon, 20 Apr 2020 19:19:31 +1000, Chris Angelico wrote:
> >
> >> In the case of a genexp, the expression has a value which is a generator
&g
> On 20 Apr 2020, at 10:29, Veek M wrote:
>
> On Mon, 20 Apr 2020 19:19:31 +1000, Chris Angelico wrote:
>
>> In the case of a genexp, the expression has a value which is a generator
>> object. When you pass that to all(), it takes it and then iterates over
>
>
Veek M writes:
> The docs state that a expression is some combination of value, operator,
> variable and function. Also you cannot add or combine a generator
> expression with a value as you would do with 2 + 3 + 4. For example,
> someone on IRC suggested this
> all(a ==
On Mon, Apr 20, 2020 at 8:26 PM Veek M wrote:
>
> but one can do the following
> (x for x in 'apple').next() * 2
>
> def foo():
>(yield 2)
> foo().next() * 3
>
> (lambda x: 2)()*4
>
> generator expr, yield expr, lambda expression
> all requ
but one can do the following
(x for x in 'apple').next() * 2
def foo():
(yield 2)
foo().next() * 3
(lambda x: 2)()*4
generator expr, yield expr, lambda expression
all require some modification (insertion of a .next or explicit () so
it's quite confusing..
expressio
On 20/04/20 9:19 PM, Chris Angelico wrote:
On Mon, Apr 20, 2020 at 6:51 PM Veek M wrote:
The docs state that a expression is some combination of value, operator,
variable and function. Also you cannot add or combine a generator
expression with a value as you would do with 2 + 3 + 4. For
Also you will note, one can do:
( 2 if 3 > 2 else 4 ) + 4
so the () is just for precedence but otherwise a Conditional Expression
works as expected by returning a value to be added to + 4.
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, 20 Apr 2020 19:19:31 +1000, Chris Angelico wrote:
> In the case of a genexp, the expression has a value which is a generator
> object. When you pass that to all(), it takes it and then iterates over
but an object is NOT THE SAME as it's value! '2' is an object whi
On Mon, Apr 20, 2020 at 6:51 PM Veek M wrote:
>
> The docs state that a expression is some combination of value, operator,
> variable and function. Also you cannot add or combine a generator
> expression with a value as you would do with 2 + 3 + 4. For example,
> someone on IRC
The docs state that a expression is some combination of value, operator,
variable and function. Also you cannot add or combine a generator
expression with a value as you would do with 2 + 3 + 4. For example,
someone on IRC suggested this
all(a == 'a' for a in 'apple') but
Am Montag, 14. Oktober 2019 13:56:09 UTC+2 schrieb Chris Angelico:
>
> (My apologies for saying this in reply to an unrelated post, but I
> also don't see those posts, so it's not easy to reply to them.)
>
> ChrisA
Nothing to apologize and thank you for clarification,
I was already checking my s
On Mon, Oct 14, 2019 at 10:41 PM Eko palypse wrote:
>
> Am Sonntag, 13. Oktober 2019 21:20:26 UTC+2 schrieb moi:
> > [Do not know why I spent hours with this...]
> >
> > To answer you question.
> > Yes, I confirm.
> > It seems that as soon as one works with bytes and when
> > a char is encoded in
Am Sonntag, 13. Oktober 2019 21:20:26 UTC+2 schrieb moi:
> [Do not know why I spent hours with this...]
>
> To answer you question.
> Yes, I confirm.
> It seems that as soon as one works with bytes and when
> a char is encoded in more than 1 byte, "re" goes into
> troubles.
>
First, sorry for a
the current buffer to me.
The problem is that the buffer can have all possible encodings.
cp1251, cp1252, utf8, ucs-2 ... but scintilla informs me about
which encoding is currently used.
I wanted to realize a regular expression tester with Python3,
and mark the text that has been matched by regular
re.LOCALE are slow. It may be more efficient to
decode text and use Unicode regular expression.
Thank you, I guess I'm convinced to always decode everything (re pattern and
text) to utf8 internally and then do the re search but then I would need to
figure out the correct position, hmm -
On Sun, Oct 13, 2019 at 7:16 AM Richard Damon wrote:
>
> On 10/12/19 3:46 PM, Eko palypse wrote:
> > Thank you very much for your answer.
> >
> >> You have to be able to match bytes, not strings.
> > May I ask you to elaborate on this, sorry non-native English speaker.
> > The buffer I receive is
charsets. So even if you set the utf-8 locale, it
would not help.
Regular expressions with re.LOCALE are slow. It may be more efficient to
decode text and use Unicode regular expression.
+1
It's best to treat re.LOCALE as being for old legacy encodings that
use/used 8 bits per character. Whe
On 10/12/19 3:46 PM, Eko palypse wrote:
> Thank you very much for your answer.
>
>> You have to be able to match bytes, not strings.
> May I ask you to elaborate on this, sorry non-native English speaker.
> The buffer I receive is a byte-like buffer.
>
>> I don't think you'll be able to 100% reliab
hen you're matching text (the normal way you use a regular
expression), every element in the RE matches a character (or
emptiness). For instance, the regular expression "^[bc]at$" has these
elements:
"^" matches emptiness at the start
"[bc]" matches either "
ow. It may be more efficient to
> decode text and use Unicode regular expression.
Thank you, I guess I'm convinced to always decode everything (re pattern and
text) to utf8 internally and then do the re search but then I would need to
figure out the correct position, hmm - some ongoi
Thank you very much for your answer.
> You have to be able to match bytes, not strings.
May I ask you to elaborate on this, sorry non-native English speaker.
The buffer I receive is a byte-like buffer.
> I don't think you'll be able to 100% reliably match bytes in this way.
> You're asking it to
would not help.
Regular expressions with re.LOCALE are slow. It may be more efficient to
decode text and use Unicode regular expression.
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, Oct 13, 2019 at 5:11 AM Eko palypse wrote:
>
> What needs to be set in order to be able to use a re search within
> utf8 encoded bytes?
You have to be able to match bytes, not strings.
> So how can I make it work with utf8 encoded text?
> Note, decoding it to a string isn't preferred as
What needs to be set in order to be able to use a re search within
utf8 encoded bytes?
My test, being on a windows PC with cp1252 setup, looks like this
import re
import locale
cp1252 = 'Ärger im Paradies'.encode('cp1252')
utf8 = 'Ärger im Paradies'.encode('utf-8')
print('cp1252:', cp1252)
pr
.7/library/re.html#regular-expression-objects
nor with help
import re
lex = re.compile("foo")
help(lex.scanner)
Help on built-in function scanner:
scanner(string, pos=0, endpos=2147483647) method of _sre.SRE_Pattern
instance
Does anybody know where to find a doc ?
--
https://mail.python.
do) thing and I think he'd be happy.
> You'll have to accept that not all Python objects can be represented
> as literals.
I don't think SR minds if the result is not a literal. I think the hope
was simply that eval(repr(E)) === E for any expression E. You could, in
a ve
Am 17.05.19 um 06:13 schrieb Stefan Ram: However, look at this
|>>> print( str( print ))
|
|>>> print( repr( print ))
|
. While it is nice that »str( print )« gives some useful
information, I would expect »repr( print )« to give
»print« -
This is impossible. Python does not use "
Hi,
I'd like to use a program to convert between basic regular expression
(BRE) and extended regular expression (ERE). (see man grep for the
definition of BRE and ERE). Does python has a module for this purpose?
Thanks.
--
Regards,
Peng
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, Oct 29, 2018 at 05:16:11PM +, MRAB wrote:
> > Logically it should not because
> >
> > >s'::15>>$
> >
> > does not match
> >
> > ::\d*>>$
> >
> > but I am not sure how to tell it that :-)
> >
> For something like that, I'd use parsing by recursive descent.
>
> It might be
be either a length or a "from-until"
>
> - a length will be a positive integer (no bounds checking)
>
> - "from-until" is: a positive integer, a '-', and a positive integer (no sanity checking)
>
> - options needs to be able to contain nearly anythi
On Sun, Oct 28, 2018 at 11:57:48PM +0100, Brian Oney wrote:
> On Sun, 2018-10-28 at 22:04 +0100, Karsten Hilbert wrote:
> > [^<:]
>
> Would a simple regex work?
This brought about the solution.
However, not this way:
> >>> import re
> >>> t = '$$'
> >>> re.findall('[^<>:$]+', t)
> ['name', 'op
> Right, I am not trying to do that. I was, however, worried
> that I need to make the expression not "trip over" fragments
> of what might seem to constitute part of another placeholder.
>
> $<$::15>>$
>
> Pass 1 might fill in to:
>
> $
On Mon, Oct 29, 2018 at 12:10:04AM +0100, Thomas Jollans wrote:
> On 28/10/2018 22:04, Karsten Hilbert wrote:
> > - options needs to be able to contain nearly anything, except '::'
>
> Including > and $ ?
Unfortunately, it might. Even if I assume that earlier passes
are "inside", and thusly "fil
ain '$' '<' '>' ':'
> >
> > - range can be either a length or a "from-until"
> >
> > - a length will be a positive integer (no bounds checking)
> >
> > - "from-until" is: a positive integer, a '
On 28/10/2018 22:04, Karsten Hilbert wrote:
> - options needs to be able to contain nearly anything, except '::'
Including > and $ ?
--
https://mail.python.org/mailman/listinfo/python-list
On 28/10/2018 22:04, Karsten Hilbert wrote:
> - options needs to be able to contain nearly anything, except '::'
>
> Is that sufficiently defined and helpful to design the regular expression ?
so options isn't '.*', but more like '(:?[^:]+)*' (F
On 2018-10-28 21:04, Karsten Hilbert wrote:
On Sun, Oct 28, 2018 at 09:43:27PM +0100, Karsten Hilbert wrote:
Let my try to explain the expression I am actually after
(assuming .compile with re.VERBOSE):
rx_works = '
\$< # start of match is
On Sun, 2018-10-28 at 22:04 +0100, Karsten Hilbert wrote:
> [^<:]
Would a simple regex work?
I mean:
~$ python
Python 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> t = '$$'
>>> re.f
On Sun, Oct 28, 2018 at 10:04:39PM +0100, Karsten Hilbert wrote:
> - options needs to be able to contain nearly anything, except '::'
This seems to contradict the "nesting" requirement, but the
nesting restriction "earlier parsing passes go inside" makes
it possible.
Karsten
--
GPG 40BE 5B0E C
On Sun, Oct 28, 2018 at 09:43:27PM +0100, Karsten Hilbert wrote:
> Let my try to explain the expression I am actually after
> (assuming .compile with re.VERBOSE):
>
> rx_works = '
> \$< # start of match is literal '$
Now that MRAB has shown me the follies of my ways I would
like to learn how to properly write the regular expression I
need.
This part:
> rx_works = '\$<[^<:]+?::.*?::\d*?>\$|\$<[^<:]+?::.*?::\d+-\d+>\$'
> # it fails if switched around:
>
On 2018-10-28 18:51, Karsten Hilbert wrote:
Dear list members,
I cannot figure out why my regular expression does not work as I expect it to:
#---
#!/usr/bin/python
from __future__ import print_function
import re as regex
rx_works = '\$<[^<:]
Dear list members,
I cannot figure out why my regular expression does not work as I expect it to:
#---
#!/usr/bin/python
from __future__ import print_function
import re as regex
rx_works = '\$<[^<:]+?::.*?::\d*?>\$|\$<[^<:]+?::.*?::\d+-\d+>\$&
Ben Finney writes:
> Ajay Patel writes:
>
> > L = [1,2,3]
>
> That's not an expression; it is an assignment statement.
>
> The right-hand side is an expression. […] in this case, [the object] a new
> instance of 'list' […] is the result of evaluating t
Ajay Patel writes:
> L = [1,2,3]
That's not an expression; it is an assignment statement.
The right-hand side is an expression. It will (at the top level) create
a list.
To create a new instance of the 'list' type, Python will call the type's
'__new__' metho
On Fri, Sep 28, 2018 at 8:52 AM Ajay Patel wrote:
>
> Hello gauys,
>
> Which list class method will call for below codes?
>
> L = [1,2,3]
> And
> L =[]
None. Simple assignment does not call any methods. It just takes the
value on the right hand side and says, hey, "L", you now mean that
thing, k?
Hello gauys,
Which list class method will call for below codes?
L = [1,2,3]
And
L =[]
Thanks,
Ajay
--
https://mail.python.org/mailman/listinfo/python-list
Thank you all for thoughtful excellent updates!
Aldi
--
https://mail.python.org/mailman/listinfo/python-list
On Sat, 21 Jul 2018 17:37:00 +0100, MRAB wrote:
> On 2018-07-21 15:20, aldi.kr...@gmail.com wrote:
>> Hi,
>> I have a long text, which tells me which files from a database were
>> downloaded and which ones failed. The pattern is as follows (at the end of
>> this post). Wrote a tiny program, but
MRAB wrote:
> On 2018-07-21 15:20, aldi.kr...@gmail.com wrote:
>> Hi,
>> I have a long text, which tells me which files from a database were
>> downloaded and which ones failed. The pattern is as follows (at the end
>> of this post). Wrote a tiny program, but still is raw. I want to find
>> term "
On 2018-07-21 15:20, aldi.kr...@gmail.com wrote:
Hi,
I have a long text, which tells me which files from a database were downloaded and which
ones failed. The pattern is as follows (at the end of this post). Wrote a tiny program,
but still is raw. I want to find term "ERROR" and go 5 lines abov
Hi,
I have a long text, which tells me which files from a database were downloaded
and which ones failed. The pattern is as follows (at the end of this post).
Wrote a tiny program, but still is raw. I want to find term "ERROR" and go 5
lines above and get the name with suffix XPT, in this first
Kunal Jamdade writes:
> There is a filename say:- 'first-324-True-rms-kjhg-Meterc639.html' .
>
> I want to extract the last 4 characters. I tried different regex. but
> i am not getting it right.
>
> Can anyone suggest me how should i proceed.?
os.path.splitext(name) # most likely; also: os.path
fname = 'first-324-True-rms-kjhg-Meterc639.html'
# with string manipulation
stem, suffix = fname.rsplit('.', 1)
print(stem[-4:])
# oo-style with str manipulation
import pathlib
path = pathlib.Path(fname)
print(path.stem[-4:])
--
https://mail.python.org/mailman/listinfo/python-list
Kunal Jamdade wrote:
> There is a filename say:- 'first-324-True-rms-kjhg-Meterc639.html' .
>
> I want to extract the last 4 characters. I tried different regex. but i am
> not getting it right.
>
> Can anyone suggest me how should i proceed.?
You don't need
1 - 100 of 2366 matches
Mail list logo