Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-08 Thread Martin Di Paola
Then, you must put the initialization (dynamically loading the modules) into the function executed in the foreign process. You could wrap the payload function into a class instances to achieve this. In the foreign process, you call the instance which first performs the initialization and then exe

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-07 Thread Dieter Maurer
Martin Di Paola wrote at 2022-3-6 20:42 +: >>Try to use `fork` as "start method" (instead of "spawn"). > >Yes but no. Indeed with `fork` there is no need to pickle anything. In >particular the child process will be a copy of the parent so it will >have all the modules loaded, including the dyna

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-07 Thread Martin Di Paola
I understand that yes, pickle.loads() imports any necessary module but only if they can be find in sys.path (like in any "import" statement). Dynamic code loaded from a plugin (which we presume it is *not* in sys.path) will not be loaded. Quick check. Run in one console the following: import mu

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-07 Thread Barry
> On 7 Mar 2022, at 02:33, Martin Di Paola wrote: > > Yes but I think that unpickle (pickle.loads()) does that plus > importing any module needed Are you sure that unpickle will import code? I thought it did not do that. Barry -- https://mail.python.org/mailman/listinfo/python-list

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Martin Di Paola
Yeup, that would be my first choice but the catch is that "sayhi" may not be a function of the given module. It could be a static method of some class or any other callable. Ah, fair. Are you able to define it by a "path", where each step in the path is a getattr() call? Yes but I think th

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Martin Di Paola
I'm not so sure about that. The author of the plugin knows they're writing code that will be dynamically loaded, and can therefore expect the kind of problem they're having. It could be argued that it's their responsibility to ensure that all the needed code is loaded into the subprocess. Ye

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Greg Ewing
On 7/03/22 9:36 am, Martin Di Paola wrote: It *would* be my fault if multiprocessing.Process fails only because I'm loading the code dynamically. I'm not so sure about that. The author of the plugin knows they're writing code that will be dynamically loaded, and can therefore expect the kind of

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Chris Angelico
On Mon, 7 Mar 2022 at 07:37, Martin Di Paola wrote: > > > > > > >The way you've described it, it's a hack. Allow me to slightly redescribe it. > > > >modules = loader() > >objs = init(modules) > > > >def invoke(mod, func): > ># I'm assuming that the loader is smart enough to not load > >#

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Martin Di Paola
Try to use `fork` as "start method" (instead of "spawn"). Yes but no. Indeed with `fork` there is no need to pickle anything. In particular the child process will be a copy of the parent so it will have all the modules loaded, including the dynamic ones. Perfect. The problem is that `fork` is t

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Martin Di Paola
The way you've described it, it's a hack. Allow me to slightly redescribe it. modules = loader() objs = init(modules) def invoke(mod, func): # I'm assuming that the loader is smart enough to not load # a module that's already loaded. Alternatively, load just the # module you need,

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Dieter Maurer
ng multiprocessing.Process to run the code and in MacOS, the >default start method for such process is using "spawn". My understanding >is that Python spawns an independent Python server (the child) which >receives what to execute (the target function) from the parent process. >

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Chris Angelico
MacOS. > > He was using multiprocessing.Process to run the code and in MacOS, the > default start method for such process is using "spawn". My understanding > is that Python spawns an independent Python server (the child) which > receives what to execute (the target function) fro

Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Martin Di Paola
start method for such process is using "spawn". My understanding is that Python spawns an independent Python server (the child) which receives what to execute (the target function) from the parent process. In pseudo code this would be like: modules = loader() # load the plugins (Python mod

byexample: free, open source tool to find snippets of code in your docs and execute them as regression tests

2021-05-03 Thread Martin Di Paola
Hi everyone, I would like to share a free, open source tool with you that I've been developing in the last few years. You'll be probably familiar with things like this in the Python documentation: ``` >>> 1 + 3 4 ``` byexample will find those snippets, it will exec

RE: Are there Python ways to execute queries on PostgreSQL without getting data over?

