Is there any need for overloading operators in python?

Member Avatar
Member Avatar
+0 forum 1

This short Python code gets the local time from the PC as a formatted string using time.strftime('%H:%M:%S'). The time string is displayed in a label using a larger font. A recursive function checks the time five times per second, and updates the time string, if it has changed. Five times per second may sound like overkill, but keeps the display from acting spasmodic.

Member Avatar
Member Avatar
+2 forum 13

Hi everyone, i am in need of ideas and want a bit of advise...i want to make a serial port sniffer which will be able to read the data goin in and out of the serial port between two other programs..... im not sure how i will be able to access a port when its already open....:confused: all advises are heartily welcome Thank you....

Member Avatar
Member Avatar
+0 forum 10

Years ago I wrote a program in Fortran for a structural analysis class. At the time I had very little programming experience and mottled my way through the assignment. Fast forward to now and I'm attempting to teach myself Python 3. I figured I'd would try to convert the old program from Fortran to Python. I've made some good progress but I've hit a wall. I've got the program running to the point where all the element stiffness matrices are defined and combined into the structure stiffness matrix using the code number technique. The structure stiffness matrix is triangular. At …

Member Avatar
Member Avatar
+0 forum 7

Hi, I have created a quiz whixh displays an artist and the first letter of their song and the user has to guess the song. However, I need help looping the quiz so it displays another artists if the user has anwered correctly after their first or second guess. Thank You score=0 import random def random_line(songs): lines =open("songs.txt").read().splitlines() return random.choice(lines) print(random_line("songs.txt")) guess1=input("please enter your first guess:\n") found = False with open('answers.txt') as file: for line in file: line = line.strip() if guess1== line: print("Your answer is correct") found = True score = score + 3 print("You score is ",score,"points") break …

Member Avatar
Member Avatar
+0 forum 1

Hello all, I was wondering if I could get some questions answered about how cupons work in the work place. I have an idea which involves creating a very flexible cupon service, but would require knowing the rudiments of how cupons work. The main question I have is how is tax calculated on a ware as it is sold under a cupon service. I believe that would be the only thing I would have to stringently mandate as far as the cupon goes, since the institution wishes to clear the merchendise from the floor. The service would involve some C# …

Member Avatar
Member Avatar
+0 forum 3

HI All! I need to have some help. I have a python function name is abc.py and variable is declared in abc.py, variable name is 'uname'. How can i call variable name 'uname' of abc.py in my batch file name testing.bat and get uname value in my batch testing.bat file? Best Regards Sarfraz

Member Avatar
Member Avatar
+0 forum 8

![code_error.png](/attachments/large/4/0618569524bcc2abec40e81e5691d469.png) I'm relatively new to python, and I'm trying to create a pokemon battle. This error has come up, I've looked up solutions but it hasn't helped me as I can't understand it properly. Please help, I'd like to learn especially since I'm planning on taking IT and computer science for GCSEs. Thank you in advance.

Member Avatar
Member Avatar
+0 forum 5

i am here ![Screen_Shot_2018-12-28_at_6_47_38_PM.png](/attachments/large/4/237abffd6067e29aa8bd690c2c1a74ec.png) i want to merge all rowsof 3 rd col so that output looks like... end result should be.... ![Screen_Shot_2018-12-28_at_6_49_34_PM.png](/attachments/large/4/92adfc647020ab9265f7d7248758c82f.png)

Member Avatar
Member Avatar
+0 forum 2

i didnt have3 a question

Member Avatar
Member Avatar
+0 forum 2

Let's say you want to send a short private message to your friend, but don't want grandma to snoop around and find it. One way is to use the Python Image Library (PIL) and hide the message in a picture file's pixels. Just looking at the picture you will barely detect any difference between the before and after picture. All your friend needs is the decode_image portion of this simple code to get the message back.

Member Avatar
Member Avatar
+5 forum 15

Hello, I need help on getting solution for the below python code. The code gives the required output which is that it dispaly number of prime number that user wants. if user inputs 4 Actual Output: 2, 3 , 5 , 7 The main question is that I do not have idea on how to give rank to those prime numbers. For Example: The 1st prime number is 2 The 2nd prime number is 3 The 3rd prime number is 5 The 4th prime number is 7 and so on. Can anyone please help to write the code to get …

Member Avatar
Member Avatar
+0 forum 2

import csv import xlwt import os import sys #import openpyxl # Look for input file in same location as script file: inputfilename = os.path.join(os.path.dirname(sys.argv[0]), 'book2.txt') # Strip off the path basefilename = os.path.basename(inputfilename) # Strip off the extension basefilename_noext = os.path.splitext(basefilename)[0] # Get the path of the input file as the target output path targetoutputpath = os.path.dirname(inputfilename) # Generate the output filename outputfilename = os.path.join(targetoutputpath, basefilename_noext+'.xls') # Create a workbook object workbook = xlwt.Workbook() # Add a sheet object worksheet = workbook.add_sheet(basefilename_noext, cell_overwrite_ok=True) # Get a CSV reader object set up for reading the input file with tab delimiters datareader …

