Response for PING in ircbot.
Got problem with responding for Ping, tried so many ways to response and always end up with time out or other error. This time: ERROR :(Ping timeout: 264 seconds) Traceback (most recent call last): s.send(bytes('PONG ' + data.split()[1], 'UTF-8')) BrokenPipeError: [Errno 32] Broken pipe while True: time.sleep(2) data=s.recv(2040).decode('utf8') data = data.strip("\n\r") print(data) if data.find ("PING :"): s.send(bytes('PONG ' + data.split()[1], 'UTF-8')) -- Thanks -- https://mail.python.org/mailman/listinfo/python-list
Python lunch and file accessing challenges
Hi I'm new to Python and currently taking part in a Data Science course. Python is the main coding/programming language for the course. We were guided to download the Python application through Anaconda which worked. I have been using Jupyther through a browser to practice Python exercises. However anytime we are given an assignment in Python and I download, it doesn't open in Python. How can I lunch Python on my PC and secondly how can I open Python files on my PC. Thank you. David -- https://mail.python.org/mailman/listinfo/python-list
Re: Python lunch and file accessing challenges
On Sun, Jan 31, 2021 at 5:26 AM jackson kwame via Python-list wrote: > > Hi > > I'm new to Python and currently taking part in a Data Science course. Python > is the main coding/programming language for the course. We were guided to > download the Python application through Anaconda which worked. I have been > using Jupyther through a browser to practice Python exercises. However > anytime we are given an assignment in Python and I download, it doesn't open > in Python. > > > How can I lunch Python on my PC and secondly how can I open Python files on > my PC. > I would recommend looking in your Start menu for Idle, for a start. There are quite a few ways to have lunch with Python, although most of them would end up with the python having lunch with you. So I would recommend looking through your course's instructions for how they advise you to run things. Are you supposed to use a text editor and then run a script? Are you supposed to work interactively? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Response for PING in ircbot.
On 30Jan2021 16:50, Bischoop wrote: >Got problem with responding for Ping, tried so many ways to response >and always end up with time out or other error. This time: > >ERROR :(Ping timeout: 264 seconds) >Traceback (most recent call last): >s.send(bytes('PONG ' + data.split()[1], 'UTF-8')) >BrokenPipeError: [Errno 32] Broken pipe This says you're getting EPIPE trying to send. What that means may depend on how your socket was set up, which you do not show. Is it a stream or a datagram, for example? Let's look at the documentation for "send". No, not the docs.python.org documentation, but the underlying system call because the Python socket module is a very thin wrapper for the operating system socket operations. I do not know your operating system, so I'm looking on a Linux system using the command "man 2 send" (which might be spelled "man -s 2 send" on some platforms): Right off the bat it says: The send() call may be used only when the socket is in a connected state (so that the intended recipient is known). The send() call may be used only when the socket is in a onnected state (so that the intended recipient is known). The only difference between send() and write(2) is the presence of flags. With a zero flags argument, send() is equivalent to write(2). Also, the following call send(sockfd, buf, len, flags); is equivalent to sendto(sockfd, buf, len, flags, NULL, 0); where the "NULL, 0" represents "no target address". In Python you have a socket object "s" so that: s.send(... it equivalent to the C code: send(s, ... shown above. So, to your error: you're getting EPIPE (that's the OS error behind BrokenPipeError), and looking in the manual page in the ERRORS section: EPIPE The local end has been shut down on a connection oriented socket. In this case, the process will also receive a SIGPIPE unless MSG_NOSIGNAL is set. and in BUGS: Linux may return EPIPE instead of ENOTCONN. so also looking for ENOTCONN: If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET) socket, the arguments dest_addr and addrlen are ignored (and the error EISCONN may be returned when they are not NULL and 0), and the error ENOTCONN is returned when the socket was not actually connected. and again in the ERRORS section: ENOTCONN The socket is not connected, and no target has been given. We're back to: what kind of socket it this? A datagram socket (eg UDP) normally requires a target address, typically the address from which you received the first packet (the ping). A stream connection (eg TCP) needs to be connected. If you're got a stream connection, getting a message implies that the connection has been established, and maybe the connection was closed before you sent your reply. More detail needed, particularly: how is the socket set up, and what's doing the sending of the "ping"? Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: idlelib re-use
Am 28.01.21 um 20:57 schrieb Terry Reedy: On 1/28/2021 5:53 AM, Robin Becker wrote: I googled in vain for instances where parts of idlelib are re-used in a simplistic way. I would like to use the editor functionality in a tkinter window and also probably run code in a subprocess. Are there any examples around that do these sorts of things? turtledemo reuses IDLE's colorizer and read-only textviews. I have seen occasional hints on stackoverflow of other such uses. One barrier to reuse is that the parts are highly interconnected, with numerous import loops. (Changing the form of some imports from 'import x' to 'from x import y' can make IDLE startup fail.) Some objects, like EditorWindow, are too monolithic. You cannot put a toplevel inside another toplevel. Yes, you can. There are two possiblities, the one is converting the toplevel into a frame with wm_forget(), after which you can simply pack it into another frame. The second one is configuring a frame as a container, which allows to even embed a window from a foreign application. I'm not sure this works on all platforms, though. Christian -- https://mail.python.org/mailman/listinfo/python-list