Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Numeric Enigma Machine
Post: RE: Numeric Enigma Machine

And that's just on the forward pass. You're not applying any rotation at all on the reverse pass.
bowlofred General Coding Help 9 499 Mar-28-2024, 06:07 AM
    Thread: Numeric Enigma Machine
Post: RE: Numeric Enigma Machine

Think of it this way. Imagine you have a very simplified rotor: [0, 1, 2, 3, 4] This is five straight lines. 0->0, 1->1 etc... What happens when the rotor is moved one click down? Nothin...
bowlofred General Coding Help 9 499 Mar-28-2024, 04:44 AM
    Thread: Numeric Enigma Machine
Post: RE: Numeric Enigma Machine

When you shift the array, you are changing how the inputs map to the identical outputs. But I think in your problem thats not how rotors work. As an example the first line on R1 maps input 0 to ...
bowlofred General Coding Help 9 499 Mar-27-2024, 10:52 PM
    Thread: Speeding up code using cache
Post: RE: Speeding up code using cache

I think creating your own is the way to go here. lru_cache doesn't have any method to invalidate individual entries. Even if it did, you'd already have to have to stat the file and manage the logi...
bowlofred General Coding Help 1 539 Jul-29-2023, 04:52 AM
    Thread: urllib can't find "parse"
Post: RE: urllib can't find "parse"

Just because modules share a namespace or package doesn't mean you can import the top of the namespace and see everything. In this case, urllib isn't a module and it doesn't do anything useful if im...
bowlofred General Coding Help 6 2,165 Jul-24-2023, 03:30 AM
    Thread: How can I change the uuid name of a file to his original file?
Post: RE: How can I change the uuid name of a file to hi...

Why are you uploading it with a UUID name instead of the original name? If the original name is safe to rename it to, it's presumably just as safe to upload it that way. But in both cases you'd wan...
bowlofred General Coding Help 2 922 Jul-17-2023, 04:19 PM
    Thread: Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att
Post: RE: Python: Regex is not good for re.search (Attri...

Doing regex on HTML is super annoying. Use an HTML parser instead (like beautifulsoup). Your regex is anchored at the front of the string. If your new_file_content contains the entire file, then t...
bowlofred General Coding Help 9 1,496 Jun-28-2023, 07:32 AM
    Thread: Computing GC Content
Post: RE: Computing GC Content

(Jun-25-2023, 10:04 PM)uwl Wrote: which asks me to find the GC content Is that the entire specification of the problem? It looks to me like it wants you to examine the GC content of different file...
bowlofred General Coding Help 3 946 Jun-26-2023, 04:09 PM
    Thread: Code is returning the incorrect values. syntax error
Post: RE: Code is returning the incorrect values. syntax...

On line 4, you input() num. That means you have a string. On line 7 and 8, you test if the string can be interpreted as an integer, but you don't change anything. So num is still a string. So in t...
bowlofred General Coding Help 6 1,214 Jun-18-2023, 07:05 PM
    Thread: Python won 't do decimals
Post: RE: Python won 't do decimals

Please show the output of python -V and the contents of example.py. I cant run your first example because remainder isn't assigned.
bowlofred General Coding Help 5 707 Jun-08-2023, 03:38 PM
    Thread: Comparing List values to get indexes
Post: RE: Comparing List values to get indexes

The only print statements are in a conditional when they are set to 1. So you will never see anything that says it is 0. You're printing every time it's set to 1, not just at the end. I think your ...
bowlofred General Coding Help 7 1,156 Jun-08-2023, 03:35 PM
    Thread: how to return a reference to an object?
Post: RE: how to return a reference to an object?

(Jun-07-2023, 01:06 AM)Skaperen Wrote: i want to increment the object. i can do this when i get it directly from a dict like so: cars_per_train[which_train] += 1 # one car passes by so count it. If ...
bowlofred General Coding Help 8 1,188 Jun-07-2023, 01:52 AM
    Thread: Why am I getting this error?
Post: RE: Why am I getting this error?

The first argument of any method is the object itself (which is usually termed self in the argument list). Any other arguments you give come after that. So when you do: example_class_object.set_exam...
bowlofred General Coding Help 3 642 Jun-05-2023, 11:34 PM
    Thread: how to return a reference to an object?
Post: RE: how to return a reference to an object?

What do you mean by object references? A name that the object has been assigned to or something else? Can you show how your dict is constructed?
bowlofred General Coding Help 8 1,188 Jun-05-2023, 11:28 PM
    Thread: Rows not adding to sqlite3 database using SQLAlchemy
Post: RE: Rows not adding to sqlite3 database using SQLA...

(Jun-01-2023, 03:45 PM)Calab Wrote: When I get a successful connection, it will return from the function, so never do the finally block. The db shouldn't close. No, that's incorrect. The finally bl...
bowlofred General Coding Help 11 1,687 Jun-02-2023, 05:53 PM
    Thread: Rows not adding to sqlite3 database using SQLAlchemy
Post: RE: Rows not adding to sqlite3 database using SQLA...

If you want to use the DB, why are you closing it in get_db? What's the purpose of the db.close() there? If you want to close it on an exception, put that in the exception block, not a finally bloc...
bowlofred General Coding Help 11 1,687 Jun-01-2023, 03:23 PM
    Thread: The way to chase how the set of integer is iterated in mutating loop
Post: RE: The way to chase how the set of integer is ite...

I don't think it's documented beyond "don't modify objects while you're iterating over them". The iterator may do odd things in those cases. Python sets are hash tables that are dynamically sized. ...
bowlofred General Coding Help 4 826 May-26-2023, 06:28 AM
    Thread: Badly defined python code?
Post: RE: Badly defined python code?

The previous "line" is the config = on line 11. The closing parenthesis for the config expression doesn't matter. But the indentation of line 11 does. Line 20 does not have the same indentation as...
bowlofred General Coding Help 2 612 May-25-2023, 08:12 PM
    Thread: how can I call the API using python
Post: RE: how can I call the API using python

.content isn't a method the way .json() is, it's an attribute. You don't use parenthesis with it. print(requests.get(appraisal.format(domain), headers=headers).content)
bowlofred General Coding Help 5 2,207 May-15-2023, 01:43 AM
    Thread: how can I call the API using python
Post: RE: how can I call the API using python

It's saying that the response it received couldn't be decoded as JSON. It could be a simple HTML message saying that the key isn't matching or similar. Instead of invoking the .json() method on the ...
bowlofred General Coding Help 5 2,207 May-14-2023, 11:26 PM

User Panel Messages

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