[Tutor] sound implementation problems
Dave Angel
davea at davea.name
Fri Jun 14 06:53:32 CEST 2013
On 06/13/2013 11:55 PM, Jim Mooney wrote:
> Alan Gauld <alan.gauld at btinternet.com>
>
> That's a dodgy way to solve the problem since if you change IDE or run the
>> program outside the IDE that startup script will likely get forgotten and
>> not be used. Remember you are not expected to use
>> an IDE for anything other than developing the code, its not
>> intended to be a runtime environment. Relying on the IDE is
>> a bad habit to develop.
>>
>
> Got me already ;') I reinstalled Py2.7 since there are too many things not
> available yet for Py3.3 - but I know which one is loading at the command
> line since I specify Python2.7 or Python3.3 (The Activestate dist copies
> and renames one of the Pys so that's clear
Renames one of what "Pys" ?
> - I just went and copied and
> renamed the other - along with pip) My IDE startup script has been changed
> to also go to the proper working directory.
What IDE would that be?
>
> BUT - Py 3.3 at the command prompt
Do you mean Py 3.3.bat ? With a space in the program name, even? Or
something else?
> uses my 3.3 working directory, and Py
> 2.7 ALSO uses the 3.3 working directory, which is not what I want,
Then why did you write those batch files to change directories at all?
What's wrong with getting the current directory from <big pause> "the
actual current directory" ?
> obviously. Those are two different sets of scripts that won't always play
> together.
>
> Is there a way to set up each different interpreter, either Py 3.3 or Py
> 2.2, to automatically change to a particular working directory when you
> call it - with a command line switch for instance? I can os.chdir after it
> starts, of course, but that's a drag and I'll forget to do it at some
> point.
So you're intending that all the 2.7 scripts you write will use the same
current directory? Regardless of the wishes of the author/user?
If I can do that from the call to Python I can make a batch file for
> each one, with two different names - and easy typing ones like Py27 and
> Py33 ;')
>
> I see one possible candidate in python --help
> -c cmd : program passed in as string (terminates option list)
>
> But what does "program passed in as a string(terminates option list)" mean?
> How do I stringify import os > os.chdir('my directory') ? That's unclear to
> me.
>
> Speaking of Py distributions I used ActiveState for various reasons, but I
> looked at Enthought Canopy and was really annoyed. You can go over their
> entire website and they don't tell you which Python version it's for - 2.7
> and 3.3 being a bit different. It's almost like they hide it. ActiveState
> makes it clear so I used them. I'm pretty sure Canopy is for 2.7 but I'm
> not going to do a huge download on a slow connection when they don't tell
> you.
>
>
I don't understand your problem at all. Current directory should nearly
always be decided by the user of the code, and should have nothing to do
with either the location of the interpreter or the location of the
script. And in the 1% of scripts where you cannot figure out how to work
with that, you can add the two lines to the beginning of the script.
(And lots more lines to the documentation for the script)
As for how the unknown IDE decides what to make the current directory
when running a particular script, that presumably is the job of the
project file. If it forces all scripts to run in the same directory,
then contact the author and ask for an update.
As others have said, many times the files your script wants to
manipulate will go in locations determined at run time, and not relative
to the current directory. The current directory should only be used as
a target (if at all) for those files you the user wants to create
explicitly. In that case, he decides their location by switching to
that directory.
What I really detest (as a user) is programs that allow me to specify
the filename, but won't let me specify a complete path, instead making
their own decision on file path. So filename completion won't work, and
any intuitive understanding of where this named file will go goes up in
smoke.
--
DaveA
More information about the Tutor
mailing list