Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
Chris Angelico wrote: > look for a STORE_ATTR opcode. If there aren't any, there can't > be any "self.foo = bar". (You can't be certain of the converse, as > "other_object.foo = bar" will also show up as STORE_ATTR.) This very useful, I will look into it, thanks. Sincerely, Iwo Herka -- https:/

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Chris Angelico
On Mon, Nov 26, 2018 at 7:56 AM Chris Angelico wrote: > > On Mon, Nov 26, 2018 at 7:55 AM Iwo Herka wrote: > > > > > class Foo: > > >def setup(self): ... > > >__init__ = lambda self: self.setup() > > > > Sorry, didn't address this. This is fine too, since I'm assuming that > > only method

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Chris Angelico
On Mon, Nov 26, 2018 at 7:52 AM Iwo Herka wrote: > > > Why are lambda functions not instrumented? > > Because, if I didn't forget about anything, assignment > in lambdas is invalid. That is, > > lambda self. self.x = 1 > > or > > lambda self: (self.x = 1) > > will throw SyntaxError. Ther

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
> class Foo: >def setup(self): ... >__init__ = lambda self: self.setup() Sorry, didn't address this. This is fine too, since I'm assuming that only methods named __init__ are allowed to mutate the object. Because 'setup' is not '__init__' it's disqualified. Sincerely, Iwo Herka -- https:

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Chris Angelico
On Mon, Nov 26, 2018 at 7:55 AM Iwo Herka wrote: > > > class Foo: > >def setup(self): ... > >__init__ = lambda self: self.setup() > > Sorry, didn't address this. This is fine too, since I'm assuming that > only methods named __init__ are allowed to mutate the object. > Because 'setup' is n

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
> Why are lambda functions not instrumented? Because, if I didn't forget about anything, assignment in lambdas is invalid. That is, lambda self. self.x = 1 or lambda self: (self.x = 1) will throw SyntaxError. Therefore, I don't have to worry that someone will attempt to mutate the ob

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Chris Angelico
On Mon, Nov 26, 2018 at 7:45 AM Iwo Herka wrote: > > Everything works fine, except that I have to cover the following: > > foo = lambda self: None > > class Foo: > __init__ = foo > > Since I'm treating FunctionType and LambdaType differently (I don't have > to instrument lambdas, I

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
Chris Angelico wrote: > [...] why do you care about the difference? What is it in your code that > cares about whether a function was created with "def" or with "lambda"? In answer to my previous question on the list, (https://mail.python.org/pipermail/python-list/2018-November/738151.html), wher

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Chris Angelico
On Mon, Nov 26, 2018 at 6:54 AM Iwo Herka wrote: > > > That said, though: if you want to distinguish a lambda function from a > > def function, you can do so with reasonable reliability using the > > function's name: > > That's what I'm using currently, thank you for the suggestion. > Nonetheless,

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
> That said, though: if you want to distinguish a lambda function from a > def function, you can do so with reasonable reliability using the > function's name: That's what I'm using currently, thank you for the suggestion. Nonetheless, it feels hacky - that's why I tried to use LambdaType and, to

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Chris Angelico
On Mon, Nov 26, 2018 at 6:06 AM Iwo Herka wrote: > > Hello, > > Can someone please provide a use-case for having LambdaType > separate to FunctionType? Clarification: This is talking about the 'types' module. > Since they are equal > (LambdaType == FunctionType) it seems a bit superfluous to me.

Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
Hello, Can someone please provide a use-case for having LambdaType separate to FunctionType? Since they are equal (LambdaType == FunctionType) it seems a bit superfluous to me. For example, I cannot do the following: if type(foo) is FunctionType and not type(foo) is LambdaType: ... W

Re: Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread Chris Angelico
On Mon, Nov 26, 2018 at 5:40 AM srinivasan wrote: > > Dear Karsten, > > With the help of Mrab Inputs, I tried Even with "return > stdout.strip().decode("utf-8")", it still seems to be an issue, I am using > python 3.6, is this causing a issue? No, it isn't. Two things are causing most of your is

Re: how to match list members in py3.x

2018-11-25 Thread Muhammad Rizwan
On Sunday, 25 November 2018 13:48:42 UTC-5, Alister wrote: > On Sun, 25 Nov 2018 08:49:03 -0800, Muhammad Rizwan wrote: > > > On Sunday, 25 November 2018 10:59:46 UTC-5, Alister wrote: > >> On Sun, 25 Nov 2018 07:43:42 -0800, Muhammad Rizwan wrote: > >> > >> > for each word in each line how can

Re: how to match list members in py3.x

2018-11-25 Thread Alister via Python-list
On Sun, 25 Nov 2018 08:49:03 -0800, Muhammad Rizwan wrote: > On Sunday, 25 November 2018 10:59:46 UTC-5, Alister wrote: >> On Sun, 25 Nov 2018 07:43:42 -0800, Muhammad Rizwan wrote: >> >> > for each word in each line how can we check to see if a word is >> > already present in a list and if it i

Re: Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Dear Karsten, With the help of Mrab Inputs, I tried Even with "return stdout.strip().decode("utf-8")", it still seems to be an issue, I am using python 3.6, is this causing a issue? /home/srinivasan/Downloads/wifidisconnectissuenov23_homework/venv/bin/python /home/srinivasan/Downloads/wifidiscon

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Dear Mrab, Even with "return stdout.strip().decode("utf-8")", it still seems to be an issue, I am using python 3.6, is this causing a issue? /home/srinivasan/Downloads/wifidisconnectissuenov23_homework/venv/bin/python /home/srinivasan/Downloads/wifidisconnectissuenov23_homework/qa/test_library/t

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Thanks a lot for your quick responses Mrab and appreciate the same. I changed the snippet as below, still it seems to be an issue, I am using python3 version: def main(ssid, pw): try: cmd = "nmcli device wifi connect '%s' password '%s'" % (ssid, pw) proc = subprocess.Popen(

Aw: Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread Karsten Hilbert
> Even only with "*proc.decode("utf-8")"* in the above code still it seems to > throw the error No it does not. It throws the same TYPE of error due to the same SORT of mistake you made. You need to read carefully and try to think about what you read. Karsten -- https://mail.python.org/mailman/

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread MRAB
On 2018-11-25 17:54, srinivasan wrote: Hope now I have changed on the string output as below, could you please correct me if am still wrong? import sys import subprocess interface = "wlan0" def main(ssid, pw):     try:         cmd = "nmcli device wifi connect '%s' password '%s'" % (ssid, pw

Re: Python2.7 unicode conundrum

2018-11-25 Thread Richard Damon
On 11/25/18 12:51 PM, Robert Latest via Python-list wrote: > Hi folks, > what semmingly started out as a weird database character encoding mix-up > could be boiled down to a few lines of pure Python. The source-code > below is real utf8 (as evidenced by the UTF code point 'c3 a4' in the > third lin

Re: Python2.7 unicode conundrum

2018-11-25 Thread Thomas Jollans
On 25/11/2018 18:51, Robert Latest via Python-list wrote: > Hi folks, > what semmingly started out as a weird database character encoding mix-up > could be boiled down to a few lines of pure Python. The source-code > below is real utf8 (as evidenced by the UTF code point 'c3 a4' in the > third line

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Even only with "*proc.decode("utf-8")"* in the above code still it seems to throw the error #return proc.strip().decode("utf-8") #return proc.decode("utf-8").strip() *return proc.decode("utf-8")* Error: /home/srinivasan/Downloads/wifidisconnectissuenov23_homework/venv/bin/python /home

Python2.7 unicode conundrum

2018-11-25 Thread Robert Latest via Python-list
Hi folks, what semmingly started out as a weird database character encoding mix-up could be boiled down to a few lines of pure Python. The source-code below is real utf8 (as evidenced by the UTF code point 'c3 a4' in the third line of the hexdump). When just printed, the string "s" is displayed cor

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Hope now I have changed on the string output as below, could you please correct me if am still wrong? import sys import subprocess interface = "wlan0" def main(ssid, pw): try: cmd = "nmcli device wifi connect '%s' password '%s'" % (ssid, pw) proc = subprocess.Popen(cmd, st

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread MRAB
On 2018-11-25 17:13, srinivasan wrote: Dear Python Experts Team, As am newbie still learning the python syntax from past 2 weeks, Excuse me, If this might be silly question, As I am trying to execute shell command (ie, nmcli) using "subprocess.Popen". 1. Am trying to improve the below code with

Re: help me in a program in python to implement Railway Reservation System using file handling technique.

2018-11-25 Thread Bob Gailer
On Nov 24, 2018 1:35 AM, wrote: > > hello all, > please hepl me in the above program. What do you mean by "the above program"? I don't see any. python to implement Railway Reservation System using file handling technique. > > System should perform below operations. > a. Reserve a ticket for a p

Aw: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread Karsten Hilbert
> Kindly do the needful as am stuck with this issue from 2 days How about YOU do the needful and post code that can actually be tested. Karsten -- https://mail.python.org/mailman/listinfo/python-list

Re: how to match list members in py3.x

2018-11-25 Thread Richard Damon
On 11/25/18 12:28 PM, Muhammad Rizwan wrote: > Below is my approach which I am sure is wrong somewhere and it doesn't work > the way expected, the append doesn't do anything in my code nor does it > returns any traceback all i see is a empty list printed at the end, I am > using win10 x64 python

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread Wildman via Python-list
On Sun, 25 Nov 2018 22:43:10 +0530, srinivasan wrote: > Dear Python Experts Team, > > As am newbie still learning the python syntax from past 2 weeks, Excuse me, > If this might be silly question, As I am trying to execute shell command > (ie, nmcli) using "subprocess.Popen". > > *return pro

Re: how to match list members in py3.x

2018-11-25 Thread Muhammad Rizwan
On Sunday, 25 November 2018 12:14:37 UTC-5, Joel Goldstick wrote: > On Sun, Nov 25, 2018 at 11:51 AM Muhammad Rizwan > <> wrote: > > > > On Sunday, 25 November 2018 11:41:56 UTC-5, Joel Goldstick wrote: > > > On Sun, Nov 25, 2018 at 11:36 AM Muhammad Rizwan > > > <> wrote: > > > > > > > > IF YOU

Re: how to match list members in py3.x

2018-11-25 Thread Joel Goldstick
On Sun, Nov 25, 2018 at 11:51 AM Muhammad Rizwan wrote: > > On Sunday, 25 November 2018 11:41:56 UTC-5, Joel Goldstick wrote: > > On Sun, Nov 25, 2018 at 11:36 AM Muhammad Rizwan > > <> wrote: > > > > > > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. > > > > > > > > >

Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Dear Python Experts Team, As am newbie still learning the python syntax from past 2 weeks, Excuse me, If this might be silly question, As I am trying to execute shell command (ie, nmcli) using "subprocess.Popen". 1. Am trying to improve the below code with "try" and "exception", could you please

Re: how to match list members in py3.x

2018-11-25 Thread tony
On 25/11/2018 17:30, Muhammad Rizwan wrote: > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. > > Why would anyone want to help you? -- https://mail.python.org/mailman/listinfo/python-list

Re: how to match list members in py3.x

2018-11-25 Thread Muhammad Rizwan
On Sunday, 25 November 2018 11:41:56 UTC-5, Joel Goldstick wrote: > On Sun, Nov 25, 2018 at 11:36 AM Muhammad Rizwan > <> wrote: > > > > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. > > > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > That isn't

Re: how to match list members in py3.x

2018-11-25 Thread Muhammad Rizwan
On Sunday, 25 November 2018 10:59:46 UTC-5, Alister wrote: > On Sun, 25 Nov 2018 07:43:42 -0800, Muhammad Rizwan wrote: > > > for each word in each line how can we check to see if a word is already > > present in a list and if it is not how to append that word to a new list > > the 1st step is t

Re: how to match list members in py3.x

2018-11-25 Thread Muhammad Rizwan
Thank you -- https://mail.python.org/mailman/listinfo/python-list

Re: how to match list members in py3.x

2018-11-25 Thread Joel Goldstick
On Sun, Nov 25, 2018 at 11:36 AM Muhammad Rizwan wrote: > > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. > > > -- > https://mail.python.org/mailman/listinfo/python-list That isn't a productive way to get assistance. It is true that people here are often very knowled

Re: how to match list members in py3.x

2018-11-25 Thread Brian Oney via Python-list
On Sun, 2018-11-25 at 07:43 -0800, Muhammad Rizwan wrote: > for each word in each line how can we check to see if a word is already > present in a list and if it is not how to append that word to a new list For your problem consider a set. https://en.wikipedia.org/wiki/Set_theory For the python

Re: how to match list members in py3.x

2018-11-25 Thread Muhammad Rizwan
IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. -- https://mail.python.org/mailman/listinfo/python-list

Re: how to match list members in py3.x

2018-11-25 Thread Alister via Python-list
On Sun, 25 Nov 2018 07:43:42 -0800, Muhammad Rizwan wrote: > for each word in each line how can we check to see if a word is already > present in a list and if it is not how to append that word to a new list the 1st step is to stay awake in class & listen to your instructor, then try to apply th

how to match list members in py3.x

2018-11-25 Thread Muhammad Rizwan
for each word in each line how can we check to see if a word is already present in a list and if it is not how to append that word to a new list -- https://mail.python.org/mailman/listinfo/python-list

Re: help me in a program in python to implement Railway Reservation System using file handling technique.

2018-11-25 Thread francis
On Saturday, 24 November 2018 14:33:29 UTC+8, jasmin amrutia wrote: > hello all, > please hepl me in the above program. python to implement Railway Reservation > System using file handling technique. > > System should perform below operations. > a. Reserve a ticket for a passenger. > b. List in