Problem installing functools with pip

Hi all,

So, I’ve been trying to come up with a solution to pass parameters with my functions housed in a dictionary. It turns out the answer could be in the functools package. My quest to solve one of my problems has led me straight to another:

PS C:\Users\nmalo\documents\coding\Python\LPTHW\projects\gorthonweb\gorthonweb> pip install functools
Collecting functools
  Using cached
    Complete output from command python egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\nmalo\appdata\local\programs\python\python37\lib\site-packages\setuptools\", line 4, in <module>
        import functools
      File "C:\Users\nmalo\AppData\Local\Temp\pip-install-u0h5o61w\functools\", line 34
        raise TypeError, 'compose expects at least one argument'
    SyntaxError: invalid syntax

Command "python egg_info" failed with error code 1 in C:\Users\nmalo\AppData\Local\Temp\pip-install-u0h5o61w\functools\

I’ve checked out GitHub and Stack Overflow, and it seems as though there isn’t actually a consensus on how to fix this - but it does appear to be a problem specific to python 3.7. I’ve tried updating my setuptoops package to the most recent version, but that didn’t do the trick. Other people are recommending I download other packages that can act as facilitators, but I’d rather not jump down this rabbit hole of installing packages in vain if I don’t have to.

Does anyone have any knowledge on this?

I don’t have a solution to this, but is your Python installed in your main system or in a virtual environment?

Also, out of curiosity, what do you mean by passing parameters with functions housed in a dictionary? You mean that the dict values are function definitions and the keys are the function names? What kind of args/parameters would require functools? Can you post a sample?

Also, what did you use to install Python? Is it ActiveState, Cygwin, Windows Subsystem for Linux (WSL) or something else entirely?

You’re going to scream, but functools is included in python now:

I also believe I used some of this in a few of the LCLive videos, but I might be able to cover this module on Saturday when I do the next class. It could be a good topic and it does solve a few things in the oop code I was working on.

1 Like

Honestly, it could be worse: I only spent a few hours looking into it. And it’s a really good thing that the folks at python included it in 3.7. I was getting so many different answers on all the Stack Overflow threads I looked at. Also, it would have been nice if pip would have just told me I had already satisfied the requirement.

@austen This is a good example of what I’m trying to do, in a way. I’m making a combat system for our web-based game, and I don’t want it to be a bunch of if-statements because that isn’t going to be compatible with the forms I’ll be working with in my template and app.

player_choice = str(input("It's your turn! > "))

So, I’m using this to grab the function call from my dictionary - like this one:

def basic_attack(self, enemy, block):

Only, in the dictionary, I can’t pass these parameters. It’s just going to say they’re undefined. But I also can’t include the function call without the parameters because it’s going to say I’m missing positional arguments.

Here’s another thread I found on the partial class found in the functools package.

Man, you are soooo close to implementing OOP the way Python does it. Did you go through my OOPSchool code and the videos? If you did that, and then used functools to attach the self/dict from my code, you’d mostly have python’s oop. Just a thought dropped in your head.

1 Like

I watched OOPSchool 1, but I made the mistake of doing so at like 11:00 at night. I’ll be watching that again.

Honestly, I could use a break from working on this exercise. And I really need to start watching these seminars. I’ll check them out. I’m always aiming for comprehension, and it’s an added bonus If I can apply it to this exercise.

Thank you!

So, do you have your OOPSchool code anywhere? I’ve made my own module to follow along, so if not I’ll have that.

Yes, I mention it in the blog post

But here it is directly: