Git Product home page Git Product logo

Comments (9)

ehmatthes avatar ehmatthes commented on July 29, 2024 1

I'm glad we got that sorted. :)

I see numbers in there. There's a module in the Python standard library named numbers.py. If you end up needing that module, or using a library that depends on that module, this can cause some bugs that can be hard to sort out. You might consider renaming that file.

I'll admit I had a file called numbers.py in the first edition of PCC, and it caused some issues for some readers. 🤦

from pcc_3e.

ehmatthes avatar ehmatthes commented on July 29, 2024

Thank you for letting me know. I believe your system recognizes .py files as executable files, and knows where to find the Python interpreter when it needs to run a .py file.

from pcc_3e.

MarOPhotos avatar MarOPhotos commented on July 29, 2024

Yes, was a little bit frustrating when I can’t even execute the first “Hello world” assignment. Almost grabbed me a book of py for dummies. This is for those who shall share my similar faith and to never give up 😁
Thank you for responding Eric.

from pcc_3e.

ehmatthes avatar ehmatthes commented on July 29, 2024

Are you saying this worked:

> hello_world

But this did not:

> python hello_world.py

Or was it this?

> python hello_world

from pcc_3e.

MarOPhotos avatar MarOPhotos commented on July 29, 2024

The second one.
python hello_world

from pcc_3e.

ehmatthes avatar ehmatthes commented on July 29, 2024

Okay, that's interesting. Are you sure you saved your file as hello_world.py, and not hello_world?

For a simple script like hello world, the .py extension isn't always needed:

~/test_code/py_ext_tester$  ls -alh     
-rw-r--r--    1 eric  staff    23B May  3 08:31 hello
-rw-r--r--    1 eric  staff    23B May  3 08:31 hello.py
-rw-r--r--    1 eric  staff    23B May  3 08:34 hello.txt
~/test_code/py_ext_tester$  python hello.py
Hello world!
~/test_code/py_ext_tester$  python hello.txt
Hello world!
~/test_code/py_ext_tester$  python hello
Hello world!

This example is on macOS, but the same thing should apply to Windows.

It gets confusing because file browsers such as Windows Explorer used to show all file extensions by default. Now they tend to hide extensions unless you configure them to show all extensions. So you might see hello_world in Explorer, but it might actually be hello_world.py. Even more confusing, people will sometimes see hello_world.py in Explorer, when the file is actually named hello_world.py.py!

You can check the filename definitively in the terminal with the dir command. Can you run dir in the directory where your hello world file is saved, and share the output?

from pcc_3e.

MarOPhotos avatar MarOPhotos commented on July 29, 2024

That is a good point. I’ll check the file name when i get home later and share the output. I remember saving it as hello_world.py from the vs window though it dropped the .py when it went windows to save as i recall but i did not put much thought to that as my default does not show the file extensions.

from pcc_3e.

MarOPhotos avatar MarOPhotos commented on July 29, 2024

C:\Users\marop\OneDrive\Desktop\python_work>dir
Volume in drive C is BOOTCAMP
Volume Serial Number is 0246-9FF7

Directory of C:\Users\marop\OneDrive\Desktop\python_work

05/03/2024 04:39 AM

.
05/03/2024 04:39 AM ..
05/01/2024 05:15 PM .vscode
05/01/2024 09:49 PM 399 bicycles
05/03/2024 04:39 AM 1,235 Cars
05/01/2024 06:05 PM 182 hello_world
05/03/2024 05:20 AM 589 lapamilya.py
05/01/2024 06:12 PM 172 mensahe.py
05/01/2024 09:22 PM 433 name.py
05/01/2024 07:04 PM 249 name_cases.py
05/01/2024 07:10 PM 392 name_quotes
05/01/2024 09:21 PM 223 numbers
05/01/2024 09:32 PM 13 Zen_Python
10 File(s) 3,887 bytes
3 Dir(s) 422,718,844,928 bytes free

C:\Users\marop\OneDrive\Desktop\python_work>/test_code/py_ext_tester$ ls -alh
'
' is not recognized as an internal or external command,
operable program or batch file.

from pcc_3e.

MarOPhotos avatar MarOPhotos commented on July 29, 2024

You're right. Apparently, I saved it as hello_world, and not hello_world.py

from pcc_3e.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.