Download and print reddit page which can be redirected to file I wanted to save the a reddit thread to a .org file. I noticed that it is easier to use pandoc to convert .md to .org (esp when it comes to list items).
My code prints the output to the screen which can be redirected to the required file.
Process is as follows.
python reddit_download.py -u &lt;url_to_download&gt; &gt; myfile.md
pandoc -s myfile.md -o myfile.org

My script
reddit_config.py
class Config:
    client_id = 'myID'
    client_secret = 'mySecret'
    password = 'my_password'
    user_agent = 'my_user_agent'
    username = 'my_username'

reddit_download.py
import argparse
import praw
from reddit_config import Config


def reddit():
    red = praw.Reddit(client_id=Config.client_id,
                      client_secret=Config.client_secret,
                      user_agent=Config.user_agent,
                      username=Config.username,
                      password=Config.password)
    return red


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('-u', '--url', required=True, help='URL required', dest='url')
    return parser


def get_full_page(reddit_instance, url):
    post = reddit_instance.submission(url=url)

    page = [{
        # content of post
        &quot;id&quot;: post.id,
        &quot;parent&quot;: post.id,
        &quot;body&quot;: post.selftext,
        &quot;author&quot;: post.author.name,
        &quot;ups&quot;: post.ups,
        &quot;title&quot;: post.title
    }]

    # all comments/replies
    list_of_comments = post.comments.list()
    list_of_comments_with_desired_attributes = [{
            &quot;id&quot;: comment.id,
            &quot;parent&quot;: comment.parent_id.replace('t1_', '').replace('t3_', ''),
            &quot;body&quot;: comment.body,
            &quot;author&quot;: comment.author.name,
            &quot;ups&quot;: comment.ups
        }
        for comment in list_of_comments
    ]

    page += list_of_comments_with_desired_attributes

    return page


def lookup(loc):
    comment_lookup = dict()
    for comment in loc:
        comment_id = comment[&quot;id&quot;]
        if comment_id != comment[&quot;parent&quot;]:
            parent_id = comment[&quot;parent&quot;]
            children = comment_lookup.get(parent_id)
            if not children:
                children = comment_lookup[parent_id] = list()
            children.append(comment.copy())
        else:
            parent = comment.copy()
    return parent, comment_lookup


def hierarchy(parent_element, comment_lookup):
    parents = comment_lookup.get(parent_element[&quot;id&quot;], list())
    for parent in parents:
        hierarchy(parent, comment_lookup)
    if parents:
        parent_element['children'] = parents
    return parent_element


def org(post_dict, parent_id, visited=None, depth=1):
    if visited is None:
        visited = set()
    visited.add(parent_id)
    print('#'*depth, post_dict.get('ups'), post_dict.get('author'), end='\n\n')
    title = post_dict.get('title')
    if title is not None:
        print(post_dict.get('title', ''), end='\n\n')
    print(post_dict.get('body'), end='\n\n')
    children = post_dict.get('children')
    if children is not None:
        for child in children:
            if child.get('id') not in visited:
                org(child, child.get('id'), visited, depth+1)
    return ''


if __name__ == '__main__':
    parser = parse_args()
    args = parser.parse_args()
    reddit = reddit()
    page = get_full_page(reddit, args.url)
    parent, comment_lookup = lookup(page)
    post = hierarchy(parent, comment_lookup)
    post_id = post.get('id')
    org(post, post_id)

Is there a way to improve this code? I am confused how to remove the print statements and build a string to write to a file. Effectively I don't have to redirect the output in shell to a file.
Configuration
Your reddit_config.Config needs to be changed so that, rather than hard-coded strings in a Python module, these are externalized to environment variables, or a permissions-restricted configuration file.
List construction alternatives
There are some alternatives to your concatenate-and-return in get_full_page: you can either make this a generator function -
    yield {
        # content of post
        &quot;id&quot;: post.id,
        &quot;parent&quot;: post.id,
        &quot;body&quot;: post.selftext,
        &quot;author&quot;: post.author.name,
        &quot;ups&quot;: post.ups,
        &quot;title&quot;: post.title
    }
    # ...
    yield from (
        {
            &quot;id&quot;: comment.id,
            &quot;parent&quot;: comment.parent_id.replace('t1_', '').replace('t3_', ''),
            &quot;body&quot;: comment.body,
            &quot;author&quot;: comment.author.name,
            &quot;ups&quot;: comment.ups
        }
        for comment in list_of_comments
    )

or you can star-expand -
return [
    {
        # content of post
        &quot;id&quot;: post.id,
        &quot;parent&quot;: post.id,
        &quot;body&quot;: post.selftext,
        &quot;author&quot;: post.author.name,
        &quot;ups&quot;: post.ups,
        &quot;title&quot;: post.title
    },
    *(
        {
            &quot;id&quot;: comment.id,
            &quot;parent&quot;: comment.parent_id.replace('t1_', '').replace('t3_', ''),
            &quot;body&quot;: comment.body,
            &quot;author&quot;: comment.author.name,
            &quot;ups&quot;: comment.ups
        }
        for comment in list_of_comments
    ),
]

Truthy lists
Your
if not children

is too broad. This statement will pass if children == [], which it doesn't need to - instead, consider
if children is None:

or better yet, replace this whole mechanism with a defaultdict.
Unused return
org() returns '', which both has no meaning and is unused, so you can just delete that line.