Hack Forums
[Python] Python Sources (Newbie) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Python Sources (Newbie) (/showthread.php?tid=6123285)



Python Sources (Newbie) - Alern - Nov 24, 2020

github.com/TigerNetv/TigerBOX-v0.01 (TigerBox - Network Scanner, Proxy Scraper, IPTool, Password Generator)
github.com/TigerNetv/LeakME (LeakME - Search engine like leakedsource)
Please review my codes :)


RE: Python Sources (Newbie) - ViperCode - Nov 24, 2020

Hey cool release regarding the TigerBox one, useful little stuff packed into one.
I'd say try building onto it to advance your skills and also build a even cooler project while doing it :D


RE: Python Sources (Newbie) - Alern - Nov 24, 2020

(Nov 24, 2020 03:25 PM)ViperCode Wrote:  Hey cool release regarding the TigerBox one, useful little stuff packed into one.
I'd say try building onto it to advance your skills and also build a even cooler project while doing it :D

Thanks so much ! :)


RE: Python Sources (Newbie) - tux1 - Nov 25, 2020

Looks interesting and thanks for sharing your code with the community.

I had a brief look through the code, just fyi when opening files with the 'with' operator it closes them automatically when it exits the code block.
PHP Code

<?php 
        with open
('all_proxies.txt', 'wb') as f:
            f.write(alltypes.content)
        print("Proxies saved!")
        #f.close() #you can remove this 
https://lerner.co.il/2015/01/18/dont-use-python-close-files-answer-depends/


RE: Python Sources (Newbie) - G.P.D. - Nov 25, 2020

Your code looks great.
As tux1 said, you don't need to close the file stream.
One thing I'd like to add is that you create useless variables :

Code
sql = "SELECT * FROM accounts WHERE password ='" + password + "'"
mycursor.execute(sql)

Your sql variable is only used in the execute method. I'd write :

Code
mycursor.execute("SELECT * FROM accounts WHERE password ='" + password + "'")




Same thing for :

Code
myresult = mycursor.fetchall()
for result in myresult:
    print(result)

Just write :

Code
for result in mycursor.fetchall():
    print(result)



RE: Python Sources (Newbie) - Alern - Nov 26, 2020

(Nov 25, 2020 01:49 PM)Whait Wrote:  Your code looks great.
As tux1 said, you don't need to close the file stream.
One thing I'd like to add is that you create useless variables :

Code
sql = "SELECT * FROM accounts WHERE password ='" + password + "'"
mycursor.execute(sql)

Your sql variable is only used in the execute method. I'd write :

Code
mycursor.execute("SELECT * FROM accounts WHERE password ='" + password + "'")




Same thing for :

Code
myresult = mycursor.fetchall()
for result in myresult:
    print(result)

Just write :

Code
for result in mycursor.fetchall():
    print(result)

Thanks dude ! :)


RE: Python Sources (Newbie) - G.P.D. - Nov 26, 2020

(Nov 26, 2020 11:17 AM)Alern Wrote:  Thanks dude ! :)

Actually, you can even write the print in one line :

Code
[print(result) for result in mycursor.fetchall()]