Κυριακή 18 Αυγούστου 2019


can you access pydrive or drive api without an authorized domain?
localhost isn't allowed anymore??? whats the deal? you can select windows cli tool, and it says you need a domain??!!!! the pydrive instructions are wrong, there's not web app anymore I followed the standard instructions. It seems google has changed the policy? Now redirect urls must be authorized in a 'consent screen' Unfortunately, only top level domains are accepted and not localhost. So what am I to do? Is pydrive only for domain holders now? Quickstart Authentication Drive API requires OAuth2.0...
Python Educational
1m
Writing then reading x,y,z point file back into list without garbling?
I'm having problems that indicate a beginner's mistake somewhere in how I am using Python. Hopefully this will be an easy one for this forum to solve. I have a list of x,y,z points I initialized like this: xyzpoints = [0 for _ in range(pointcount)] After the program loads two points into the list it looks like this when printed out using print(xyzpoints) [(171.67511323648006, 155.49370352782847, -132.80950138616407), (-210.19042287726438, 126.74418623666149, 105.09470674531258)] I then saved the...
Python Educational
1m
b = a?
a = [1,2,3] b = a a = [4,5,6] Why does 'b' return 1,2,3 and not 4,5,6 if the value of 'a' was changed? submitted by /u/DennisErectus [link] [comments]
Python Educational
7h
please help me solving this
guys i have started taking a course in edx which was offered by MIT on Introduction to Python Fundamentals.......there are many modules and and section each section contains some tasks ......i have a problem with a task please help me writing the code for the below task # [ ] print a message that there is "No Parking" on index 0 or index 4 streets submitted by /u/Worth_Butterfly [link] [comments]
Python Educational
7h
Need help with interval click
Hi guys, I am learning python and I've created this script for instagram auto like and auto follow. However, I tried to randomise the time interval between likes but it does not work. Can you please help and point me to the right direction? from selenium import webdriver from selenium.webdriver.common.keys import Keys import time class InstagramBot: def __init__(self, username, password): self.username = username self.password = password self.driver = webdriver.Chrome("H:\\chromedriver.exe") def...
Python Educational
7h
Factor's Efficiently?
I have a quick question. I'm doing a problem on Exercism called Perfect Number. I originally came up with a rather inefficient solution using list comprehensions, but in the pursuit of something way faster I headed over to stack overflow. I ended up finding a super clean solution and implemented it, but I'm having trouble understanding the aliquot section of the code I wrote and how exactly it works. The goal is basically to compare the sum of the factors of a number and classify it based on how...
Python Educational
8h
Python mutliproccessing question? I think?
So, I have this python script that pulls environmental data from a temp/humidity sensor. Then turns on or off a wemo smart switch depending on the values. It also ships the data to an influx db. I have that part down fine. What I would like it to also do is every x minutes or hours as defined in the config turn the fan on for some also user defined period of time and then shut off, while still running the main loop. import time import board import busio #Add Temperature/Humidity sensor driver import...
Python Educational
8h
WinSound plays error sound instead of sound I selected.
import winsoundwinsound.PlaySound("C:\Desktop\MonGo\\audio\\background_music.wav", winsound.SND_FILENAME) I don't know if i'm doing something wrong lol. I've tried changing the slashes but that didn't work. submitted by /u/kingbooker48 [link] [comments]
Python Educational
8h
I'm new to classes. How would I make it so not all the parameters need to be filled for it to work?
If I have something like: class fish_types: def __init__(self,type1,type2,type3) self.type1 = type1 self.type2 = type2 self.type3 = type3 fish = ('cod','trout') print(fish.type1) How can I get the class to not yell at me about not fulfilling all parameters in the fish line? How can I get it to accept more than are required? submitted by /u/xain1112 [link] [comments]
Python Educational
8h
I feel like I could use OOP on this media organising program but I'm not sure, can someone help?
I made the first version of this program which will help me organise my list of shows and movies to watch but I think I'm going about it the wrong way. I think I should look for a more OOP approach but I'm REALLY bad and REALLY new to classes and stuff so any help would be appreciated. ​ I have two main questions about stuff I'm stuck on: Should I make a class for the categories (movies, shows, anime)? And what features should that class have? Should I store all my data in dictionaries or should...
Python Educational
8h
Using Python3 on a Mac
So I'm using a Mac and want to use Python3......and I realize this is probably a very obvious thing to ask but HOW DO I DO THAT?? I've downloaded everything and I'm currently using terminal, I'm writing a program but the issue w terminal is....if u make a mistake( a typo or a missing : for example).....you can't go back to fix it. its so frustrating and I just lost almost an hours work.........theres no way this is what Mac users do. What am I missing? submitted by /u/xxsemiramisxx [link]...
Python Educational
8h
What XPath expression should I use to fetch the number of likes and comments on a YouTube video?
I'm using Python to find the amount of likes and amount of comments of any given YouTube video, but I can't figure out the right XPath expression to fetch them. I used ChroPath to extract the XPath of the comments and likes count, but to no success. This is the XPath that I've been using for amount of comments: //yt-formatted-string[@class='count-text style-scope ytd-comments-header-renderer'] And this is for amount of likes: //div[@id='info']//ytd-toggle-button-renderer[1]//a[1]//yt-icon-button[1]...
Python Educational
8h
Is there a way to make it so music would play?
Is there a way to make an audio file play while the .py file is on? Thanks. submitted by /u/kingbooker48 [link] [comments]
Python Educational
9h
Python for Network Engineer
I am a network engineer and also python beginner. Can someone suggest beginner project to help me develop and which website or group can I join to gain more experience. submitted by /u/cardlord [link] [comments]
Python Educational
9h
Read all entry widgets
I apologize for what is probably a simple answer. I have a gui where I'm trying to read every entry widget and write it to a text file. Below is my code. The error I'm getting is that it's saying 'e' is not defined. import tkinter as tk def writetofile(): for i in range(1,3): datatoWrite = e[i].get() print(datatoWrite) text = open("D:\Electronics\Projects\SandBox\writetest.txt","a") text.write(datatoWrite) text.write("\n") text.close() form = tk.Tk() form.title ("Sample GUI") L1 = tk.Label(form,...
Python Educational
9h
Permanently storing data in a data structure?
We we design a BST for a leetcode problem (or something of the like), we fill in data, and test it for algorithmic purposes for faster traversing, searching, etc. My question is how can I save a data structure permanently so that the data is stored even when the program isn't running. Would I need a database or something? submitted by /u/alrightfrankie [link] [comments]
Python Educational
9h
[HELP] Pyautogui does not work when I minimize the remote desktop window.
For some reason, pyautogui stops working when I minimize the remote desktop window. Set Failsafe = false. ​ Any other solutions? submitted by /u/analytics_depot [link] [comments]
Python Educational
9h
When I install new modules, Python can't find them?
Hi there! I've been coding in Python for a few months, and modules/ libraries I've had for a while (like seaborn, numpy etc) can be imported into Pycharm (which I've just started using) just fine. However, when I install a new module (I just installed Tweepy), when I attempt to import it, I get a ModuleNotFoundError! I'm assuming this is because for whatever reason, the new modules are being installed somewhere else. Is there a way to fix this? I've used print(os.path.abspath(seaborn.__file__)) to...
Python Educational
9h
Need help with refactoring two set of almost similar functions if
Hello all, I am a system admin currently learning python for work. I have been tasked to write a script that fixes printer issues in our office network. I initially wrote a fully working python script but it was too ugly and I started refactoring the scripts so that repeated actions were moved to functions and most function does only one job. Now I am at the last leg of refactoring and stumbled upon two set of similar functions that are almost the same except for an additional if else block within...
Python Educational
9h
Else statement says Statement Expected.
I've tried so many other options, and nothing worked. else: if catch1 == "No" or catch1 == "no": submitted by /u/kingbooker48 [link] [comments]
Python Educational
9h
AttributeError: 'NoneType' object has no attribute 'replace'
I am trying to return all the items to the text box that have the users search input in them. when i print the basic code to terminal it all works fine but when i return the results i get the error: AttributeError: 'NoneType' object has no attribute 'replace'. Been stuck on the same error for weeks and cant seem to get passed this. Any help would be EXTREMELY appreciated. ​ python code: ​ # main.py from kivy.app import App from kivy.lang import Builder from kivy.uix.screenmanager import ScreenManager,...
Python Educational
9h
Python Algo
I am building a program that configures new linux installations (regardless of distribution) using both python3 and bash. Here's what I'm struggling with: I have multiple txt files that represent groups of software I may want installed ( a base group and full group). Each file consists of a single name on each line (neovim\nhtop\nfirefox...). I have already figured out how to determine the package manager on the system the program is run on (apt-get, yum, pacman, etc) but now need to loop through...
Python Educational
10h
Regex Help (whitespace issue
I have this string: SOCIAL SKILLS 2."Talks to his peers."(Sometimes) AGGRESSION3. "Hits other people."(Sometimes) Note that the spacing is not uniform. I want 4 groups: (category)(number)(survey item)(response). Ex: (SOCIAL SKILLS)(2.)("Talks to his peers.")((Sometimes)) Currently, my regex is this: (\bSocial Skills\b|\bAggression\b) *(\d+\.) *(.*?) *(\(.*?\)) This is able to successfully capture (SOCIAL SKILLS)(2.)("Talks to his peers.")((Sometimes)) ,but is unable to capture (AGGRESSION)(3.)("Hits...
Python Educational
10h
Else statement shows Statement expected
Hey again! Sorry for posting this the third time, I keep getting this error. If ya'll can tell me how to fix it forever i'd be thankful! Anyways, here's the script. if gender : "Male" print("Just " + name + ", Ethan, Lucas.") else: if gender : "Female" print(name + "Hilda, Rosa, May.") submitted by /u/kingbooker48 [link] [comments]
Python Educational
11h
Quick Numpy question: How do we use np.where?
This is frustrating. You probably know the issue I'm talking about. import numpy as np tens = [20, 40, 60, 80] nptens = np.array(tens) print(nptens) nptenso = np.array_split(list(nptens), 2) npt = np.where(list(nptenso) == 20) print(npt) It gives out (array([], dtype=int64),) But I want to find the index of 40 in a 2x2 grid. So it should be (array([0], dtype=int64), array([1], dtype=int64)) It usually works most of the times that I've used it, so I have no idea why it's doing this to me now. I've...
Python Educational
11h
How to make python type a specific message for one variable within a list
https://ibb.co/0fjzw1h https://ibb.co/c8ZX451 I need it to print Mat please take the poll and not Jen, since she already did Help would be appreciated Update: the problem is fixed submitted by /u/Amacei [link] [comments]
Python Educational
11h
Else statement shows Statement expected.
if char : char print("You stayed as " + char + ". Good choice.") else: print("Good choice! " + newchar + " was always my favorite.") I'm super new to python, so could anyone help me? submitted by /u/kingbooker48 [link] [comments]
Python Educational
11h
How do I make a button that runs the whole code?
I'm trying to make a DnD character generator app and I can't figure out how to make a button run the code again for a new character without the user having to exit out of the app. need black bg and white and light grey letters 1 button alliance,race,class slots 6 stat slots from tkinter import * import random from random import randint clas = ['Barbarian', 'Bard', 'Cleric', 'Druid', 'Fighter', 'Monk', 'Paladin', 'Ranger', 'Rogue', 'Sorcerer', 'Warlock', 'Wizard'] background = ['Acolyte', 'Charlatan',...
Python Educational
11h
Do I have to run every line in jupyter again after opening it again?
title. submitted by /u/meshikhah [link] [comments]
Python Educational
12h
Stuck with PyQT5 + MVC - trying to update controller with value, but can't figure out what to do. Please help!
Hello, I'm a beginner so I apologize in advance for my mistakes, for both in code and design. I'd really appreciate if someone can point out the mistakes I made. StackOverflow was not much of a help and the guy replying to all my questions (I asked two and he downvoted both) was very condescending. Anyway, so I am currently working on making a GUI that should add one name and four images for the said thing. Example : name = cat and four images of the cat. I am trying to follow an MVC pattern. Currently...
Python Educational
12h
Print only on change
Hopefully this word vomit makes sense. I’m trying to learn python and working on a small side project to help me do so. Thus far I have a script that uses the request library to check the status code of a website and print to screen if the website is down. I have the script in a while loop and have it run every 60 seconds. I want it to only print to the screen once if the website is down and again after the website comes back up. Help is appreciated. ​ Update 2: I'm testing this on a CentOS VM. To...
Python Educational
12h
Try-else Clarification
I'm currently learning about exception handling and such and I want to confirm my understanding about the else statement. Is it correct to say that the else block will only run if the try block is successful(generates no exceptions)? submitted by /u/Regex00 [link] [comments]
Python Educational
12h
if elif not executing
The if elif statement is not executing in the following code. The goal is to identify the files with .LOG extension in the chosen directory and then output a text file depending on the presence of that .LOG file. Here is the code and please keep in mind this is my first time posting code on here. filepaths = '/home/myname/Gaussian' for content in filepaths: ext = os.path.splitext(content)[-1].upper() if ext != ".LOG": with open(os.path.join('/home/myname/Gaussian','outputfile'),'w') as f: f.write('There...
Python Educational
12h
Help with creation of python program.
Hey guys so ive been working for a while now on my first python program, i spent a while coding it together and it works pretty well. The issue is its supposed to be a school project i have to hand in and a requirement was it either is an app for android or a desktop executable file. The issue is it is a script that depends on external files as well including a .json and .h5 file. Is there a way i can mold all of the files together to create a single executable file that i can run and which will...
Python Educational
13h
Seeking for feedback to my python script
TL;DR: Seeking for constructive feedback on this script I wrote, thanks! :) Hey all, I'm currently in the process of learning Python and I wrote this little script. Do you have any thoughts / feedback on how to improve this code? The goal of this script is to simply change the wallpaper of the machine to whatever service (bing, "lorempicsum" or local) is chosen. Depending on the service (standard is local), one can apply different arguments. GitHub Repository submitted by /u/relega [link]...
Python Educational
13h
How do you compile dependencies with a finished .exe?
Sorry if it's a stupid question, I started learning python yesterday. I'm creating a simple code with stuff like a login screen and main menu and I want to test it in an executable file. However, the way that I've set it up is that every page is its own file. That way it's a little easier to understand while I'm starting out. In order for each file to cooperate together I've been using the import function and nothing else. I've been using pyinstaller and python 3.7.something. Thank you. submitted...
Python Educational
13h
Trying to find the correct widget in Tkinter
I'm currently working on a table assignment project in which the Tkinter window displays a visual of multiple tables with names inside. I also want there to be buttons inside the tables that say things like "add person" or "remove person". I don't know what to use (ex. Canvas, rectangle, listbox, or something else altogether). Sorry if my explanation is unclear, feel free to PM me for clarification but of course, there is no obligation to help. Thank you so much! submitted by /u/lonely_oboe...
Python Educational
13h
Tuple Index Error Out of Range
Hi, Im using Selenium/PhantomJS and Requests module to some magic. They have different cookie syntax that one getting and the other setting. The PhantomJS method gets the cookies as a dict. The requests wants them passed in as named keyword arguments. I wanted to test if I can simply build the named string using format and then pass that in or eval it (if python has that) into a variable. However I keep getting the Tuple Out of Index Error. Though, Im perplexed as to why. Example Code: dictcookie...
Python Educational
13h

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

Αρχειοθήκη ιστολογίου