Member Avatar
+0 forum 0

How can I locally save an image using its URL address?

Member Avatar
Member Avatar
+1 forum 3

What is the difference between the term Shallow copy and Deep?

Member Avatar
Member Avatar
+0 forum 4

Initially, I've a simple program to print out the whole output to the console. **Initial Code to display output in the console only** import os, subprocess print("1. Before") os.system('ver') subprocess.run('whoami') print('\n2. After') **Output in console** 1. Before Microsoft Windows [Version 10] user01 2. After Then, I decided to have a copy on a log file (log.txt) too while maintaining the original output to the console. So, this is the new code. import os, subprocess, sys old_stdout = sys.stdout log_file = open("log.txt","w") sys.stdout = log_file print("1. Before") # This appear in message.log only, but NOT in console os.system('ver') # This appear …

Member Avatar
Member Avatar
+0 forum 1

You must then use a loop (for or while) to find the sum of all the numbers in the geometric sequence of 3 less than N. The geometric sequence of 3 looks like this 1, 3, 9, 27, 81, 243, ... where you start with the number one and multiply the previous number by 3 to get the next number. add the sequences together to get answer

Member Avatar
Member Avatar
+0 forum 4

Hi How to read the second line in text file(MyData,txt) #MyData.txt line1 line2 line3 line4 line5 #read the second line f = open ("MyData.txt","r") for line in f: if line == 2: print line else: print "somthing wrong !" f.close()

Member Avatar
Member Avatar
+0 forum 1

I have a bank system that's using a tkinter class to run the program with a graphical user interface looking like this: LARGE_FONT = ("Verdana", 12) class BankSystemGUI(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) container = tk.Frame(self) container.pack(side="top", fill="both", expand=True) container.grid_rowconfigure(0, weight=1) container.grid_columnconfigure(0, weight=1) self.frames = {} for F in (LoginPage, PageOne): frame = F(container, self) self.frames[F] = frame frame.grid(row=0, column=0, sticky="nsew") self.show_frame(LoginPage) def show_frame(self, cont): frame = self.frames[cont] frame.tkraise() class LoginPage(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self, parent) label_1 = tk.Label(self, text="Welcome to the Python Bank System", font=LARGE_FONT) label_1.pack(pady=10, padx=10) label_2 = tk.Label(self, text="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", font=LARGE_FONT) label_2.pack(pady=10, padx=10) button1 = …

Member Avatar
Member Avatar
+0 forum 1

Hello everybody, I want to convert python to c but ı did not find any converter. Is it possible to convert

Member Avatar
Member Avatar
+0 forum 1

A simple way to create a toggle button for the Tkinter Python GUI toolkit.

Member Avatar
Member Avatar
+1 forum 13

What are the different file-processing modes with Python?

Member Avatar
Member Avatar
+0 forum 2

Is it appropriate to say that a function not having a return statement is valid?

Member Avatar
Member Avatar
+0 forum 5

Why the part will not have add() and remove() ways whereas Jcomponent Have add() And Remove() ways?

Member Avatar
Member Avatar
+0 forum 2

i want to display this number pattern in python, help me! 9 89 789 6789 56789 456789 3456789 23456789 123456789

Member Avatar
Member Avatar
+0 forum 5

Can anyone help me with the process of making an executable python script in Unix?

Member Avatar
Member Avatar
+0 forum 4

Hi, i have a textfile with a string in it. The string is built like this: test =""" [ "this is a text and its supposed to contain every possible char." ], [ "like *.;#]§< and many more." ], [ "plus there are even newlines in it." ]""" I want to parse out each text in between the square brackets and the quotes. So my desired output would be a list like the following: `['this is a text and its supposed to contain every possible char.', 'like *.;#]§< and many more.', 'plus there are even newlines in it.']` I tried …

Member Avatar
Member Avatar
+0 forum 6

What function should I use to convert JSON into Python data?

Member Avatar
Member Avatar
+0 forum 1

So I'm trying to create a UI that allows multiple buttons in the same window. All of the are toggles to control GPIO outputs to control relays. I've managed to get them to all work individually in their own files, but when put into the same file is all on or all off. There is only 4 toggles for now, as a demonstration for my boss, but there will be many more on the final product.` Below is the code I've come up with so far. (keep in mind I only started learning Python and coding in general yesterday) I'm …

Member Avatar
Member Avatar
+1 forum 4

I've seen the following code for binding the Escape Key to a Tkinter GUI: import Tkinter as tk def exit(): root.destroy() root = tk.Tk() root.bind("<Escape>", exit) root.mainloop() However, when I add this to my GUI program, I don't get a response when Esc key is pressed. It does nothing. Any suggestions?

Member Avatar
Member Avatar
+0 forum 1

The End.