5 (main, Oct 28 2022, 17:28:38) [GCC] on linux
x = ('%' + "2023-11" + '%')
x
'%2023-11%'
x = ('%' + x + '%',)
x
('%%2023-11%%',)
x.__class__.__name__
'tuple'
--
https://mail.python.org/mailman/listinfo/python-list
="NULL"
print(f"{id} {d['foo']} {d['bar']}")
Is there any more compact way of achieving the same thing?
Cheers,
Loris
Yes. e.g.
d.get('foo', "NULL")
Duncan
Or make d a defaultdict.
from collections import defaultdict
dic = defaultdict(lambda:'NULL')
dic['foo'] = 'astring'
dic['foo']
'astring'
dic['bar']
'NULL'
Duncan
--
https://mail.python.org/mailman/listinfo/python-list
imo$
It's treating the "2023-11" plus % at each end as separate variables to
the binding, this is crazy! I've done similar elsewhere and it works
OK, what on earth am I doing wrong here? It has to be something very
silly but I can't see it at the moment.
--
Chris Green
·
--
https://mail.python.org/mailman/listinfo/python-list
say this seems very non-pythonesque to me, the 'obvious'
default simply doesn't work right, and I really can't think of a case
where the missing comma would make any sense at all.
Maybe I've had too much to eat and drink tonight! :-)
--
Chris Green
·
--
https://mail.python.org/mailman/listinfo/python-list
Am 24.11.2023 um 22:49 schrieb Rimu Atkinson via Python-list:
I really can't think of a case
where the missing comma would make any sense at all.
That is pretty tricky, yes.
The comma means it's a tuple. Without the comma, it's just a string with
parenthesis around
On 11/24/23 14:10, Chris Green via Python-list wrote:
Chris Green wrote:
This is driving me crazy, I'm running this code:-
OK, I've found what's wrong:-
cr.execute(sql, ('%' + "2023-11" + '%'))
should be:-
cr.execute(sql, ('
On 11/25/2023 3:31 AM, Loris Bennett via Python-list wrote:
Hi,
I want to print some records from a database table where one of the
fields contains a JSON string which is read into a dict. I am doing
something like
print(f"{id} {d['foo']} {d['bar']}")
How
On 11/24/2023 4:49 PM, Rimu Atkinson via Python-list wrote:
I really can't think of a case
where the missing comma would make any sense at all.
That is pretty tricky, yes.
The comma means it's a tuple. Without the comma, it's just a string with
parenthesis around it, wh
on, more that doing the
obvious doesn't work which, in Python, it usually does in my
experience.
The error message could be a bit more helpful too, maybe one of those
"... did you mean ?" ones could point one in the right direction.
--
Chris Green
·
--
https://mail.python.org/mailman/listinfo/python-list
Question: is there any other way to use a
context manager only object within a class,
with methods accessing the object?
Or any other solution to the same situation?
Thanks a lot in advance.
P.S.: currently gmail posts are deleted, due
to excessive spam, so I'll not see any reply
coming from this family of addresses.
bye,
--
piergiorgio
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, 26 Nov 2023 at 21:08, Michael F. Stemper via Python-list
wrote:
>
> On 24/11/2023 21.45, [email protected] wrote:
> > Grizz[l]y,
> >
> > I think the point is not about a sorted list or sorting in general It is
> > about reasons why maintaining a data
Michael F. Stemper via Python-list schreef op 25/11/2023 om 15:32:
On 24/11/2023 21.45,[email protected] wrote:
> Grizz[l]y,
>
> I think the point is not about a sorted list or sorting in general It is
> about reasons why maintaining a data structure such as a list in a prog
)
perform some operations in this context (--> body of `with` statement)
tear down the context (--> method `__exit__`).
If you do not have this case (e.g. usually if you open the file
in a class's `__init__`), you do not use a context manager.
--
https://mail.python.org/mailman/listinfo/python-list
, it makes
sense to use the expanded language if it results in faster writing perhaps
of faster code with fewer mistakes.
-Original Message-----
From: Python-list On
Behalf Of Michael F. Stemper via Python-list
Sent: Saturday, November 25, 2023 9:32 AM
To: [email protected]
Subject: Re: R
al Message-----
From: Python-list On
Behalf Of Chris Angelico via Python-list
Sent: Sunday, November 26, 2023 6:49 AM
To: [email protected]
Subject: Re: RE: Newline (NuBe Question)
On Sun, 26 Nov 2023 at 21:08, Michael F. Stemper via Python-list
wrote:
>
> On 24/11/2023 21.45, avi.e.gr...
On 11/27/2023 12:48 AM, Chris Angelico via Python-list wrote:
On Sun, 26 Nov 2023 at 21:08, Michael F. Stemper via Python-list
wrote:
On 24/11/2023 21.45, [email protected] wrote:
Grizz[l]y,
I think the point is not about a sorted list or sorting in general It is
about reasons why
s variable name would make complete sense.
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
On 11/27/2023 1:08 AM, Roel Schroeven via Python-list wrote:
I prefer namedtuples or dataclasses over tuples. They allow you to refer
to their fields by name instead of index: student.gpa is much clearer
than student[2], and makes it less likely to accidentally refer to the
wrong field.
+1
On 11/27/2023 10:04 AM, Peter J. Holzer via Python-list wrote:
On 2023-11-25 08:32:24 -0600, Michael F. Stemper via Python-list wrote:
On 24/11/2023 21.45, [email protected] wrote:
Of course, for serious work, some might suggest avoiding constructs like a
list of lists and switch to using
came from the Latin word for news. Be that as it
may, and I have no interest in this topic, in the future I may use the ever
popular names of Primus, Secundus and Tertius and get blamed for using
Latin.
-Original Message-
From: Python-list On
Behalf Of DL Neil via Python-list
Sent: Sunda
On Mon, 27 Nov 2023 at 13:52, AVI GROSS via Python-list
wrote:
> Be that as it
> may, and I have no interest in this topic, in the future I may use the ever
> popular names of Primus, Secundus and Tertius and get blamed for using
> Latin.
>
Imperious Prima flashes forth her edi
components of an object but verify the validity of the contents or do
logging or any number of other things. Using a list or tuple does nothing
else.
So if you need nothing else, they are often suitable and sometimes even
preferable.
-Original Message-----
From: Python-list On
Behalf Of D
On 2023-11-26, Dieter Maurer via Python-list wrote:
> If you do not have this case (e.g. usually if you open the file
> in a class's `__init__`), you do not use a context manager.
He knows that. The OP wrote that he wants to use that can
_only_ be used by a context manager, but he
On 2023-11-27, Grant Edwards via Python-list wrote:
> On 2023-11-26, Dieter Maurer via Python-list wrote:
>
>> If you do not have this case (e.g. usually if you open the file
>> in a class's `__init__`), you do not use a context manager.
>
> He knows that. The OP wro
On 27/11/23 9:03 am, Stefan Ram wrote:
Above, "have" is followed by another verb in "have been",
so it should be eligible for a contraction there!
Yes, "been" is the past participle of 'to be", so "I've been" is
fine.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
er:
def __init__(self):
self.cm = device_open()
self.device = self.cm.__enter__()
# Other methods here for doing things with
# self.device
def close(self):
self.cm.__exit__(None, None, None)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
s) does
say "hashable"!
So if you need nothing else, they are often suitable and sometimes even
preferable.
Yes, (make a conscious choice to) use the best tool for the job - but
don't let bias cloud your judgement, don't take the ideas of the MD's
nephew as 'Gospel', and DO design the way forward...
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list
ferent modules and do not call `parse_args` themselves.
Any ideas appreciated,
Regards,
DG
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, 27 Nov 2023 at 22:31, Dom Grigonis via Python-list
wrote:
>
> Hi all,
>
> I have a situation, maybe someone can give some insight.
>
> Say I want to have input which is comma separated array (e.g.
> paths='path1,path2,path3') and convert it to the desired o
ble.
Have to head out as this is already long enough.
-Original Message-
From: 'DL Neil'
Sent: Monday, November 27, 2023 2:49 AM
To: [email protected]; [email protected]
Subject: Re: Newline (NuBe Question)
Avi,
On 11/27/2023 4:15 PM, [email protected] wrote:
&g
to have a class
where the device is opened in the __init__()
and used in some methods.
Any ideas?
bye,
--
piergiorgio
--
https://mail.python.org/mailman/listinfo/python-list
except Exception as e:
print(f"Error: {e}")
finally:
# Close the SSH connection
ssh.close()
if __name__ == "__main__":
run_scripts()
i used this but i am unable to know what ip address to use?
--
https://mail.python.org/mailman/listinfo/python-list
).
Note, YOUR program must now make sure that the __exit__ function is called, and
handle any exceptions that got thrown, and that ob and var are put somewhere
you can access them at that later time.
> On Nov 27, 2023, at 12:24 PM, Piergiorgio Sartor via Python-list
> wrote:
>
> O
).
Note, YOUR program must now make sure that the __exit__ function is called, and
handle any exceptions that got thrown, and that ob and var are put somewhere
you can access them at that later time.
> On Nov 27, 2023, at 12:24 PM, Piergiorgio Sartor via Python-list
> wrote:
>
> O
il.python.org/mailman/listinfo/python-list
On 11/27/23 04:29, Dom Grigonis via Python-list wrote:
Hi all,
I have a situation, maybe someone can give some insight.
Say I want to have input which is comma separated array (e.g.
paths='path1,path2,path3') and convert it to the desired output - list:
import argpa
ats Wichmann via Python-list
> wrote:
>
> On 11/27/23 04:29, Dom Grigonis via Python-list wrote:
>> Hi all,
>> I have a situation, maybe someone can give some insight.
>> Say I want to have input which is comma separated array (e.g.
>> paths='path1,path2,pat
the
base Action class's initializer with the rest of the args
super().__init__(option_strings=option_strings, *args, **kwargs)
Hopefully someone else has done this kind of thing because now I'm just
guessing!
--
https://mail.python.org/mailman/listinfo/python-list
gs, **kwargs)
>
> Hopefully someone else has done this kind of thing because now I'm just
> guessing!
>
>
--
https://mail.python.org/mailman/listinfo/python-list
ultdict.
>
> from collections import defaultdict
>
> dic = defaultdict(lambda:'NULL')
> dic['foo'] = 'astring'
> dic['foo']
> 'astring'
> dic['bar']
> 'NULL'
>
> Duncan
>
I have gone with the 'd.get' solution, as I am just need to print the
dict to the terminal. The dict is actually from a list of dicts which
is generated by querying a database, so I don't think the defaultdict
approach would be so appropriate, but it's good to know about it.
Thanks,
Loris
--
This signature is currently under constuction.
--
https://mail.python.org/mailman/listinfo/python-list
DL Neil writes:
> On 11/25/2023 3:31 AM, Loris Bennett via Python-list wrote:
>> Hi,
>> I want to print some records from a database table where one of the
>> fields contains a JSON string which is read into a dict. I am doing
>> something like
>>
les-across-modules-from-user-defined-config-file
I think I could probably get that to work, but are there any better
alternatives?
Cheers,
Loris
--
This signature is currently under constuction.
--
https://mail.python.org/mailman/listinfo/python-list
return s, n
--8<---cut here---end--->8---
--
https://mail.python.org/mailman/listinfo/python-list
def powers_of_2_in(n):
s = 0
while n % 2 == 0:
s += 1
n = n // 2
return s, n
> On 30 Nov 2023, at 02:44, Julieta Shem via Python-list
> wrote:
>
> How would you write this procedure?
>
> --8<---cut here---start---
On 2023-11-29 at 21:44:01 -0300,
Julieta Shem via Python-list wrote:
> How would you write this procedure?
>
> --8<---cut here---start->8---
> def powers_of_2_in(n):
> s = 0
> while "I still find factors of 2 in n...":
&g
Julieta Shem writes:
How would you write this procedure?
def powers_of_2_in(n):
...
def powers_of_2_in(n):
return (n ^ (n - 1)).bit_count() - 1
--
https://mail.python.org/mailman/listinfo/python-list
nted to
see if I could use the terminfo stuff directly to retain
use of regular input() and print() functions.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
otos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
g on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
You can let itertools.groupy find the groups.
max((len(tuple(group)), key) for key, group in itertools.groupby(s))
# (4, 'c')
--
https://mail.python.org/mailman/listinfo/python-list
importing
that and waiting as they all load.
-Original Message-
From: Python-list On
Behalf Of Ethan Furman
Sent: Thursday, January 14, 2021 2:36 PM
To: [email protected]
Subject: Re: why sqrt is not a built-in function?
On 1/14/21 11:06 AM, Eli the Bearded wrote:
> "There shoul
n than
shouting at newsgroups. Perhaps juggling balls?
Best wishes
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list
my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
hout requiring the user to type input between prints?
Or what parameter should I be setting where?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
On 14/01/2021 16:12, Alan Gauld via Python-list wrote:
> #
> import curses as cur
> cur.setupterm()
>
> bold = cur.tigetstr('bold')
> cls = cur.tigetstr('clear')
>
> cur.putp(cls)
> name = input("Hello, what's your name?
c.
Do you know where that is documented? I'd be interested in
reading more.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
On 15/01/2021 21:41, Dennis Lee Bieber wrote:
> On Fri, 15 Jan 2021 13:19:26 +, Alan Gauld via Python-list
> declaimed the following:
>
>> So the native C functions work as expected.
>> Why does the Python wrapper not?
>
> Are you running Python from a p
e the terminfo functions come in and, as you
saw from the C code, are fairly trivial to use in C.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
On 18/01/2021 22:14, Random832 wrote:
> On Fri, Jan 15, 2021, at 13:36, Alan Gauld via Python-list wrote:
>> That could make a big difference, the putp() function specifically
>> states that it writes to stdout.
>
> I think there is a reasonable argument that this is a defici
ly fond of Winduhs.
--
Mladen Gogala
Database Consultant
http://mgogala.byethost5.com
--
https://mail.python.org/mailman/listinfo/python-list
.
Running out of memory is an OS error and should be checked on the OS
level.
--
Mladen Gogala
Database Consultant
http://mgogala.byethost5.com
--
https://mail.python.org/mailman/listinfo/python-list
Cygwin version is typically much easier and
more natural.
--
Mladen Gogala
Database Consultant
https://dbwhisperer.wordpress.com
--
https://mail.python.org/mailman/listinfo/python-list
g/mailman/listinfo/python-list
something to
match another by repeatedly copying the same sequence as many times as
needed. If a generator finishes, you want it to restart with the same
sequence until you stop asking.
This is just a thought, not a request for such a feature.
-Original Message-
From: Python-list On
Behalf
at is it scanning?
> >
> > > My favorite (I'm using now) is VS Code with Python extension,
> > > it's very
> > > light. Recently also started background scanning, but that's
> > > generally
> > done
> > > in 30 seconds.
> >
> > Same question, what is it scanning?
> >
> > --
> > Grant
> >
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
--
https://mail.python.org/mailman/listinfo/python-list
t:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
tp://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
however, remains your brain.
Amen to that, regardless of any software tool used.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
cises. However anytime we are
given an assignment in Python and I download, it doesn't open in Python.
How can I lunch Python on my PC and secondly how can I open Python files on my
PC.
Thank you.
David
--
https://mail.python.org/mailman/listinfo/python-list
.
--
https://mail.python.org/mailman/listinfo/python-list
On 27/01/2021 18:32, flaskee via Python-list wrote:
>
> While print() is groovy and all,
> if anyone runs across a non-pdb python debugger (standalone or IDE-based)
> please let me know.
>
There are many. But why must it be non-pdb? That seems rather arbitrary.
Or do you really
before too. But this is the
message I get.
And yes, i have checked, the input tag is the only tag with that class name, so
there isn´t another tag which selenium could´ve interacted with.
regards, me.
--
https://mail.python.org/mailman/listinfo/python-list
?
Can someone help me please? Thank you
--
https://mail.python.org/mailman/listinfo/python-list
uldphotos
--
https://mail.python.org/mailman/listinfo/python-list
. It worked fine. Then, I
typed it into my shell and got an error. Why is it working in the command
prompt but not in the actual shell?
--
https://mail.python.org/mailman/listinfo/python-list
.
You can decode it as utf-8 and ignore the BOM character, or as someone
else has rightly said, Python can decode it as utf-8-sig, which does
that automatically for you.
--
https://mail.python.org/mailman/listinfo/python-list
10. helmik. 2021 klo 5.10 Martin Lopez ([email protected])
kirjoitti:
> Where do I inquire about installation support?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list
ke 10. helmik. 2021 klo 5.07 Terry Reedy ([email protected]) kirjoitti:
> On 2/9/2021 9:55 AM, Philipp Daher via Python-list wrote:
> > Hello,
> >
> > I’ve just typed „pip install selenium“ into my command prompt on windows
> 10. Although my computer told me that the
yet follows the expected rules as if it was being interpreted.
But a more pleasant attitude may make the same points, not that I am sure what
those are and what is being asked. It sounds more like being told.
-Original Message-
From: Python-list On
Behalf Of Mr Flibble
Sent: Thursday
https://mail.python.org/mailman/listinfo/python-list
.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
lickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
vice would be to ditch Idle
and use VSCode. It's fabulous.
--
Mladen Gogala
Database Consultant
https://dbwhisperer.wordpress.com
--
https://mail.python.org/mailman/listinfo/python-list
thing will cause delays in others and so on.
Obviously, beyond the scope but my point is they do not necessarily operate
in one pass over the list and are quite a bit more complex.
-Original Message-
From: Python-list On
Behalf Of Dan Stromberg
Sent: Saturday, February 13, 2021 2:13
rogram web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
scussion.
-Original Message-
From: Python-list On
Behalf Of Mr Flibble
Sent: Saturday, February 13, 2021 7:07 PM
To: [email protected]
Subject: Re: New Python implementation
On 13/02/2021 18:11, Alan Gauld wrote:
> On 13/02/2021 16:09, Mr Flibble wrote:
>> On 13/02/2021 00:0
,
'DB_TYPE_ROWID', 'DB_T
...
>>> conn=cx_Oracle.Connection("scott/tiger@ora19c")
>>>
Please use PSYCOPG2 instead of cx_Oracle. After you do it
from python3 interpreter do it from Idle:
On Sat, 13 Feb 2021 22:08:11 +
tional
compiled language like C.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
.
--
https://mail.python.org/mailman/listinfo/python-list
On 15/02/2021 02:26, Avi Gross via Python-list wrote:
> I think we have discussed this a few times.
Indeed, many times!
And there is a natural tendency for a group focused on a
programming language to fixate on language improvements. But
it's worth while to back up and look at re
perience groups.
-Original Message-----
From: Python-list On
Behalf Of Grant Edwards
Sent: Monday, February 15, 2021 4:00 PM
To: [email protected]
Subject: Re: New Python implementation
On 2021-02-15, Roel Schroeven wrote:
> Is it your intention to not only compile procedural and
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
.. a little.
I am not sure I agree that a language like Scheme or Logo or Brainfuck, with
their small number of building blocks, would be harder to learn.
To me, Python is the lego boxes from the early 2000s, where there were so many
specialized pieces that you felt that the original design might as well be the
only design.
Regards,
Tarjei
--
https://mail.python.org/mailman/listinfo/python-list
my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
--
https://mail.python.org/mailman/listinfo/python-list
l Message-
From: Python-list On
Behalf Of Christian Gollwitzer
Sent: Tuesday, February 16, 2021 2:25 AM
To: [email protected]
Subject: Re: New Python implementation
Am 15.02.21 um 21:37 schrieb Roel Schroeven:
>
> So your claim is that your compiler is able to, or will be able to,
&g
then be the
optimal choice.
- Tarjei Bærland
PS: I can't remember in what context I visited it, but thanks for an
inspiring site.
--
https://mail.python.org/mailman/listinfo/python-list
sure what quite what my feelings are regarding this,
perhaps Python is the best of all possible options.
- Tarjei
Note, I am emphatically saying this in the context of a maths class.
--
https://mail.python.org/mailman/listinfo/python-list
t were handed in and
returned a day later, or having to wait a long time for a compile to complete,
with errors.
--
https://mail.python.org/mailman/listinfo/python-list
then.io/2014/01/01/how-tcp-backlog-works-in-linux.html
<http://veithen.io/2014/01/01/how-tcp-backlog-works-in-linux.html>
Humbly,
Karen
--
https://mail.python.org/mailman/listinfo/python-list
2501 - 2600 of 5869 matches
Mail list logo