0

Suppose I have the following python "module" named bloop.py:

def f(x):
    return x+1

def a(x):
    return f(x)

How can I make function f(x) unavailable, or unusable, when the script is imported? This means that when the user attempts to do something like the below, it will fail.

import bloop
print bloop.f(10)
Ethan Bierlein
  • 3,353
  • 4
  • 28
  • 42
  • 2
    you can't . . . by convention, if you change the name from `f` to `_f`, that marks it as "private", but python doesn't enforce this. the leading underscore is little more than convention. – mgilson Oct 26 '14 at 00:20
  • You mean, you want bloop.a to succeed (which calls f) but bloop.f to produce some error? May I ask why? – mdurant Oct 26 '14 at 00:21

0 Answers0