2020-10-19 Thread David Raymond
> Are there Python ways to execute queries on PostgreSQL without getting data > over? > > Are there ways just to fire off PostgreSQL queries and not get data into > Python? > > Regards, > > David What is your use case for this? Normally when you do basic things

Re: Are there Python ways to execute queries on PostgreSQL without getting data over?

2020-10-18 Thread Mats Wichmann
On 10/18/20 5:53 AM, Shaozhong SHI wrote: > Are there Python ways to execute queries on PostgreSQL without getting data > over? > > Are there ways just to fire off PostgreSQL queries and not get data into > Python? > > Regards, > > David > When you "execute

Are there Python ways to execute queries on PostgreSQL without getting data over?

2020-10-18 Thread Shaozhong SHI
Are there Python ways to execute queries on PostgreSQL without getting data over? Are there ways just to fire off PostgreSQL queries and not get data into Python? Regards, David -- https://mail.python.org/mailman/listinfo/python-list

Execute python script from VB6 to display Outlook Window

2019-12-22 Thread wojtek . dominicana
is a different between calling script via Shell() function and run it directly from command line. I tried of course solution as follows: Set obj = CreateObject("WScript.Shell") obj.Run sPythonFile but its the same situation. I createt bat file and I execute this bat file which has insi

Re: How execute at least two python files at once when imported?

2019-11-08 Thread Gregory Ewing
Cameron Simpson wrote: I was unsure as to how serialised this was: just the import data structures or the whole source-of-the-module. It's the whole source. I found that out the hard way once -- I had a thread that imported a module whose main code ran an event processing loop. It stopped any o

Re: How execute at least two python files at once when imported?

2019-11-07 Thread Cameron Simpson
On 08Nov2019 00:52, Greg Ewing wrote: Cameron Simpson wrote: Spencer's modules run unconditional stuff in addition to defining classes. That may cause trouble. It will -- because of the import lock, they won't run simultaneously in the same process. I was unsure as to how serialised this wa

Re: How execute at least two python files at once when imported?

2019-11-07 Thread Gregory Ewing
Cameron Simpson wrote: Spencer's modules run unconditional stuff in addition to defining classes. That may cause trouble. It will -- because of the import lock, they won't run simultaneously in the same process. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

OT language barrier, was: How execute at least two python files at once when imported?

2019-11-07 Thread Christian Gollwitzer
Am 06.11.19 um 17:34 schrieb Igor Korot: On Wed, Nov 6, 2019 at 10:22 AM Spencer Du wrote: Sorry if I haven't stated my requirements clearly. I just wanted a way to import at least two python files in parallel and I wanted to know how this can be done or a reason why its bad as stated in a

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Cameron Simpson
On 06Nov2019 08:16, Spencer Du wrote: Sorry if I haven't stated my requirements clearly. I just wanted a way to import at least two python files in parallel and I wanted to know how this can be done or a reason why its bad as stated in another post. Parallel imports can be fine. However, yo

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Cameron Simpson
On 06Nov2019 18:15, Rhodri James wrote: On 06/11/2019 16:02, Spencer Du wrote: Why is importing modules in parallel bad? To put it as simply as I can: 1. The import mechanism is complicated, even the bits that are user-visible. Fiddling with it has a high chance of going wrong. 2. Multi-

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Richard Damon
On 11/6/19 3:37 PM, Michael Torrie wrote: > On 11/6/19 9:16 AM, Spencer Du wrote: >> I just wanted a way to import at least two python files in parallel >> and I wanted to know how this can be done or a reason why its bad as >> stated in another post. > It's not "bad," but it's also not possible.

Re: How execute at least two python files at once when imported?

