Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: list comprehension
Post: RE: list comprehension

Thanks. I tried results = [die_1.roll() + die_2.roll() for roll_num in range(50000)]
HenryJ General Coding Help 3 2,785 Feb-21-2018, 07:22 AM
    Thread: list comprehension
Post: list comprehension

Hi, Is it possible to convert the below for loop to a list comprehension and get "results"? for roll_num in range(50000): result = die_1.roll() + die_2.roll() results.append(result)
HenryJ General Coding Help 3 2,785 Feb-21-2018, 06:44 AM
    Thread: why the generator expression after IF always returns True
Post: why the generator expression after IF always retur...

Hi, Why is the generator expression after IF statement always return True? Is it because the if statement only checks whether there is a new value "generated" by the expression, if so, then it will r...
HenryJ General Coding Help 1 2,720 Feb-13-2018, 06:59 AM
    Thread: Django model.py model.foreignkey()
Post: Django model.py model.foreignkey()

Hi All, I am a newbie on Django framework and a bit confused on the models. 1. When a "class" in the model.py, can I just understand it as "table" in database? For example, in the code below, "Test...
HenryJ Web Scraping & Web Development 1 3,232 Feb-08-2018, 06:00 AM
    Thread: Django-admin.exe
Post: Django-admin.exe

Hi guys, I am using Win10 OS. I installed Django framework using cmd. After installation completed, I got the "Django-admin" in the folder python\Scripts, which is expected. If I want to create Djang...
HenryJ General Coding Help 1 4,388 Feb-06-2018, 07:41 AM
    Thread: why is this try.....except statement not working?
Post: RE: why is this try.....except statement not worki...

(Feb-06-2018, 02:48 AM)Larz60+ Wrote: don't know what else is for, try: for repo_dict in repo_dicts: try: descr=repo_dict['description'] print('\nName:',repo_dict['name']) print('Owner:',repo_dict['...
HenryJ General Coding Help 3 8,771 Feb-06-2018, 02:57 AM
    Thread: why is this try.....except statement not working?
Post: why is this try.....except statement not working?

Hi all, I received an exception UnicodeEncodeError: 'UCS-2' codec can't encode characters in position 34-34: Non-BMP character not supported in TkSo I try to use the statement "try...except...else" t...
HenryJ General Coding Help 3 8,771 Feb-06-2018, 02:45 AM
    Thread: sorted dictionary?
Post: sorted dictionary?

Hi experts, This is a short one **smile** Just wondering if there is a way to sort the print out of a dictionary. For example, if I print the dictionary, I got the result like: {2: 16, 5: 22, 4: 20...
HenryJ General Coding Help 2 2,820 Feb-05-2018, 08:02 AM
    Thread: how to print out all the link <a> under each h2 section using beautifulsoup
Post: RE: how to print out all the link <a> under each h...

(Feb-02-2018, 02:51 AM)metulburr Wrote: print(h2.a.text.strip())Thank you so much for your kind help. It works! Best Regards, Henry
HenryJ Web Scraping & Web Development 2 12,462 Feb-02-2018, 02:55 AM
    Thread: how to print out all the link <a> under each h2 section using beautifulsoup
Post: how to print out all the link <a> under each h2 se...

Hi all, I am a newbie on Python, forgive me if my question sounds silly. So I am trying to print out all the <a> url under each h2 section. The html structure is like: <div> <h2&...
HenryJ Web Scraping & Web Development 2 12,462 Feb-02-2018, 02:43 AM

User Panel Messages

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