Newbie Question - Breaking a Function into two The Next CEO of Stack OverflowCalling a function of a module by using its name (a string)How to merge two dictionaries in a single expression?How can I do a line break (line continuation) in Python?Convert two lists into a dictionary in PythonHow to flush output of print function?How to return multiple values from a function?Using global variables in a functionLimiting floats to two decimal pointsHow to make a chain of function decorators?How do I concatenate two lists in Python?
Players Circumventing the limitations of Wish
Spaces in which all closed sets are regular closed
Towers in the ocean; How deep can they be built?
Does higher Oxidation/ reduction potential translate to higher energy storage in battery?
It is correct to match light sources with the same color temperature?
Is it correct to say moon starry nights?
Help! I cannot understand this game’s notations!
From jafe to El-Guest
Film where the government was corrupt with aliens, people sent to kill aliens are given rigged visors not showing the right aliens
Can this note be analyzed as a non-chord tone?
TikZ: How to fill area with a special pattern?
What was Carter Burke's job for "the company" in Aliens?
Cannot shrink btrfs filesystem although there is still data and metadata space left : ERROR: unable to resize '/home': No space left on device
The Ultimate Number Sequence Puzzle
Purpose of level-shifter with same in and out voltages
What happened in Rome, when the western empire "fell"?
Defamation due to breach of confidentiality
Vector calculus integration identity problem
What is the process for cleansing a very negative action
(How) Could a medieval fantasy world survive a magic-induced "nuclear winter"?
Does the Idaho Potato Commission associate potato skins with healthy eating?
Is it convenient to ask the journal's editor for two additional days to complete a review?
Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?
IC has pull-down resistors on SMBus lines?
Newbie Question - Breaking a Function into two
The Next CEO of Stack OverflowCalling a function of a module by using its name (a string)How to merge two dictionaries in a single expression?How can I do a line break (line continuation) in Python?Convert two lists into a dictionary in PythonHow to flush output of print function?How to return multiple values from a function?Using global variables in a functionLimiting floats to two decimal pointsHow to make a chain of function decorators?How do I concatenate two lists in Python?
So I am new to python and I have a function that I need to break into two parts. Previously it was one function but after some advice from someone that knows way more than me, I was given the tip that my function did too much, and I need to break it down to two separate things; so here I am.
Below is the code broken into two parts.
I am wondering do I have to mention the pathlist
in both functions?
What this is supposed to do is check if the files exist and then if they do then run the second function to remove the actual directories.
def check_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
remove_directory(pathslist)
dirs_to_delete = [
'C:MyDirectoryPath1',
'C:MyDirectoryPath2',
'C:MyDirectoryPath3'
]
def remove_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
python python-3.x
|
show 1 more comment
So I am new to python and I have a function that I need to break into two parts. Previously it was one function but after some advice from someone that knows way more than me, I was given the tip that my function did too much, and I need to break it down to two separate things; so here I am.
Below is the code broken into two parts.
I am wondering do I have to mention the pathlist
in both functions?
What this is supposed to do is check if the files exist and then if they do then run the second function to remove the actual directories.
def check_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
remove_directory(pathslist)
dirs_to_delete = [
'C:MyDirectoryPath1',
'C:MyDirectoryPath2',
'C:MyDirectoryPath3'
]
def remove_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
python python-3.x
"Do I have to mention the pathlist in both functions?" If you want to perform operations on an input, you sure do.
– esqew
Mar 8 at 17:34
I guess I was second guessing it was able to pull and use the pathlist from the other function or do the directories need to be listed in both spots?
– Jason Lucas
Mar 8 at 17:35
The advice to break this up is vaguely bogus. You should certainly not have identical code in many places.
– tripleee
Mar 8 at 17:38
WhileM
is harmless, you should generally use double backslashes, forward slashes, or raw strings when passing around Windows file names.
– tripleee
Mar 8 at 17:44
@tripleee The advice to break up the code is good; I just don't think OP did it in the best way.
– thumbtackthief
Mar 11 at 13:39
|
show 1 more comment
So I am new to python and I have a function that I need to break into two parts. Previously it was one function but after some advice from someone that knows way more than me, I was given the tip that my function did too much, and I need to break it down to two separate things; so here I am.
Below is the code broken into two parts.
I am wondering do I have to mention the pathlist
in both functions?
What this is supposed to do is check if the files exist and then if they do then run the second function to remove the actual directories.
def check_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
remove_directory(pathslist)
dirs_to_delete = [
'C:MyDirectoryPath1',
'C:MyDirectoryPath2',
'C:MyDirectoryPath3'
]
def remove_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
python python-3.x
So I am new to python and I have a function that I need to break into two parts. Previously it was one function but after some advice from someone that knows way more than me, I was given the tip that my function did too much, and I need to break it down to two separate things; so here I am.
Below is the code broken into two parts.
I am wondering do I have to mention the pathlist
in both functions?
What this is supposed to do is check if the files exist and then if they do then run the second function to remove the actual directories.
def check_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
remove_directory(pathslist)
dirs_to_delete = [
'C:MyDirectoryPath1',
'C:MyDirectoryPath2',
'C:MyDirectoryPath3'
]
def remove_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
python python-3.x
python python-3.x
edited Mar 8 at 17:38
tripleee
95.2k13133189
95.2k13133189
asked Mar 8 at 17:32
Jason LucasJason Lucas
297
297
"Do I have to mention the pathlist in both functions?" If you want to perform operations on an input, you sure do.
– esqew
Mar 8 at 17:34
I guess I was second guessing it was able to pull and use the pathlist from the other function or do the directories need to be listed in both spots?
– Jason Lucas
Mar 8 at 17:35
The advice to break this up is vaguely bogus. You should certainly not have identical code in many places.
– tripleee
Mar 8 at 17:38
WhileM
is harmless, you should generally use double backslashes, forward slashes, or raw strings when passing around Windows file names.
– tripleee
Mar 8 at 17:44
@tripleee The advice to break up the code is good; I just don't think OP did it in the best way.
– thumbtackthief
Mar 11 at 13:39
|
show 1 more comment
"Do I have to mention the pathlist in both functions?" If you want to perform operations on an input, you sure do.
– esqew
Mar 8 at 17:34
I guess I was second guessing it was able to pull and use the pathlist from the other function or do the directories need to be listed in both spots?
– Jason Lucas
Mar 8 at 17:35
The advice to break this up is vaguely bogus. You should certainly not have identical code in many places.
– tripleee
Mar 8 at 17:38
WhileM
is harmless, you should generally use double backslashes, forward slashes, or raw strings when passing around Windows file names.
– tripleee
Mar 8 at 17:44
@tripleee The advice to break up the code is good; I just don't think OP did it in the best way.
– thumbtackthief
Mar 11 at 13:39
"Do I have to mention the pathlist in both functions?" If you want to perform operations on an input, you sure do.
– esqew
Mar 8 at 17:34
"Do I have to mention the pathlist in both functions?" If you want to perform operations on an input, you sure do.
– esqew
Mar 8 at 17:34
I guess I was second guessing it was able to pull and use the pathlist from the other function or do the directories need to be listed in both spots?
– Jason Lucas
Mar 8 at 17:35
I guess I was second guessing it was able to pull and use the pathlist from the other function or do the directories need to be listed in both spots?
– Jason Lucas
Mar 8 at 17:35
The advice to break this up is vaguely bogus. You should certainly not have identical code in many places.
– tripleee
Mar 8 at 17:38
The advice to break this up is vaguely bogus. You should certainly not have identical code in many places.
– tripleee
Mar 8 at 17:38
While
M
is harmless, you should generally use double backslashes, forward slashes, or raw strings when passing around Windows file names.– tripleee
Mar 8 at 17:44
While
M
is harmless, you should generally use double backslashes, forward slashes, or raw strings when passing around Windows file names.– tripleee
Mar 8 at 17:44
@tripleee The advice to break up the code is good; I just don't think OP did it in the best way.
– thumbtackthief
Mar 11 at 13:39
@tripleee The advice to break up the code is good; I just don't think OP did it in the best way.
– thumbtackthief
Mar 11 at 13:39
|
show 1 more comment
1 Answer
1
active
oldest
votes
Not exactly. If you are passing in the entire pathslist to remove_directory
, you're going to try to remove each one whether or not it exists, making your check_directory function unnecessary. I think what you mean is in your check_directory function to only pass the path that exists in to remove_directory:
def check_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
remove_directory(path)
dirs_to_delete = [
'C:MyDirectoryPath1',
'C:MyDirectoryPath2',
'C:MyDirectoryPath3'
]
def remove_directory(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
You may want to try writing a comment for every function you write describing what it does. The second you use the word "and" or an additional verb, that's a hint that you may be better off splitting the function into multiple parts (that's just a rule of thumb, not an absolute). In addition, you want to avoid repeating code--if you have the same lines of code in two separate functions, that's another hint that you need to rethink your design.
Edit: As pointed out in the comments, the way you've written it means that calling check_directory
will remove the directory if it exists. It seems reasonable to expect that someone would call check_directory
for reasons other than wanting to remove it, and you'd be better off having remove_directory
call check_directory
rather than the other way around:
def check_directory(path):
# returns true if path is an existing directory
return os.path.exists(path) and os.path.isdir(path)
def remove_directory(pathlist):
for path in pathlist:
if check_directory(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
3
I've upvoted because you're answering the direct question. A bit out of scope of the topic at hand, but the method namecheck_directory
becomes a bit mis-leading if this were to become part of a bigger project. Someone usingcheck_directory
might be curious to know why it's also deleting the directory they pass in. A better paradigm would be to callcheck_directory()
inremove_directory()
– esqew
Mar 8 at 17:38
@esqew That's a good point.
– thumbtackthief
Mar 8 at 17:39
@thumbtackthief - I edited my code but when calling the function i am getting a error - TypeError: check_directory() missing 1 required positional argument: 'path'
– Jason Lucas
Mar 8 at 19:30
@JasonLucas That means somewhere you're callingcheck_directory
without passing in an argument.
– thumbtackthief
Mar 8 at 19:54
to call the function "check_directory" to start checking for folders do i need to do anything other then check_directory()
– Jason Lucas
Mar 8 at 20:21
|
show 3 more comments
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55068229%2fnewbie-question-breaking-a-function-into-two%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Not exactly. If you are passing in the entire pathslist to remove_directory
, you're going to try to remove each one whether or not it exists, making your check_directory function unnecessary. I think what you mean is in your check_directory function to only pass the path that exists in to remove_directory:
def check_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
remove_directory(path)
dirs_to_delete = [
'C:MyDirectoryPath1',
'C:MyDirectoryPath2',
'C:MyDirectoryPath3'
]
def remove_directory(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
You may want to try writing a comment for every function you write describing what it does. The second you use the word "and" or an additional verb, that's a hint that you may be better off splitting the function into multiple parts (that's just a rule of thumb, not an absolute). In addition, you want to avoid repeating code--if you have the same lines of code in two separate functions, that's another hint that you need to rethink your design.
Edit: As pointed out in the comments, the way you've written it means that calling check_directory
will remove the directory if it exists. It seems reasonable to expect that someone would call check_directory
for reasons other than wanting to remove it, and you'd be better off having remove_directory
call check_directory
rather than the other way around:
def check_directory(path):
# returns true if path is an existing directory
return os.path.exists(path) and os.path.isdir(path)
def remove_directory(pathlist):
for path in pathlist:
if check_directory(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
3
I've upvoted because you're answering the direct question. A bit out of scope of the topic at hand, but the method namecheck_directory
becomes a bit mis-leading if this were to become part of a bigger project. Someone usingcheck_directory
might be curious to know why it's also deleting the directory they pass in. A better paradigm would be to callcheck_directory()
inremove_directory()
– esqew
Mar 8 at 17:38
@esqew That's a good point.
– thumbtackthief
Mar 8 at 17:39
@thumbtackthief - I edited my code but when calling the function i am getting a error - TypeError: check_directory() missing 1 required positional argument: 'path'
– Jason Lucas
Mar 8 at 19:30
@JasonLucas That means somewhere you're callingcheck_directory
without passing in an argument.
– thumbtackthief
Mar 8 at 19:54
to call the function "check_directory" to start checking for folders do i need to do anything other then check_directory()
– Jason Lucas
Mar 8 at 20:21
|
show 3 more comments
Not exactly. If you are passing in the entire pathslist to remove_directory
, you're going to try to remove each one whether or not it exists, making your check_directory function unnecessary. I think what you mean is in your check_directory function to only pass the path that exists in to remove_directory:
def check_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
remove_directory(path)
dirs_to_delete = [
'C:MyDirectoryPath1',
'C:MyDirectoryPath2',
'C:MyDirectoryPath3'
]
def remove_directory(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
You may want to try writing a comment for every function you write describing what it does. The second you use the word "and" or an additional verb, that's a hint that you may be better off splitting the function into multiple parts (that's just a rule of thumb, not an absolute). In addition, you want to avoid repeating code--if you have the same lines of code in two separate functions, that's another hint that you need to rethink your design.
Edit: As pointed out in the comments, the way you've written it means that calling check_directory
will remove the directory if it exists. It seems reasonable to expect that someone would call check_directory
for reasons other than wanting to remove it, and you'd be better off having remove_directory
call check_directory
rather than the other way around:
def check_directory(path):
# returns true if path is an existing directory
return os.path.exists(path) and os.path.isdir(path)
def remove_directory(pathlist):
for path in pathlist:
if check_directory(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
3
I've upvoted because you're answering the direct question. A bit out of scope of the topic at hand, but the method namecheck_directory
becomes a bit mis-leading if this were to become part of a bigger project. Someone usingcheck_directory
might be curious to know why it's also deleting the directory they pass in. A better paradigm would be to callcheck_directory()
inremove_directory()
– esqew
Mar 8 at 17:38
@esqew That's a good point.
– thumbtackthief
Mar 8 at 17:39
@thumbtackthief - I edited my code but when calling the function i am getting a error - TypeError: check_directory() missing 1 required positional argument: 'path'
– Jason Lucas
Mar 8 at 19:30
@JasonLucas That means somewhere you're callingcheck_directory
without passing in an argument.
– thumbtackthief
Mar 8 at 19:54
to call the function "check_directory" to start checking for folders do i need to do anything other then check_directory()
– Jason Lucas
Mar 8 at 20:21
|
show 3 more comments
Not exactly. If you are passing in the entire pathslist to remove_directory
, you're going to try to remove each one whether or not it exists, making your check_directory function unnecessary. I think what you mean is in your check_directory function to only pass the path that exists in to remove_directory:
def check_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
remove_directory(path)
dirs_to_delete = [
'C:MyDirectoryPath1',
'C:MyDirectoryPath2',
'C:MyDirectoryPath3'
]
def remove_directory(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
You may want to try writing a comment for every function you write describing what it does. The second you use the word "and" or an additional verb, that's a hint that you may be better off splitting the function into multiple parts (that's just a rule of thumb, not an absolute). In addition, you want to avoid repeating code--if you have the same lines of code in two separate functions, that's another hint that you need to rethink your design.
Edit: As pointed out in the comments, the way you've written it means that calling check_directory
will remove the directory if it exists. It seems reasonable to expect that someone would call check_directory
for reasons other than wanting to remove it, and you'd be better off having remove_directory
call check_directory
rather than the other way around:
def check_directory(path):
# returns true if path is an existing directory
return os.path.exists(path) and os.path.isdir(path)
def remove_directory(pathlist):
for path in pathlist:
if check_directory(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
Not exactly. If you are passing in the entire pathslist to remove_directory
, you're going to try to remove each one whether or not it exists, making your check_directory function unnecessary. I think what you mean is in your check_directory function to only pass the path that exists in to remove_directory:
def check_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
remove_directory(path)
dirs_to_delete = [
'C:MyDirectoryPath1',
'C:MyDirectoryPath2',
'C:MyDirectoryPath3'
]
def remove_directory(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
You may want to try writing a comment for every function you write describing what it does. The second you use the word "and" or an additional verb, that's a hint that you may be better off splitting the function into multiple parts (that's just a rule of thumb, not an absolute). In addition, you want to avoid repeating code--if you have the same lines of code in two separate functions, that's another hint that you need to rethink your design.
Edit: As pointed out in the comments, the way you've written it means that calling check_directory
will remove the directory if it exists. It seems reasonable to expect that someone would call check_directory
for reasons other than wanting to remove it, and you'd be better off having remove_directory
call check_directory
rather than the other way around:
def check_directory(path):
# returns true if path is an existing directory
return os.path.exists(path) and os.path.isdir(path)
def remove_directory(pathlist):
for path in pathlist:
if check_directory(path):
shutil.rmtree(path)
print(colored('Found ' + path + ' removing', 'green'))
edited Mar 11 at 13:49
answered Mar 8 at 17:36
thumbtackthiefthumbtackthief
2,61252763
2,61252763
3
I've upvoted because you're answering the direct question. A bit out of scope of the topic at hand, but the method namecheck_directory
becomes a bit mis-leading if this were to become part of a bigger project. Someone usingcheck_directory
might be curious to know why it's also deleting the directory they pass in. A better paradigm would be to callcheck_directory()
inremove_directory()
– esqew
Mar 8 at 17:38
@esqew That's a good point.
– thumbtackthief
Mar 8 at 17:39
@thumbtackthief - I edited my code but when calling the function i am getting a error - TypeError: check_directory() missing 1 required positional argument: 'path'
– Jason Lucas
Mar 8 at 19:30
@JasonLucas That means somewhere you're callingcheck_directory
without passing in an argument.
– thumbtackthief
Mar 8 at 19:54
to call the function "check_directory" to start checking for folders do i need to do anything other then check_directory()
– Jason Lucas
Mar 8 at 20:21
|
show 3 more comments
3
I've upvoted because you're answering the direct question. A bit out of scope of the topic at hand, but the method namecheck_directory
becomes a bit mis-leading if this were to become part of a bigger project. Someone usingcheck_directory
might be curious to know why it's also deleting the directory they pass in. A better paradigm would be to callcheck_directory()
inremove_directory()
– esqew
Mar 8 at 17:38
@esqew That's a good point.
– thumbtackthief
Mar 8 at 17:39
@thumbtackthief - I edited my code but when calling the function i am getting a error - TypeError: check_directory() missing 1 required positional argument: 'path'
– Jason Lucas
Mar 8 at 19:30
@JasonLucas That means somewhere you're callingcheck_directory
without passing in an argument.
– thumbtackthief
Mar 8 at 19:54
to call the function "check_directory" to start checking for folders do i need to do anything other then check_directory()
– Jason Lucas
Mar 8 at 20:21
3
3
I've upvoted because you're answering the direct question. A bit out of scope of the topic at hand, but the method name
check_directory
becomes a bit mis-leading if this were to become part of a bigger project. Someone using check_directory
might be curious to know why it's also deleting the directory they pass in. A better paradigm would be to call check_directory()
in remove_directory()
– esqew
Mar 8 at 17:38
I've upvoted because you're answering the direct question. A bit out of scope of the topic at hand, but the method name
check_directory
becomes a bit mis-leading if this were to become part of a bigger project. Someone using check_directory
might be curious to know why it's also deleting the directory they pass in. A better paradigm would be to call check_directory()
in remove_directory()
– esqew
Mar 8 at 17:38
@esqew That's a good point.
– thumbtackthief
Mar 8 at 17:39
@esqew That's a good point.
– thumbtackthief
Mar 8 at 17:39
@thumbtackthief - I edited my code but when calling the function i am getting a error - TypeError: check_directory() missing 1 required positional argument: 'path'
– Jason Lucas
Mar 8 at 19:30
@thumbtackthief - I edited my code but when calling the function i am getting a error - TypeError: check_directory() missing 1 required positional argument: 'path'
– Jason Lucas
Mar 8 at 19:30
@JasonLucas That means somewhere you're calling
check_directory
without passing in an argument.– thumbtackthief
Mar 8 at 19:54
@JasonLucas That means somewhere you're calling
check_directory
without passing in an argument.– thumbtackthief
Mar 8 at 19:54
to call the function "check_directory" to start checking for folders do i need to do anything other then check_directory()
– Jason Lucas
Mar 8 at 20:21
to call the function "check_directory" to start checking for folders do i need to do anything other then check_directory()
– Jason Lucas
Mar 8 at 20:21
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55068229%2fnewbie-question-breaking-a-function-into-two%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"Do I have to mention the pathlist in both functions?" If you want to perform operations on an input, you sure do.
– esqew
Mar 8 at 17:34
I guess I was second guessing it was able to pull and use the pathlist from the other function or do the directories need to be listed in both spots?
– Jason Lucas
Mar 8 at 17:35
The advice to break this up is vaguely bogus. You should certainly not have identical code in many places.
– tripleee
Mar 8 at 17:38
While
M
is harmless, you should generally use double backslashes, forward slashes, or raw strings when passing around Windows file names.– tripleee
Mar 8 at 17:44
@tripleee The advice to break up the code is good; I just don't think OP did it in the best way.
– thumbtackthief
Mar 11 at 13:39