2019-11-06 Thread jfong
Igor Korot於 2019年11月7日星期四 UTC+8上午12時34分35秒寫道: > Hi, > > On Wed, Nov 6, 2019 at 10:22 AM Spencer Du wrote: > > > > Hi > > > > Sorry if I haven't stated my requirements clearly. > > > > I just wanted a way to import at least two python files in parallel and I > > wanted to know how this can be don

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Michael Torrie
On 11/6/19 9:16 AM, Spencer Du wrote: > I just wanted a way to import at least two python files in parallel > and I wanted to know how this can be done or a reason why its bad as > stated in another post. It's not "bad," but it's also not possible. Nor does it make sense. That's why so many people

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Bob van der Poel
On Wed, Nov 6, 2019 at 11:15 AM Rhodri James wrote: > On 06/11/2019 16:02, Spencer Du wrote: > > Why is importing modules in parallel bad? > > To put it as simply as I can: > > 1. The import mechanism is complicated, even the bits that are > user-visible. Fiddling with it has a high chance of go

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Rhodri James
On 06/11/2019 16:02, Spencer Du wrote: Why is importing modules in parallel bad? To put it as simply as I can: 1. The import mechanism is complicated, even the bits that are user-visible. Fiddling with it has a high chance of going wrong. 2. Multi-threading is less complicated than import,

RE: How execute at least two python files at once when imported?

2019-11-06 Thread David Raymond
"Why is importing modules in parallel bad?" In general I'd say that "import foo" is supposed to be there because you want the classes, functions, variables etc. in foo to be available in your current program. A module should never run a whole bunch of time consuming stuff when it's imported. If

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Igor Korot
Hi, On Wed, Nov 6, 2019 at 10:22 AM Spencer Du wrote: > > Hi > > Sorry if I haven't stated my requirements clearly. > > I just wanted a way to import at least two python files in parallel and I > wanted to know how this can be done or a reason why its bad as stated in > another post. This is n

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Karsten Hilbert
On Wed, Nov 06, 2019 at 08:16:07AM -0800, Spencer Du wrote: > Sorry if I haven't stated my requirements clearly. > > I just wanted a way to import at least two python files in parallel and I > wanted to know how this can be done or a reason why its bad as stated in > another post. You stated yo

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
Hi Sorry if I haven't stated my requirements clearly. I just wanted a way to import at least two python files in parallel and I wanted to know how this can be done or a reason why its bad as stated in another post. Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Igor Korot
Hi, I think what you are trying is a "chicken-egg" problem. You should clearly state you requirements in order for us to help you. If you have a problem with English I'm sure there is some python-related list/forum in your native language. Just google it. Thank you. On Wed, Nov 6, 2019 at 10:07

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
Why is importing modules in parallel bad? Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Antoon Pardon
On 5/11/19 19:33, Spencer Du wrote: > Hi > > I want to execute at least two python files at once when imported but I dont > know how to do this. Currently I can only import each file one after another > but what i want is each file to be imported at the same time. Can you help

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Rhodri James
On 06/11/2019 11:42, Rhodri James wrote: On 06/11/2019 09:51, Spencer Du wrote: On Tuesday, 5 November 2019 19:44:46 UTC+1, Rhodri James  wrote: On 05/11/2019 18:33, Spencer Du wrote: I want to execute at least two python files at once when imported but I dont know how to do this. Currently I

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Rhodri James
On 06/11/2019 09:51, Spencer Du wrote: On Tuesday, 5 November 2019 19:44:46 UTC+1, Rhodri James wrote: On 05/11/2019 18:33, Spencer Du wrote: I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
On Tuesday, 5 November 2019 19:44:46 UTC+1, Rhodri James wrote: > On 05/11/2019 18:33, Spencer Du wrote: > > I want to execute at least two python files at once when imported but > > I dont know how to do this. Currently I can only import each file one > > after another bu

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
On Tuesday, 5 November 2019 19:41:59 UTC+1, Bob Gailer wrote: > On Nov 5, 2019 1:35 PM, "Spencer Du" wrote: > > > > Hi > > > > I want to execute at least two python files at once when imported but I > dont know how to do this. Currently I can only import

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
On Tuesday, 5 November 2019 21:05:02 UTC+1, Terry Reedy wrote: > On 11/5/2019 1:33 PM, Spencer Du wrote: > > > I want to execute at least two python files at once when imported but I > > dont know how to do this. Currently I can only import each file one after > > an

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
On Tuesday, 5 November 2019 19:37:32 UTC+1, Karsten Hilbert wrote: > > I want to execute at least two python files at once when imported but I > > dont know how to do this. > > Currently I can only import each file one after another but what i want is > > each file t

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
On Wednesday, 6 November 2019 09:05:42 UTC+1, Christian Gollwitzer wrote: > Am 06.11.19 um 03:59 schrieb Dennis Lee Bieber: > > On Tue, 5 Nov 2019 10:33:20 -0800 (PST), Spencer Du > > declaimed the following: > > > >> Hi > >> > >> I want t

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Christian Gollwitzer
Am 06.11.19 um 03:59 schrieb Dennis Lee Bieber: On Tue, 5 Nov 2019 10:33:20 -0800 (PST), Spencer Du declaimed the following: Hi I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what

