Posts

Network programming in python with examples

GETING A HOST NAME >>> import socket >>> host_name = socket.gethostname() >>> print ("Host name: %s" %host_name) >>> print ("IP address: %s",host_name) GETTING A HOST NAME WITH A FUNCTION DEFINITION import socket def print_machine_info():      host_name = socket.gethostname()      ip_address = socket.gethostbyname(host_name)      print ("Host name: " ,host_name)      print ("IP address: " ,ip_address) if __name__ == '__main__':      print_machine_info() The hostname is what you assigned to your computer when you configured your operating system. This output will be different on your machine depending on the system's host configuration. Here hostname indicates where the Python interpreter is currently executing. Retrieving a remote machine's IP address If you need to know the IP address of a remote machine, you can use a built-in library function, gethostbyname(). In this c...

PYTHON PROGRAMMING IN AND OUT

Image
PYTHON FOR ALL   Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to be highly readable. It uses English keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages. Python is Interpreted − Python is processed at runtime by the interpreter. You do not need to compile your program before executing it. This is similar to PERL and PHP. Python is Interactive − You can actually sit at a Python prompt and interact with the interpreter directly to write your programs. Python is Object-Oriented − Python supports Object-Oriented style or technique of programming that encapsulates code within objects. Python is a Beginner's Language − Python is a great language for the beginner-level programmers and supports the development of a wide range of applications from simple text processing to WWW browsers to games. Python is an open-source and cross-platform pro...