Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Need some help with simple coding!
Post: RE: Need some help with simple coding!

I can't believe 33 years old people were born in 1989.. **cry** By the way, the program will not give correct results next year. Python can give you the current year import datetime current_year = da...
Gribouillis Homework 5 153 Jan-15-2022, 05:35 PM
    Thread: please help with classes and return values
Post: RE: please help with classes and return values

I find it difficult to understand what the program does. Perhaps you should learn python the easy way...
Gribouillis General Coding Help 5 275 Jan-14-2022, 07:53 AM
    Thread: ord()
Post: RE: ord()

Try for i in range(104, 96, -1): print(chr(i))
Gribouillis General Coding Help 2 138 Jan-12-2022, 06:46 AM
    Thread: please looking for typo in my code (solution please)
Post: RE: please looking for typo in my code (solution p...

There must be a class named 'Scene' that you forgot to include in the script.
Gribouillis General Coding Help 1 114 Jan-12-2022, 06:45 AM
    Thread: find 2 largest equal numbers
Post: RE: find 2 largest equal numbers

@deanhystad More interesting is the extended Euclide algorithm which produces two integers u and v such that a * u + b * v = gcd(a, b)
Gribouillis General Coding Help 13 352 Jan-10-2022, 09:13 PM
    Thread: find 2 largest equal numbers
Post: RE: find 2 largest equal numbers

It prints only 1 because when you print("D", f) the value of the variable f is the last value that was assigned to f by a statement f = ..., and this last value turns out to be 1. Previous values of f...
Gribouillis General Coding Help 13 352 Jan-10-2022, 04:09 PM
    Thread: find 2 largest equal numbers
Post: RE: find 2 largest equal numbers

If you print "D" only once, it will be printed only once.
Gribouillis General Coding Help 13 352 Jan-10-2022, 03:22 PM
    Thread: How to solve this file handling issue?
Post: RE: How to solve this file handling issue?

When the program exits the with open... block, the file is automatically closed.
Gribouillis General Coding Help 3 158 Jan-10-2022, 09:36 AM
    Thread: How to solve this file handling issue?
Post: RE: How to solve this file handling issue?

You could perhaps refactor it like this import time import serial import datetime import os ser = serial.Serial(port='/dev/serial0', baudrate=900000, parity=serial.PARITY_NONE, stopbits=seri...
Gribouillis General Coding Help 3 158 Jan-10-2022, 07:50 AM
    Thread: console pwd file
Post: RE: console pwd file

It is doable but a simpler solution is perhaps to display the exception with a tkinter window. For example, suppose that the program is executed by running a main() function def main(): print(1 / ...
Gribouillis General Coding Help 4 159 Jan-09-2022, 08:25 PM
    Thread: PYTHONSTARTUP not working
Post: RE: PYTHONSTARTUP not working

Usually I don't use IPython, but I never use PYTHONSTARTUP either. 'ipython' is only an interactive shell, it runs the same CPython interpreter than the 'python' command.
Gribouillis News and Discussions 9 393 Jan-09-2022, 07:47 AM
    Thread: tk is not defined
Post: RE: tk is not defined

The error message doesn't match your code on the screenshot. The code says fenetre = Tk() and the error message says fenetre = tk(). It is not possible.
Gribouillis General Coding Help 7 247 Jan-09-2022, 07:43 AM
    Thread: tk is not defined
Post: RE: tk is not defined

Try this to see what gets imported import tkinter print(tkinter)
Gribouillis General Coding Help 7 247 Jan-08-2022, 08:43 AM
    Thread: PYTHONSTARTUP not working
Post: RE: PYTHONSTARTUP not working

As PYTHONSTARTUP is only used in interactive mode, it seems to me that a better alternative is to use the IPython shell instead of the Python shell. Apparently, if you put .py files in the directory ~...
Gribouillis News and Discussions 9 393 Jan-07-2022, 10:06 PM
    Thread: Dynamic File Name to a shared folder with open command in python
Post: RE: Dynamic File Name to a shared folder with open...

sjcsvat Wrote:# getting Error below, not able to format the file pathPlease post the error message as well. Error messages are very useful to understand what's going on. Also you shouldn't call wf.clo...
Gribouillis General Coding Help 9 286 Jan-06-2022, 07:09 AM
    Thread: what works with the with statement?
Post: RE: what works with the with statement?

You could wrap it in a context manager import contextlib import os @contextlib.contextmanager def osopen(*args, **kwargs): fd = os.open(*args, **kwargs) try: yield fd finally: ...
Gribouillis News and Discussions 7 480 Jan-05-2022, 07:49 AM
    Thread: Hiding "undesired" info
Post: RE: Hiding "undesired" info

I think the first step is to find which exact statement in your code triggers the unwanted output. Once you have found it, you could try to redirect stderr temporarily to capture this specific output.
Gribouillis General Coding Help 4 293 Jan-03-2022, 05:51 PM
    Thread: Hiding "undesired" info
Post: RE: Hiding "undesired" info

This question is addressed on the Pypi page of module SpeechRecognition (search the word 'annoying' in the page).
Gribouillis General Coding Help 4 293 Jan-03-2022, 03:07 PM
    Thread: what works with the with statement?
Post: RE: what works with the with statement?

It is more difficult to track objects returned by functions from the contextlib module, such as functions decorated by the contextmanager decorator. They are functions that return contexts.
Gribouillis News and Discussions 7 480 Jan-03-2022, 11:14 AM
    Thread: an httpd server
Post: RE: an httpd server

ndc85430 Wrote:Note that there are also third party HTTP servers like Gunicorn that are likely better for production use.I've always missed an effective tutorial about the simplest and secure way to d...
Gribouillis News and Discussions 9 326 Jan-03-2022, 08:15 AM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020