Skip to content

Instantly share code, notes, and snippets.

@kkoyun
kkoyun / gist:18423287f08051e721b67aeb891cc47f
Last active October 17, 2017 14:33
requests modülüyle dosya çekip yazmak / downloading files with "requests" module and saving them
#!/usr/bin/env python3
# requests modülüyle ilgili detaylı açıklamalar (ingilizce) http://requests.readthedocs.io/ sitesinde
# mac OS'te Python'a eklemek için terminal penceresinde (Python 3.x için)
# pip3 install requests
# windows'ta ekleme için komut penceresinde
# pip install requests
import requests
@kkoyun
kkoyun / gist:71ccb37cc7cd4bf1c2722a1876c3a807
Created October 8, 2017 05:24
Shelve modülüyle liste saklanması / Storage of lists via shelve module
#!/usr/bin/env python3
import shelve
# "shelf" dosyalarında her listenin bir ismi olmak zorunda
# Bu modül kullanılarak bir shelf dosyasındafarklı isimlerle birden çok
# liste saklanabilir.
# Every list in a shelf file is required to have a name
# More than one list can be stored in a shelf file using
@kkoyun
kkoyun / gist:60d9ca095a26ac2107332cd08cb02bad
Last active October 1, 2017 16:27
Kelimeleri ayırmak / Getting words separately
#! Python3
import re
string = '[Hello, World Şeyma!]'
pattern = r'\b(\w+)\b'
sRegex = re.compile(pattern)
mo = sRegex.findall(string)
print(mo)
@kkoyun
kkoyun / tahta python türkiye.py
Last active September 13, 2017 14:12
List manipulation example
#! python3
ilkTahta = [['a', 1],['a', 2],['a', 3],
['b', 1],['b', 2],['b', 3],
['c', 1],['c', 2],['c', 3]]
sonTahta = [['a', 1],['a', 2],['a', 3],
['b', 1],['b', 2],['b', 3],
['c', 1],['c', 2],['c', 3]]
@kkoyun
kkoyun / character replacement.py
Created September 7, 2017 21:47
Character replacement program
kelimeNumara = {'A': '11', 'a': '11', 'E': '22', 'e': '22'}
kelime = input('Kelime giriniz: ')
kelime = list(kelime)
for i in range(len(kelime)):
    if not kelimeNumara.get(kelime[i], False):
        continue
    else:
        kelime[i] = kelimeNumara[kelime[i]]
@kkoyun
kkoyun / test deepcopy.py
Last active September 6, 2017 20:45
Testing differences between three methods to copy lists (Python3.6)
import copy
c = ['a', 'b', ['f', 'g']]
print('original list c: ', c)
print('\ndirect assignment')
d = c
print('new list d: ', d)
print('primary list equivalence:', id(c) == id(d))