Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Michael Selik Newsgroups: comp.lang.python Subject: Re: [Q] ImportError by __import__() on Python >= 3.4 Date: Thu, 02 Jun 2016 14:15:45 +0000 Lines: 13 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de K0ekR5NeUACYF0Jn8VQRVwHcUyOW+yNkNYKmQ2zV5hKA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; 'subject:Python': 0.05; 'exit': 0.07; "'w')": 0.09; 'block.': 0.09; 'flush': 0.09; 'thu,': 0.15; '2016': 0.16; '``with``': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'subject:] ': 0.19; 'to:name:python-list@python.org': 0.20; 'to:2**1': 0.21; 'file.': 0.22; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'statement': 0.32; 'file': 0.34; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'question,': 0.35; 'but': 0.36; 'received:209.85': 0.36; "wasn't": 0.36; 'to:addr:python-list': 0.36; 'received:209': 0.38; 'received:209.85.220': 0.38; 'to:addr:python.org': 0.40; 'your': 0.60; 'close': 0.61; 'kuwata': 0.84; 'makoto': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=22VezkgrX3+mDiOM034+313cFKVgKHB5tSLoZiAjC5I=; b=LNpUJ4iZKPl9ADhjsO1LD154dQuUKHQB2/7taOnRUXRyF1xsax+fMxdZ/ouDFdhJid MsXfRMXYV9RrlAEyGZVLjTLQUbYYIj+d8JiGauJI0tn3+1JWPUDtaPFupPOe6Z6ZF7m6 lLEZyQs7HqN2ip0U0ae7VH3hOT6guoz1KGjb3ZYwI5T4TYYTxL5Q/lmy2FdcXIHT8r3o ViIBxehTmUmOoXYcNxU/mtY7K9GRRWSytL6Add+iKhGQ1t0HcEtB5jrr2XLMvcrp4Gyx MRgzQLzv+ov4oRdQSBUbK2g3bQOoycJhz6sMrE/h28KU/eGsbQKkvRgMNVeNqIehT6As K8zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=22VezkgrX3+mDiOM034+313cFKVgKHB5tSLoZiAjC5I=; b=C+kW6EmgYza/9K4jVQcX7UgZYRR0nDaK8TnEMZ2vi/vfsLu6ppvE7lRIw6QqphntXG 49uVXKh6t4a/1NxEAs9SCm+T+XHJ5G8GoQIPkDAco6ih5yBcTLf7Oq1kFVrFmMAd2aK3 yk60JpV7ROZN+Q0S8PqJqnzVePK/U4fu71GyxfKqPLD5mhSJgX3L2XunwO7hyW23e1pb RTtpmtt6bZp7IrXRHJPeignNW//HotEA1DCa6EKhalms3Vm9pN6VQ+13FLYcBn+rNPfJ eZfUaNCpKSGdpKkjHZ8zjmgoX0Kq4cA+e/vACwOUvUasORjXoFaxJx++CQhXgG+AJOks 4peQ== X-Gm-Message-State: ALyK8tKttjtOGeP4RW5l9qjsbR+incd9WxVU/Va9glMrTRobC/GSt3IQjvIhPtGr4EiksQc3I2eiIJB5fcmRyw== X-Received: by 10.55.151.199 with SMTP id z190mr42035519qkd.172.1464876954926; Thu, 02 Jun 2016 07:15:54 -0700 (PDT) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:109369 On Thu, Jun 2, 2016 at 10:06 AM Makoto Kuwata wrote: > os.mkdir(name) > with open(name + "/__init__.py", 'w') as f: > f.write("X=1") > f.flush() > > Please give me any advices or hints. > This wasn't your question, but you don't need to flush the file. The ``with`` statement will automatically flush and close your file for you after you exit the block.