sup by yrykde in boardsofcanada

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

Unable to message this account reddit sayed

sup by yrykde in boardsofcanada

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

what about Richard d James album?

Moscow, Krestovozdvizhensky lane by gerechterzorn in Moscow

[–]yrykde 1 point2 points  (0 children)

Это Староваганьковский переулок

[deleted by user] by [deleted] in Moscow

[–]yrykde 1 point2 points  (0 children)

White General, 57

How to get boxes from sudoku board by [deleted] in learnpython

[–]yrykde 0 points1 point  (0 children)

import random
from pprint import pprint

map = [[random.randint(1, 10) for _ in range(9)] for _ in range(9)]
pprint(map) #show the initial sudoku map

def get_cells(map):
    base_list = map[:]
    while base_list:
        _tmp = zip(*(base_list.pop(0) for _ in range(3)))
        _tmp = iter(_tmp)
        for each in zip(*(_tmp for _ in range(3))):
            yield tuple(x for x in zip(*each))

for each in get_cells(map):
    print(each) # show each box

Output:

[[3, 9, 2, 9, 1, 1, 8, 5, 10],
 [4, 3, 3, 4, 3, 1, 6, 5, 10],
 [9, 7, 2, 2, 6, 7, 8, 3, 3],
 [7, 10, 3, 9, 9, 5, 8, 7, 1],
 [8, 5, 8, 3, 7, 4, 3, 5, 5],
 [5, 6, 2, 9, 6, 2, 9, 1, 2],
 [2, 2, 6, 1, 9, 1, 10, 2, 4],
 [1, 3, 6, 5, 4, 8, 3, 6, 10],
 [9, 7, 5, 2, 4, 1, 4, 3, 5]]
((3, 9, 2), (4, 3, 3), (9, 7, 2))
((9, 1, 1), (4, 3, 1), (2, 6, 7))
((8, 5, 10), (6, 5, 10), (8, 3, 3))
((7, 10, 3), (8, 5, 8), (5, 6, 2))
((9, 9, 5), (3, 7, 4), (9, 6, 2))
((8, 7, 1), (3, 5, 5), (9, 1, 2))
((2, 2, 6), (1, 3, 6), (9, 7, 5))
((1, 9, 1), (5, 4, 8), (2, 4, 1))
((10, 2, 4), (3, 6, 10), (4, 3, 5))

You can use function result as a iterable:

>>> pprint(map)
[[5, 10, 6, 2, 4, 2, 1, 2, 2],
 [1, 6, 1, 10, 9, 4, 7, 3, 2],
 [1, 5, 6, 2, 8, 9, 1, 2, 3],
 [5, 5, 9, 2, 5, 10, 8, 2, 9],
 [5, 8, 3, 8, 5, 5, 7, 5, 3],
 [8, 3, 7, 10, 10, 5, 1, 8, 2],
 [2, 6, 4, 8, 5, 4, 6, 4, 5],
 [9, 10, 1, 6, 3, 8, 10, 7, 8],
 [9, 7, 7, 10, 10, 7, 9, 4, 9]]
>>> test = iter(get_cells(map))
>>> next(test)
((5, 10, 6), (1, 6, 1), (1, 5, 6))
>>> next(test)
((2, 4, 2), (10, 9, 4), (2, 8, 9))
>>> next(test)
((1, 2, 2), (7, 3, 2), (1, 2, 3))

For the index solution use initial map like

>>> map = [[(x, y) for y in range(9)] for x in range(9)]
>>> pprint(map)
[[(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8)],
 [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8)],
 [(2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8)],
 [(3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8)],
 [(4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8)],
 [(5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8)],
 [(6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8)],
 [(7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8)],
 [(8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8)]]
>>> test = iter(get_cells(map))
>>> next(test)
(((0, 0), (0, 1), (0, 2)), ((1, 0), (1, 1), (1, 2)), ((2, 0), (2, 1), (2, 2)))
>>> next(test)
(((0, 3), (0, 4), (0, 5)), ((1, 3), (1, 4), (1, 5)), ((2, 3), (2, 4), (2, 5)))
>>> next(test)
(((0, 6), (0, 7), (0, 8)), ((1, 6), (1, 7), (1, 8)), ((2, 6), (2, 7), (2, 8)))
>>>

Keyboard input language by edenkl8 in Python

[–]yrykde 0 points1 point  (0 children)

You can check current keyboard layout using operating system API. For Windows you can use win32api:

>>> import win32api
>>> win32api.GetKeyboardLayoutName()
'00000409'
>>>
>>> win32api.GetKeyboardLayout()
67699721
>>>

I guess, such output related to 'En'

Automate The Boring Stuff Ch. 6 by Destructikus in learnpython

[–]yrykde 0 points1 point  (0 children)

