Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Quick reddit account migration script

Hey everyone, I haven't touched python in a while so I wanted to program a little script to migrate to a new account and wipe the old one (I'm a little paranoid about anonymity). Figured I would post it in hopes of some tips or critique, and maybe someone will find it useful. I also apologize if this isn't the right sub for this, didn't know where to post

import praw
#Account Migration Script
#By:/u/letmelive123
#Date:6/24/2017

#Warning! Using this script will entirely wipe the parent Account.
#To use input accounts and body to replace comments with
#parentAcc is the account being wiped
#secAcc is the account you are moving to
#body is the text that will replace all comments on parentAcc


#This function will transfer new multireddits to the target account.
#Note:We convert 'multi' to str and partition it to extract the multireddit name
#This is because parentAcc.user.multireddits() returns a list of paths to multireddits
def transferMultis():
for multi in parentAcc.user.multireddits():
s = str(multi)
parentAcc.multireddit(name=s.partition("/m/")[2], redditor=parentAcc.user.me()).update(visibility='public')
secAcc.multireddit(name=s.partition("/m/")[2], redditor=parentAcc.user.me()).copy(display_name=None)
parentAcc.multireddit(name=s.partition("/m/")[2],redditor=parentAcc.user.me()).delete()


#This function will transfer new multireddits to the target account.
def transferSubs():
for sub in parentAcc.user.subreddits():
s = str(sub)
secAcc.subreddit(s).subscribe()
parentAcc.subreddit(s).unsubscribe()

#This function will clean the comments of parentAcc.
def wipeComments(body):
for comment in parentAcc.redditor(name=str(parentAcc.user.me())).comments.top(time_filter='all'):
comment.edit(body)


###WARNING###
#This Account will be wiped
###WARNING###
#Parent Account
parentAcc = praw.Reddit(client_id='',
client_secret='',
password='k',
user_agent='AccMigrate by /u/letmelive123',
username='')

#Secondary Account
secAcc = praw.Reddit(client_id='',
client_secret='',
password='',
user_agent='AccMigrate by /u/letmelive123',
username='')

#Body for replacing comments
body="Test"

print("Hello welcome to AccMigrate.")
print("Please note wiping comments does take some time.")

transferMultis()
transferSubs()
wipeComments(body) print("done")


/r/Python
https://redd.it/6j6rpp
Rendering template - URL hash suddenly disappeared?? very weird issue

Hey guys, something a bit weird happened to me today.

So while working on my user account route, which uses tabs navigated by hash for users to see different sections, for example

/account#general-settings

etc

My route to go there was simply

@app.route("/account")
@login_required
def account():
return render_template('user_account.html', title="Account")

anyway, I was having it work, where in Javascript, I did window.location.hash and the hash would come up like general-settings - all good.

in the HTML my routes to go to are set up like so

<a class="list-group-item list-group-item-action active" data-toggle="list" href="#account-general">General</a>
<a class="list-group-item list-group-item-action" data-toggle="list" href="#account-info">Plan Information</a>
<a class="list-group-item list-group-item-action" data-toggle="list" href="#account-notifications">Notifications</a>
<a class="list-group-item list-group-item-action" data-toggle="list" href="#account-change-password">Change password</a>
<a class="list-group-item list-group-item-action" data-toggle="list" href="#account-billing">Billing</a>


and yet when I click on one of these, the page does change, and I see the other list, but the URL and hash does not change...


now I

/r/flask
https://redd.it/9ykef7