From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 8JEdOPnht2LTBQEAbAwnHQ (envelope-from ) for ; Sun, 26 Jun 2022 06:35:05 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cGYFOPnht2Li6gAAauVa8A (envelope-from ) for ; Sun, 26 Jun 2022 06:35:05 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6AB283C562 for ; Sun, 26 Jun 2022 06:35:05 +0200 (CEST) Received: from localhost ([::1]:36916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5JzE-0004pv-IU for larch@yhetil.org; Sun, 26 Jun 2022 00:35:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5Jwk-0002yh-61 for emacs-orgmode@gnu.org; Sun, 26 Jun 2022 00:32:30 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:36755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5Jwi-0002WT-K3 for emacs-orgmode@gnu.org; Sun, 26 Jun 2022 00:32:29 -0400 Received: by mail-pf1-x436.google.com with SMTP id x138so3361761pfc.3 for ; Sat, 25 Jun 2022 21:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=E94kGLOuqHnQPclMJKku1bTNqG49HooO0a5OmSY9dXE=; b=EvjfPqjjDiAx9TUvBkZ96PM6/+A3LExBhpvYreYienFzLNIA4YpBEEt4ouil8vRuJn R48KRRuEcE9RA9eua0Hesw0ci47bWK04seqcT61qKyPRow1Qw3AeYCs2Z8uS6r0mQApx inW5Ie3NYzGMSn70VDKorg2dtwFmffVtMLfTTYVCe2GhlYVz1GNo0ZaJDJ2JWCBjJON4 I7uFOt8wYm1Dp2k2JgnJFNHKAIWXymzp+gv2VA9JRB8cDJO2TZYEpS4AHavqC/qifum/ cJzuCPepfStBs7XBIQF5WYo2kaqOnIr8WU4dKif0wbKalvZYNNjg4PhDrTg5piGX79Gl hGuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=E94kGLOuqHnQPclMJKku1bTNqG49HooO0a5OmSY9dXE=; b=OoUsBaeNh0O4Rht5DWGBTd0G93DcWe8S6KBC7yz6dNc7wMCDPZ1vbeq4rECUWRLeIx mO3G6/71mg5x1zFEYz765SX1XqV84QHjEnQa3nCsYfEQjQ5tFbyqHyYzqJonFEa/OJ55 DH7pfVXKxUkHSw/osJi4DS+/5sd+FmAhJeTRc8mSVKb4Mk26RUn5K55fhRIJoHVlsNPu PJtttsaZJ3bOXNxiAgFmbNGSWbyT/P0mp1mtcoyx/w3tU4AtK5ojIi5L60CWyphsCBWV 6PpNEwpnYPMRSqHtw5l3utZi9o7eE1U6/JO5jtJwjZTBr1ArSf6r+H2OVSurzFj9HmFo ugvg== X-Gm-Message-State: AJIora/UKfH8GlM/ECSs9pcQKsaYzJZBgmTfXJosW3H/dQjcooXZMQHX UQX9GKNiME4ZuDZpNxCga0s= X-Google-Smtp-Source: AGRyM1vwpQvqq6enqtgiJTKb/Np/IXCjqFODOp6L9s2DB43MJNdnYod+y34BLGVPkcW8UTMkPnDxQA== X-Received: by 2002:a63:440d:0:b0:401:9e3e:7d2d with SMTP id r13-20020a63440d000000b004019e3e7d2dmr6347146pga.446.1656217946893; Sat, 25 Jun 2022 21:32:26 -0700 (PDT) Received: from localhost ([104.223.86.8]) by smtp.gmail.com with ESMTPSA id p10-20020a170902bd0a00b00161ac982b9esm4468392pls.185.2022.06.25.21.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jun 2022 21:32:26 -0700 (PDT) From: Ihor Radchenko To: Ivar Fredholm Cc: Tim Cross , emacs-orgmode@gnu.org Subject: Re: Using exec functions to simplify session code In-Reply-To: <4GgreROUkMant3E8LK7kKgeciZbHZDaEywwaKsZk34klCmvBr9paFe9ay4YziC80ubNd7mqwbbETwbjv6Q9EIs_3M1mM_Mv3H9cHOOyVr1I=@protonmail.com> References: <1vlD0t1ffNxmDCckK6W2md-OzxdCEmzV4IIF9Yop-sNhQgF1lg5bgmaTAO4YcS66JoHyTEBUzJiaY4n8g5l_lxWFiaQ4u_a-CKlvMAoOKCM=@protonmail.com> <87tu8a7txl.fsf@gmail.com> <4GgreROUkMant3E8LK7kKgeciZbHZDaEywwaKsZk34klCmvBr9paFe9ay4YziC80ubNd7mqwbbETwbjv6Q9EIs_3M1mM_Mv3H9cHOOyVr1I=@protonmail.com> Date: Sun, 26 Jun 2022 12:33:39 +0800 Message-ID: <875yko3uxo.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=yantar92@gmail.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1656218105; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=E94kGLOuqHnQPclMJKku1bTNqG49HooO0a5OmSY9dXE=; b=bLqJb2/qkl+cqqdKDHo0wq+l5xOUABajdAqVhrJMwE9RO3HsXaTqJBK07uM2yW5vi5IceJ SQ+T9+IGz1QQfdV0Jnxya7OzsT6olYbv/v4Qqi/bF9gOQfH/2uP4G97MPNg+UA45pB79/A dDKKUECexv/1oQZ3ijQXgF0lREkQKFEZkAMWCiSukORpu7flSdslEO708zvZEhh+ptO3wi 7vKd5cuD8qd8p80XuGM4qsqZ39zgmnby2Wj4eiAZb+uFyq62GcLE5yobdgps8QYBZfTVZZ DUSKtTHo456iDFsKcJZ4/OBuwfCrxyRFN4htLGk2nXXGLY1oCmDJw8MYVE5I4w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1656218105; a=rsa-sha256; cv=none; b=WO0gOxSlyQ8uVX0KTKYFzDTMGgVzbkZlMEpTegTJ03dnYCWAnJUKoCS2zHkbK6gii8NFhI Vd8267qrGBqzGTZN61qcjM97uaEVbLpRKeLM7Kbfjsu1cKxCbAghz/adZgmLFsnUVElLsv sHvV6lbGaZHYY9EHa/yALU8wiuK61B51QiosXTT9N3CnIdmNkYl3sa+qRrQ5PdXgOIad6/ gyH1W5JyQWZxk2cPHj/LXqClBCePrqV6KNzFWTFBLGdewfc0oVELABQBpNb/AhxO2Jsoc0 mcoQ1rbo+P88+8KaHSTHzonFSi/m+zl1bsPpU92pj+wulaWPeH7j4m2pG5DAWQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=EvjfPqjj; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -7.26 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=EvjfPqjj; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 6AB283C562 X-Spam-Score: -7.26 X-Migadu-Scanner: scn0.migadu.com X-TUID: twC5uHmDeUO1 Ivar Fredholm writes: > At this point, Babel calls org-babel-execute:python, which decides, based on the 'session' header, whether or not to call python3 tmp_code.py or to feed each line in tmp_code.py into the session interpreter. What I am wondering is if we could replace the code for the latter option (in ob-comint.el) by just sending the interpreter the command 'exec(open("tmp_code.py").read())'. ob-comint.el knows nothing about the interpreter. So, what you are describing should be implemented by the corresponding ob-*.el backends. They know all the details about the interpreter being used. Also, some interpreters behave differently if they run commands line-by-line vs. inside script file. In particular, the script commands may be echoed before their output in some cases (e.g. bash scripts and .bat files, AFAIR). Best, Ihor