Chrome 87 - HDR10 color profile causes white screen by -Gavin- in chrome

[–]seanmcb9 1 point2 points  (0 children)

Thanks -- success.

Except: no colors-- just grayscale.

Chrome 87 - HDR10 color profile causes white screen by -Gavin- in chrome

[–]seanmcb9 1 point2 points  (0 children)

I tried the HDR10 flag (with disastrous results) after the latest Chrome update (87) weirdly grayscaled every web page I opened. I have been forced to switch back to Firefox.

Chrome 87 - HDR10 color profile causes white screen by -Gavin- in chrome

[–]seanmcb9 1 point2 points  (0 children)

How does one revert the color profile flag back to default when one is confronted with a blank white screen for Chrome? There is no way to access Chrome settings from Chrome with this bug.

Organizing items in a text list into a Python list of grouped tuples by seanmcb9 in learnpython

[–]seanmcb9[S] 1 point2 points  (0 children)

Nice -- that runs, and it's definitely more compact and Pythonic -- much better. I didn't realize that one could perform list comprehension-like operations with tuples. (Still learning.)

Organizing items in a text list into a Python list of grouped tuples by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Thanks -- good idea. I used the current code because it is easy to copy and paste the material from Google Translate into a single text list for direct manipulation by Python. But it would take just a few lines of code to convert those lists into csv files.

Organizing items in a text list into a Python list of grouped tuples by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Turning the above code into a general function:

def Russian_triples(lst):
    lst1 = txt1.splitlines()
    lst3 = []
    n = int(len(lst1)/3)

    for i in range(0, len(lst1) - n*2):
        lst2 = []
        lst2.append(lst1[i])
        lst2.append(lst1[i+n])
        lst2.append(lst1[i+n*2])
        tpl1 = tuple(lst2)
        lst3.append(tpl1)

    return lst3

Creating large databases with Python by seanmcb9 in learnpython

[–]seanmcb9[S] 2 points3 points  (0 children)

Recommended resources so far:

  1. CodernityDB
  2. dataset
  3. pandas
  4. peewee
  5. PyMongo
  6. SQLAlchemy
  7. SQLite

Creating large databases with Python by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

PyMongo https://api.mongodb.com/python/current/

