This gives the expected results:
with open(data_file, newline="") as reader:
csvreader = csv.DictReader(reader)
for row in csvreader:
#print(row)
match row[RULE_TYPE]:
case "RANGE":
print("range")
case "MANDATORY":
print("mandatory")
case _:
print("nothing to do")
This:
RANGE = "RANGE"
MANDATORY
>
> The bytecode compiler doesn't know that you intend RANGE
> to be a constant -- it thinks it's a variable to bind a
> value to.
>
> To make this work you need to find a way to refer to the
> value that isn't just a bare name. One way would be to
> define your constants using an enum:
>
> class O
I'm writing a database connectivity module to be used by other modules and
leveraging the jaydebeapi module.
>From what I can tell jaydebeapi contains no built-in timeout capability, so
then I turned to https://pypi.org/project/timeout-decorator/.
My goal is to have a default timeout of, say, 10 se
import inspect
def my_example(arg1, arg2):
print(inspect.stack()[0][3])
my_frame = inspect.currentframe()
args,_,_,values = inspect.getargvalues(my_frame)
args_rendered = [f"{x}: {values[x]}" for x in args]
print(args_rendered)
my_example("a", 1)
The above "works" in the sense it prints what I
> My question is: let's say I wanted to add a type hint for my_frame.
> >
> > my_frame: some_class_name = inspect.currentframe()
> >
> > What would I put for some_class_name?
> > "frame" (without quotations) is not recognized,
> > Nor is inspect.frame.
>
> We know Python code is executed in an exec
>
> Jason Friedman wrote at 2023-8-3 21:34 -0600:
> > ...
> >my_frame = inspect.currentframe()
> > ...
> >My question is: let's say I wanted to add a type hint for my_frame.
>
> `my_frame` will be an instance of `Types.FrameType`.
>
Confirmed. Thank you!
--
https://mail.python.org/mailman/listinf
I want to be able to write code like this:
with Database() as mydb:
conn = mydb.get_connection()
cursor = conn.get_cursor()
cursor.execute("update table1 set x = 1 where y = 2")
cursor.close()
cursor = conn.get_cursor()
cursor.execute("update table2 set a = 1 where b = 2")
cursor.close()
I'd like
I have two questions, please (this is after reading
https://docs.readthedocs.io/en/stable/guides/cross-referencing-with-sphinx.html#automatically-label-sections
).
This is my project structure:
my_project
api
stuff1.py
stuff2.py
lib
stuff3.py
stuff4.py
main_application.py
>
> def construct_response(exit_code: int, message: str) -> Response:
> """
> Construct a Flask-suitable response
>
> :param exit_code: 0 or something else
> :param message: something useful
> :return: a Flask-suitable response
> """
>
>
> @app.route(f"/{version}/", methods=
And I can answer my own Question 2:
:func:`my_project.main_application.construct_response`
On Mon, Aug 28, 2023 at 1:39 PM Jason Friedman wrote:
> def construct_response(exit_code: int, message: str) -> Response:
>> """
>> Construct a Flask-suitable response
>>
>> :param exit_code: 0
def construct_response(exit_code: int, message: str) -> Response:
>> """
>> Construct a Flask-suitable response
>>
>> :param exit_code: 0 or something else
>> :param message: something useful
>> :return: a Flask-suitable response
>> """
>>
>>
>> @app.route(f"/{version}/", me
On Sun, Nov 5, 2023 at 1:23 PM office officce via Python-list <
python-list@python.org> wrote:
> which python version is better to be used and how to make sure it works on
> my window 10 because i downloaded it and it never worked so I uninstall to
> do that again please can you give me the steps
On Wed, Aug 21, 2024 at 4:04 PM Daniel via Python-list <
python-list@python.org> wrote:
>
> An example of use, here's a weather service tied to a finger. Put your
> city name as the user. This isn't mine, but it is inspiring. Example:
>
> finger mi...@graph.no
>
> For all options, go to the help f
>
> (a) An error-prone "feature" is returning -1 if a substring is not found
> by "find", since -1 currently refers to the last item. An example:
>
> >>> s = 'qwertyuiop'
> >>> s[s.find('r')]
> 'r'
> >>> s[s.find('p')]
> 'p'
> >>> s[s.find('a')]
> 'p'
> >>>
>
> If "find" is unsuccessful, an er
🙏
On Tue, Dec 3, 2024 at 5:06 PM Thomas Wouters via Python-list <
python-list@python.org> wrote:
> Another big release day! Python 3.13.1 and 3.12.8 were regularly scheduled
> releases, but they do contain a few security fixes. That makes it a nice
> time to release the security-fix-only versions
>
> Trying to compile Python-3.12.9 on Ubuntu-24.04
>
> The compilation is complete without errors but I have this message:
>
>
> The necessary bits to build these optional modules were not foun
16 matches
Mail list logo