struct.(un)pack and ASCIIZ strrings

2005-06-18 Thread Sergey Dorofeev
I can use string.unpack if string in struct uses fixed amount of bytes. But is there some extension to struct modue, which allows to unpack zero-terminated string, size of which is unknown? E.g. such struct: long, long, some bytes (string), zero, short, short, short. -- http://mail.python.org/ma

treating MIME messages

2006-12-21 Thread Sergey Dorofeev
Hello all. Anybody who has idle time, please look at my version of MIME tools at http://www.fidoman.ru/prog/mime/. Questions and critical notes are welcome. If somebody will consider that interesting, I will refine these modules and put to pypi. -- http://mail.python.org/mailman/listinfo/pyth

subexpressions

2007-06-01 Thread Sergey Dorofeev
Hello all! Please help, is there way to use sub-expressions in lambda? For example, if I want to calculate sin(x^2)+cos(x^2) I must code: lambda x: sin(x*x)+cos(x*x) How to make x*x to be evaluated once? -- http://mail.python.org/mailman/listinfo/python-list

Re: subexpressions

2007-06-01 Thread Sergey Dorofeev
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Please help, is there way to use sub-expressions in lambda? For example, if I want to calculate sin(x^2)+cos(x^2) I must code: lambda x: sin(x*x)+cos(x*x) How to make x*x to be evaluated once? >>> >>

Re: subexpressions

2007-06-01 Thread Sergey Dorofeev
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Sergey Dorofeev wrote: > >> Please help, is there way to use sub-expressions in lambda? >> For example, if I want to calculate sin(x^2)+cos(x^2) I must code: >> lambda x: si

Re: subexpressions

2007-06-01 Thread Sergey Dorofeev
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What syntax would you suggest for a lambda enhanced to cover your use > case? > I suppose you will end up with roughly the same number of characters, all > crammed in one line -- or broken into lines at a random positio

module email

2007-01-24 Thread Sergey Dorofeev
Hello. Why does not work? -- import email.message import smtplib import time m=email.message.Message() m.set_type("multipart/mixed") m["From"]="Sergey Dorofeev <[EMAIL PROTECTED]>" m["To"]="Sergey Dorofeev <[EMAIL PROTECTE

Re: module email

2007-01-25 Thread Sergey Dorofeev
"Rob Wolfe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> p2=email.message.Message() >> p2.set_type("message/rfc822") >> p2.set_payload(m) > > Payload is a _list_ of Message objects (is_multipart() == True) > or a _string_ object (is_multipart() == False) but never just Message

f---ing typechecking

2007-02-14 Thread Sergey Dorofeev
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> (1,)+[1] Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate tuple (not "list") to tuple >>> [1]+(1,)

Re: f---ing typechecking

2007-02-14 Thread Sergey Dorofeev
"James Stroud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >[1]+(1,) >> >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: can only concatenate list (not "tuple") to list >> >> >> Its ugly and boring. > > Agreed. This would be similar to: > > py> 1

Re: f---ing typechecking

2007-02-14 Thread Sergey Dorofeev
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It's effectively a tuple with field names. I don't know when the switch > occurred (it's in 2.2, as far back as my built interpreter versions > currently go), but back in the day os.stat used to return a plain old > tuple. posix.sta