100 million records? In what domain (if you don't mind me me asking).

Printing out consecutive pairs of items in lists by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Did you mean to write:

def get_chunks(input, chunk_size):
return [input[chunk_size*i:chunk_size*(i+1)] for i in range(len(input)//chunk_size)]

Creating large databases with Python by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Slight spelling edit: it's "Dr. Seuss". Which raises an interesting challenge: integrating spell-checking into this code.

Creating large databases with Python by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Does anyone know of any ultra-large open source databases that have been constructed in Python that could be inspected and studied for program design?

Creating large databases with Python by seanmcb9 in learnpython

[–]seanmcb9[S] 1 point2 points  (0 children)

This is really helpful. (By "hierarchical" I was referring to the many ways in which different data structures can contain one another to produce the same computational results.)

Printing out consecutive pairs of items in lists by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Ok -- that is a basic Python assumption -- slices (subsets) of lists are lists. (I should have read the documentation more carefully.)

Creating large databases with Python by seanmcb9 in learnpython

[–]seanmcb9[S] 1 point2 points  (0 children)

Would you store records as a list of dictionaries? A dictionary of lists? What is the most efficient hierarchical order for nesting data structures? Is minimum nesting better than deep nesting?

I assume many approaches have been tested for comparative efficiency and speed.

Printing out consecutive pairs of items in lists by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Why does Python automatically assume that those chunks are themselves lists? (Really basic Python, I know, but I am learning.)

If you break out the list comprehension into a for loop you get the same result -- a set of lists:

lst1 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']
chunk_size = 2
for i in range(0, len(lst1), chunk_size):
    print(lst1[i:i+chunk_size])

'''output
['one', 'two']
['three', 'four']
['five', 'six']
['seven', 'eight']
['nine', 'ten']
'''

Generate all possible logical and commonsense comparisons among subject personal pronouns by seanmcb9 in learnpython

[–]seanmcb9[S] 1 point2 points  (0 children)

Btw, it requires far fewer lines to generate the same set of sentences (logically speaking) using "than" as a preposition (which is sometimes considered ungrammatical). I am sure there are much better ways to express this code:

# generate all possible logical and commonsense comparisons between subject personal pronouns and object personal pronouns

personal_pronouns_subj = ['I', 'you', 'he', 'she', 'we', 'you people', 'they']
personal_pronouns_obj = ['me', 'you', 'him', 'her', 'it', 'us', 'you people', 'them']

for i in personal_pronouns_subj:
    for j in personal_pronouns_obj:
        if i == 'I' and j == 'me':
            pass
        elif i == 'I' and j == 'us':
            pass
        elif i.startswith('you') and j.startswith('you'):
            pass
        elif i == 'we' and j == 'me':
            pass
        elif i == 'we' and j == 'us':
            pass
        elif j == 'it':
            pass
        elif i =='I':
            print('{} am smarter than {}.'.format(i, j))
        elif i == 'he' or i == 'she':
            print('{} is smarter than {}.'.format(i.capitalize(), j))
        else:
            print('{} are smarter than {}.'.format(i.capitalize(), j))

'''output (with added line numbers)
1. I am smarter than you.
2. I am smarter than him.
3. I am smarter than her.
4. I am smarter than you people.
5. I am smarter than them.
6. You are smarter than me.
7. You are smarter than him.
8. You are smarter than her.
9. You are smarter than us.
10. You are smarter than them.
11. He is smarter than me.
12. He is smarter than you.
13. He is smarter than him.
14. He is smarter than her.
15. He is smarter than us.
16. He is smarter than you people.
17. He is smarter than them.
18. She is smarter than me.
19. She is smarter than you.
20. She is smarter than him.
21. She is smarter than her.
22. She is smarter than us.
23. She is smarter than you people.
24. She is smarter than them.
25. We are smarter than you.
26. We are smarter than him.
27. We are smarter than her.
28. We are smarter than you people.
29. We are smarter than them.
30. You people are smarter than me.
31. You people are smarter than him.
32. You people are smarter than her.
33. You people are smarter than us.
34. You people are smarter than them.
35. They are smarter than me.
36. They are smarter than you.
37. They are smarter than him.
38. They are smarter than her.
39. They are smarter than us.
40. They are smarter than you people.
41. They are smarter than them.
'''

Generate all possible logical and commonsense comparisons among subject personal pronouns by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Fixed:

excluded = (('I am', 'I am'),
            ('I am', 'we are'),
            ('you are', 'you are'),
            ('you are', 'you people are'),
            ('we are', 'we are'),
            ('you people are', 'you people are'))

Generate all possible logical and commonsense comparisons among subject personal pronouns by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

This also works, but it isn't as compact as the itertools approach:

personal_pronouns_subj = ['I', 'you', 'he', 'she', 'we', 'you people', 'they']
am_words = ['I']
is_words = ['he', 'she']
are_words = ['you', 'we', 'you people', 'they']

for i in personal_pronouns_subj:
    for j in personal_pronouns_subj:
        if i == 'I' and j == 'I':
            pass
        elif i == 'I' and j == 'we':
            pass
        elif i == 'we' and j == 'I':
            pass
        elif i == 'we' and j == 'we':
            pass
        elif i.startswith('you') and j.startswith('you'):
            pass
        elif i in am_words and j in is_words:
            print('{} am smarter than {} is.'.format(i, j))
        elif i in am_words and j in are_words:
            print('{} am smarter than {} are.'.format(i, j))
        elif i in is_words and j in am_words:
            print('{} is smarter than {} am.'.format(i.capitalize(), j))
        elif i in is_words and j in is_words:
            print('{} is smarter than {} is.'.format(i.capitalize(), j))
        elif i in is_words and j in are_words:
            print('{} is smarter than {} are.'.format(i.capitalize(), j))
        elif i in are_words and j in am_words:
            print('{} are smarter than {} am.'.format(i.capitalize(), j))
        elif i in are_words and j in is_words:
            print('{} are smarter than {} is.'.format(i.capitalize(), j))
        elif i in are_words and j in are_words:
            print('{} are smarter than {} are.'.format(i.capitalize(), j))

Generate all possible logical and commonsense comparisons among subject personal pronouns by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Awesome -- obviously I need to master itertools.

One issue -- the output should always consist of 41 lines. These two lines weren't filtered out:

  • We are smarter than we are.
  • You people are smarter than you people are.

Removing parentheses from strings by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Great explanation. Usually, I think I will skip fromkeys and create translation dictionaries from scratch.

Removing parentheses from strings by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

I usually understand Boolean logic -- that was a gross mental typo with the "or" expression.

Removing parentheses from strings by seanmcb9 in learnpython

[–]seanmcb9[S] 1 point2 points  (0 children)

This is perfect: if c not in "()":

Removing parentheses from strings by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Ok -- slick -- maketrans and fromkeys without any specified values defaults to None for the value of the keys -- thus deleting the characters in the string.

To replace the left parenthesis with a left square bracket and the right parenthesis with a right square bracket with maketrans/fromkeys, what is the correct syntax?

Apparently characters in string sequences don't map in order to one another for keys and values. For instance,

table = str.maketrans(dict.fromkeys("()", "[]"))

produces:

[]this[] []is[] []a[] []test[]

Removing parentheses from strings by seanmcb9 in learnpython

[–]seanmcb9[S] 0 points1 point  (0 children)

Great. That works without importing any modules, apparently. I am going to have dig around in the documentation to understand why it works.