Re: How execute at least two python files at once when imported?

2019-11-05 Thread Terry Reedy
On 11/5/2019 1:33 PM, Spencer Du wrote: I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. Can you help me write the code for

Re: How execute at least two python files at once when imported?

2019-11-05 Thread Rhodri James
On 05/11/2019 18:33, Spencer Du wrote: I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. That is a very odd requirement. Why

Re: How execute at least two python files at once when imported?

2019-11-05 Thread Bob Gailer
On Nov 5, 2019 1:35 PM, "Spencer Du" wrote: > > Hi > > I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. Can

Aw: How execute at least two python files at once when imported?

2019-11-05 Thread Karsten Hilbert
> I want to execute at least two python files at once when imported but I dont > know how to do this. > Currently I can only import each file one after another but what i want is > each file to be imported > at the same time. Can you explain why that seems necessary ? Ka

How execute at least two python files at once when imported?

2019-11-05 Thread Spencer Du
Hi I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. Can you help me write the code for this? embedded.py is the main file to

Re: Execute complex shell commands within python and obtain the output.

2019-09-03 Thread Hongyi Zhao
On Tue, 03 Sep 2019 17:27:59 +1000, Cameron Simpson wrote: > It was merely that it is hardwired in your code (and you need to wire in > something). Just keep in mind that _if_ this script runs in a non-utf8 > environment the decoding may be wrong. Unlikely to actually happen > though. Thanks, fix

Re: Execute complex shell commands within python and obtain the output.

2019-09-03 Thread Cameron Simpson
On 03Sep2019 03:59, Hongyi Zhao wrote: On Tue, 03 Sep 2019 08:24:17 +1000, Cameron Simpson wrote: Finally, the .decode('utf8') assumes your locale is UTF8 based. It probably is, but if it isn't then you may get mojibake. Nowadays, most of the os use utf8 as the default locale. Am I wrong?

Re: Execute complex shell commands within python and obtain the output.

2019-09-02 Thread Hongyi Zhao
On Tue, 03 Sep 2019 08:24:17 +1000, Cameron Simpson wrote: > It seems reasonable to me, but I would not use stderr=subprocess.STDOUT. > Why did you do that? The stderr stream pretty much exists to avoid > polluting stdout with error messages. Thanks for your suggestion. > > For really complex s

Re: Execute complex shell commands within python and obtain the output.

