Re: function got multiple values for keyword argument for value
On Wednesday, October 30, 2013 2:34:19 PM UTC-7, Mark Lawrence wrote: > On 30/10/2013 21:10, > > > search(lane,value=None,start=105,stop=115,GUI=True) -> function definition > > > search(lane,value=value,start=start, stop=stop,GUI=True) -> function call > > > > > > I get the error "search()" got multiple keyword argument for value" > > > > > > I understand when this error comes up - if I had a function definition like > > below > > > > > > def func(a): > > > --- > > > > > > and if I called it as "func(0,a)" where I am passing 2 parameters instead > > of 1, I would end up with the error message. > > > > > > I dont follow why I get it when the number of arguments I am calling with > > the function call match the parameters in the definition. > > > > > > Please advise. > > > > > > > I suspect that you've a method rather than a function so I hope this > > helps > > http://stackoverflow.com/questions/18821193/typeerror-init-got-multiple-values-for-keyword-argument-name > > > > I also believe that you could be using google groups in which case would > > you please be kind enough to read, digest and action this > > https://wiki.python.org/moin/GoogleGroupsPython > Python is the second best programming language in the world. > But the best has yet to be invented. Christian Tismer > Mark Lawrence Mark - I am not having an issue with __init__. It has nothing to do with "self". It is a user-defined function, but it is not __init__ -- https://mail.python.org/mailman/listinfo/python-list
Re: function got multiple values for keyword argument for value
On Wednesday, October 30, 2013 2:50:03 PM UTC-7, KR wrote: > On Wednesday, October 30, 2013 2:34:19 PM UTC-7, Mark Lawrence wrote: > > On 30/10/2013 21:10, > > > search(lane,value=None,start=105,stop=115,GUI=True) -> function definition > > > search(lane,value=value,start=start, stop=stop,GUI=True) -> function call > > > I get the error "search()" got multiple keyword argument for value" > > > I understand when this error comes up - if I had a function definition > > > like below > > > def func(a): > > > and if I called it as "func(0,a)" where I am passing 2 parameters instead > > > of 1, I would end up with the error message. > > > I dont follow why I get it when the number of arguments I am calling with > > > the function call match the parameters in the definition. > > > Please advise. > > I suspect that you've a method rather than a function so I hope this > > helps > > http://stackoverflow.com/questions/18821193/typeerror-init-got-multiple-values-for-keyword-argument-name > > I also believe that you could be using google groups in which case would > > you please be kind enough to read, digest and action this > > https://wiki.python.org/moin/GoogleGroupsPython > > Python is the second best programming language in the world. > > But the best has yet to be invented. Christian Tismer > > Mark Lawrence > Mark - I am not having an issue with __init__. It has nothing to do with > "self". It is a user-defined function, but it is not __init__ Cleaned up even better. Sorry that I missed it in my last post. -- https://mail.python.org/mailman/listinfo/python-list
Re: Issuing commands using "exec_command()" of paramiko AND also sending commands together
Hi Sreenathan Nair:
import os, sys,
import connectlibs as ssh
s = ssh.connect("xxx.xx.xx.xxx", "Admin", "Admin")
channel = s.invoke_shell()
channel.send("net use F: xyz.xy.xc.xa\\dir\n")
>>>32
channel.send("net use\n")
>>>7
channel.recv(500)
'Last login: Tue Jun 2 23:52:29 2015 from
xxx.xx.xx.xx\r\r\n\x1b]0;~\x07\r\r\n\x1b[32mAdmin@WIN \x1b[33m~\x1b[0m\r\r\n$
net use F: xyz.xy.xc.xa\\dir\r\nSystem error 67 has
occurred.\r\r\n\r\r\nThe network name cannot be
found.\r\r\n\r\r\n\x1b]0;~\x07\r\r\n\x1b[32mAdmin@WIN \x1b[33m~\x1b[0m\r\r\n$
net use'
>>>
Above is the what I have for code which is what I am encountering on my setup.
A. I need to be able to parse the o/p of 2 commands 1. "net use F:
xyz.xy.xc.xa\\dir" and 2. "net use".
B. When I use chan.recv(x) -> with certain 'x' bytes. What if I dont know what
kind of a response I am expecting - I mean its not a usual response - if I give
"x" bytes whereas in reality "x" could be 1 bytes more than the ACTUAL
number of bytes in which case Python hangs.
What do people use in such cases.
On Wednesday, June 3, 2015 at 12:10:08 AM UTC-7, Sreenathan Nair wrote:
> Hi,
>
>
> Could you be more specific about your problem? Perhaps an example of
> something similar to what you're trying to do would be helpful.
>
>
> Usually the process is to instantiate paramiko.SSHCLIENT, use the connect()
> method with desired parameters and execute commands using the exec_command().
> If you'd like to process the output of the command execution, then you would
> store the result of exec_command() into three variables (it return a 3-tuple
> of Channel objects).
>
>
> i.e com_stdin, com_stdout, com_stderr =
> my_ssh_client_instance.exec_command("")
>
>
> The instance of SSHCLIENT is live until the close() method is called. Meaning
> subsequent commands can be executed the same way.
>
>
>
>
> On Wed, Jun 3, 2015 at 8:07 AM, Pythonista wrote:
> Using paramiko's exec_command(), i would like to send a command, process its
> output and do it for several other commands. I notice that its not quick
> enough or something like that.
>
> How would I handle that scenario AND also providing multiple commands
> together (there is 1 post on stackoverflow for issuing multiple commands but
> I am not sure if someone has tried it. It didnt work for me!
>
> Thanks!
> --
> https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
getting rid of the recursion in __getattribute__
It is perfectly explained in the standards here [1] saying that: In order to avoid infinite recursion in this method, its implementation should always call the base class method with the same name to access any attributes it needs, for example, object.__getattribute__(self, name). Therefore, I wrote a code following what the standard says: class Sample(): def __init__(self): self.a = -10 def __getattribute__(self, name): if name == 'a': return object.__getattribute__(self, name) raise AttributeError() s = Sample() result = s.a print(result) I did not fall into recursion, and the output was -10 I used here object.__getattribute__(self, name) cause the base class of Sample is object. If I derive the Sample class from another class such as A, I should change object.__getattribute__(self, name) to A.__getattribute__(self, name) as the base class of class Sample is class A. class A: pass class Sample(A): def __init__(self): self.a = -10 def __getattribute__(self, name): if name == 'a': return A.__getattribute__(self, name) raise AttributeError() s = Sample() result = s.a print(result) which gives the same output as expected. No recursion and -10. However, when I try the code without deriving from a class: class AnyClassNoRelation: pass class Sample(): def __init__(self): self.a = -10 def __getattribute__(self, name): if name == 'a': return AnyClassNoRelation.__getattribute__(self, name) raise AttributeError() s = Sample() result = s.a print(result) and calling __getattribute__ via any class (in this example class AnyClassNoRelation) instead of object.__getattribute__(self, name) as the standard says call using the base class, I get the same output: no recursion and -10. So my question: How come this is possible (having the same output without using the base class's __getattribute__? Although the standards clearly states that __getattribute__ should be called from the base class. In order to avoid infinite recursion in this method, its implementation should always call the base class method with the same name to access any attributes it needs, for example, object.__getattribute__(self, name). Literally, I can call __getattribute__ with anyclass (except Sample cause it will be infinite recursion) I define and it works just fine. Could you explain me why that happens? [1] https://docs.python.org/3/reference/datamodel.html#object.__getattribute__ -- https://mail.python.org/mailman/listinfo/python-list
Wats the code?
I wonder anyone knows the line of Python codes to generate 1000 threads concurrently?RegardsFind just what you are after with the more precise, more powerful new MSN Search Try it now. -- http://mail.python.org/mailman/listinfo/python-list
Re: Wats the code?
It's socket threading. I'm had to create a client/server multi-threading simulator where the client sends 1000 threads to the server to "stress" the server. The server can handle more than 1 client concurrently. I would like to hear your comments, tips and relevant soure codes. Do advise. Thanks. Find your perfect match at MSN Personals with Match.com -- http://mail.python.org/mailman/listinfo/python-list
About socket threading
Hi, Do anyone know the Python source codes on how the client can send/"pump"a lot of threads to the server class? Receive MSN Hotmail alerts over SMS! -- http://mail.python.org/mailman/listinfo/python-list
Hi, about socket programming and threading
Hi All!I wonder if anyone knows the simple code structure for a multithreaded web server handling multiple clients at the same time?Thanx!Regards.KrzGet an advanced look at the new version of MSN Messenger. -- http://mail.python.org/mailman/listinfo/python-list
About multithreaded webserver
Hi,Do anyone know the Python source codes on how to write a simple multithreaded webserver class?RegardsFind the lowest fare online with MSN Travel -- http://mail.python.org/mailman/listinfo/python-list
TypeError in HMAC module.
Hi,
I am trying to create a hashed message for authentication for a REST API
call. I have got the key from a keyring as :-
key = keyring.get_password('AWS_keyring','username')
& calculating the signature as :-
signature = hmac(key, message.encode('UTF-8'),
hashlib.sha1).digest().encode('base64')[:-1]
But, while running the script I get the following errors :-
File "/usr/lib64/python2.6/hmac.py", line 133, in new
return HMAC(key, msg, digestmod)
File "/usr/lib64/python2.6/hmac.py", line 72, in __init__
*self.outer.update(key.translate(trans_5C))*
*TypeError: character mapping must return integer, None or unicode*
My python version is :-
# python -V
Python 2.6.9
Can someone please help me as to how I can resolve this issue. Thanks in
advance.
--
*Thanks and Regards*
*Prabir Sarkar*
--
https://mail.python.org/mailman/listinfo/python-list
Re: How to make a Python script to audio read a text file on phone ?
On Sunday, March 17, 2013 7:34:18 PM UTC+5:30, Nic wrote:
> I've installed Python on my Nokia E71 (Symbian S60 3rd FP1) and found a
> script example which can read out text, see example below.
>
> I want to make the script to asks me for a text file instead and then reads
> out the content. I guess it works with a .txt file, dont know if other
> formats work. Regards!
>
>
>
>
>
> [Quote]
>
>
>
> # Copyright (c) 2006 Jurgen Scheible
>
> # This script performs a query with a single-field dialog (text input field)
>
> # and lets the phone speak out the text (text to speech) that the users have
> typed in
>
> # NOTE: this script runs only with Python S60 version 3.1.14 or above
>
> # NOTE: this script doesn't work on all S60 phones neccessarily. Check your
> phone model if it has text to speech capability at all
>
>
>
> import appuifw
>
> import audio
>
>
>
> text = appuifw.query(u"Type a word:", "text")
>
> audio.say(text)
>
>
>
> [End Quote]
Here is a code that works fine for PC. Hope it'll work for you..
def op():
global TXT, L
filepath = tkFileDialog.askopenfilename(filetypes=[("Text Files","*.txt")])
if(len(filepath) == 0):
return 0
F = open(filepath,'r')
TXT = F.read()
F.close()
filename = filepath.split("/")
filename = filename[-1]
L.config(text=filename+": "+filepath)
def play():
global TXT
audio.say(TXT) ##Used as mentioned
print "said"
from Tkinter import *
import Tkconstants, tkFileDialog
import audio ##used as mentioned
TXT = ""
root = Tk()
root.title("Read that Out!!")
L = Label(text="No File Selected!",width="35",fg="black",bg="white")
L.grid(row=1,column=1)
F = Frame(root)
F.grid(row=2,column=1)
Button(F,text="Open File",command=op).grid(row=1,column=1)
Button(F,text="Read File",command=play).grid(row=1,column=2)
root.mainloop()
--
http://mail.python.org/mailman/listinfo/python-list
How to have python 2 and 3 both on windows?
I have some scripts that are old and won't work under python2 and at the same time I am writing new scripts which will use python3. However, if python 2 and 3 cannot co-exist in a windows box it will be impossible to transition What I try:- remove all pythons and launchers- Use windows installer and install python2 in python27 directory- Use windows installer and install python3 in python310 directory- When installing python3 I opt in to install the launcher- Test with py -2 and py -3 and see that I get the expected prompt- just typing python gets me python2 -- https://mail.python.org/mailman/listinfo/python-list
Re: How to have python 2 and 3 both on windows?
Please excuse the formatting in my previous message. And it is not complete even, so here is the rest of it. What happens after I follow the above steps: - Upon running one of my python 2 scripts (using python2), I see this error: """ ^SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 237-238: truncated \u escape I tried for a bit, but I could not isolate the content of the file that may be causing this problem. But any idea about this problem would be greatly appreciated. Removing python3 solves this issue.. Sunil On Friday, April 22, 2022, 09:09:22 AM PDT, Sunil KR via Python-list wrote: I have some scripts that are old and won't work under python2 and at the same time I am writing new scripts which will use python3. However, if python 2 and 3 cannot co-exist in a windows box it will be impossible to transition What I try:- remove all pythons and launchers- Use windows installer and install python2 in python27 directory- Use windows installer and install python3 in python310 directory- When installing python3 I opt in to install the launcher- Test with py -2 and py -3 and see that I get the expected prompt- just typing python gets me python2 -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to have python 2 and 3 both on windows?
I am happy with how the python starts up. When I use python I get python 2. I am ok with using py -3 for my new scripts, even using the shebang like #!py -3 I don't want to put a unix (or for that matter windows) path in the shebang, as it is not platform portable But the real question/s for me is/are -- Why are my strings being sent to python3, so that I get the unicode related error? -- in other cases I see error pertaining to the print function In my case, I don't own the python2 scripts and so I am not allowed to change any part of them. And I wouldn't need to either, if I can make python 2 and 3 coexist on my system > On 22 Apr 2022, at 17:10, Sunil KR via Python-list wrote: > > I have some scripts that are old and won't work under python2 and at the > same time I am writing new scripts which will use python3. However, if python > 2 and 3 cannot co-exist in a windows box it will be impossible to transition > What I try:- remove all pythons and launchers- Use windows installer and > install python2 in python27 directory- Use windows installer and install > python3 in python310 directory- When installing python3 I opt in to install > the launcher- Test with py -2 and py -3 and see that I get the expected > prompt- just typing python gets me python2 As you have proved you can install many versions of python at the same time on windows. In your scripts set the shebang to run the python version you want. E.g #!/usr/bin/python2 Or #!/usr/bin/python3 The python launcher py.exe will then do the right thing after looking at en shebang line. Also you can edit the INI file of the py.exe launcher to set the defaults the way you want them. Do a search for “py.exe ini” to file the path to the file, I do not have it my finger tips. Tip “py.exe -0” will list the state of installed pythons. Barry > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: How to have python 2 and 3 both on windows?
The question is not one of conversion. The question is this: When I have both python 2 and python3, why is my python 2 script breaking? And when I remove python3 the problem goes away? In both cases (regardless of installing python 3 or not) I am using only python 2 to run the python2 script. Why does the installation of python3 affect the python2, and how can I get them to work without stepping on one another? On Saturday, April 23, 2022, 09:59:46 PM PDT, Dennis Lee Bieber wrote: On Sun, 24 Apr 2022 01:19:38 + (UTC), Sunil KR declaimed the following: > >-- Why are my strings being sent to python3, so that I get the unicode related >error? >-- in other cases I see error pertaining to the print function In python2, the default for strings is BYTES -- you must explicitly ask for unicode (for literals, using u'literal' notation). Python3 strings are, by default, interpreted as unicode (with the encoding for source code [and hence, literals] specified somewhere via a special comment). Getting a normal python2 string requires using the b'literal' notation to indicate /bytes/. Also, in Python2, print is a language statement, not a function. If you have any print statements that do not have ( ) surrounding the output items, it WILL fail in Python3. >In my case, I don't own the python2 scripts and so I am not allowed to change >any part of them. And I wouldn't need to either, if I can make python 2 and 3 >coexist on my system > Even if you are not "allowed to change" those scripts, have you tried feeding them through the 2to3 conversion script just to see what type of changes would be required? https://docs.python.org/3/library/2to3.html -- Wulfraed Dennis Lee Bieber AF6VN [email protected] http://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Verifying I installed Python correctly
cd C:\google-python-exercises> python hello.py this doesn't looks like a valid command. However, is it because a newline got swallowed by misformatting? For clarity, I am reproducing the correct version of the steps: cd /d C:\google-python-exercises python hello.py The error is: The system cannot find the path specified. If the above version of the steps is what you actually performed, I think that by "path" it may be referring to the python command. For the system to be able to find python, its location should be updated in the "PATH" environment variable. If you would rather not distract yourself with modifying the PATH variable you can do what Barry says and just use py, because py is installed in a location already specified in PATH If you want to fix your PATH environment variable there is more than one way to do this and you may find this out by googling, as you may get a better illustrated answer than it would be possible on this forum Sunil On Monday, April 25, 2022, 10:50:52 AM PDT, Greg wrote: I am trying to get Hello World to appear under my directory. The files of *C:\Users\gd752>cd C:\google-python-exercises> python hello.py* *The system cannot find the path specified.* *C:\Users\gd752>cd C:\google-python-exercises>* *The syntax of the command is incorrect.* I installed version 3.10. I am stuck and could use some help. Thx, [image: directory pic.png] -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
