ncraike / fang

Dependency injection system for Python
MIT License
15 stars 1 forks source link

Getting error TypeError: unsupported operand type(s) for &: 'list' and 'list' #13

Open sbansal6 opened 7 years ago

sbansal6 commented 7 years ago

Running the example code:-

import fang

di = fang.Di(namespace='.com.example.myproject')

@di.dependsOn('multiplier') def multiply(n): '''Multiply the given number n by some configured multiplier.''' multiplier = di.resolver.unpack(multiply) return multiplier * n

providers = fang.ResourceProviderRegister(namespace='.com.example.myproject')

@providers.register('multiplier') def give_multiplier(): '''Give a multiplier of 2.''' return 2

def main():

Here at our program entry-point, we configure what set of providers

# will be used to meet our dependencies
di.providers.load(providers)
# Prints 10
print(multiply(5))

if name == 'main': main()

ncraike commented 7 years ago

Hi @sbansal6.

Sorry for taking a bit to reply on this. I had a busy few days, and this is a hobby project for me.

I'm having trouble reproducing the TypeError you gave above.

How are you running the code above? Did you copy and paste it from the GitHub page? And how have you installed Fang? Do you install Fang with pip install fang? Are you running Python 3.3 or later?

The repository contains a copy of the example code in examples/introduction.py, so if you have cloned the repository and have Fang installed, the easiest way to test that example is by running python3 examples/introduction.py.

If I run that in my terminal, I get output like:

$ python3 examples/introduction.py
10

The example code just outputs 10.

I'm happy to help you debug the problem further. Would you mind posting what operating system you're using (Windows, macOS, Linux)? And the output of python3 --version and pip show fang?

ncraike commented 7 years ago

@sbansal6 Are you running this with Python 2?

sbansal6 commented 7 years ago

yes , i am using python 2.7

On Feb 19, 2017 4:15 PM, "Nathan Craike" notifications@github.com wrote:

@sbansal6 https://github.com/sbansal6 Are you running this with Python 2?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ncraike/fang/issues/13#issuecomment-280961697, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2DZ5V7Mwr_gmDt7lHlnZOY5ohJKdwcks5reNsHgaJpZM4L_1iB .

ncraike commented 7 years ago

Okay. Fang actually requires Python 3.4 or later.

I expected that the packaging settings I have in setup.py would prevent you installing Fang on Python 2.7, but maybe that is not the case.

How did you install Fang on your system?