Tuesday, April 13, 2010

comp.lang.python - 25 new messages in 13 topics - digest

comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en

comp.lang.python@googlegroups.com

Today's topics:

* 2.7 beta 1 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/39f109348b481411?hl=en
* !!! Kausha-s very HOT kiss scene.avi !!! - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/a829a51b4cf98243?hl=en
* curious about python version numbers - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/f8a5028affe772ed?hl=en
* packaging multiple python scripts as Windows exe file - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/3ef1def17875655c?hl=en
* Tough sorting problem: or, I'm confusing myself - 2 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/aabfedc7358f00a4?hl=en
* DjangoCon Europe - 24. - 26.5.2010 in Berlin - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/e2fac8bbf0736a6f?hl=en
* HTMLParser can't read japanese - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/86fb4a74b8ae55ba?hl=en
* Error using httlib's HTTPSConnection with PKCS#12 certificate - 1 messages,
1 author
http://groups.google.com/group/comp.lang.python/t/42d1c3972542bd2b?hl=en
* Code dojo on Thursday? - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/01c4c1aa43a144c0?hl=en
* Generating a rainbow? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/065e0b50c4aaca64?hl=en
* Unit testing errors (testing the platform module) - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/934c18b2e8f1272e?hl=en
* Handling quotes in xml.dom text nodes - 2 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/0b2a583f147f1cd7?hl=en
* Constructing an if statement from the client data in python - 1 messages, 1
author
http://groups.google.com/group/comp.lang.python/t/6c5a7a542eb39dbd?hl=en

==============================================================================
TOPIC: 2.7 beta 1
http://groups.google.com/group/comp.lang.python/t/39f109348b481411?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 12:09 am
From: Dennis Lee Bieber


On Mon, 12 Apr 2010 14:56:04 +0100, Mark Lawrence
<breamoreboy@yahoo.co.uk> declaimed the following in
gmane.comp.python.general:


> vehicle. Ok, it's slower, but it gets me there in the end.
>
Better you... Since in my case the punctuation would have to be "it
gets me, there, in the end" <G>

If it's not unseasonably rainy, my commute vehicle is an overloaded
touring style Aprilia Scarabeo 500.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/


==============================================================================
TOPIC: !!! Kausha-s very HOT kiss scene.avi !!!
http://groups.google.com/group/comp.lang.python/t/a829a51b4cf98243?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 12:25 am
From: "\"Lou \" Shy Amateur Strips"


!!! Kausha-s very HOT kiss scene.avi !!!

http://sites.google.com/site/hifiprofile/
http://sites.google.com/site/hifiprofile/

<<< EXTREME HOT GALLERIES >>>

http://sites.google.com/site/hifiprofile/


==============================================================================
TOPIC: curious about python version numbers
http://groups.google.com/group/comp.lang.python/t/f8a5028affe772ed?hl=en
==============================================================================

== 1 of 4 ==
Date: Sun, Apr 11 2010 7:52 pm
From: Alex Hall


Hi all,
I am just curious: if Python3.x is already out, why is 2.7 being
released? Are there two main types of Python? Thanks.

--
Have a great day,
Alex (msg sent from GMail website)
mehgcap@gmail.com; http://www.facebook.com/mehgcap


== 2 of 4 ==
Date: Tues, Apr 13 2010 1:58 am
From: "Alf P. Steinbach"


* Alex Hall:
> Hi all,
> I am just curious: if Python3.x is already out, why is 2.7 being
> released? Are there two main types of Python? Thanks.

Old code and old programming habits may work as-is with 2.7 but not with a 3.x
implementation.

So yes, there are two main extant variants of Python, 2.x and 3.x (and more if
you count even earlier versions).

2.7 helps to ease the transition, and provides bug-fixes and better efficiency
for the 2.x variant.


Cheers & hth.,

- Alf


== 3 of 4 ==
Date: Tues, Apr 13 2010 3:13 am
From: Ben Finney


Alex Hall <mehgcap@gmail.com> writes:

