Hi,
I want to sub-class the datetime.timezone class, but when I derive from
datetime.timezone I get an error message "TypeError: type
'datetime.timezone' is not an acceptable base type".
Why do I get this error? Is there something specific to do to avoid it?
Below is an example of code:
Python 3
2011/1/1 Stefan Behnel
> Baptiste Lepilleur, 01.01.2011 10:01:
>
> Hi,
>> I'm trying to port a small library to Python 3.x, and I'm wondering what
>> is
>> the best way to port statements such as the one belows that are
>> frequently
>> found in
2011/1/1 Stefan Behnel
> Terry Reedy, 01.01.2011 11:08:
>
> On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote:
>>
>> Is there a way to mark string literals so that 2to3 automatically
>>> prefixes them with 'b'? Is there a simpler trick?
>>>
>
Hi,
I'm trying to port some network protocol library to Python 3.x, and it
defines many bytes literals as plain string.
How do you define bytes literals so that the library can be ported to Python
3.x using only 2to3? For example:
In python 2.x, I need:
self.buffer = '\n'
In python 3.x,
Hi,
I'm trying to port a small library to Python 3.x, and I'm wondering what is
the best way to port statements such as the one belows that are frequently
found in network protocol implementation:
headerparts = ("%s:%s\n" % (key, value) for key, value in
headers.iteritems())
frame
Hi,
I stumbled on a small bug with httplib2 that I reduced to the example below.
It seems that with Python 3, when an exception is handled it "unbound" the
previously declared local variable. This did not occurs with Python 2.5.
It is a Python 3 feature? I did not find anything in the what's news
2010/2/24 Lars Gustäbel
> On Wed, Feb 24, 2010 at 09:37:19AM +0100, Baptiste Lepilleur wrote:
> > I stumbled uppon this and find it somewhat odd: some class methods of
> > TarFile and TarInfo do not appears in either the online documentation or
> > search while t
I stumbled uppon this and find it somewhat odd: some class methods of
TarFile and TarInfo do not appears in either the online documentation or
search while they have a doc string:
http://docs.python.org/search.html?q=gzopen
http://docs.python.org/library/tarfile.html?highlight=tarfile#tarfile.TarF
Reading python io.IOBase class documentation, I'm kind of confused at the
expected behavior of operation on a closed file object.
The io.IOBase class doc says:
"""Note that calling any method (even inquiries) on a closed stream is
undefined. Implementations may raise
IOErrorin this case."""
But t
Hi,
I'm looking for the equivalent of the built-in chr(x) function that would
return a bytes type taking an integer as parameter.
The easiest way I found to do this is the function below, but there must be
some simpler way to do that and I must be overlooking something fairly
obvious...
def byte(
By adding a before the closing brace of the tucomma after 1. Python allow
this to disambiguate between braced expression and tuple
>>> type( (1,) )
2009/12/4 Петров Александр
>
> How could I tell Python that "(1)" is not an integer, but an one-arity
> tuple ?
>
> Thank you,
> Alexander Petrov
By adding a before the closing brace of the tuple. Python allow this to
disambiguate between braced expression and tuple
>>> type( (1,) )
2009/12/4 Петров Александр
>
> How could I tell Python that "(1)" is not an integer, but an one-arity
> tuple ?
>
> Thank you,
> Alexander Petrov
> --
> ht
I think you can use python itself for "pre-processing". Here is an
(shortened) example from PyPy RPython paper:
# operators: the docstrings contain the
# symbol associated with each operator
class Op_Add(BinaryExpr):
’+’
class Op_Sub(BinaryExpr):
’-’
# INIT-TIME only: build the table of
#
2009/11/7 MRAB
> Baptiste Lepilleur wrote:
>
[..]
>> Do I need to replace all codecs.open with the built-in open function? If
>> so, why does codecs.open still exist?
>>
>> The documentation says of codecs.open() that "Files are always opened in
> b
After applying 2to3.py to port a 2.6 script to 3.1, I get the following
error when running my script:
File "purekeyworddbtest.py", line 143, in __init__
f = codecs.open(EXCLUDED_KEYWORDS_FILE, 'rt', 'utf-8')
File "c:\Python31\lib\codecs.py", line 870, in open
file = builtins.open(filena
I'm looking for a tool that could be used in a pre-commit step to check that
only features available in a "old" python version are used, say python 2.3
for example.
Does any one know of one ?
--
http://mail.python.org/mailman/listinfo/python-list
I activated httplib debug, and when trace are printed, a UnicodeError
exception is thrown. I have already set sys.stdout to use utf-8 encoding
(this removed the exception when *I* was printing unicode), but from the
stacktrace below, the encoding seems to magically have switched to 'ascii'
when
17 matches
Mail list logo