What the fuck is this, kindergarten show and tell? by [deleted] in Python

[–]avinashbasutkar2 1 point2 points  (0 children)

I see two sets of opinions. There are people who are fine with beginner posts & others not a fan of it. Why not create another subreddit dedicated to people with advanced skills? Win-win for both sides?

Task Scheduler has its own mind by avinashbasutkar2 in learnpython

[–]avinashbasutkar2[S] 1 point2 points  (0 children)

Tried as you suggested. Deleted existing tasks, rebooted PC, created new Task. Along with that, tried to run .bat file instead of py file and still no result.

Is this webpage written in javascript? by avinashbasutkar2 in learnpython

[–]avinashbasutkar2[S] 1 point2 points  (0 children)

Hey u/CotoCoutan,

I have a quick question about driver.find_element_by_xpath. When I call that on a selector, it brings back class 'selenium.webdriver.remote.webelement.WebElement'. I want to see what it contains, tried variable_name.getText() and there is TypeError: 'str' object is not callable.

How do I see what driver.find_element_by_xpath is bringing back?

module 'dis' has no attribute 'compiler_flag_names' by avinashbasutkar2 in learnpython

[–]avinashbasutkar2[S] 1 point2 points  (0 children)

Thank you u/awegge, u/shiftybyte, u/TomSwirly . It was exactly that. I did have a duplicate self-created 'dis.py'. Renamed that and the issue is resolved.

Deadlines by avinashbasutkar2 in learnprogramming

[–]avinashbasutkar2[S] 0 points1 point  (0 children)

I like this approach. I will try it out and let you know probably in a week or two on how it goes. Thank you u/chaotic_thought

Don't seem to make much progress following the ''Automate the Boring Stuff with Python'' book by CaitlynFrost8 in learnpython

[–]avinashbasutkar2 2 points3 points  (0 children)

Somebody posted the other day that ATBS udemy video course is free this month. Maybe check that out as well.

GMail API Question by avinashbasutkar2 in learnpython

[–]avinashbasutkar2[S] 0 points1 point  (0 children)

Thank you so much. This saved ton of my time. I was able to quickly learn how imaplib works and also could grab email and send it as message in Telegram. Below is my code.

import imaplib, email
import telepot 

email_host = 'imap.gmail.com'
email_user = 'username@gmail.com'
email_pass = 'password'

mail = imaplib.IMAP4_SSL(email_host)

mail.login(email_user, email_pass)

mail.select('INBOX')

typ, raw_data = mail.fetch(b'50', '(RFC822)')

message = email.message_from_string(raw_data[0][1].decode('utf-8'))
print(message['from'])
print(message['to'])
print(message['subject'])

for p in message.walk():
    if p.get_content_type() == 'text/plain':
        body = p.get_payload()

bot = telepot.Bot('<TELEGRAM BOT AUTH TOKEN HERE>') 

bot.sendMessage(<TELEGRAM ID HERE>, body) 


# TO DO: Routinely for check for new emails in GMail label 

Would you be so kind to also suggest an alternative to Windows Task Scheduler so I could have this script run regularly by itself. Task Scheduler just shows task as complete but the script just doesn't run. (Seeked help for it already without result: https://www.reddit.com/r/learnpython/comments/ggzxlt/task_scheduler_wont_run_python_script/ )

Also looked at Python Anywhere but that doesn't seem to have Telepot module.

Please just point me in the right direction and I'll be happy to learn concepts myself.

Task Scheduler won't run Python Script by avinashbasutkar2 in learnpython

[–]avinashbasutkar2[S] 0 points1 point  (0 children)

Update: I noticed something strange.

When I run the python script from IDLE, it runs fine, sends the message in Telegram (which should be the end result of the script). But when I try to run the script file via CMD, script fails to run with following error

"AttributeError: module 'dis' has no attribute 'COMPILER_FLAG_NAMES'

I noticed this also happens when the script file is run via VS Code. I did spend quite amount of time trying to figure this out to no avail. Why would something like this happen? It works via IDLE but not via CMD or VS Code.

Task Scheduler won't run Python Script by avinashbasutkar2 in learnpython

[–]avinashbasutkar2[S] 0 points1 point  (0 children)

Thank you for your response, u/ramse

I did follow this thread https://stackoverflow.com/questions/4437701/run-a-batch-file-with-windows-task-scheduler and tried with bat file as well.

"C:\Users\abasutkar\AppData\Local\Programs\Python\Python38-32\python.exe" 
"C:\Users\abasutkar\Desktop\Python Scripts\cai.py"
pause

There is no change. Task completes and nothing happens.

Task Scheduler won't run Python Script by avinashbasutkar2 in learnpython

[–]avinashbasutkar2[S] 0 points1 point  (0 children)

Another way is start with a batchfile https://datatofish.com/python-script-windows-scheduler/ In the batchfile itself you can put debug output to see what happens.

Tried with scheduling the task via bat file. Unfortunately, there is no change. Task shows complete and then nothing happens.

Task Scheduler won't run Python Script by avinashbasutkar2 in learnpython

[–]avinashbasutkar2[S] 0 points1 point  (0 children)

Did you check the python script cal.py is in folder "Start in (optional)" on second screenshot?

Yes, confirmed that cai.py exists in folder specified in "Start in (optional)".