> I am just curious: if Python3.x is already out, why is 2.7 being
> released? Are there two main types of Python?

Python 3.x brings improvements that break backward compatibility:

Python 3.0 (a.k.a. "Python 3000" or "Py3k") is a new version of the
language that is incompatible with the 2.x line of releases. The
language is mostly the same, but many details, especially how
built-in objects like dictionaries and strings work, have changed
considerably, and a lot of deprecated features have finally been
removed. Also, the standard library has been reorganized in a few
prominent places.

<URL:http://www.python.org/download/releases/3.0/>

For that reason, when Python 3.x was being planned, the Python
developers committed to supporting Python 2.x with backward-compatible
releases for an indeterminate length of time to allow third-party
libraries to steadily migrate to Python 3.x so it becomes more
attractive to use it for all new development.

Python 2.7 has been announced to be the last feature release in the 2.x
series:

Python 2.7 is scheduled to be the last major version in the 2.x
series before it moves into 5 years of bugfix-only mode.

<URL:http://www.python.org/download/releases/2.7/>

--
\ "The Initial Mystery that attends any journey is: how did the |
`\ traveller reach his starting point in the first place?" —Louise |
_o__) Bogan, _Journey Around My Room_ |
Ben Finney


== 4 of 4 ==
Date: Tues, Apr 13 2010 6:54 am
From: Alex Hall


Thanks, everyone, for the answers! I am still on 2.6 since so many
packages rely on it. I got 3.1 at first, but I could not get much to
work with it so I installed 2.6 and have only found one package which
refuses to work, instead of a lot of them.

On 4/13/10, Shashwat Anand <anand.shashwat@gmail.com> wrote:
> It is like releasing window Xp SP3 even if Vista is out.
>
> The problem is we should start using python 3.x but many application like
> django, twisted had not migrated yet. Hence this stuff to support 2.x . 2.7
> is the last 2.x version, no more.
>
> On Tue, Apr 13, 2010 at 2:28 PM, Alf P. Steinbach <alfps@start.no> wrote:
>
>> * Alex Hall:
>>
>> Hi all,
>>> I am just curious: if Python3.x is already out, why is 2.7 being
>>> released? Are there two main types of Python? Thanks.
>>>
>>
>> Old code and old programming habits may work as-is with 2.7 but not with a
>> 3.x implementation.
>>
>> So yes, there are two main extant variants of Python, 2.x and 3.x (and
>> more
>> if you count even earlier versions).
>>
>> 2.7 helps to ease the transition, and provides bug-fixes and better
>> efficiency for the 2.x variant.
>>
>>
>> Cheers & hth.,
>>
>> - Alf
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>


--
Have a great day,
Alex (msg sent from GMail website)
mehgcap@gmail.com; http://www.facebook.com/mehgcap

==============================================================================
TOPIC: packaging multiple python scripts as Windows exe file
http://groups.google.com/group/comp.lang.python/t/3ef1def17875655c?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Apr 12 2010 3:20 pm
From: Alex Hall


Hi all,
While my project is still suffering from major import problems, I will
soon have to try to package it as a Windows executable file. I do not
want an installer; I want the user to be able to run the program for
as long as they want, then to quit (by using a command from inside the
program) and that is it. Nothing to install, no files to copy, no
registry editing, just start and use it until done.

I know about the popular solutions for this sort of thing, but I read
that a DLL is required, and that this dll cannot be (legally)
distributed by myself? A few questions here:
1. Did I read this wrong / is this outdated? Please answer 'yes' as
this will be a real pain to deal with.

2. If I must have it but can distribute it, where should it go so my
program can find it?

3. If the user must download it for legal reasons, instead of me
giving it to them, can I just have a Python script take care of it and
put it in the same directory as the program, so the program can find
it, or do I need to register the dll with the system? If I need to
register, does this require admin login?

Thanks as always!

--
Have a great day,
Alex (msg sent from GMail website)
mehgcap@gmail.com; http://www.facebook.com/mehgcap

==============================================================================
TOPIC: Tough sorting problem: or, I'm confusing myself
http://groups.google.com/group/comp.lang.python/t/aabfedc7358f00a4?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Apr 13 2010 4:25 am
From: david jensen


On Apr 11, 9:39 pm, Raymond Hettinger <pyt...@rcn.com> wrote:

> The overall algorithm looks about right.
> The inner-loop could be tighted-up a bit.
> And you could replace the outer sort with a heap.
>
> best2 = {}
> for i in itertools.combinations(range( 2**m), n-1):
>     scorelist = []
>     for j in range( 2**m ):
>         if j not in i:
>             k = tuple(sorted(i + (j,)))
>             scorelist.append((j, res[k][k.index(j)]))
>     best2[i] = heapq.nlargest(2, scorelist,
> key=operator.itemgetter(1))
>
> Raymond

Thanks for the ideas... I should have seen the k = tuple(sorted(i +
(j,))). I'm not sure a heap will help much, and at least to me,
doesn't improve readability.

Thanks for taking a look, I appreciate it!

David


== 2 of 2 ==
Date: Tues, Apr 13 2010 4:31 am
From: david jensen


On Apr 12, 1:22 am, Paul McGuire <pt...@austin.rr.com> wrote:
> On Apr 9, 10:03 am, david jensen <dmj....@gmail.com> wrote:
>
>
>
> > Hi all,
>
> > I'm trying to find a good way of doing the following:
>
> > Each n-tuple in combinations( range( 2 ** m ), n ) has a corresponding
> > value n-tuple (call them "scores" for clarity later). I'm currently
> > storing them in a dictionary, by doing:
>
> > ----
> > res={}
> > for i in itertools.combinations( range( 2**m ) , n):
> >     res[ i ] = getValues( i )    # getValues() is computationally
> > expensive
> > ----
>
> > For each (n-1)-tuple, I need to find the two numbers that have the
> > highest scores versus them. I know this isn't crystal clear, but
> > hopefully an example will help: with m=n=3:
>
> > Looking at only the (1, 3) case, assuming:
> > getValues( (1, 2, 3) ) == ( -200, 125, 75 )    # this contains the
> > highest "other" score, where 2 scores 125
> > getValues( (1, 3, 4) ) == ( 50, -50, 0 )
> > getValues( (1, 3, 5) ) == ( 25, 300, -325 )
> > getValues( (1, 3, 6) ) == ( -100, 0, 100 )    # this contains the
> > second-highest, where 6 scores 100
> > getValues( (1, 3, 7) ) == ( 80, -90, 10  )
> > getValues( (1, 3, 8) ) == ( 10, -5, -5 )
>
> > I'd like to return ( (2, 125), (6, 100) ).
>
> > The most obvious (to me) way to do this would be not to generate the
> > res dictionary at the beginning, but just to go through each
> > combinations( range( 2**m), n-1) and try every possibility... this
> > will test each combination n times, however, and generating those
> > values is expensive. [e.g. (1,2,3)'s scores will be generated when
> > finding the best possibilities for (1,2), (1,3) and (2,3)]
>
> Add a memoizing decorator to getValues, so that repeated calls will do
> lookups instead of repeated calculations.
>
> -- Paul

Thanks for the idea... I'd thought of that, but didn't use it because
I don't think it improves complexity or readability: just makes it a
little more intuitive.

But thanks for your time!

David

==============================================================================
TOPIC: DjangoCon Europe - 24. - 26.5.2010 in Berlin
http://groups.google.com/group/comp.lang.python/t/e2fac8bbf0736a6f?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 4:36 am
From: Markus Zapke-Gründemann


DjangoCon Europe[1] is a Django[2] conference that aims to bring
together the community and provide a wide range of sessions, panels,
lightning talks and showcases of Django usage within various businesses.
We aim to educate and bring people together to turn new ideas into
working code!

The conference is organized by the German Django Association[3], takes
place from the 24th to 26th of May 2010 and is located in Berlin,
Germany. Sprints will be held on the 27th and 28th of May.

Tickets for the conference are available on a first-come, first-served
basis, and are priced by attendee type:

* Corporate: 595 EUR
* Hobbyist: 289 EUR
* Student: 199 EUR

After many trials and tribulations, we're delighted to announce that
DjangoCon Europe is accepting talk submissions until the 1st of May.

Django is a high-level Python Web framework that encourages rapid
development and clean, pragmatic design.


[1] http://www.djangocon.eu/
[2] http://www.djangoproject.com/
[3] http://djangode.pbworks.com/


==============================================================================
TOPIC: HTMLParser can't read japanese
http://groups.google.com/group/comp.lang.python/t/86fb4a74b8ae55ba?hl=en
==============================================================================

== 1 of 3 ==
Date: Tues, Apr 13 2010 4:40 am
From: Dodo


Here's a small script to generate again the error
running windows 7 with python 3.1

FILE : parseShift.py

import urllib.request as url
from html.parser import HTMLParser

class myParser(HTMLParser):
def handle_starttag(self, tag, attrs):
print("Start of %s tag : %s" % (tag, attrs))

test = myParser()
handle = url.urlretrieve("http://localhost/shift.html")
handleTemp = open( handle[0] , encoding="Shift-JIS" )
test.feed( handleTemp.read() )
handleTempl.close()

FILE : shift.html (encoded Shift-JIS)

<p class="thisisclass (not_in_japanese) reading_this_should_be_ok">Some
random japanese
<p><strong>東方プロジェクト</strong> <a href="#" title="キャプテン・ムラ
サ">Link</a>

OUTPUT

Start of p tag : [('class', 'thisisclass (not_in_japanese)
reading_this_should_be_ok')]
Start of p tag : []
Start of strong tag : []
Traceback (most recent call last):
File "D:\Dorian\Python\parseShift.py", line 12, in <module>
test.feed( handleTemp.read() )
File "C:\Python31\lib\html\parser.py", line 108, in feed
self.goahead(0)
File "C:\Python31\lib\html\parser.py", line 148, in goahead
k = self.parse_starttag(i)
File "C:\Python31\lib\html\parser.py", line 268, in parse_starttag
self.handle_starttag(tag, attrs)
File "D:\Dorian\Python\parseShift.py", line 6, in handle_starttag
print("Start of %s tag : %s" % (tag, attrs))
File "C:\Python31\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position
44-52: c
haracter maps to <undefined>


any help?
Dorian


== 2 of 3 ==
Date: Tues, Apr 13 2010 4:45 am
From: Dodo


alright, it's just because of Windows cmd
in IDLE it works fine

any workaround?

Dorian

Le 13/04/2010 13:40, Dodo a écrit :
> Here's a small script to generate again the error
> running windows 7 with python 3.1
>
> FILE : parseShift.py
>
> import urllib.request as url
> from html.parser import HTMLParser
>
> class myParser(HTMLParser):
> def handle_starttag(self, tag, attrs):
> print("Start of %s tag : %s" % (tag, attrs))
>
>
> test = myParser()
> handle = url.urlretrieve("http://localhost/shift.html")
> handleTemp = open( handle[0] , encoding="Shift-JIS" )
> test.feed( handleTemp.read() )
> handleTempl.close()
>
> FILE : shift.html (encoded Shift-JIS)
>
> <p class="thisisclass (not_in_japanese) reading_this_should_be_ok">Some
> random japanese
> <p><strong>東方プロジェクト</strong> <a href="#" title="キャプテン・ムラ
> サ">Link</a>
>
> OUTPUT
>
> Start of p tag : [('class', 'thisisclass (not_in_japanese)
> reading_this_should_be_ok')]
> Start of p tag : []
> Start of strong tag : []
> Traceback (most recent call last):
> File "D:\Dorian\Python\parseShift.py", line 12, in <module>
> test.feed( handleTemp.read() )
> File "C:\Python31\lib\html\parser.py", line 108, in feed
> self.goahead(0)
> File "C:\Python31\lib\html\parser.py", line 148, in goahead
> k = self.parse_starttag(i)
> File "C:\Python31\lib\html\parser.py", line 268, in parse_starttag
> self.handle_starttag(tag, attrs)
> File "D:\Dorian\Python\parseShift.py", line 6, in handle_starttag
> print("Start of %s tag : %s" % (tag, attrs))
> File "C:\Python31\lib\encodings\cp1252.py", line 19, in encode
> return codecs.charmap_encode(input,self.errors,encoding_table)[0]
> UnicodeEncodeError: 'charmap' codec can't encode characters in position
> 44-52: c
> haracter maps to <undefined>
>
>
> any help?
> Dorian

== 3 of 3 ==
Date: Tues, Apr 13 2010 4:56 am
From: Stefan Behnel


Dodo, 13.04.2010 13:40:
> Here's a small script to generate again the error
> running windows 7 with python 3.1
>
> FILE : parseShift.py
>
> import urllib.request as url
> from html.parser import HTMLParser
>
> class myParser(HTMLParser):
> def handle_starttag(self, tag, attrs):
> print("Start of %s tag : %s" % (tag, attrs))

You problem is the last line. Your terminal does not support printing the
text, so you get an exception here.

Either change your terminal encoding to a suitable encoding, or write the
text to an encoded file instead (see the 'encoding' option of the open()
function for that).

Stefan


==============================================================================
TOPIC: Error using httlib's HTTPSConnection with PKCS#12 certificate
http://groups.google.com/group/comp.lang.python/t/42d1c3972542bd2b?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 6:30 am
From: Rémi


I'm trying to use httplib's HTTPSConnection for client validation,
using a PKCS #12 certificate. I know the certificate is good, as I
can connect to the server using it in MSIE and Firefox.

Here's my connect function (the certificate includes the private key).
I've pared it down to just the basics:

def connect(self, cert_file, host, usrname, passwd):
self.cert_file = cert_file
self.host = host

self.conn = httplib.HTTPSConnection(host=self.host, port=self.port,
key_file=cert_file, cert_file=cert_file)

self.conn.putrequest('GET', 'pathnet/,DanaInfo=200.222.1.1+')
self.conn.endheaders()
retCreateCon = self.conn.getresponse()

if is_verbose:
print "Create HTTPS connection, " + retCreateCon.read()

# ...


(Note: the request path is correct, as I connect to it in MSIE and
Firefox. I changed the IP address for the post.)

When I try to run this using a PKCS#12 certificate (a .pfx file), I
get back what appears to be an openSSL error. Here is the entire error
traceback:

File "Usinghttplib_Test.py", line 175, in <module>
t.connect(cert_file=opts["-keys"], host=host_name, usrname=opts["-
username"], passwd=opts["-password"])
File "Usinghttplib_Test.py", line 40, in connect
self.conn.endheaders()
File "c:\python26\lib\httplib.py", line 904, in endheaders
self._send_output()
File "c:\python26\lib\httplib.py", line 776, in _send_output
self.send(msg)
File "c:\python26\lib\httplib.py", line 735, in send
self.connect()
File "c:\python26\lib\httplib.py", line 1112, in connect
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
File "c:\python26\lib\ssl.py", line 350, in wrap_socket
suppress_ragged_eofs=suppress_ragged_eofs)
File "c:\python26\lib\ssl.py", line 113, in __init__
cert_reqs, ssl_version, ca_certs) ssl.SSLError: [Errno 336265225]
_ssl.c:337: error:140B0009:SSL
routines:SSL_CTX_use_PrivateKey_file:PEM lib


Notice, the openSSL error notes "PEM lib", which I found odd, since
I'm not trying to use a PEM certificate.

For kicks, I converted the PKCS#12 cert to a PEM cert, and ran the
same code using *that*. In that case, I received no error, I was
prompted to enter the PEM pass phrase, and the code did attempt to
reach the server. (I received the response "The service is not
available. Please try again later.", but I believe that would be
because the server does not accept the PEM cert. I can't connect in
Firefox to the server using the PEM cert either.)

Is httplib's HTTPSConnection supposed to support PCKS#12
certificates? (That is, pfx files.) If so, why does it look like
openSSL is trying to load it inside the PEM lib? Am I doing this all
wrong?

Any advice is welcome.

Regards,
Remi.

==============================================================================
TOPIC: Code dojo on Thursday?
http://groups.google.com/group/comp.lang.python/t/01c4c1aa43a144c0?hl=en
==============================================================================

== 1 of 3 ==
Date: Tues, Apr 13 2010 6:50 am
From: John Maclean


Is there a code Dojo in London on Thurs? I've requested two places but
have not heard a reply yet.


--
John Maclean MSc. (DIC) Bsc. (Hons),Core Linux Systems Engineering,07739
171 531


== 2 of 3 ==
Date: Tues, Apr 13 2010 7:49 am
From: Tim Golden


On 13/04/2010 14:50, John Maclean wrote:
> Is there a code Dojo in London on Thurs? I've requested two places but
> have not heard a reply yet.
>
>

It's usually the first Thursday in the month. I've not heard about
one this Thursday. (Doesn't mean I'm right, of course).

TJG


== 3 of 3 ==
Date: Tues, Apr 13 2010 8:58 am
From: MRAB


Tim Golden wrote:
> On 13/04/2010 14:50, John Maclean wrote:
>> Is there a code Dojo in London on Thurs? I've requested two places but
>> have not heard a reply yet.
>>
> It's usually the first Thursday in the month. I've not heard about
> one this Thursday. (Doesn't mean I'm right, of course).
>
It looks like the 7th dojo was on 4 March and the 8th dojo was on 1
April, which were the first Thursdays of the month.

==============================================================================
TOPIC: Generating a rainbow?
http://groups.google.com/group/comp.lang.python/t/065e0b50c4aaca64?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 6:51 am
From: Giacomo Boffi


Tobiah <toby@rcsreg.com> writes:

> I'm having a difficult time with this. I want
> to display a continuous range of hues using HTML
> hex representation (#RRGGBB). How would I go
> about scanning through the hues in order to
> make a rainbow?

if you mean real rainbows when you say "rainbow", as rainbows go from
low to high wavelengths and you have to specify colors to your display
in RGB, i think that you have to read, e.g.,

http://www.physics.sfasu.edu/astro/color.html

otoh if you mean simply a continuos palette with varying hues,
excellent answers were already posted

hth
g
--
compro mobili vecchi - vendo mobili antichi

==============================================================================
TOPIC: Unit testing errors (testing the platform module)
http://groups.google.com/group/comp.lang.python/t/934c18b2e8f1272e?hl=en
==============================================================================

== 1 of 4 ==
Date: Tues, Apr 13 2010 7:01 am
From: John Maclean


I normally use languages unit testing framework to get a better
understanding of how a language works. Right now I want to grok the
platform module;


1 #!/usr/bin/env python
2 '''a pythonic factor'''
3 import unittest
4 import platform
5
6 class TestPyfactorTestCase(unittest.TestCase):
7 def setUp(self):
8 '''setting up stuff'''
13
14 def testplatformbuiltins(self): 15
'''platform.__builtins__.blah '''
16 self.assertEquals(platform.__builtins__.__class__, "<type 'd
ict'>")
17
18
19 def tearDown(self):
20 print 'cleaning stuff up'
21
22 if __name__ == "__main__":
23 unittest.main()


Is there an error in my syntax? Why is my test failing? Line 16.


python stfu/testing/test_pyfactor.py
Fcleaning stuff up

======================================================================
FAIL: platform.__builtins__.blah
----------------------------------------------------------------------
Traceback (most recent call last):
File "stfu/testing/test_pyfactor.py", line 16, in testplatformbuiltins
self.assertEquals(platform.__builtins__.__class__, "<type 'dict'>")
AssertionError: <type 'dict'> != "<type 'dict'>"

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (failures=1)

--
John Maclean MSc. (DIC) Bsc. (Hons),Core Linux Systems Engineering,07739
171 531


== 2 of 4 ==
Date: Tues, Apr 13 2010 7:11 am
From: "Martin P. Hellwig"


On 04/13/10 15:01, John Maclean wrote:
> I normally use languages unit testing framework to get a better
> understanding of how a language works. Right now I want to grok the
> platform module;
>
>
> 1 #!/usr/bin/env python
> 2 '''a pythonic factor'''
> 3 import unittest
> 4 import platform
> 5
> 6 class TestPyfactorTestCase(unittest.TestCase):
> 7 def setUp(self):
> 8 '''setting up stuff'''
> 13
> 14 def testplatformbuiltins(self): 15
> '''platform.__builtins__.blah '''
> 16 self.assertEquals(platform.__builtins__.__class__, "<type 'd
> ict'>")
> 17
> 18
> 19 def tearDown(self):
> 20 print 'cleaning stuff up'
> 21
> 22 if __name__ == "__main__":
> 23 unittest.main()
>
>
> Is there an error in my syntax? Why is my test failing? Line 16.
>
>
> python stfu/testing/test_pyfactor.py
> Fcleaning stuff up
>
> ======================================================================
> FAIL: platform.__builtins__.blah
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "stfu/testing/test_pyfactor.py", line 16, in testplatformbuiltins
> self.assertEquals(platform.__builtins__.__class__, "<type 'dict'>")
> AssertionError:<type 'dict'> != "<type 'dict'>"
>
> ----------------------------------------------------------------------
> Ran 1 test in 0.000s
>
> FAILED (failures=1)
>

What happens if you change this line:
self.assertEquals(platform.__builtins__.__class__, "<type 'dict'>")

To something like:
self.assertEquals(platform.__builtins__.__class__, type(dict()))

or
self.assertEquals(str(platform.__builtins__.__class__), "<type 'dict'>")

--
mph

== 3 of 4 ==
Date: Tues, Apr 13 2010 7:19 am
From: MRAB


John Maclean wrote:
> I normally use languages unit testing framework to get a better
> understanding of how a language works. Right now I want to grok the
> platform module;
>
>
> 1 #!/usr/bin/env python
> 2 '''a pythonic factor'''
> 3 import unittest
> 4 import platform
> 5
> 6 class TestPyfactorTestCase(unittest.TestCase):
> 7 def setUp(self):
> 8 '''setting up stuff'''
> 13
> 14 def testplatformbuiltins(self): 15
> '''platform.__builtins__.blah '''
> 16 self.assertEquals(platform.__builtins__.__class__, "<type 'd
> ict'>")
> 17
> 18
> 19 def tearDown(self):
> 20 print 'cleaning stuff up'
> 21
> 22 if __name__ == "__main__":
> 23 unittest.main()
>
>
> Is there an error in my syntax? Why is my test failing? Line 16.
>
>
> python stfu/testing/test_pyfactor.py
> Fcleaning stuff up
>
> ======================================================================
> FAIL: platform.__builtins__.blah
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "stfu/testing/test_pyfactor.py", line 16, in testplatformbuiltins
> self.assertEquals(platform.__builtins__.__class__, "<type 'dict'>")
> AssertionError: <type 'dict'> != "<type 'dict'>"
>
> ----------------------------------------------------------------------
> Ran 1 test in 0.000s
>
> FAILED (failures=1)
>
platform.__builtins__.__class__ returns a dict, which is not the same as
"<type 'dict'>", a string.


== 4 of 4 ==
Date: Tues, Apr 13 2010 7:28 am
From: "J. Cliff Dyer"


The problem is that the class of platform.__builtins__ is a dict, not a
string containing the text "<type 'dict'>".

Try replacing line 16 with this:

self.assertEqual(type(platform.__builtins__), dict)

Cheers,
Cliff


On Tue, 2010-04-13 at 15:01 +0100, John Maclean wrote:
> I normally use languages unit testing framework to get a better
> understanding of how a language works. Right now I want to grok the
> platform module;
>
>
> 1 #!/usr/bin/env python
> 2 '''a pythonic factor'''
> 3 import unittest
> 4 import platform
> 5
> 6 class TestPyfactorTestCase(unittest.TestCase):
> 7 def setUp(self):
> 8 '''setting up stuff'''
> 13
> 14 def testplatformbuiltins(self): 15
> '''platform.__builtins__.blah '''
> 16 self.assertEquals(platform.__builtins__.__class__, "<type 'd
> ict'>")
> 17
> 18
> 19 def tearDown(self):
> 20 print 'cleaning stuff up'
> 21
> 22 if __name__ == "__main__":
> 23 unittest.main()
>
>
> Is there an error in my syntax? Why is my test failing? Line 16.
>
>
> python stfu/testing/test_pyfactor.py
> Fcleaning stuff up
>
> ======================================================================
> FAIL: platform.__builtins__.blah
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "stfu/testing/test_pyfactor.py", line 16, in testplatformbuiltins
> self.assertEquals(platform.__builtins__.__class__, "<type 'dict'>")
> AssertionError: <type 'dict'> != "<type 'dict'>"
>
> ----------------------------------------------------------------------
> Ran 1 test in 0.000s
>
> FAILED (failures=1)
>
> --
> John Maclean MSc. (DIC) Bsc. (Hons),Core Linux Systems Engineering,07739
> 171 531

==============================================================================
TOPIC: Handling quotes in xml.dom text nodes
http://groups.google.com/group/comp.lang.python/t/0b2a583f147f1cd7?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Apr 13 2010 8:26 am
From: Chaim Krause


I am building a web page (HTML 4.01 Transitional) using
xml.dom.minidom. I have created a <script> node and I have added the
Javascript as a child text node. The issue is that the Javascript
includes quotes that I want to survive when I write the XML to a file.
The issue for me is that they are translated into &quot;.

I know that this is the expected behavior, but I cannot find a manner
to override this behavior to have the quotes survive.

For example, what I want:
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

What I get:
var map = new
google.maps.Map(document.getElementById(&quot;map_canvas&quot;),
myOptions);

What do you suggest I do to get the desired behavior without rewriting
xml.dom? Or is overriding the method the best way to go?


== 2 of 2 ==
Date: Tues, Apr 13 2010 8:52 am
From: Chaim Krause


I am looking to find the best answer to my question, but in the mean
time I have resorted to monkey patching.

def _write_data_no_quote(writer, data):
"Writes datachars to writer."
data = data.replace("&", "&amp;").replace("<", "&lt;")
data = data.replace(">", "&gt;")
writer.write(data)

minidom._write_data = _write_data_no_quote

Maybe this is the best way to do this. I'm not sure.

==============================================================================
TOPIC: Constructing an if statement from the client data in python
http://groups.google.com/group/comp.lang.python/t/6c5a7a542eb39dbd?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Apr 13 2010 9:25 am
From: Benjamin Kaplan


All the operators are available as functions in the operator module.
Just use a dict to select the correct function.


import operator

ops = {"and": operator.and_, "or": operator.or_}

op1 = ops[lo1]
op3 = ops[lo3]

if op3( op1( condition1, condition2), condition4) :
#do something

On Tue, Apr 13, 2010 at 11:56 AM, Vishal Rana <ranavishal@gmail.com> wrote:
>
> Hi,
>
> I need to construct an if statement from the data coming from the client as below:
>
> conditions: condition1, condition2, condition3, condition4 logical operators: lo1, lo2, lo3 (Possible values: "and" "or")
>
> Eg.
>
> if condition1 lo1 condition2 lo3 condition4:
>
>     # Do something
>
> I can think of eval/exec but not sure how safe they are! Any better approach or alternative? Appreciate your responses :)
>
> PS: Client-side: Flex, Server-side: Python, over internet
>
> Thanks
>
> Vishal
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en

To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate