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?
--
https://mail.python.org/mailman/listinfo/python-list
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 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
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
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
fileno() in not supported. Is it only in 3.1? What is the workaround?
--
https://mail.python.org/mailman/listinfo/python-list
What is the problem and how to overcome this problem?
--
https://mail.python.org/mailman/listinfo/python-list
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
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 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 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 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?
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
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 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 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
What is Popen class?
--
https://mail.python.org/mailman/listinfo/python-list
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:
also
what does
rowshtml += (rowhtml % ((fieldname,) * 3)) expand to?
--
https://mail.python.org/mailman/listinfo/python-list
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:
kindly let me know
what does
%%(%s)% mean
--
https://mail.python.org/mailman/listinfo/python-list
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
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
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
25 matches
Mail list logo