Personal tools
Document Actions

FAQs

View entire FAQ in full Up to table of contents
Frequently Asked Questions

Python

Get IP using Python

How to get IP address of my computer?

import socket
socket.gethostbyname(socket.gethostname())
socket.gethostbyname_ex(socket.gethostname())

How to lock a file

How can I lock a file, so that other user can't modify it?

Use mmap

see documant at

http://docs.python.org/lib/module-mmap.html

password

How do I check unix password?

import pwd, crypt

def login(user, password):
"Check if user would be able to login using password"
try:
pw1 = pwd.getpwnam(user)[1]
pw2 = crypt.crypt(password, pw1[:2])
return pw1 == pw2
except KeyError:
return 0 # no such user

user = raw_input("username:")
password = raw_input("password:")

if login(user, password):
print "welcome", user
else:
print "login failed"

webbrowser.open Firefox 3 Issue

Problem with Pmv help link button?

On Linux with the latest Firefox 3 when you click to open help link bme.pngthere is a following issue:

http://bugs.python.org/issue1911

This FAQ applies to: 1.5.4

by Sargis Dallakyan last modified 2007-07-09 17:20 Molecular Graphics Laboratory, TSRI

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: