On 2023-01-27, Mark Bourne wrote:
> So Python is even flexible enough to be made to deal with insane
> situations where False is 2!
IIRC, in VMS DCL even numbers were false and odd numbers were true.
In Unix shells, a return code of 0 is true and non-0 is false.
Though that's not really the s
May I point out that some dynamic situations can in a sense be normalized?
The example below posits a dynamically allocated dictionary during run time.
But why can't you have a placeholder variable name in place and make your
placeholder a link to the dictionary (or other item) before invoking the
On 1/27/2023 5:10 PM, Christian Gollwitzer wrote:
Am 27.01.23 um 21:43 schrieb Johannes Bauer:
I don't understand why you fully ignore literally the FIRST example I
gave in my original post and angrily claim that you solution works
when it does not:
x = { "y": "z" }
s = "-> {x['y']}"
print(s.
On 1/27/2023 3:33 PM, Johannes Bauer wrote:
Am 25.01.23 um 20:38 schrieb Thomas Passin:
x = { "y": "z" }
s = "-> {target}"
print(s.format(target = x['y']))
Stack overflow to the rescue:
No.
Search phrase: "python evaluate string as fstring"
https://stackoverflow.com/questions/47339121/h
On 28/01/2023 05.37, mutt...@dastardlyhq.com wrote:
This is probably a dumb newbie question but I've just started to learn
python3 and eval() isn't behaving as I'd expect in that it works for
some things and not others. eg:
eval("1+1")
2
eval("print(123)")
123
eval("for i in range(1,10): i"
On Sat, 28 Jan 2023 at 11:45, Greg Ewing wrote:
>
> On 26/01/23 6:10 am, Chris Angelico wrote:
> > And that's a consequence of a system wherein there is only one concept
> > of "success", but many concepts of "failure". Whoever devised that
> > system was clearly a pessimist :)
>
> Murphy's Law fo
On Sat, 28 Jan 2023 at 11:45, wrote:
>
> Hi
>
> This is probably a dumb newbie question but I've just started to learn
> python3 and eval() isn't behaving as I'd expect in that it works for
> some things and not others. eg:
>
> >>> eval("1+1")
> 2
> >>> eval("print(123)")
> 123
> >>> eval("for i i
avi.e.gr...@gmail.com wrote:
...
Interestingly, I wonder if anyone has
designed an alternate object type that can be used mostly in place of
Booleans but which imposes changes and restrictions so trying to add a
Boolean to an integer, or vice versa, results in an error. Python is
flexible enough
Am 27.01.23 um 21:43 schrieb Johannes Bauer:
I don't understand why you fully ignore literally the FIRST example I
gave in my original post and angrily claim that you solution works when
it does not:
x = { "y": "z" }
s = "-> {x['y']}"
print(s.format(x = x))
Traceback (most recent call last):
mutt...@dastardlyhq.com writes:
> Hi
It looks like you posted this question via Usenet. comp.lang.python is
essentially dead as a Usenet group. It exists, and gets NNTP versions
of mail sent to the mailing list, but nothing posted to the group via
NNTP get send on the mailing list. I prefer Us
Am 27.01.23 um 20:18 schrieb Chris Angelico:
All you tell us is
what you're attempting to do, which there is *no good way to achieve*.
Fair enough, that is the answer. It's not possible.
Perhaps someone will be inspired to write a function to do it. 😎
See, we don't know what "it" is, so it
Am 23.01.23 um 17:43 schrieb Stefan Ram:
Johannes Bauer writes:
x = { "y": "z" }
s = "-> {x['y']}"
print(s.format(x = x))
x = { "y": "z" }
def s( x ): return '-> ' + x[ 'y' ]
print( s( x = x ))
Except this is not at all what I asked for. The string "s" in my example
is just that, an exampl
Am 25.01.23 um 20:38 schrieb Thomas Passin:
x = { "y": "z" }
s = "-> {target}"
print(s.format(target = x['y']))
Stack overflow to the rescue:
No.
Search phrase: "python evaluate string as fstring"
https://stackoverflow.com/questions/47339121/how-do-i-convert-a-string-into-an-f-string
de
Am 23.01.23 um 19:02 schrieb Chris Angelico:
This is supposedly for security reasons. However, when trying to emulate
this behavior that I wanted (and know the security implications of), my
solutions will tend to be less secure. Here is what I have been thinking
about:
If you really want the f
Hi
This is probably a dumb newbie question but I've just started to learn
python3 and eval() isn't behaving as I'd expect in that it works for
some things and not others. eg:
>>> eval("1+1")
2
>>> eval("print(123)")
123
>>> eval("for i in range(1,10): i")
Traceback (most recent call last):
File
On 26/01/23 6:10 am, Chris Angelico wrote:
And that's a consequence of a system wherein there is only one concept
of "success", but many concepts of "failure". Whoever devised that
system was clearly a pessimist :)
Murphy's Law for Unix: If something can go wrong, it will go
wrong 255 times out
On 1/25/23 19:50, Jach Feng wrote:
> To me, argparse has been just a tool which I can use in a CLI app.
argparse is just a tool for dealing with command-line *flags*, which are
common in command-line tools. argparse interprets the command line as a
bunch of flags because that's what it's designe
On 1/27/2023 5:54 PM, Rob Cliffe via Python-list wrote:
Whoa! Whoa! Whoa!
I appreciate the points you are making, Chris, but I am a bit taken
aback by such forceful language.
I generally agree with asking for what the intent is. In this case it
seems pretty clear that the OP wants to use the
On Sat, 28 Jan 2023 at 10:08, Rob Cliffe via Python-list
wrote:
>
> Whoa! Whoa! Whoa!
> I appreciate the points you are making, Chris, but I am a bit taken
> aback by such forceful language.
The exact same points have already been made, but not listened to.
Sometimes, forceful language is require
On 1/27/2023 4:53 PM, Ivan "Rambius" Ivanov wrote:
Hello Cameron,
On Fri, Jan 27, 2023 at 4:45 PM Cameron Simpson wrote:
On 27Jan2023 15:31, Ivan "Rambius" Ivanov wrote:
I am developing a script that accepts a time zone as an option. The
time zone can be any from pytz.all_timezones. I have
Whoa! Whoa! Whoa!
I appreciate the points you are making, Chris, but I am a bit taken
aback by such forceful language.
On 27/01/2023 19:18, Chris Angelico wrote:
On Sat, 28 Jan 2023 at 05:31, Rob Cliffe via Python-list
wrote:
On 23/01/2023 18:02, Chris Angelico wrote:
Maybe, rather than ask
Hello Cameron,
On Fri, Jan 27, 2023 at 4:45 PM Cameron Simpson wrote:
>
> On 27Jan2023 15:31, Ivan "Rambius" Ivanov
> wrote:
> >I am developing a script that accepts a time zone as an option. The
> >time zone can be any from pytz.all_timezones. I have
> >
> >def main():
> >parser = argparse
On 27Jan2023 15:31, Ivan "Rambius" Ivanov wrote:
I am developing a script that accepts a time zone as an option. The
time zone can be any from pytz.all_timezones. I have
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
[...]
Hello,
On Fri, Jan 27, 2023 at 4:22 PM Weatherby,Gerard wrote:
>
> Why not something like:
>
>
> parser.add_argument("-z", "--zone")
>
>args = parser.parse_args()
>if args.zone and args.zone not in ptyz.all_timezones:
>
> print(“Invalid timezone”,file=sys.s
Why not something like:
parser.add_argument("-z", "--zone")
args = parser.parse_args()
if args.zone and args.zone not in ptyz.all_timezones:
print(“Invalid timezone”,file=sys.stderr)
…
From: Python-list on
behalf of Ivan "Rambius" Ivanov
Hello,
I am developing a script that accepts a time zone as an option. The
time zone can be any from pytz.all_timezones. I have
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
args = parser.parse_args()
print(args)
On Sat, 28 Jan 2023 at 05:31, Rob Cliffe via Python-list
wrote:
> On 23/01/2023 18:02, Chris Angelico wrote:
> > Maybe, rather than asking for a way to treat a string as code, ask for
> > what you ACTUALLY need, and we can help?
> >
> > ChrisA
> Fair enough, Chris, but still ISTM that it is reason
On 23/01/2023 18:02, Chris Angelico wrote:
On Tue, 24 Jan 2023 at 04:56, Johannes Bauer wrote:
Hi there,
is there an easy way to evaluate a string stored in a variable as if it
were an f-string at runtime?
...
This is supposedly for security reasons. However, when trying to emulate
this be
On 24/01/2023 04:22, Dino wrote:
$ python
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> b = True
>>> isinstance(b,bool)
True
>>> isinstance(b,int)
True
>>>
That immediately tells you that either
On 25/01/2023 19:38, Thomas Passin wrote:
Stack overflow to the rescue:
Search phrase: "python evaluate string as fstring"
https://stackoverflow.com/questions/47339121/how-do-i-convert-a-string-into-an-f-string
def effify(non_f_str: str):
return eval(f'f"""{non_f_str}"""')
print(ef
On 1/27/23, Bela Gesztesi wrote:
>
> I'm not that familiar with the steps to be taken.
>
> How do I find the app version of Python for my desktop?
> or
> I don't know how to disable the "python.exe" and "python3.exe" app aliases
To install the app version, run "python3" from the command line. Thi
On 2023-01-27 2:14 PM, Frank Millman wrote:
I have changed it to async, which I call with 'asyncio.run'. It now
looks like this -
server = await asyncio.start_server(handle_client, host, port)
await setup_companies()
session_check = asyncio.create_task(
check_sessions(
On 2023-01-26 7:16 PM, Dieter Maurer wrote:
Frank Millman wrote at 2023-1-26 12:12 +0200:
I have written a simple HTTP server using asyncio. It works, but I don't
always understand how it works, so I was pleased that Python 3.11
introduced some new high-level concepts that hide the gory details.
33 matches
Mail list logo