Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python 3 from command line
#1
Can't figure out why I cannot run these two small scripts from the command line. Pasted below is a copy of the results I get. It did work at a point in time, but I am doing something wrong that I haven't been able to dope out.

C:\Users\Dixon\mymodules>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> search4vowels('abcde')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'search4vowels' is not defined
>>> quit()

C:\Users\Dixon\mymodules>type search4vowels
The system cannot find the file specified.

C:\Users\Dixon\mymodules>dir
Volume in drive C is Windows
Volume Serial Number is 7478-065A

Directory of C:\Users\Dixon\mymodules

02/14/2020 05:40 PM <DIR> .
02/14/2020 05:40 PM <DIR> ..
02/14/2020 05:23 PM 308 vsearch.py
1 File(s) 308 bytes
2 Dir(s) 452,053,323,776 bytes free

C:\Users\Dixon\mymodules>type vsearch.py
(# -*- coding: utf-8 -*-
"""
Created on Fri Feb 14 17:13:51 2020

@author: -
"""

def search4vowels(phrase:str) -> set:
vowels = set('aeiou')
return vowels.intersection(set(phrase))

def search4letters(phrase: str, letters: str) -> set:
return set(letters).intersection(set(phrase))

C:\Users\Dixon\mymodules>

Here's what happens when I 'import' the module vsearch.py

C:\Users\Dixon\mymodules>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import vsearch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Dixon\mymodules\vsearch.py", line 8
def search4vowels(phrase:str) -> set:
^
SyntaxError: invalid syntax
>>>
Reply


Messages In This Thread
python 3 from command line - by Dixon - Mar-01-2020, 05:27 PM
RE: python 3 from command line - by snippsat - Mar-01-2020, 08:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Command line argument issue space issue mg24 5 1,353 Oct-26-2022, 11:05 PM
Last Post: Yoriz
  accept command line argument mg24 5 1,350 Sep-27-2022, 05:58 PM
Last Post: snippsat
  multi-line CMD in one-line python kucingkembar 5 4,003 Jan-01-2022, 12:45 PM
Last Post: kucingkembar
  Accessing varying command line arguements Rakshan 3 2,067 Jul-28-2021, 03:18 PM
Last Post: snippsat
  How to input & output parameters from command line argument shantanu97 1 2,587 Apr-13-2021, 02:12 PM
Last Post: Larz60+
  Passing List of Objects in Command Line Python usman 7 3,212 Sep-27-2020, 03:45 PM
Last Post: ndc85430
  Taking Multiple Command Line Argument Input bwdu 6 4,073 Mar-29-2020, 05:52 PM
Last Post: buran
  Running linux command line apps... dbrdh 0 1,663 Jan-30-2020, 01:14 PM
Last Post: dbrdh
  Python convert multi line into single line formatted string karthidec 2 9,464 Dec-23-2019, 12:46 PM
Last Post: karthidec
  command line input (arg parse) and data exchange Simba 7 4,341 Dec-06-2019, 11:58 PM
Last Post: Simba

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020