0

I have a python program that creates a numbered list up to the value i enter I have tried using new-alias numberlist "python C:\path\to\file\numberlist.py" to do this but it returns the error

numberlist : The term 'python C:\path\to\file\numberlist.py' is not recognized as the name of a cmdlet, function, script file, or operable program

Does anyone know what I can do to make this work on PowerShell?

Mathias
  • 73
  • 1
  • 8
  • Do you mean this `alias new="python C:\path\to\file\numberlist.py"`? – rish_hyun Feb 06 '21 at 18:19
  • No. I would like the name to be numberlist still. and new-alias is what i have used to create a new alias – Mathias Feb 06 '21 at 18:22
  • 1
    In short: Unlike in POSIX-compatible shells such as `bash`, you _cannot include pass-through arguments_ in a PowerShell alias definition - you need a _function_ for that. PowerShell aliases are simply _alternative names_ for other commands, with no ability to "bake in" arguments - see the [linked duplicate](https://stackoverflow.com/q/55539278/45375). Therefore: `function numberlist { python C:\path\to\file\numberlist.py @args }` – mklement0 Feb 06 '21 at 18:29
  • Glad to hear it was helpful, @Mathias. – mklement0 Feb 06 '21 at 20:59
  • @mklement0, this should've been an answer. It just saves my day. – MrCrHaM Oct 29 '22 at 03:09
  • Glad to hear it, @MrCrHaM, but answers already exist: please see the linked duplicates. – mklement0 Oct 30 '22 at 06:02

0 Answers0