boB

boB

Practical Programming, Third Edition: Statement about current working directory on p. 177 is incorrect.

On page 177 the authors state: “…When you run a Python program, the current working directory is the directory where that program is saved…” This is incorrect. The current working directory will be whatever the current directory is from which the program is started. For instance the following demonstrates this:


import os

print(“Testing!”)
print("Current working directory: ", os.getcwd())
print("Source code file: ", file)
with open(‘test_text.txt’) as f:
print(f.read())

PS C:> Users\boB\Practical_Programming\testing.py # NOT the
program directory.
Testing!
Current working directory: C:
Source code file: C:\Users\boB\Practical_Programming\testing.py
Traceback (most recent call last):
File “C:\Users\boB\Practical_Programming\testing.py”, line 6, in
with open(‘test_text.txt’) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘test_text.txt’
PS C:> cd .\Users\boB\Practical_Programming
PS C:\Users\boB\Practical_Programming> .\testing.py # Now in the
program’s folder.
Testing!
Current working directory: C:\Users\boB\Practical_Programming
Source code file: C:\Users\boB\Practical_Programming\testing.py
This is just a plain text file of no import.
This is the second line of a boring file.

Cheers!
boB Stepp

Popular Prag Prog topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
herminiotorres
Hi! I know not the intentions behind this narrative when called, on page XI: mount() |> handle_event() |> render() but the correc...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
New
tkhobbes
After some hassle, I was able to finally run bin/setup, now I have started the rails server but I get this error message right when I vis...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New

Other popular topics Top

New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
New

Latest in PragProg

View all threads ❯