Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: How do I mask Hex value wiht 0xFF?
Post: RE: How do I mask Hex value wiht 0xFF?

A couple ways you could do it. Since you're starting with strings, just treat them as strings. Print the last two letters of each. Otherwise, you could convert the strings into a number, mask it of...
bowlofred General Coding Help 2 144 Nov-23-2021, 09:02 AM
    Thread: Catching a crash within a library code
Post: RE: Catching a crash within a library code

If the library were to catch the exception and not re-raise it, then there would be nothing for the library caller to catch. I think the library has 3 choices: * Not catch the error (or raise its ow...
bowlofred General Coding Help 9 301 Nov-22-2021, 11:02 AM
    Thread: Catching a crash within a library code
Post: RE: Catching a crash within a library code

That the second one is caught seems odd. How about this? ... except Exception as e: print(repr(e)) print(type(e))
bowlofred General Coding Help 9 301 Nov-22-2021, 01:28 AM
    Thread: Catching a crash within a library code
Post: RE: Catching a crash within a library code

Looks correct to me. Two things to try: Make sure that the code logic and micropython aren't doing anything odd here. This should be caught as well: try: raise OSError('Test error') blynk =...
bowlofred General Coding Help 9 301 Nov-21-2021, 11:47 PM
    Thread: Catching a crash within a library code
Post: RE: Catching a crush within a library code

That should work if the OSError is the exception thrown. Can you show the actual code and a traceback where it doesn't work?
bowlofred General Coding Help 9 301 Nov-21-2021, 10:48 PM
    Thread: how to get non-exponential format
Post: RE: how to get non-exponential format

You can use either format or f-strings and the "f"ixed point specifier. >>> format(2.0**54, "f") '18014398509481984.000000' >>> f"{2.0**54:f}" '18014398509481984.000000'Default is 6...
bowlofred General Coding Help 1 136 Nov-21-2021, 08:51 PM
    Thread: printing a string in reverse
Post: RE: printing a string in reverse

If it's a string, then you can create a reversed string by slicing with a -1 step.. >>> x = "foobar" >>> print(x[::-1]) raboof
bowlofred General Coding Help 2 202 Nov-20-2021, 12:54 AM
    Thread: Sudden Problem with pexpect
Post: RE: Sudden Problem with pexpect

(Nov-19-2021, 04:56 PM)gw1500se Wrote: Hmm. That is not what I get from manually launching. Thanks. At least you gave me a direction to look. What is the content of config? Can you just see someth...
bowlofred General Coding Help 3 201 Nov-19-2021, 11:21 PM
    Thread: Sudden Problem with pexpect
Post: RE: Sudden Problem with pexpect

It was reading from the program trying to find your expected string. But then the program gave back an EOF (it exited). And the last few things that it received before exiting was: Quote: d *BEFORE...
bowlofred General Coding Help 3 201 Nov-19-2021, 04:45 PM
    Thread: trying to understand a string literal in a basic server program
Post: RE: trying to understand a string literal in a bas...

This is using the format language for f-strings. The first bit inside the braces is the thing you want to evaluate (and print the str() representation of), and the second bit (after the colon) is the...
bowlofred General Coding Help 4 219 Nov-13-2021, 11:46 PM
    Thread: producing numbers out of a list
Post: RE: producing numbers out of a list

(Nov-12-2021, 04:14 PM)bouraque7878 Wrote: What about if i want to product numbers out of the same digits without repition ? I mean i don't want to product numbers like 1111, 1114, 1115 etc. I want ...
bowlofred General Coding Help 10 566 Nov-12-2021, 04:22 PM
    Thread: Numeric Anagrams - Count Occurances
Post: RE: Numeric Anagrams - Count Occurances

Although these are numbers, you can still deal with it as strings. If you alphabetically sort each number, you can collapse each to be the "reference" number for each of the anagrams. So "312" woul...
bowlofred General Coding Help 2 233 Nov-12-2021, 05:48 AM
    Thread: producing numbers out of a list
Post: RE: producing numbers out of a list

Possibly want product. Although shoving the results together to make numbers isn't always trivial. from itertools import product digits = "1457" for number_str in product(digits, repeat=4): nu...
bowlofred General Coding Help 10 566 Nov-09-2021, 08:46 PM
    Thread: Convert string to path using Python 2.7
Post: RE: Convert string to path using Python 2.7

In line 5 you start with a datetime (from now()), but then convert it into a date (with .date()). In line 8 you're comparing a timestamp to a date which won't match. What you might want is to comp...
bowlofred General Coding Help 10 519 Nov-09-2021, 03:21 AM
    Thread: Convert string to path using Python 2.7
Post: RE: Convert string to path using Python 2.7

Please try to upgrade to python3. os.path.* methods are mostly string manipulations. They return paths in the form of a string, not a path object. So after you get the normpath in np, you could gat...
bowlofred General Coding Help 10 519 Nov-08-2021, 09:23 PM
    Thread: Remove an item from a list contained in another item in python
Post: RE: Remove an item from a list contained in anothe...

Does order matter? Can there be duplicates? If order doesn't matter and there are no duplicates, make each one a set and use issubset() on each one to see if it's contained.
bowlofred General Coding Help 19 827 Nov-06-2021, 10:31 PM
    Thread: Serializing Python data Correctly (JSON)
Post: RE: Serializing Python data Correctly (JSON)

You can't append to JSON data like a log file or a database. If you want to add data to it you need to: * read in the existing data to a list or dict * append or add your data to that object * dump t...
bowlofred General Coding Help 4 303 Nov-04-2021, 04:24 PM
    Thread: i making a terminal sign up website thing
Post: RE: i making a terminal sign up website thing

Please use bbcode tags for your python code (you can press the python button above the editor). (Nov-04-2021, 03:15 AM)Kenrichppython Wrote: if YesNo == f: This code checks if the variable YesNo ha...
bowlofred General Coding Help 1 221 Nov-04-2021, 03:57 AM
    Thread: Updating a config file [solved]
Post: RE: Updating a config file

I'm not sure I understand the environment, but I think you can modify them before you hand the config off to the client. Are you using it something like this? from mqtt_as import MQTTClient, config ....
bowlofred General Coding Help 8 402 Nov-04-2021, 12:53 AM
    Thread: Updating a config file [solved]
Post: RE: Updating a config file

I'm assuming you just edit it with a text editor and overwrite the placeholders on the right. Unless someone has written a GUI that prompts for it directly.
bowlofred General Coding Help 8 402 Nov-04-2021, 12:30 AM

User Panel Messages

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