UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 308: character maps to

2014-11-14 Thread satishmlmlml
For 'mimetypes' in the code given below, python is giving the following error. Kindly help. >>> import os >>> matches = [] >>> for (dirname, dirshere, fileshere) in os.walk(r'C:\Python34'): for filename in fileshere: if filename.endswith('.py'): pat

How to get file descriptors of sys.stdin, sys.stdout and sys.stderr?

2014-11-13 Thread satishmlmlml
How to get file descriptors of sys.stdin, sys.stdout and sys.stderr? -- https://mail.python.org/mailman/listinfo/python-list

How to get file descriptors of sys.stdin, sys.stdout and sys.stderr?

2014-11-13 Thread satishmlmlml
How to get file descriptors of sys.stdin, sys.stdout and sys.stderr? -- https://mail.python.org/mailman/listinfo/python-list

Re: fileno() not supported in Python 3.1

2014-11-13 Thread satishmlmlml
How to get file descriptor number for the following: sys.stdin sys.stdout sys.stderr It is displaying io.UnsupportedOperation: fileno error Kindly help. -- https://mail.python.org/mailman/listinfo/python-list

fileno() not supported in Python 3.1

2014-11-13 Thread satishmlmlml
import sys for stream in (sys.stdin, sys.stdout, sys.stderr): print(stream.fileno()) io.UnsupportedOperation: fileno Is there a workaround? -- https://mail.python.org/mailman/listinfo/python-list

Bad file descriptor

2014-11-13 Thread satishmlmlml
import os os.write(1, b'Hello descriptor world\n') OSError: Bad file descriptor How to give a file descriptor number to this function? How to get a file descriptor number? -- https://mail.python.org/mailman/listinfo/python-list

Re: io.UnsupportedOperation: fileno

2014-11-13 Thread satishmlmlml
fileno() in not supported. Is it only in 3.1? What is the workaround? -- https://mail.python.org/mailman/listinfo/python-list

Re: io.UnsupportedOperation: fileno

2014-11-13 Thread satishmlmlml
What is the problem and how to overcome this problem? -- https://mail.python.org/mailman/listinfo/python-list

io.UnsupportedOperation: fileno

2014-11-13 Thread satishmlmlml
import sys for stream in (sys.stdin, sys.stdout, sys.stderr): print(stream.fileno()) io.UnsupportedOperation: fileno -- https://mail.python.org/mailman/listinfo/python-list

How to recover bytes function?

2014-11-13 Thread satishmlmlml
file = open('data.bin', 'rb') bytes = file.read() bytes b'\x00\x00\x00\x02spam\x00\x03?\x9d\xf3\xb6' records = [bytes([char] * 8) for char in b'spam'] TypeError: 'bytes' object is not callable How to recover bytes function? -- https://mail.python.org/mailman/listinfo/python-list

What is ?s here?

2014-11-11 Thread satishmlmlml
What does ?s do in the following piece of code? import re, pprint text = open('books.xml').read() pattern = '(?s)isbn="(.*?)".*?(.*?)' found = re.findall(pattern, text) mapping = {isbn: title for (isbn, title) in found} pprint.pprint(mapping) Here is books.xml Python & XML

What is \1 here?

2014-11-11 Thread satishmlmlml
What does \1 do in the following piece of code(fourth line)? import re print(re.sub('[ABC]', '*', 'XAXAXBXBXCXC')) print(re.sub('[ABC]_', '*', 'XA-XA_XB-XB_XC-XC_')) print(re.sub('(.) spam', 'spam\\1', 'x spam, y spam')) def mapper(matchobj): return 'spam' + matchobj.group(1) print(re.sub('(

What does (?P) pattern syntax do?

2014-11-10 Thread satishmlmlml
What does ?P and match in the following piece of code? re.search('(?P\w*)/(?P\w*)', '...aaa/bbb/ccc]').groups() -- https://mail.python.org/mailman/listinfo/python-list

What is rstrip() in python?

2014-11-09 Thread satishmlmlml
What is rstrip() in python? What does it do in the following piece of code? import sqlite3 conn = sqlite3.connect('dbase1') curs = conn.cursor() file = open('data.txt') rows = [line.rstrip().split(',') for line in file] -- https://mail.python.org/mailman/listinfo/python-list

Re: What is description attribute in python?

2014-11-09 Thread satishmlmlml
curs is coming from the following piece of code import sqlite3 conn = sqlite3.connect('dbase1') curs = conn.cursor() -- https://mail.python.org/mailman/listinfo/python-list

What does zip mean?

2014-11-09 Thread satishmlmlml
What does zip return in the following piece of code? curs.execute('select * from people') colnames = [desc[0] for desc in curs.description] rowdicts = [] for row in curs.fetchall(): rowdicts.append(dict(zip(colnames, row))) -- https://mail.python.org/mailman/listinfo/python-list

What is description attribute in python?

2014-11-09 Thread satishmlmlml
What does description attribute in the following code mean? curs.execute('select * from people') colnames = [desc[0] for desc in curs.description] -- https://mail.python.org/mailman/listinfo/python-list

Popen class?

2014-10-31 Thread satishmlmlml
What is Popen class? -- https://mail.python.org/mailman/listinfo/python-list

What does %%(%s)s mean/expand to in Python? What does rowshtml += (rowhtml % ((fieldname, ) * 3)) expand to? Kindly explain.

2014-10-28 Thread satishmlmlml
def fetchRecord(db, form): try: key = form['key'].value record = db[key] fields = record.__dict__ fields['key'] = key except: fields = dict.fromkeys(fieldnames, '?') fields['key'] = 'Missing or invalid key!' return fields def updateRecord(db, form): if not 'key' in form:

Re: %%(%s)s mean in python

2014-10-28 Thread satishmlmlml
also what does rowshtml += (rowhtml % ((fieldname,) * 3)) expand to? -- https://mail.python.org/mailman/listinfo/python-list

%%(%s)s mean in python

2014-10-28 Thread satishmlmlml
def fetchRecord(db, form): try: key = form['key'].value record = db[key] fields = record.__dict__ fields['key'] = key except: fields = dict.fromkeys(fieldnames, '?') fields['key'] = 'Missing or invalid key!' return fields def updateRecord(db, form): if not 'key' in form:

Re: % symbol in python

2014-10-28 Thread satishmlmlml
kindly let me know what does %%(%s)% mean -- https://mail.python.org/mailman/listinfo/python-list

Re: % symbol in python

2014-10-28 Thread satishmlmlml
import cgi, shelve, sys, os shelvename = 'class-shelve' fieldnames = ('name', 'age', 'job', 'pay') form = cgi.FieldStorage() print('Content-type: text/html') sys.path.insert(0, os.getcwd()) replyhtml = """ People Input Form key $ROWS$ """ rowhtml = '%s\n' rows

Re: % symbol in python

2014-10-28 Thread satishmlmlml
import cgi, shelve, sys, os shelvename = 'class-shelve' fieldnames = ('name', 'age', 'job', 'pay') form = cgi.FieldStorage() print('Content-type: text/html') sys.path.insert(0, os.getcwd()) replyhtml = """ People Input Form key $ROWS$ """ rowhtml = '%s\n' rowshtml = '' for fieldname in fi

% symbol in python

2014-10-28 Thread satishmlmlml
key rowhtml = '%s\n" what does % mean in first line of code and what does %%(%s)s mean in second line of code kindly explain -- https://mail.python.org/mailman/listinfo/python-list