If you don't want to use os.chmod and prefer to have the file created with appropriate permissions, then you may use os.open to create the appropriate file descriptor and then open the descriptor:
import os
# The default umask is 0o22 which turns off write permission of group and others
os.umask(0)
descriptor = os.open(
    path='filepath',
    flags=(
        os.O_WRONLY  # access mode: write only
        | os.O_CREAT  # create if not exists
        | os.O_TRUNC  # truncate the file to zero
    ),
    mode=0o777
)
with open(descriptor, 'w') as fh:
    fh.write('some text')
    # the descriptor is automatically closed when fh is closed
Using a custom opener will make things easier and less error-prone. open will generate the appropriate flags for our opener according to the requested mode (w):
import os
os.umask(0)
def opener(path, flags):
    return os.open(path, flags, 0o777)
with open('filepath', 'w', opener=opener) as fh:
    fh.write('some text')
Python 2 Note:
The built-in open() in Python 2.x doesn't support opening by file descriptor. Use os.fdopen instead; otherwise you'll get:
TypeError: coercing to Unicode: need string or buffer, int found.