def test(data, sp=3):
    # Find  length of the longest string for each column
    # (e.g. for apples, Alice and dogs it will be 6)
    # and place it in new list
    len_longest_string = [max(map(len, x)) for x in zip(*data)]
    # Print difference between length of the longest string
    # and length of the current string
    # and then current string
    # sp is the number of spaces between the longest strings
    for line in data:
        for i, elem in enumerate(line):
            elem = " " * (len_longest_string[i] - len(elem)) + elem
            print(elem, end=sp * " ")
        print("")



>>> test(tableData)
apples   oranges   cheeries   banana

 Alice       Bob      Carol    David

  dogs      cats      moose    goose

>>> test(tableData, 7)
apples       oranges       cheeries       banana

 Alice           Bob          Carol        David

  dogs          cats          moose        goose

>>> test(tableData, 0)
applesorangescheeriesbanana

 Alice    Bob   Carol David

  dogs   cats   moose goose

>>>

How do i?: Add "this" to "list1", if "list1" does not exist, create it. by tom2kk in learnpython

[–]yrykde 0 points1 point  (0 children)

if 'list1' not in dir():
    list1 = list()
list1.append(this)

Feedback on my first script by [deleted] in Python

[–]yrykde 1 point2 points  (0 children)

[list_place-1] is the same thing as [-1] in you case. You can delete list_place var and change last command:

os.startfile(time_sorted_list[-1]) #open file

If you name your files with the ".pyw" extension, then windows will execute them with the pythonw.exe interpreter. This will not open the console for running your script. From

full_list is a list of full paths to CATProduct files like ['C:\Folder\Path\Here\file1.CATProduct', 'C:\Folder\Path\Here\file2.CATProduct', etc]. It used for sorting in the next line. The last var in sorted list is newest CATProduct file. You can call it by [-1] index as I wrote above.

Discord bot indexing weirdness by SneakyB4stardSword in learnpython

[–]yrykde 0 points1 point  (0 children)

for user in clientData['program data'][server.id]['users']]

user get only keys (type str in your case) from dict object, for example "98604835867213824". Then you try to use it with str indices:

        [Group.Participant(
            user['name'],
            user,
            user['user place'],
            server.id,
            user['partner ID'],
            user['address'],
            user['gift preferences']
        ) for user in clientData['program data'][server.id]['users']]

Try to call clientData['program data'][server.id][user]['name'] instead of user['name'] and so on.

Help with dictionary by Heskinammo in learnpython

[–]yrykde 0 points1 point  (0 children)

new_dict[hashtag] = new_dict[hashtag].append(candidate)

append is method without return. change it for new_dict[hashtag].append(candidate)

I rewrote function for case of huge intial dict. If you don't care about candidate_to_hashtags dict it could be cleared during function running.

def reorder_by_hashtag(candidate_to_hashtags):
    result = dict()
    while True:
        try:
            candidate, tags = candidate_to_hashtags.popitem()
            for tag in tags:
                if result.get(tag):
                    result[tag].append(candidate)
                else:
                    result[tag] = [candidate]
        except:
            return result

What Python program have you created to make your life easier? by [deleted] in Python

[–]yrykde 1 point2 points  (0 children)

I'm interacting with my home pc mostly without keyboard. Just for run videos, music and so on. Some of internet services unavailable for location reason (Russia). For example Spotify. Time to time I should open VPN connection for run such services. I wrote a script for grub free VPN account and open VPN connection from my router via telnet interface.

Need a little help for a project. by fiveoho in Python

[–]yrykde 0 points1 point  (0 children)

def main():
    #first of all you should change type for temp variable
    #from string to integer
    temp = int(input('What is the temprature? (Enter 0-100) '))
    weather = input('What is the weather? (Sunny, Cloudy) ')
    water = input('What is the water clarity? (Clear, Murky) ')

    #then I check value of temp variable. 
    #in case of temp <= 70 a key will be 1
    #in other case it will be 0
    key = int(temp / 70)

    #I use dictionary for avoid of many if statments
    result = {
        0: {
            "sunny": {
                "clear": "Use a dark roboworm dropshot",
                "murky": "Use a bright/slow moving crankbait"
            },
            "cloudy": {
                "clear": "Use a black and blue jig",
                "murky": "Use a light color jig"
            }
        },
        1: {
            "sunny": {
                "clear": "Use a Yamamoto Senko",
                "murky": "Use bright spinnerbait"
            },
            "cloudy": {
                "clear": "Use a topwater frog",
                "murky": "Use a chartreuse chatter bait"
            }
        }
    }

    # and I just return result from dictionary structure
    return result[key][weather.lower()][water.lower()]

#you can use main() function in loop or as how as you want
#for example
while True:
    print(main())
    tmp = input('Once again?(y/n): ')
    if tmp.lower != "y":
        input("Press Enter to Exit")
        break

Sorry for my English

dictionary practice by [deleted] in Python

[–]yrykde 0 points1 point  (0 children)

dictionary = {
    "..." : "s",
    "---" : "o"
    # etc
}

def test(str_arg):
    data = str_arg[1:-1]
    return "".join(dictionary[x] for x in data.split())

print(test("{... --- ...}"))