2019-09-02 Thread Cameron Simpson
On 02Sep2019 13:20, Hongyi Zhao wrote: I try to execute some complex shell commands with in python and obtain the output, I tried the following method: For python 3.x: import subprocess cmd= some_complex_command_with_pipe_and_others ps = subprocess.Popen (cmd,shell=True,stdout=subprocess.PIPE

Execute complex shell commands within python and obtain the output.

2019-09-02 Thread Hongyi Zhao
Hi, I try to execute some complex shell commands with in python and obtain the output, I tried the following method: For python 3.x: import subprocess cmd= some_complex_command_with_pipe_and_others ps = subprocess.Popen (cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT) output

Re: How do i execute some code when I have subscribed to a topic with a message payload for mqtt in python?

2019-08-09 Thread Rhodri James
On 08/08/2019 21:47, Spencer Du via Python-list wrote: Ok so here is some code below. How do I write an if code block to execute some commands when I subscribe to the topic: microscope/light_sheet_microscope/UI and which has a message which is a device type published to it. I want to execute

Re: How do i execute some code when I have subscribed to a topic with a message payload for mqtt in python?

2019-08-08 Thread Spencer Du via Python-list
On Thursday, 8 August 2019 22:48:11 UTC+2, Spencer Du wrote: > Ok so here is some code below. How do I write an if code block to execute > some commands when I subscribe to the topic: > microscope/light_sheet_microscope/UI and which has a message which is a > device type publis

How do i execute some code when I have subscribed to a topic with a message payload for mqtt in python?

2019-08-08 Thread Spencer Du via Python-list
Ok so here is some code below. How do I write an if code block to execute some commands when I subscribe to the topic: microscope/light_sheet_microscope/UI and which has a message which is a device type published to it. I want to execute some code to check if the device has a python file in the

Can not execute options trade

2019-07-25 Thread spawnaga
The placeOrder command does not send the order for options trades. I tried to submit the order for stocks and it went through but not options # -*- coding: utf-8 -*- """ Created on Wed Jul 24 21:58:32 2019 @author: Alex Oraibi """ import time from time import localtime, strftime from ib.ext.Con

Re: How to execute shell command in Python program?

2019-07-23 Thread Madhavan Bomidi
Thanks for your suggestions. I have sorted the issue as follows: import pexpect child = pexpect.spawn('./opac') child.sendline('opac') This works!!! -- https://mail.python.org/mailman/listinfo/python-list

Re: How to execute shell command in Python program?

2019-07-20 Thread DL Neil
On 21/07/19 5:07 AM, Peter J. Holzer wrote: On 2019-07-20 15:39:58 +0100, Chris Narkiewicz via Python-list wrote: Madhavan Bomidi wrote: import subprocess subprocess.call(['./opac'],shell=True) There may be an os.chdir() missing here. subprocess.call(['./opac', "my-input.inp"], shell=True)

Re: How to execute shell command in Python program?

2019-07-20 Thread Peter J. Holzer
On 2019-07-20 15:39:58 +0100, Chris Narkiewicz via Python-list wrote: > Madhavan Bomidi wrote: > > import subprocess > > subprocess.call(['./opac'],shell=True) There may be an os.chdir() missing here. > subprocess.call(['./opac', "my-input.inp"], shell=True) We don't know whether the OP's progra

Re: How to execute shell command in Python program?

2019-07-20 Thread Chris Narkiewicz via Python-list
Madhavan Bomidi wrote: > import subprocess > subprocess.call(['./opac'],shell=True) subprocess.call(['./opac', "my-input.inp"], shell=True) The array takes command with a list of arguments. This way you don't need to do space escaping and other Jujitsu gimmicks. If you want to feed the command f

How to execute shell command in Python program?

2019-07-20 Thread Madhavan Bomidi
Hi, I have the following shell commands to run my executable created with gfortran: - $ pwd /OPAC/opac31a/opac31 $ ls extback.dat opacopac.f result terr.dat input opac.cfg

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Cameron Simpson
On 11Feb2019 08:17, Irv Kalb wrote: On Feb 11, 2019, at 7:25 AM, Neal Becker wrote: I have code with structure: ``` if cond1: [some code] if cond2: #where cond2 depends on the above [some code] [ more code] else: [ do xxyy ] else: [ do the same xxyy as above ] ``` So what's the best

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Neal Becker
Chris Angelico wrote: > On Tue, Feb 12, 2019 at 3:21 AM Neal Becker wrote: >> >> Chris Angelico wrote: >> >> > On Tue, Feb 12, 2019 at 2:27 AM Neal Becker >> > wrote: >> >> >> >> I have code with structure: >> >> ``` >> >> if cond1: >> >> [some code] >> >> if cond2: #where cond2 depends on t

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Irv Kalb
> On Feb 11, 2019, at 7:25 AM, Neal Becker wrote: > > I have code with structure: > ``` > if cond1: > [some code] > if cond2: #where cond2 depends on the above [some code] >[ more code] > > else: >[ do xxyy ] > else: > [ do the same xxyy as above ] > ``` > > So what's the best sty

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Chris Angelico
On Tue, Feb 12, 2019 at 3:21 AM Neal Becker wrote: > > Chris Angelico wrote: > > > On Tue, Feb 12, 2019 at 2:27 AM Neal Becker wrote: > >> > >> I have code with structure: > >> ``` > >> if cond1: > >> [some code] > >> if cond2: #where cond2 depends on the above [some code] > >> [ more cod

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Neal Becker
Chris Angelico wrote: > On Tue, Feb 12, 2019 at 2:27 AM Neal Becker wrote: >> >> I have code with structure: >> ``` >> if cond1: >> [some code] >> if cond2: #where cond2 depends on the above [some code] >> [ more code] >> >> else: >> [ do xxyy ] >> else: >> [ do the same xxyy as a

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Dan Sommers
On 2/11/19 9:25 AM, Neal Becker wrote: I have code with structure: ``` if cond1: [some code] if cond2: #where cond2 depends on the above [some code] [ more code] else: [ do xxyy ] else: [ do the same xxyy as above ] ``` So what's the best style to handle this? As coded, i

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Chris Angelico
On Tue, Feb 12, 2019 at 2:27 AM Neal Becker wrote: > > I have code with structure: > ``` > if cond1: > [some code] > if cond2: #where cond2 depends on the above [some code] > [ more code] > > else: > [ do xxyy ] > else: > [ do the same xxyy as above ] > ``` > > So what's the best s

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Neal Becker
Rhodri James wrote: > On 11/02/2019 15:25, Neal Becker wrote: >> I have code with structure: >> ``` >> if cond1: >>[some code] >>if cond2: #where cond2 depends on the above [some code] >> [ more code] >> >>else: >> [ do xxyy ] >> else: >>[ do the same xxyy as above ] >>

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Rhodri James
On 11/02/2019 15:25, Neal Becker wrote: I have code with structure: ``` if cond1: [some code] if cond2: #where cond2 depends on the above [some code] [ more code] else: [ do xxyy ] else: [ do the same xxyy as above ] ``` So what's the best style to handle this? As coded,

exit 2 levels of if/else and execute common code

2019-02-11 Thread Neal Becker
I have code with structure: ``` if cond1: [some code] if cond2: #where cond2 depends on the above [some code] [ more code] else: [ do xxyy ] else: [ do the same xxyy as above ] ``` So what's the best style to handle this? As coded, it violates DRY. Try/except could be used with

Error while calling a subprocess and execute another script from one py file

2018-12-30 Thread sandeep . bayi6
uot; " in arg) or ("\t" in arg) or not arg TypeError: argument of type 'module' is not iterable ---------- > I'm currently facing this error while execute another py_script from one > script. > and i

Re: failed to execute scapy commands from remote server

2018-08-09 Thread Rhodri James
On 09/08/18 13:11, Iranna Mathapati wrote: 2. When I try to execute scapy cmds in remote server I get the below error child_remote.sendline=sendp(arp3,iface='enp6s0f0',count=100) Traceback (most recent call last): File "", line 1, in File "/usr/local/li

failed to execute scapy commands from remote server

2018-08-09 Thread Iranna Mathapati
Hi Team, I have to ssh a remote server and execute scapy commands there. but its able to execute all linux commands from remote server handle I use pexpect and hitting issue. 1. SSH to remote shell via pexpect from current server parser_ip_add='192.168.1.83' ch

Re: Can I execute a python code written in Python 2.7 (using numpy and tensor flow executed in linux) in Winpython 3.6 on Windows?

2018-04-17 Thread Terry Reedy
On 4/17/2018 1:00 AM, Rishika Sen wrote: Here is the code that has been written in Python 2.7, numpy, tensorflow: https://drive.google.com/open?id=1JZe7wfRcdlEF6Z5C0ePBjtte_2L4Kk-7 One must 'sign in' to read this. Can you please let me know what changes I have to make to exe

Can I execute a python code written in Python 2.7 (using numpy and tensor flow executed in linux) in Winpython 3.6 on Windows?

2018-04-16 Thread Rishika Sen
Here is the code that has been written in Python 2.7, numpy, tensorflow: https://drive.google.com/open?id=1JZe7wfRcdlEF6Z5C0ePBjtte_2L4Kk-7 Can you please let me know what changes I have to make to execute it on WinPython 3.6? Else, is there a version on Python 2.7 in Winpython? I have

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-15 Thread Gregory Ewing
Grant Edwards wrote: Where are the UTIs stored? Do OS X filesystems still have a "resource fork"? UTIs are stored as extended attributes. Resource forks still exist, but they're deprecated. Things that used to be kept in resource forks are now usually just files in the application bundle -- w

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-15 Thread Gregory Ewing
Steve D'Aprano wrote: They are still supported (-ish) by OS X, but have been superseded by Uniform Type Identifiers. https://en.wikipedia.org/wiki/Uniform_Type_Identifier I know, what I'm not sure about is how much those are used by apps these days, with so much of the widely used software be

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-15 Thread Grant Edwards
On 2017-12-15, Steve D'Aprano wrote: > On Fri, 15 Dec 2017 09:48 am, Gregory Ewing wrote: [...] > Classic MacOS associated two such pieces of metadata with each file: the > creator and type. [...] > > https://en.wikipedia.org/wiki/Creator_code > >> I believe MacOSX also has the ability to store a

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-15 Thread alister via Python-list
On Fri, 15 Dec 2017 11:48:20 +1300, Gregory Ewing wrote: > Rhodri James wrote: >> Even then there was RiscOS, which divorced file names from file types >> entirely. > > As did classic MacOS. > > I believe MacOSX also has the ability to store a file type as metadata, > but it doesn't seem to be u

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-15 Thread Steve D'Aprano
On Fri, 15 Dec 2017 09:48 am, Gregory Ewing wrote: > Rhodri James wrote: >> Even then there was RiscOS, which divorced file names from file types >> entirely. > > As did classic MacOS. Classic MacOS associated two such pieces of metadata with each file: the creator and type. Regardless of the op

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-14 Thread Gregory Ewing
Rhodri James wrote: Even then there was RiscOS, which divorced file names from file types entirely. As did classic MacOS. I believe MacOSX also has the ability to store a file type as metadata, but it doesn't seem to be used much. -- Greg -- https://mail.python.org/mailman/listinfo/python-li

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-14 Thread Chris Angelico
On Fri, Dec 15, 2017 at 3:06 AM, Dennis Lee Bieber wrote: > C:\Users\Wulfraed>assoc .docx > .docx=Word.Document.12 > > C:\Users\Wulfraed>ftype word.document.12 > word.document.12="C:\Program Files\Microsoft > Office\Root\Office16\WINWORD.EXE" /n "%1" /o "%u" I'm almost afraid to ask... why "word.

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-14 Thread Chris Angelico
On Thu, Dec 14, 2017 at 10:53 PM, Rhodri James wrote: > On 14/12/17 07:25, Chris Angelico wrote: >> >> So it's an imperfect solution even as far as it goes, and a highly >> limiting way to do things. I'm sure it made good sense back when >> MS-DOS file systems ruled the Windows world, and 8.3 was

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-14 Thread Rhodri James
On 14/12/17 07:25, Chris Angelico wrote: So it's an imperfect solution even as far as it goes, and a highly limiting way to do things. I'm sure it made good sense back when MS-DOS file systems ruled the Windows world, and 8.3 was just the way of things. Even then there was RiscOS, which divorce

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-13 Thread Chris Angelico
On Thu, Dec 14, 2017 at 5:44 PM, Christian Gollwitzer wrote: > Am 14.12.17 um 02:55 schrieb Chris Angelico: >> >> On Thu, Dec 14, 2017 at 12:35 PM, Rick Johnson >> wrote: >>> >>> On Tuesday, December 12, 2017 at 10:42:54 PM UTC-6, eryk sun wrote: >>> [...] That said, I don't see this fe

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-13 Thread Christian Gollwitzer
Am 14.12.17 um 02:55 schrieb Chris Angelico: On Thu, Dec 14, 2017 at 12:35 PM, Rick Johnson wrote: On Tuesday, December 12, 2017 at 10:42:54 PM UTC-6, eryk sun wrote: [...] That said, I don't see this feature as being very useful compared to just using "open with" when I occasionally need to o

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-13 Thread Chris Angelico
On Thu, Dec 14, 2017 at 12:35 PM, Rick Johnson wrote: > On Tuesday, December 12, 2017 at 10:42:54 PM UTC-6, eryk sun wrote: > [...] >> That said, I don't see this feature as being very useful >> compared to just using "open with" when I occasionally need >> to open a file with a non-default progra

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-13 Thread Rick Johnson
On Tuesday, December 12, 2017 at 10:42:54 PM UTC-6, eryk sun wrote: [...] > That said, I don't see this feature as being very useful > compared to just using "open with" when I occasionally need > to open a file with a non-default program. That's the point i was trying to make, but i think it may

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-13 Thread eryk sun
On Wed, Dec 13, 2017 at 9:04 PM, Chris Angelico wrote: > On Thu, Dec 14, 2017 at 7:56 AM, eryk sun wrote: >> On Wed, Dec 13, 2017 at 5:43 AM, Chris Angelico wrote: >>> >>> A Windows equivalent would be to have a .py file associated normally >>> with the regular console, but some individual ones

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-13 Thread Chris Angelico
On Thu, Dec 14, 2017 at 7:56 AM, eryk sun wrote: > On Wed, Dec 13, 2017 at 5:43 AM, Chris Angelico wrote: >> >> A Windows equivalent would be to have a .py file associated normally >> with the regular console, but some individual ones associated with >> pythonw.exe - without renaming them to .pyw

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-13 Thread eryk sun
On Wed, Dec 13, 2017 at 5:43 AM, Chris Angelico wrote: > > A Windows equivalent would be to have a .py file associated normally > with the regular console, but some individual ones associated with > pythonw.exe - without renaming them to .pyw. AFAIK there is no way to > do this on Windows short of

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-12 Thread Chris Angelico
On Wed, Dec 13, 2017 at 3:41 PM, eryk sun wrote: > On Tue, Dec 12, 2017 at 3:30 PM, Chris Angelico wrote: >> On Wed, Dec 13, 2017 at 12:54 AM, Rick Johnson >> wrote: >>> Chris Angelico wrote: >>> Which is why OS/2, back in the 1990s, had *multiple* associations for any given file. You

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-12 Thread eryk sun
On Tue, Dec 12, 2017 at 3:30 PM, Chris Angelico wrote: > On Wed, Dec 13, 2017 at 12:54 AM, Rick Johnson > wrote: >> Chris Angelico wrote: >> >>> Which is why OS/2, back in the 1990s, had *multiple* >>> associations for any given file. You could use file types >>> (sadly not MIME types - this was

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-12 Thread alister via Python-list
>> - some sort of html composer - etc >> >> Which means we are beyond the nature of the file per se to the pattern >> of its usage > > And although an automated "intuitor" could easily determine if a file > contained a markup language, we would still be force

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-12 Thread Chris Angelico
On Wed, Dec 13, 2017 at 12:54 AM, Rick Johnson wrote: > Chris Angelico wrote: > > [...] > >> > Yeah… magic… in the category of mind-reading? sooth- >> > saying? >> >> Which is why OS/2, back in the 1990s, had *multiple* >> associations for any given file. You could use file types >> (sadly not MIM

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-12 Thread Rick Johnson
Rustom Mody wrote: > This thread is getting like a mini hologram of our current > surreal time If we can put aside who is right and wrong > for a moment we see the more frightening spectacle that > Repubs and democrats, Remainers and Brexiters and so on all > over by getting more and more shrill

Re: Please tell me how to execute python file in Ubuntu by double

2017-12-12 Thread Rick Johnson
Chris Angelico wrote: [...] > > Yeah… magic… in the category of mind-reading? sooth- > > saying? > > Which is why OS/2, back in the 1990s, had *multiple* > associations for any given file. You could use file types > (sadly not MIME types - this was before MIME was the one > obvious standard

  1   2   3   4   5   6   7   8   9   10   >